From 37ae969ae0c0795d02d329067a5065e38b4aecb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=FCger?= Date: Tue, 5 Jul 2011 12:39:27 +0200 Subject: [PATCH 001/261] added instant processing of packets && freeing resources properly --- drivers/net/mmnif.c | 99 ++++++++++++++++++++++++--------------------- 1 file changed, 54 insertions(+), 45 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index a8d47d15..616652cc 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -70,7 +70,10 @@ extern HANDLE hProc; #define MMNIF_CORES 2 -#define MMNIF_WORKER_BUDGET 5 +#define MMNIF_WORKER_BUDGET 2 + +#define MMNIF_POLL_BUDGET 0x100000 +#define MMNIF_WAIT_BUDGET 0x2 /* decide whether it's polling mode or not */ @@ -84,6 +87,10 @@ static int active = 0; */ static int disable_locking = 0; +/* decide whether deliver work to a worker thread or instantly process all packets + */ +static int instant_process = 1; + /* IP address of the local core and the router core to get packets forwarded */ static unsigned int own_ip_address = 0xC0A80000; /* 192.168.0.0 */ @@ -115,8 +122,6 @@ static int pulse_irq = 0; #define RCK_INTR_MASK 0x00000002 #define RCK_NMI_MASK 0x00000001 - - /* * the memory mapped network device */ @@ -131,8 +136,10 @@ typedef struct mmnif_device_stats /* device stats (granularity in packets): * - recieve errors * - recieve successes + * - recieved bytes * - transmit errors * - transmit successes + * - transmitted bytes */ unsigned int rx_err; unsigned int rx; @@ -145,7 +152,10 @@ typedef struct mmnif_device_stats unsigned int tx_bytes; /* Heuristics : - * + * - how many times an budget overflow occured + * - how many times the polling thread polled without recieving a new message + * - how many messages are recieved via interrupt + * - how many messages are recieved via the polling thread */ unsigned int bdg_overflow; unsigned int pll_empty; @@ -167,8 +177,8 @@ typedef struct mm_rx_buffer * I won't use a single buffer the whole time. I think i will use an descripor table * and a table which descriptor is in use and use the buffer space dynamically with * descriptors - * - * And this buffer needs a lock as soon as more as cores are availible =/ + * Also timeouts should be checked so if one core dies the buffer space is not blocked + * all the time */ uint8_t queued; uint8_t pos; @@ -178,6 +188,9 @@ typedef struct mm_rx_buffer sem_t lock; +// uint32_t timestamp[MMNIF_RX_QUEUELEN]; +// uint32_t bitmap[MMNIF_RX_QUEUELEN]; + // void* rx_desc[MMNIF_CORES * MMNIF_RX_QUEUELEN]; // uint8_t rx_inuse[MMNIF_CORES * MMNIF_RX_QUEUELEN]; /* bits 1: pending 2: finished 3: free ...*/ // uint8_t fin; @@ -502,11 +515,6 @@ __inline int mmnif_worker_schedule() */ __inline void* mmnif_shmalloc() { - /* Right now every core has the same buffer for every incoming packet - * this will be removed and a buffer for each Core will be implemented - * - * but i'm first testing with two cores/processes. - */ #ifdef WIN32 mpb_size = sizeof(mm_rx_buffer_t) + MMNIF_RX_QUEUELEN* MMNIF_RX_BUFFERLEN; mpb_start_address = VirtualAlloc((char*)0x41000000 /*+ @@ -516,15 +524,8 @@ __inline void* mmnif_shmalloc() return (char*)0x41000000 + (mpb_size) * (own_ip_address - router_ip_address); #else mpb_size = (sizeof(mm_rx_buffer_t) + MMNIF_RX_QUEUELEN* MMNIF_RX_BUFFERLEN); - /* We choose a arbitrary address first - * until i know how to properly allocate shared memory - */ -// RCCE_shmalloc_init(0x80000000,48*8192); + mpb_start_address = RCCE_shmalloc(mpb_size*MMNIF_CORES); - //mpb_start_address = 0x8000000+ mpb_size * (own_ip_address - router_ip_address); - //SHMalloc(&mpb_start_address); - //mpb_start_address = kmalloc(mpb_size*MMNIF_CORES); -// mpb_start_address = 0xC0000000; return mpb_start_address + (mpb_size) * (own_ip_address - router_ip_address); #endif } @@ -773,8 +774,6 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) else mmnif_write_rx_buffl(dest_ip, pos, p->payload,p->tot_len); -// udelay(50000); - /* like above ensure we are the only ones editing the hdr */ mmnif_lock_rx_hdr(dest_ip); @@ -881,6 +880,9 @@ err_t mmnif_init(struct netif* netif) */ sem_init(&mmnif->com_poll,1); + + /* since there is no possibilty to create a full semaphore we just block it manually + */ sem_wait(&mmnif->com_poll); /* inform via interrupt should be the dafault @@ -1085,20 +1087,23 @@ static int mmnif_wait(struct netif* netif, uint32_t poll, int budget) quota = budget; mmnif->stats.bdg_overflow++; - if (mmnif->stats.bdg_overflow >= 0x10) + if (mmnif->stats.bdg_overflow >= MMNIF_WAIT_BUDGET) { /* enable polling and disable interrupts - * - - */ - mmnif_lock_rx_hdr(own_ip_address && 0xff); - mmnif->rx_buff->iv_intr = FALSE; - mmnif_unlock_rx_hdr(own_ip_address && 0xff); + * (only if polling isn't enabled anyways) + */ + if (mmnif->rx_buff->iv_intr == TRUE) + { + mmnif_lock_rx_hdr(own_ip_address && 0xff); + mmnif->rx_buff->iv_intr = FALSE; + mmnif_unlock_rx_hdr(own_ip_address && 0xff); #ifdef DEBUG_MMNIF - DEBUGPRINTF("mmnif_wait(): heuristical polling enables\n"); + DEBUGPRINTF("mmnif_wait(): heuristical polling enables\n"); #endif - sem_post(&mmnif->com_poll); - mmnif->stats.bdg_overflow = 0; + sem_post(&mmnif->com_poll); + } + + mmnif->stats.bdg_overflow = 0; } } @@ -1109,7 +1114,7 @@ static int mmnif_wait(struct netif* netif, uint32_t poll, int budget) /* fetch new data from mmnif_rx() if there is any */ if (poll) { - /* if there is no data return immeadieatly*/ + /* if there is no data return immeadieatly */ if (mailbox_ptr_tryfetch(&(mmnif->mbox), (void**) &p)) return err; } @@ -1160,7 +1165,6 @@ int mmnif_poll(void* e) { mmnif_t* mmnif; unsigned int diff = mmnif_timestamp(); - unsigned int tmp32 = 0; if (!mmnif_dev) { @@ -1184,10 +1188,7 @@ int mmnif_poll(void* e) { while (!mmnif->rx_buff->queued) { - tmp32 = mmnif_timestamp(); - diff = diff - tmp32 > 0 ? diff - tmp32 : tmp32 - diff; - mmnif->stats.pll_empty++; - if (mmnif->stats.pll_empty >= 0x100000) + if (mmnif->stats.pll_empty >= MMNIF_POLL_BUDGET) { /* enable interrupts and suspend polling * @@ -1203,9 +1204,10 @@ int mmnif_poll(void* e) } } mmnif->stats.pll_empty--; -// udelay(30000); mmnif_rx(mmnif_dev); -// mmnif_wait(mmnif_dev,0,MMNIF_WORKER_BUDGET); + + if (instant_process) + mmnif_wait(mmnif_dev,0,MMNIF_WORKER_BUDGET); } return NULL; @@ -1227,7 +1229,12 @@ void mmnif_irqhandler() mmnif = (mmnif_t*) mmnif_dev->state; while (mmnif->rx_buff->queued) + { mmnif_rx(mmnif_dev); + + if (instant_process) + mmnif_wait(mmnif_dev,0,MMNIF_WORKER_BUDGET); + } } /* @@ -1244,7 +1251,7 @@ int mmnif_open() */ IP4_ADDR(&gw, 0,0,0,0); IP4_ADDR(&ipaddr, 192,168,0,get_my_core_no() +1); - IP4_ADDR(&netmask, 255,0,0,0); + IP4_ADDR(&netmask, 255,255,255,0); own_ip_address+= get_my_core_no() +1; @@ -1288,13 +1295,13 @@ int mmnif_open() /* If interrupts are not used we immediately add the polling function * to the queue which would otherwise be done through the IRQ handler. */ -// if (no_irq) - mmnif_device_schedule(); + mmnif_device_schedule(); /* Start the device worker thread wich actually processes the incoming * packet's this is not done in the "interrupt handler" to shorten them up */ - mmnif_worker_schedule(); + if (!instant_process) + mmnif_worker_schedule(); #ifdef DEBUG_MMNIF DEBUGPRINTF("mmnif_dev is open\n"); @@ -1330,9 +1337,11 @@ int mmnif_close() #ifdef WIN32 free(mmnif->tx_buff); free(mmnif_dev); + VirtualFree(mpb_start_address,NULL,NULL); #else -// kfree(mmnif->tx_buff); -// kfree(mmnif_dev); + kfree(mmnif->tx_buff[0],MMNIF_TX_QUEUELEN * MMNIF_TX_BUFFERLEN); + kfree(mmnif_dev,sizeof(mmnif_t)); + RCCE_shfree(mpb_start_address); #endif return NULL; } From ed4f9605e0728fec3b2e51f0f1650b48c2a7dba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 12:49:42 +0200 Subject: [PATCH 002/261] benchmark --- kernel/tests.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index b6138f4d..e3c40322 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -151,6 +151,7 @@ void* server_task(void* e) char buffer[256]; struct sockaddr_in serv_addr, cli_addr; int n; + unsigned int tmp1,tmp2; /* First call to socket() function */ sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); @@ -210,6 +211,16 @@ void* server_task(void* e) kprintf("ERROR writing to socket"); return; } + + tmp1 = get_clock_tick(); + + for (n = 0; n < 1024*1024*100/256 ; n++) + send(newsockfd,buffer,sizeof(buffer)); + + tmp2 = get_clock_tick(); + + kprintf("Send 100 MB in : %d clock ticks",tmp2-tmp1); + return 0; } @@ -226,7 +237,7 @@ void* client_task(void* e) /* fill in the socket structure with host information */ memset(&pin, 0, sizeof(pin)); pin.sin_family = AF_INET; - pin.sin_addr.s_addr = inet_addr("192.168.0.2"); + pin.sin_addr.s_addr = inet_addr("192.168.0.1"); pin.sin_port = htons(5001); /* grab an Internet domain socket */ @@ -267,7 +278,7 @@ return NULL; int test_init(void) { - if (get_core_no()) + if (!get_core_no()) create_kernel_task(NULL,server_task,NULL); else create_kernel_task(NULL,client_task,NULL); From 65288e71ccdc6beb2613f2836ee16d6bd364e056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 12:53:10 +0200 Subject: [PATCH 003/261] benchmark --- kernel/tests.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index e3c40322..1340178c 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -195,7 +195,7 @@ void* server_task(void* e) /* If connection is established then start communicating */ memset(buffer,0,256); kprintf("recieving"); - n = read( newsockfd,buffer,255 ); + n = recv( newsockfd,buffer,255,0 ); if (n < 0) { kprintf("ERROR reading from socket"); @@ -205,7 +205,7 @@ void* server_task(void* e) /* Write a response to the client */ kprintf("writing"); - n = write(newsockfd,"I got your message",18); + n = send(newsockfd,"I got your message",18,0); if (n < 0) { kprintf("ERROR writing to socket"); @@ -215,7 +215,7 @@ void* server_task(void* e) tmp1 = get_clock_tick(); for (n = 0; n < 1024*1024*100/256 ; n++) - send(newsockfd,buffer,sizeof(buffer)); + send(newsockfd,buffer,sizeof(buffer),0); tmp2 = get_clock_tick(); @@ -269,6 +269,9 @@ void* client_task(void* e) /* spew-out the results and bail out of here! */ kprintf("%s\n", dir); + for (n = 0; n < 1024*1024*100/256 ; n++) + recv(sd,dir,sizeof(dir),0); + close(sd); return NULL; From 3490e384005d0913b60a5e72ba9569f001760299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 12:53:48 +0200 Subject: [PATCH 004/261] benchmark --- kernel/tests.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/tests.c b/kernel/tests.c index 1340178c..765455d5 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -231,6 +231,7 @@ void* client_task(void* e) struct sockaddr_in sin; struct sockaddr_in pin; struct hostent *hp; + int n; sleep(1); From 4d83de57af87355f87aec261b7c1ad86323eaccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 12:58:17 +0200 Subject: [PATCH 005/261] benchmark --- kernel/tests.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 765455d5..5e166a89 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -151,7 +151,7 @@ void* server_task(void* e) char buffer[256]; struct sockaddr_in serv_addr, cli_addr; int n; - unsigned int tmp1,tmp2; + uint64_t tmp1,tmp2; /* First call to socket() function */ sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); @@ -214,12 +214,12 @@ void* server_task(void* e) tmp1 = get_clock_tick(); - for (n = 0; n < 1024*1024*100/256 ; n++) + for (n = 0; n < 1024*1024 ; n++) send(newsockfd,buffer,sizeof(buffer),0); tmp2 = get_clock_tick(); - kprintf("Send 100 MB in : %d clock ticks",tmp2-tmp1); + kprintf("Send 256 MB in : %d clock ticks",tmp2-tmp1); return 0; } @@ -270,7 +270,7 @@ void* client_task(void* e) /* spew-out the results and bail out of here! */ kprintf("%s\n", dir); - for (n = 0; n < 1024*1024*100/256 ; n++) + for (n = 0; n < 1024*1024 ; n++) recv(sd,dir,sizeof(dir),0); close(sd); From c5ac92511c81663dcddd9cb2a6d71e3a3199e9ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 13:00:34 +0200 Subject: [PATCH 006/261] benchmark --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 5e166a89..a098b5f1 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -214,7 +214,7 @@ void* server_task(void* e) tmp1 = get_clock_tick(); - for (n = 0; n < 1024*1024 ; n++) + for (n = 0; n < 10 ; n++) send(newsockfd,buffer,sizeof(buffer),0); tmp2 = get_clock_tick(); From 93a22ffa1a262588374bf45098e8cebca2cc46cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 13:01:43 +0200 Subject: [PATCH 007/261] benchmark --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index a098b5f1..37c5bd3a 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -214,7 +214,7 @@ void* server_task(void* e) tmp1 = get_clock_tick(); - for (n = 0; n < 10 ; n++) + for (n = 0; n < 1024 ; n++) send(newsockfd,buffer,sizeof(buffer),0); tmp2 = get_clock_tick(); From 2f8a30a5a9b134475dd263ae58ffdf493fc9212c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 13:03:59 +0200 Subject: [PATCH 008/261] benchmark --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 37c5bd3a..5e166a89 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -214,7 +214,7 @@ void* server_task(void* e) tmp1 = get_clock_tick(); - for (n = 0; n < 1024 ; n++) + for (n = 0; n < 1024*1024 ; n++) send(newsockfd,buffer,sizeof(buffer),0); tmp2 = get_clock_tick(); From cfaaf32d96ee574d519c5262557eb54e9a3d2ef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 13:09:00 +0200 Subject: [PATCH 009/261] benchmark --- kernel/tests.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 5e166a89..d36faa19 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -148,7 +148,7 @@ __inline int get_core_no(void) void* server_task(void* e) { int sockfd, newsockfd, portno, clilen; - char buffer[256]; + char buffer[2048]; struct sockaddr_in serv_addr, cli_addr; int n; uint64_t tmp1,tmp2; @@ -214,7 +214,7 @@ void* server_task(void* e) tmp1 = get_clock_tick(); - for (n = 0; n < 1024*1024 ; n++) + for (n = 0; n < 1024 ; n++) send(newsockfd,buffer,sizeof(buffer),0); tmp2 = get_clock_tick(); @@ -226,7 +226,7 @@ void* server_task(void* e) void* client_task(void* e) { - char dir[256]; + char dir[2048]; int sd; struct sockaddr_in sin; struct sockaddr_in pin; From 725609a92c1d732060215503f87f47d27c647bbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 13:12:14 +0200 Subject: [PATCH 010/261] benchmark --- kernel/tests.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/tests.c b/kernel/tests.c index d36faa19..96203f99 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -215,7 +215,10 @@ void* server_task(void* e) tmp1 = get_clock_tick(); for (n = 0; n < 1024 ; n++) + { send(newsockfd,buffer,sizeof(buffer),0); + kprintf("-%d-",n); + } tmp2 = get_clock_tick(); From 5e1855fc72ee04c8dd9e514a4450c7170a151f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 13:14:44 +0200 Subject: [PATCH 011/261] benchmark --- kernel/tests.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 96203f99..1eee0018 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -148,7 +148,7 @@ __inline int get_core_no(void) void* server_task(void* e) { int sockfd, newsockfd, portno, clilen; - char buffer[2048]; + char buffer[1512]; struct sockaddr_in serv_addr, cli_addr; int n; uint64_t tmp1,tmp2; @@ -216,8 +216,8 @@ void* server_task(void* e) for (n = 0; n < 1024 ; n++) { - send(newsockfd,buffer,sizeof(buffer),0); kprintf("-%d-",n); + send(newsockfd,buffer,sizeof(buffer),0); } tmp2 = get_clock_tick(); @@ -229,7 +229,7 @@ void* server_task(void* e) void* client_task(void* e) { - char dir[2048]; + char dir[1512]; int sd; struct sockaddr_in sin; struct sockaddr_in pin; @@ -273,7 +273,7 @@ void* client_task(void* e) /* spew-out the results and bail out of here! */ kprintf("%s\n", dir); - for (n = 0; n < 1024*1024 ; n++) + for (n = 0; n < 1024; n++) recv(sd,dir,sizeof(dir),0); close(sd); From fcac7e2be3e59f6df70e8c83ccf75d6e52529994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 13:16:18 +0200 Subject: [PATCH 012/261] benchmark --- drivers/net/mmnif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 616652cc..297bcec4 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -23,7 +23,7 @@ #include /* struct iphdr*/ #include /* tcpip_input()*/ -//#define DEBUG_MMNIF +#define DEBUG_MMNIF #ifdef DEBUG_MMNIF #include "util.h" /* hex dump */ From 1bccbd74b316b1571fef093e1715e77793faab5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 13:21:12 +0200 Subject: [PATCH 013/261] benchmark --- drivers/net/mmnif.c | 6 +++--- kernel/tests.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 297bcec4..fa0da30e 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -23,7 +23,7 @@ #include /* struct iphdr*/ #include /* tcpip_input()*/ -#define DEBUG_MMNIF +//#define DEBUG_MMNIF #ifdef DEBUG_MMNIF #include "util.h" /* hex dump */ @@ -77,7 +77,7 @@ extern HANDLE hProc; /* decide whether it's polling mode or not */ -static int no_irq = 0; +static int no_irq = 1; /* this will be set by open() and close() and shows wether the driver is running or not */ @@ -85,7 +85,7 @@ static int active = 0; /* decide wheter it's uses locking or not */ -static int disable_locking = 0; +static int disable_locking = 1; /* decide whether deliver work to a worker thread or instantly process all packets */ diff --git a/kernel/tests.c b/kernel/tests.c index 1eee0018..0dad1458 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -276,7 +276,7 @@ void* client_task(void* e) for (n = 0; n < 1024; n++) recv(sd,dir,sizeof(dir),0); - close(sd); +// close(sd); return NULL; } From 0dc2444cf9246a286f69cb27f39a9babceb0ac5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 13:22:37 +0200 Subject: [PATCH 014/261] benchmark --- kernel/tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 0dad1458..a738620d 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -148,7 +148,7 @@ __inline int get_core_no(void) void* server_task(void* e) { int sockfd, newsockfd, portno, clilen; - char buffer[1512]; + char buffer[256]; struct sockaddr_in serv_addr, cli_addr; int n; uint64_t tmp1,tmp2; @@ -229,7 +229,7 @@ void* server_task(void* e) void* client_task(void* e) { - char dir[1512]; + char dir[256]; int sd; struct sockaddr_in sin; struct sockaddr_in pin; From dae81c31d6bc8d157c3859d18566b59c35ea3eff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 13:23:54 +0200 Subject: [PATCH 015/261] benchmark --- kernel/tests.c | 1 - 1 file changed, 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index a738620d..ba6499d3 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -216,7 +216,6 @@ void* server_task(void* e) for (n = 0; n < 1024 ; n++) { - kprintf("-%d-",n); send(newsockfd,buffer,sizeof(buffer),0); } From 8cd674f881da9eab31a665324eace57142a3f578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 13:25:22 +0200 Subject: [PATCH 016/261] benchmark --- kernel/tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index ba6499d3..2447d2a8 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -214,7 +214,7 @@ void* server_task(void* e) tmp1 = get_clock_tick(); - for (n = 0; n < 1024 ; n++) + for (n = 0; n < 1024*10 ; n++) { send(newsockfd,buffer,sizeof(buffer),0); } @@ -272,7 +272,7 @@ void* client_task(void* e) /* spew-out the results and bail out of here! */ kprintf("%s\n", dir); - for (n = 0; n < 1024; n++) + for (n = 0; n < 1024*10; n++) recv(sd,dir,sizeof(dir),0); // close(sd); From ea08d81d7bf58c9e7e22d0710c1db38eddde18dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 13:31:34 +0200 Subject: [PATCH 017/261] benchmark --- drivers/net/mmnif.c | 2 +- kernel/tests.c | 8 ++++---- lwip/src/include/lwipopts.h | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index fa0da30e..ed702f3f 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -77,7 +77,7 @@ extern HANDLE hProc; /* decide whether it's polling mode or not */ -static int no_irq = 1; +static int no_irq = 0; /* this will be set by open() and close() and shows wether the driver is running or not */ diff --git a/kernel/tests.c b/kernel/tests.c index 2447d2a8..adb3686b 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -148,7 +148,7 @@ __inline int get_core_no(void) void* server_task(void* e) { int sockfd, newsockfd, portno, clilen; - char buffer[256]; + char buffer[512]; struct sockaddr_in serv_addr, cli_addr; int n; uint64_t tmp1,tmp2; @@ -214,7 +214,7 @@ void* server_task(void* e) tmp1 = get_clock_tick(); - for (n = 0; n < 1024*10 ; n++) + for (n = 0; n < 1024 ; n++) { send(newsockfd,buffer,sizeof(buffer),0); } @@ -228,7 +228,7 @@ void* server_task(void* e) void* client_task(void* e) { - char dir[256]; + char dir[512]; int sd; struct sockaddr_in sin; struct sockaddr_in pin; @@ -272,7 +272,7 @@ void* client_task(void* e) /* spew-out the results and bail out of here! */ kprintf("%s\n", dir); - for (n = 0; n < 1024*10; n++) + for (n = 0; n < 1024; n++) recv(sd,dir,sizeof(dir),0); // close(sd); diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index b5045c6e..d85d7e9f 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -51,6 +51,8 @@ */ #define TCP_SND_BUF 2048 +#define TCP_SND_QUEUELEN 2 + /** * LWIP_BROADCAST_PING==1: respond to broadcast pings (default is unicast only) */ From db1c2a284ae9c8e8bb44e19b4dafee51ed803457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 13:34:35 +0200 Subject: [PATCH 018/261] benchmark --- kernel/tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index adb3686b..ba6499d3 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -148,7 +148,7 @@ __inline int get_core_no(void) void* server_task(void* e) { int sockfd, newsockfd, portno, clilen; - char buffer[512]; + char buffer[256]; struct sockaddr_in serv_addr, cli_addr; int n; uint64_t tmp1,tmp2; @@ -228,7 +228,7 @@ void* server_task(void* e) void* client_task(void* e) { - char dir[512]; + char dir[256]; int sd; struct sockaddr_in sin; struct sockaddr_in pin; From 80fae7f9959a0a3525860d5b835af2192ee2ae18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 13:36:05 +0200 Subject: [PATCH 019/261] benchmark --- lwip/src/include/lwipopts.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index d85d7e9f..28fe6150 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -51,7 +51,7 @@ */ #define TCP_SND_BUF 2048 -#define TCP_SND_QUEUELEN 2 +#define TCP_SND_QUEUELEN 8 /** * LWIP_BROADCAST_PING==1: respond to broadcast pings (default is unicast only) From 91f920191996e2c4e4b6f6631616a1fffad46765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 13:40:04 +0200 Subject: [PATCH 020/261] benchmark --- drivers/net/mmnif.c | 2 +- include/metalsvm/config.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index ed702f3f..616652cc 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -85,7 +85,7 @@ static int active = 0; /* decide wheter it's uses locking or not */ -static int disable_locking = 1; +static int disable_locking = 0; /* decide whether deliver work to a worker thread or instantly process all packets */ diff --git a/include/metalsvm/config.h b/include/metalsvm/config.h index f70fdd4c..15a222af 100644 --- a/include/metalsvm/config.h +++ b/include/metalsvm/config.h @@ -35,7 +35,7 @@ extern "C" { #define PAGE_SHIFT 12 #define CACHE_LINE 64 #define MAILBOX_SIZE 8 -#define TIMER_FREQ 100 /* in HZ */ +#define TIMER_FREQ 1000 /* in HZ */ #define CLOCK_TICK_RATE 1193182 /* 8254 chip's internal oscillator frequency */ #define INT_SYSCALL 0x80 #define KERNEL_SPACE (1*1024*1024*1024) From b9e65c94cd539693949d221eadb80e70d9a8963f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 13:44:48 +0200 Subject: [PATCH 021/261] benchmark --- kernel/tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index ba6499d3..3c9a30ff 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -214,7 +214,7 @@ void* server_task(void* e) tmp1 = get_clock_tick(); - for (n = 0; n < 1024 ; n++) + for (n = 0; n < 10 ; n++) { send(newsockfd,buffer,sizeof(buffer),0); } @@ -272,7 +272,7 @@ void* client_task(void* e) /* spew-out the results and bail out of here! */ kprintf("%s\n", dir); - for (n = 0; n < 1024; n++) + for (n = 0; n < 10; n++) recv(sd,dir,sizeof(dir),0); // close(sd); From 33f71cefb1eb355aafe28006ff17549f5ad992f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 13:46:27 +0200 Subject: [PATCH 022/261] benchmark --- kernel/tests.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 3c9a30ff..2996edd7 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -214,8 +214,9 @@ void* server_task(void* e) tmp1 = get_clock_tick(); - for (n = 0; n < 10 ; n++) + for (n = 0; n < 1024 ; n++) { + kprintf("%d-",n); send(newsockfd,buffer,sizeof(buffer),0); } @@ -272,7 +273,7 @@ void* client_task(void* e) /* spew-out the results and bail out of here! */ kprintf("%s\n", dir); - for (n = 0; n < 10; n++) + for (n = 0; n < 1024; n++) recv(sd,dir,sizeof(dir),0); // close(sd); From 34eb1ddfb262d33b1de3d8db2917cfba7fd9af67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 13:50:02 +0200 Subject: [PATCH 023/261] benchmark --- drivers/net/mmnif.c | 2 +- kernel/tests.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 616652cc..ed702f3f 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -85,7 +85,7 @@ static int active = 0; /* decide wheter it's uses locking or not */ -static int disable_locking = 0; +static int disable_locking = 1; /* decide whether deliver work to a worker thread or instantly process all packets */ diff --git a/kernel/tests.c b/kernel/tests.c index 2996edd7..34f6c775 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -218,6 +218,7 @@ void* server_task(void* e) { kprintf("%d-",n); send(newsockfd,buffer,sizeof(buffer),0); + udelay(10); } tmp2 = get_clock_tick(); From a8d467dcb00bc4e93ac5d12ac945258f3c85c5ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 13:51:29 +0200 Subject: [PATCH 024/261] benchmark --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 34f6c775..03aa265e 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -216,7 +216,7 @@ void* server_task(void* e) for (n = 0; n < 1024 ; n++) { - kprintf("%d-",n); +// kprintf("%d-",n); send(newsockfd,buffer,sizeof(buffer),0); udelay(10); } From 3e49b738a620a8ccea6713ffb086cbc82d4afdec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 13:55:49 +0200 Subject: [PATCH 025/261] benchmark --- kernel/tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 03aa265e..b2f23b49 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -216,9 +216,9 @@ void* server_task(void* e) for (n = 0; n < 1024 ; n++) { -// kprintf("%d-",n); + kprintf("\r%d-",n); send(newsockfd,buffer,sizeof(buffer),0); - udelay(10); + udelay(100); } tmp2 = get_clock_tick(); From 08c0b667070cb3aa6d7bfeeef8987193270b2bdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 13:58:29 +0200 Subject: [PATCH 026/261] benchmark --- drivers/net/mmnif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index ed702f3f..616652cc 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -85,7 +85,7 @@ static int active = 0; /* decide wheter it's uses locking or not */ -static int disable_locking = 1; +static int disable_locking = 0; /* decide whether deliver work to a worker thread or instantly process all packets */ From be7ca23929c25c8fea92f81bd93707e219409ac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 14:03:21 +0200 Subject: [PATCH 027/261] benchmark --- drivers/net/mmnif.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 616652cc..fefbc664 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -77,7 +77,7 @@ extern HANDLE hProc; /* decide whether it's polling mode or not */ -static int no_irq = 0; +static int no_irq = 1; /* this will be set by open() and close() and shows wether the driver is running or not */ @@ -1202,6 +1202,8 @@ int mmnif_poll(void* e) sem_wait(&mmnif->com_poll); mmnif->stats.pll_empty = 1; } + mmnif->stats.pll_empty++; + mmnif->stats.pll_empty = 0; } mmnif->stats.pll_empty--; mmnif_rx(mmnif_dev); From b1e1da3325f7e0639e93850bb3a25d0a715b555d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 14:04:31 +0200 Subject: [PATCH 028/261] benchmark --- drivers/net/mmnif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index fefbc664..c1663f0e 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -85,7 +85,7 @@ static int active = 0; /* decide wheter it's uses locking or not */ -static int disable_locking = 0; +static int disable_locking = 1; /* decide whether deliver work to a worker thread or instantly process all packets */ From 4f5505452cc57425f0afaef6b91607b806e56942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 14:08:09 +0200 Subject: [PATCH 029/261] benchmark --- drivers/net/mmnif.c | 5 ++--- kernel/tests.c | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index c1663f0e..4a3e2d93 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -77,7 +77,7 @@ extern HANDLE hProc; /* decide whether it's polling mode or not */ -static int no_irq = 1; +static int no_irq = 0; /* this will be set by open() and close() and shows wether the driver is running or not */ @@ -85,7 +85,7 @@ static int active = 0; /* decide wheter it's uses locking or not */ -static int disable_locking = 1; +static int disable_locking = 0; /* decide whether deliver work to a worker thread or instantly process all packets */ @@ -1203,7 +1203,6 @@ int mmnif_poll(void* e) mmnif->stats.pll_empty = 1; } mmnif->stats.pll_empty++; - mmnif->stats.pll_empty = 0; } mmnif->stats.pll_empty--; mmnif_rx(mmnif_dev); diff --git a/kernel/tests.c b/kernel/tests.c index b2f23b49..1b659dcb 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -218,7 +218,7 @@ void* server_task(void* e) { kprintf("\r%d-",n); send(newsockfd,buffer,sizeof(buffer),0); - udelay(100); + udelay(1000); } tmp2 = get_clock_tick(); From 820b4e3a187221f908461957884e29c89171c028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 14:09:41 +0200 Subject: [PATCH 030/261] benchmark --- drivers/net/mmnif.c | 2 +- kernel/tests.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 4a3e2d93..ba491915 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -85,7 +85,7 @@ static int active = 0; /* decide wheter it's uses locking or not */ -static int disable_locking = 0; +static int disable_locking = 1; /* decide whether deliver work to a worker thread or instantly process all packets */ diff --git a/kernel/tests.c b/kernel/tests.c index 1b659dcb..8bc3ce6c 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -216,7 +216,7 @@ void* server_task(void* e) for (n = 0; n < 1024 ; n++) { - kprintf("\r%d-",n); + kprintf("%d-",n); send(newsockfd,buffer,sizeof(buffer),0); udelay(1000); } From 8e51493181c95e918dfc1a56a5646123ddb64369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 14:16:40 +0200 Subject: [PATCH 031/261] benchmark --- drivers/net/mmnif.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index ba491915..3ba716c9 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -48,6 +48,7 @@ extern HANDLE hProc; #define DEBUGPRINTF(x,...) kprintf(x,##__VA_ARGS__) #include +#include #include #include @@ -186,7 +187,8 @@ typedef struct mm_rx_buffer uint8_t iv_intr; - sem_t lock; +// sem_t lock; + spinlock_t lock; // uint32_t timestamp[MMNIF_RX_QUEUELEN]; // uint32_t bitmap[MMNIF_RX_QUEUELEN]; @@ -543,7 +545,8 @@ __inline void mmnif_lock_rx_hdr(int dest_ip) #else if(disable_locking) return; mm_rx_buffer_t* hdr = (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size; - sem_wait(&hdr->lock); +// sem_wait(&hdr->lock); + spinlock_lock(&hdr->lock); #endif } /* mmnif_unlock_rx_hdr(): unlock the header @@ -559,7 +562,7 @@ __inline void mmnif_unlock_rx_hdr(int dest_ip) #else if(disable_locking) return; mm_rx_buffer_t* hdr = (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size; - sem_post(&hdr->lock); + spinlock_unlock(&hdr->lock); #endif } @@ -874,7 +877,8 @@ err_t mmnif_init(struct netif* netif) /* init the lock for the hdr */ - sem_init(&mmnif->rx_buff->lock,1); +// sem_init(&mmnif->rx_buff->lock,1); + spinlock_init(&mmnif->rx_buff->lock); /* init the sems for communication art */ @@ -1188,6 +1192,7 @@ int mmnif_poll(void* e) { while (!mmnif->rx_buff->queued) { + mmnif->stats.pll_empty++; if (mmnif->stats.pll_empty >= MMNIF_POLL_BUDGET) { /* enable interrupts and suspend polling @@ -1200,11 +1205,9 @@ int mmnif_poll(void* e) DEBUGPRINTF("mmnif_poll(): heuristical interrupts enabled\n"); #endif sem_wait(&mmnif->com_poll); - mmnif->stats.pll_empty = 1; - } - mmnif->stats.pll_empty++; + } } - mmnif->stats.pll_empty--; + mmnif->stats.pll_empty=0; mmnif_rx(mmnif_dev); if (instant_process) From fb42eae5bf73cff6a943fd515fdb3ff682ed3c8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 14:23:04 +0200 Subject: [PATCH 032/261] benchmark --- drivers/net/mmnif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 3ba716c9..d8d471cc 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -86,7 +86,7 @@ static int active = 0; /* decide wheter it's uses locking or not */ -static int disable_locking = 1; +static int disable_locking = 0; /* decide whether deliver work to a worker thread or instantly process all packets */ From fa8616dfebf1422b5c6e725e1c964d25f2227ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 14:25:58 +0200 Subject: [PATCH 033/261] benchmark --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 8bc3ce6c..063a9bd0 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -218,7 +218,7 @@ void* server_task(void* e) { kprintf("%d-",n); send(newsockfd,buffer,sizeof(buffer),0); - udelay(1000); +// udelay(1000); } tmp2 = get_clock_tick(); From 1f80ddb613f8330c1d6d0d40e6451d249ca2bd47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 14:32:29 +0200 Subject: [PATCH 034/261] benchmark --- drivers/net/mmnif.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index d8d471cc..c07db0b5 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -1063,9 +1063,14 @@ static void mmnif_rx(struct netif* netif) drop_packet: /* packet is lost so gather stats and leave the rx handler*/ - mmnif->rx_buff->pos++; - mmnif->rx_buff->queued--; - LINK_STATS_INC(link.drop); + mmnif_lock_rx_hdr(own_ip_address & 0xFF); + + mmnif->rx_buff->pos++; + mmnif->rx_buff->queued--; + + mmnif_unlock_rx_hdr(own_ip_address & 0xFF); + + LINK_STATS_INC(link.drop); mmnif->stats.rx_err++; return; } From e989d7f8a83f02008b2e047858137a00d133096f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 14:43:49 +0200 Subject: [PATCH 035/261] benchmark --- drivers/net/mmnif.c | 5 +++-- include/metalsvm/config.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index c07db0b5..3b4e6f87 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -78,7 +78,7 @@ extern HANDLE hProc; /* decide whether it's polling mode or not */ -static int no_irq = 0; +static int no_irq = 1; /* this will be set by open() and close() and shows wether the driver is running or not */ @@ -1197,7 +1197,8 @@ int mmnif_poll(void* e) { while (!mmnif->rx_buff->queued) { - mmnif->stats.pll_empty++; + // mmnif->stats.pll_empty++; + mmnif->stats.pll_empty = 0; if (mmnif->stats.pll_empty >= MMNIF_POLL_BUDGET) { /* enable interrupts and suspend polling diff --git a/include/metalsvm/config.h b/include/metalsvm/config.h index 15a222af..f70fdd4c 100644 --- a/include/metalsvm/config.h +++ b/include/metalsvm/config.h @@ -35,7 +35,7 @@ extern "C" { #define PAGE_SHIFT 12 #define CACHE_LINE 64 #define MAILBOX_SIZE 8 -#define TIMER_FREQ 1000 /* in HZ */ +#define TIMER_FREQ 100 /* in HZ */ #define CLOCK_TICK_RATE 1193182 /* 8254 chip's internal oscillator frequency */ #define INT_SYSCALL 0x80 #define KERNEL_SPACE (1*1024*1024*1024) From 4c3fb2c162938c613fd91361bebd3c147c052f85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 14:47:29 +0200 Subject: [PATCH 036/261] benchmark --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 063a9bd0..d146d5fd 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -218,7 +218,7 @@ void* server_task(void* e) { kprintf("%d-",n); send(newsockfd,buffer,sizeof(buffer),0); -// udelay(1000); + udelay(100); } tmp2 = get_clock_tick(); From 3f36764fec7b71d60ac178a2efb4063502d8d8b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 14:48:42 +0200 Subject: [PATCH 037/261] benchmark --- drivers/net/mmnif.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 3b4e6f87..c07db0b5 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -78,7 +78,7 @@ extern HANDLE hProc; /* decide whether it's polling mode or not */ -static int no_irq = 1; +static int no_irq = 0; /* this will be set by open() and close() and shows wether the driver is running or not */ @@ -1197,8 +1197,7 @@ int mmnif_poll(void* e) { while (!mmnif->rx_buff->queued) { - // mmnif->stats.pll_empty++; - mmnif->stats.pll_empty = 0; + mmnif->stats.pll_empty++; if (mmnif->stats.pll_empty >= MMNIF_POLL_BUDGET) { /* enable interrupts and suspend polling From 9efdb437f3061b4984ec488068d3826b337b2b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 14:55:31 +0200 Subject: [PATCH 038/261] benchmark --- kernel/tests.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index d146d5fd..10b96f50 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -214,7 +214,7 @@ void* server_task(void* e) tmp1 = get_clock_tick(); - for (n = 0; n < 1024 ; n++) + for (n = 0; n < 512 ; n++) { kprintf("%d-",n); send(newsockfd,buffer,sizeof(buffer),0); @@ -274,8 +274,11 @@ void* client_task(void* e) /* spew-out the results and bail out of here! */ kprintf("%s\n", dir); - for (n = 0; n < 1024; n++) + for (n = 0; n < 512; n++) + { recv(sd,dir,sizeof(dir),0); + udelay(100); + } // close(sd); From 962054e7ec720951262e9b3ec4c8d1074e7cc551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 14:58:09 +0200 Subject: [PATCH 039/261] benchmark --- kernel/tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 10b96f50..a9914f75 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -218,7 +218,7 @@ void* server_task(void* e) { kprintf("%d-",n); send(newsockfd,buffer,sizeof(buffer),0); - udelay(100); + // udelay(100); } tmp2 = get_clock_tick(); @@ -277,7 +277,7 @@ void* client_task(void* e) for (n = 0; n < 512; n++) { recv(sd,dir,sizeof(dir),0); - udelay(100); + // udelay(100); } // close(sd); From 205fce43d8fa5c56b275a4a4806e38f562c65b5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 15:27:45 +0200 Subject: [PATCH 040/261] benchmark --- lwip/src/include/lwipopts.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index 28fe6150..61e08e78 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -99,4 +99,6 @@ #define NETIF_DEBUG LWIP_DBG_OFF #define TIMERS_DEBUG LWIP_DBG_OFF +#define LWIP_TCPIP_CORE_LOCKING_INPUT 1 + #endif From 63b3709227d06c12cd7c52eed25b71680cb85d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 15:28:59 +0200 Subject: [PATCH 041/261] benchmark --- lwip/src/include/lwipopts.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index 61e08e78..ba930f83 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -100,5 +100,6 @@ #define TIMERS_DEBUG LWIP_DBG_OFF #define LWIP_TCPIP_CORE_LOCKING_INPUT 1 +#define LWIP_TCPIP_CORE_LOCKING 1 #endif From 1cda0edc36871dc34b14fea79761ac39762c9869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 5 Jul 2011 15:32:22 +0200 Subject: [PATCH 042/261] benchmark --- lwip/src/include/lwipopts.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index ba930f83..312de851 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -99,7 +99,5 @@ #define NETIF_DEBUG LWIP_DBG_OFF #define TIMERS_DEBUG LWIP_DBG_OFF -#define LWIP_TCPIP_CORE_LOCKING_INPUT 1 -#define LWIP_TCPIP_CORE_LOCKING 1 #endif From 140d6ec389243b2bc9dbd3ff4ac90980a5f0f8c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 7 Jul 2011 10:14:44 +0200 Subject: [PATCH 043/261] error searching && git push --- kernel/tests.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index a9914f75..b0ac7bde 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -214,8 +214,9 @@ void* server_task(void* e) tmp1 = get_clock_tick(); - for (n = 0; n < 512 ; n++) + for (n = 0; n < 1024 ; n++) { + if (n%10) kprintf("%d-",n); send(newsockfd,buffer,sizeof(buffer),0); // udelay(100); @@ -223,7 +224,7 @@ void* server_task(void* e) tmp2 = get_clock_tick(); - kprintf("Send 256 MB in : %d clock ticks",tmp2-tmp1); + kprintf("Send 512*256 Bytes in : %d clock ticks",tmp2-tmp1); return 0; } From 2de11e6c3fc99c510a376239804e5cd30fc21b41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 7 Jul 2011 10:16:12 +0200 Subject: [PATCH 044/261] error searching --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index b0ac7bde..585e7469 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -216,7 +216,7 @@ void* server_task(void* e) for (n = 0; n < 1024 ; n++) { - if (n%10) + if (!(n%10)) kprintf("%d-",n); send(newsockfd,buffer,sizeof(buffer),0); // udelay(100); From 97364a5664d74f7f2f2ccf002cbcb2c4147b9a42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 7 Jul 2011 10:19:24 +0200 Subject: [PATCH 045/261] error searching --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 585e7469..837dad4b 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -216,7 +216,7 @@ void* server_task(void* e) for (n = 0; n < 1024 ; n++) { - if (!(n%10)) + //if (!(n%10)) kprintf("%d-",n); send(newsockfd,buffer,sizeof(buffer),0); // udelay(100); From 292398a04083f53d6fa7af5146a15da4dcd36755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 7 Jul 2011 10:36:12 +0200 Subject: [PATCH 046/261] error searching --- kernel/tests.c | 2 +- lwip/src/include/lwipopts.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 837dad4b..68acd084 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -214,7 +214,7 @@ void* server_task(void* e) tmp1 = get_clock_tick(); - for (n = 0; n < 1024 ; n++) + for (n = 0; n < 512 ; n++) { //if (!(n%10)) kprintf("%d-",n); diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index 312de851..8e3c5645 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -99,5 +99,8 @@ #define NETIF_DEBUG LWIP_DBG_OFF #define TIMERS_DEBUG LWIP_DBG_OFF +#define LWIP_TCPIP_CORE_LOCKING_INPUT 1 +#define LWIP_TCPIP_CORE_LOCKING 1 + #endif From 12f0f74c9c993ceaf683f383e69ee14d952650d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 7 Jul 2011 10:42:29 +0200 Subject: [PATCH 047/261] error searching --- lwip/src/arch/sys_arch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lwip/src/arch/sys_arch.c b/lwip/src/arch/sys_arch.c index 2eef4727..5e5ba562 100644 --- a/lwip/src/arch/sys_arch.c +++ b/lwip/src/arch/sys_arch.c @@ -139,8 +139,8 @@ u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout) while (timeout) { err = sem_trywait(&sem->sem); - if (err != -1) - return err; +// if (err != -1) +// return err; udelay(1000); timeout--; } From ce0ac6bec8e421fa56d4e797f48e0d4f3c6797a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 7 Jul 2011 10:47:43 +0200 Subject: [PATCH 048/261] error searching --- lwip/src/arch/sys_arch.c | 6 +++--- lwip/src/include/lwipopts.h | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lwip/src/arch/sys_arch.c b/lwip/src/arch/sys_arch.c index 5e5ba562..80930cd8 100644 --- a/lwip/src/arch/sys_arch.c +++ b/lwip/src/arch/sys_arch.c @@ -139,8 +139,8 @@ u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout) while (timeout) { err = sem_trywait(&sem->sem); -// if (err != -1) -// return err; + if (err == 0) + return err; udelay(1000); timeout--; } @@ -232,7 +232,7 @@ void sys_mbox_post(sys_mbox_t* mbox,void* msg) */ void sys_mutex_lock(sys_mutex_t* mutex) { - sem_wait(mutex); + sem_wait(mutex); } /* sys_mutex_unlock(): unlock the given mutex diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index 8e3c5645..83b714bc 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -99,8 +99,11 @@ #define NETIF_DEBUG LWIP_DBG_OFF #define TIMERS_DEBUG LWIP_DBG_OFF + +#if 0 #define LWIP_TCPIP_CORE_LOCKING_INPUT 1 #define LWIP_TCPIP_CORE_LOCKING 1 +#endif #endif From 576188bdc5f599b28a3c9844bdf662a7e0d02d33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 7 Jul 2011 10:49:45 +0200 Subject: [PATCH 049/261] error searching --- lwip/src/include/lwipopts.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index 83b714bc..6697aba8 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -49,7 +49,7 @@ /** * TCP_SND_BUF: TCP sender buffer space (bytes). */ -#define TCP_SND_BUF 2048 +#define TCP_SND_BUF 1512 #define TCP_SND_QUEUELEN 8 From 7ef45ce6669104f1a8642221639e35ce49489a0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 7 Jul 2011 10:50:41 +0200 Subject: [PATCH 050/261] error searching --- kernel/tests.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 68acd084..0705cb58 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -148,7 +148,7 @@ __inline int get_core_no(void) void* server_task(void* e) { int sockfd, newsockfd, portno, clilen; - char buffer[256]; + char buffer[512]; struct sockaddr_in serv_addr, cli_addr; int n; uint64_t tmp1,tmp2; @@ -224,14 +224,14 @@ void* server_task(void* e) tmp2 = get_clock_tick(); - kprintf("Send 512*256 Bytes in : %d clock ticks",tmp2-tmp1); + kprintf("Send 512*512 Bytes in : %d clock ticks",tmp2-tmp1); return 0; } void* client_task(void* e) { - char dir[256]; + char dir[512]; int sd; struct sockaddr_in sin; struct sockaddr_in pin; From 84ccf232cfaee7c1c4d1146423cf156a1125cb98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 7 Jul 2011 10:54:06 +0200 Subject: [PATCH 051/261] error searching --- kernel/tests.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 0705cb58..e512ef11 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -148,7 +148,7 @@ __inline int get_core_no(void) void* server_task(void* e) { int sockfd, newsockfd, portno, clilen; - char buffer[512]; + char buffer[256]; struct sockaddr_in serv_addr, cli_addr; int n; uint64_t tmp1,tmp2; @@ -214,24 +214,24 @@ void* server_task(void* e) tmp1 = get_clock_tick(); - for (n = 0; n < 512 ; n++) + for (n = 0; n < 1024 ; n++) { //if (!(n%10)) kprintf("%d-",n); - send(newsockfd,buffer,sizeof(buffer),0); + send(newsockfd,buffer,64,0); // udelay(100); } tmp2 = get_clock_tick(); - kprintf("Send 512*512 Bytes in : %d clock ticks",tmp2-tmp1); + kprintf("Send 1024*64 Bytes in : %d clock ticks",tmp2-tmp1); return 0; } void* client_task(void* e) { - char dir[512]; + char dir[256]; int sd; struct sockaddr_in sin; struct sockaddr_in pin; From fc07a1a474ffa7eda7914faa46ae858a0f89bc30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 7 Jul 2011 10:56:23 +0200 Subject: [PATCH 052/261] error searching --- kernel/tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index e512ef11..7cf40908 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -214,9 +214,9 @@ void* server_task(void* e) tmp1 = get_clock_tick(); - for (n = 0; n < 1024 ; n++) + for (n = 0; n < 4*1024 ; n++) { - //if (!(n%10)) + if (!(n%10)) kprintf("%d-",n); send(newsockfd,buffer,64,0); // udelay(100); From bb63edf73e2244f5d8f80757c7644e52ad0a03e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 7 Jul 2011 10:59:20 +0200 Subject: [PATCH 053/261] error searching --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 7cf40908..6227693d 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -218,7 +218,7 @@ void* server_task(void* e) { if (!(n%10)) kprintf("%d-",n); - send(newsockfd,buffer,64,0); + send(newsockfd,buffer,128,0); // udelay(100); } From 9c486c47882fef21fe72282b00eca5abef16dd82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 7 Jul 2011 11:01:37 +0200 Subject: [PATCH 054/261] error searching --- kernel/tests.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/tests.c b/kernel/tests.c index 6227693d..f9e37575 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -219,6 +219,8 @@ void* server_task(void* e) if (!(n%10)) kprintf("%d-",n); send(newsockfd,buffer,128,0); + if (!(n%100)) + sleep(1); // udelay(100); } From c3071131c9c4872513450153b6e7e8f83fef44f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 7 Jul 2011 11:03:31 +0200 Subject: [PATCH 055/261] error searching --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index f9e37575..ff7a03f4 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -218,7 +218,7 @@ void* server_task(void* e) { if (!(n%10)) kprintf("%d-",n); - send(newsockfd,buffer,128,0); + send(newsockfd,buffer,32,0); if (!(n%100)) sleep(1); // udelay(100); From 111e2ba0f2f7100b3818ffe67ffce5bc4aa810c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 7 Jul 2011 11:06:43 +0200 Subject: [PATCH 056/261] error searching --- drivers/net/mmnif.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index c07db0b5..cc6a8bba 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -1144,6 +1144,7 @@ static int mmnif_wait(struct netif* netif, uint32_t poll, int budget) } npackets++; + pbuf_free(p); } /* Note : i will add an return error wich indicates that From dd4cbb6d4fcaae6b3feb6b779446c545cb17e28e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 7 Jul 2011 11:07:14 +0200 Subject: [PATCH 057/261] error searching --- kernel/tests.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index ff7a03f4..ed75a9ec 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -214,13 +214,13 @@ void* server_task(void* e) tmp1 = get_clock_tick(); - for (n = 0; n < 4*1024 ; n++) + for (n = 0; n < 1024 ; n++) { if (!(n%10)) kprintf("%d-",n); - send(newsockfd,buffer,32,0); - if (!(n%100)) - sleep(1); + send(newsockfd,buffer,256,0); + // if (!(n%100)) + // sleep(1); // udelay(100); } From f1b70611b09ff6642816008811b17f821b763611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 7 Jul 2011 17:39:57 +0200 Subject: [PATCH 058/261] error searching --- drivers/net/mmnif.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index cc6a8bba..df440501 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -78,7 +78,7 @@ extern HANDLE hProc; /* decide whether it's polling mode or not */ -static int no_irq = 0; +static int no_irq = 1; /* this will be set by open() and close() and shows wether the driver is running or not */ @@ -207,23 +207,23 @@ typedef struct mmnif * - ehternet address * - local ip address */ - struct eth_addr* ethaddr; - uint32_t ipaddr; + struct eth_addr* ethaddr; + uint32_t ipaddr; /* memory interaction variables: * - transmit queue * - pointer to transmit buffer * - pointer to recive buffer */ - uint8_t tx_queue; - uint8_t* tx_buff[MMNIF_TX_QUEUELEN]; - mm_rx_buffer_t* rx_buff; + uint8_t tx_queue; + uint8_t* tx_buff[MMNIF_TX_QUEUELEN]; + mm_rx_buffer_t* rx_buff; - sem_t com_poll; + sem_t com_poll; /* comunication mailbox */ - mailbox_ptr_t mbox; + mailbox_ptr_t mbox; }mmnif_t; @@ -1144,7 +1144,6 @@ static int mmnif_wait(struct netif* netif, uint32_t poll, int budget) } npackets++; - pbuf_free(p); } /* Note : i will add an return error wich indicates that @@ -1212,6 +1211,7 @@ int mmnif_poll(void* e) #endif sem_wait(&mmnif->com_poll); } + mmnif->stats.pll_empty = 0; } mmnif->stats.pll_empty=0; mmnif_rx(mmnif_dev); From e2107f9533139dfdcfd018ed59faa7d4f07b1549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 7 Jul 2011 17:44:34 +0200 Subject: [PATCH 059/261] error searching --- drivers/net/mmnif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index df440501..f3a7af9b 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -78,7 +78,7 @@ extern HANDLE hProc; /* decide whether it's polling mode or not */ -static int no_irq = 1; +static int no_irq = 0; /* this will be set by open() and close() and shows wether the driver is running or not */ From eee0e68bf5def2c66b9c11101813d0774dfcf6fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 7 Jul 2011 17:46:25 +0200 Subject: [PATCH 060/261] error searching --- drivers/net/mmnif.c | 2 +- lwip/src/include/lwipopts.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index f3a7af9b..cd8e014c 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -69,7 +69,7 @@ extern HANDLE hProc; #define MMNIF_RX_BUFFERLEN 1792 #define MMNIF_TX_BUFFERLEN 1792 -#define MMNIF_CORES 2 +#define MMNIF_CORES 2 #define MMNIF_WORKER_BUDGET 2 diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index 6697aba8..5fb827a7 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -93,7 +93,7 @@ #define TCPIP_DEBUG LWIP_DBG_OFF #define SYS_DEBUG LWIP_DBG_OFF #define RAW_DEBUG LWIP_DBG_OFF -#define MEM_DEBUG LWIP_DBG_OFF +#define MEM_DEBUG LWIP_DBG_ON #define IP_DEBUG LWIP_DBG_OFF #define INET_DEBUG LWIP_DBG_OFF #define NETIF_DEBUG LWIP_DBG_OFF From 91d0177bb13ac72bffa8f533625fae21a2b41f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 7 Jul 2011 17:49:41 +0200 Subject: [PATCH 061/261] error searching --- lwip/src/include/lwipopts.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index 5fb827a7..bf0d78d6 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -51,7 +51,7 @@ */ #define TCP_SND_BUF 1512 -#define TCP_SND_QUEUELEN 8 +#define TCP_SND_QUEUELEN 4 /** * LWIP_BROADCAST_PING==1: respond to broadcast pings (default is unicast only) @@ -93,7 +93,7 @@ #define TCPIP_DEBUG LWIP_DBG_OFF #define SYS_DEBUG LWIP_DBG_OFF #define RAW_DEBUG LWIP_DBG_OFF -#define MEM_DEBUG LWIP_DBG_ON +#define MEM_DEBUG LWIP_DBG_OFF #define IP_DEBUG LWIP_DBG_OFF #define INET_DEBUG LWIP_DBG_OFF #define NETIF_DEBUG LWIP_DBG_OFF From ad919c459b65e7956f37b5affa35cc0f26bf420a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 18:03:09 +0200 Subject: [PATCH 062/261] error searching --- kernel/tests.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/tests.c b/kernel/tests.c index ed75a9ec..2008bf14 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -240,6 +240,8 @@ void* client_task(void* e) struct hostent *hp; int n; + int on = 1; + sleep(1); /* fill in the socket structure with host information */ @@ -254,6 +256,8 @@ void* client_task(void* e) return; } + setsockopt( sd, IPPROTO_TCP, TCP_NODELAY, (char *) &on, sizeof( on)); + kprintf("connecting with socket nr : %d",sd); /* connect to PORT on HOST */ From 0b58aa7e86331598ce89c0f4708c3c95e0c49208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 18:11:23 +0200 Subject: [PATCH 063/261] error searching --- drivers/net/mmnif.c | 4 ++-- kernel/tests.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index cd8e014c..c2c09fa2 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -757,7 +757,7 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) mmnif_write_rx_pending(dest_ip,pending); /* and unlock the dest_ip mm_rx_buffer_hdr */ - mmnif_unlock_rx_hdr(dest_ip); +// mmnif_unlock_rx_hdr(dest_ip); /* check if there is a space in the queue without overwriting another packet */ if ((queued + pending) > MMNIF_RX_QUEUELEN) @@ -778,7 +778,7 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) mmnif_write_rx_buffl(dest_ip, pos, p->payload,p->tot_len); /* like above ensure we are the only ones editing the hdr */ - mmnif_lock_rx_hdr(dest_ip); +// mmnif_lock_rx_hdr(dest_ip); queued = mmnif_read_rx_queue(dest_ip); pending = mmnif_read_rx_pending(dest_ip); diff --git a/kernel/tests.c b/kernel/tests.c index 2008bf14..6b27f422 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -256,7 +256,7 @@ void* client_task(void* e) return; } - setsockopt( sd, IPPROTO_TCP, TCP_NODELAY, (char *) &on, sizeof( on)); + // setsockopt( sd, IPPROTO_TCP, TCP_NODELAY, (char *) &on, sizeof( on)); kprintf("connecting with socket nr : %d",sd); /* connect to PORT on HOST */ From 7987f42dc0a0136e713d63f10bd22a8009c20a1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 18:15:18 +0200 Subject: [PATCH 064/261] error searching --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 6b27f422..15faede3 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -281,7 +281,7 @@ void* client_task(void* e) /* spew-out the results and bail out of here! */ kprintf("%s\n", dir); - for (n = 0; n < 512; n++) + for (n = 0; n <1024; n++) { recv(sd,dir,sizeof(dir),0); // udelay(100); From 59d22a1bba47623ceadca55907dfb0f692412fc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 18:16:42 +0200 Subject: [PATCH 065/261] error searching --- kernel/tests.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 15faede3..2e05afbb 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -214,9 +214,9 @@ void* server_task(void* e) tmp1 = get_clock_tick(); - for (n = 0; n < 1024 ; n++) + for (n = 0; n < 1024*1024*4 ; n++) { - if (!(n%10)) + if (!(n%100)) kprintf("%d-",n); send(newsockfd,buffer,256,0); // if (!(n%100)) @@ -281,7 +281,7 @@ void* client_task(void* e) /* spew-out the results and bail out of here! */ kprintf("%s\n", dir); - for (n = 0; n <1024; n++) + for (n = 0; n <1024*1024*4; n++) { recv(sd,dir,sizeof(dir),0); // udelay(100); From 39ab1fc190bf5359f8fa4f382560e867edb602ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 18:20:31 +0200 Subject: [PATCH 066/261] error searching --- drivers/net/mmnif.c | 4 ++-- kernel/tests.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index c2c09fa2..bf647a64 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -757,7 +757,7 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) mmnif_write_rx_pending(dest_ip,pending); /* and unlock the dest_ip mm_rx_buffer_hdr */ -// mmnif_unlock_rx_hdr(dest_ip); + mmnif_unlock_rx_hdr(dest_ip); /* check if there is a space in the queue without overwriting another packet */ if ((queued + pending) > MMNIF_RX_QUEUELEN) @@ -778,7 +778,7 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) mmnif_write_rx_buffl(dest_ip, pos, p->payload,p->tot_len); /* like above ensure we are the only ones editing the hdr */ -// mmnif_lock_rx_hdr(dest_ip); + mmnif_lock_rx_hdr(dest_ip); queued = mmnif_read_rx_queue(dest_ip); pending = mmnif_read_rx_pending(dest_ip); diff --git a/kernel/tests.c b/kernel/tests.c index 2e05afbb..aaeb86ea 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -214,7 +214,7 @@ void* server_task(void* e) tmp1 = get_clock_tick(); - for (n = 0; n < 1024*1024*4 ; n++) + for (n = 0; n < 1024*4 ; n++) { if (!(n%100)) kprintf("%d-",n); @@ -281,7 +281,7 @@ void* client_task(void* e) /* spew-out the results and bail out of here! */ kprintf("%s\n", dir); - for (n = 0; n <1024*1024*4; n++) + for (n = 0; n <1024*4; n++) { recv(sd,dir,sizeof(dir),0); // udelay(100); From c783649803108546a0fdd427f20c93fa693f2cc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 18:25:02 +0200 Subject: [PATCH 067/261] error searching --- kernel/tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index aaeb86ea..017ef8b2 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -148,7 +148,7 @@ __inline int get_core_no(void) void* server_task(void* e) { int sockfd, newsockfd, portno, clilen; - char buffer[256]; + char buffer[1024]; struct sockaddr_in serv_addr, cli_addr; int n; uint64_t tmp1,tmp2; @@ -281,7 +281,7 @@ void* client_task(void* e) /* spew-out the results and bail out of here! */ kprintf("%s\n", dir); - for (n = 0; n <1024*4; n++) + for (n = 0; n <1024*4*1024*4; n++) { recv(sd,dir,sizeof(dir),0); // udelay(100); From 3db1f0d22e748c115add6cec8af82f8e981430fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 18:27:07 +0200 Subject: [PATCH 068/261] error searching --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 017ef8b2..0141aba0 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -148,7 +148,7 @@ __inline int get_core_no(void) void* server_task(void* e) { int sockfd, newsockfd, portno, clilen; - char buffer[1024]; + char buffer[2048]; struct sockaddr_in serv_addr, cli_addr; int n; uint64_t tmp1,tmp2; From ad693d9106c1f6f38d265fbb706b8ee1b01a4bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 18:29:13 +0200 Subject: [PATCH 069/261] benchmarking --- drivers/net/mmnif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index bf647a64..a56a826b 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -78,7 +78,7 @@ extern HANDLE hProc; /* decide whether it's polling mode or not */ -static int no_irq = 0; +static int no_irq = 1; /* this will be set by open() and close() and shows wether the driver is running or not */ From de550bae943dfc3c87ede04375b555788f5f0ba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 18:38:16 +0200 Subject: [PATCH 070/261] benchmarking --- drivers/net/mmnif.c | 10 ++++++---- kernel/tests.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index a56a826b..057ef9c9 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -78,7 +78,7 @@ extern HANDLE hProc; /* decide whether it's polling mode or not */ -static int no_irq = 1; +static int no_irq = 0; /* this will be set by open() and close() and shows wether the driver is running or not */ @@ -102,7 +102,7 @@ static unsigned int router_ip_address = 0xC0A80001; /* 192.168.0.1 */ * - start address * - size */ -char* mpb_start_address = NULL; +char* mpb_start_address = NULL; unsigned int mpb_size = NULL; @@ -1203,7 +1203,7 @@ int mmnif_poll(void* e) /* enable interrupts and suspend polling * */ - mmnif_lock_rx_hdr(own_ip_address && 0xff); + mmnif_lock_rx_hdr(own_ip_address && 0xff); mmnif->rx_buff->iv_intr = TRUE; mmnif_unlock_rx_hdr(own_ip_address && 0xff); #ifdef DEBUG_MMNIF @@ -1211,7 +1211,9 @@ int mmnif_poll(void* e) #endif sem_wait(&mmnif->com_poll); } - mmnif->stats.pll_empty = 0; + /* uncomment this to test only polling + */ + //mmnif->stats.pll_empty = 0; } mmnif->stats.pll_empty=0; mmnif_rx(mmnif_dev); diff --git a/kernel/tests.c b/kernel/tests.c index 0141aba0..262dbff0 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -148,7 +148,7 @@ __inline int get_core_no(void) void* server_task(void* e) { int sockfd, newsockfd, portno, clilen; - char buffer[2048]; + char buffer[256]; struct sockaddr_in serv_addr, cli_addr; int n; uint64_t tmp1,tmp2; From 34a9a412a647202815d3acff4ecd7106ee9f43fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 18:44:49 +0200 Subject: [PATCH 071/261] benchmarking --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 262dbff0..cc49e15d 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -148,7 +148,7 @@ __inline int get_core_no(void) void* server_task(void* e) { int sockfd, newsockfd, portno, clilen; - char buffer[256]; + char buffer[4096]; struct sockaddr_in serv_addr, cli_addr; int n; uint64_t tmp1,tmp2; From 02689a67cfa6de2999d4b4140a0d4aa1d26dc0d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 18:47:14 +0200 Subject: [PATCH 072/261] benchmarking --- kernel/tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index cc49e15d..39989798 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -233,7 +233,7 @@ void* server_task(void* e) void* client_task(void* e) { - char dir[256]; + char dir[1024]; int sd; struct sockaddr_in sin; struct sockaddr_in pin; @@ -281,7 +281,7 @@ void* client_task(void* e) /* spew-out the results and bail out of here! */ kprintf("%s\n", dir); - for (n = 0; n <1024*4*1024*4; n++) + while(1) { recv(sd,dir,sizeof(dir),0); // udelay(100); From 92161cc3cedc3aeb0fda6b54ebb41ba89f4b5357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 18:47:47 +0200 Subject: [PATCH 073/261] benchmarking --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 39989798..00198240 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -218,7 +218,7 @@ void* server_task(void* e) { if (!(n%100)) kprintf("%d-",n); - send(newsockfd,buffer,256,0); + send(newsockfd,buffer,sizeof(buffer),0); // if (!(n%100)) // sleep(1); // udelay(100); From 290339fc7a704354c70adb3ef27ed9fa5bf5c22b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 18:50:17 +0200 Subject: [PATCH 074/261] benchmarking --- kernel/tests.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 00198240..494b7c5a 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -148,7 +148,7 @@ __inline int get_core_no(void) void* server_task(void* e) { int sockfd, newsockfd, portno, clilen; - char buffer[4096]; + char buffer[512]; struct sockaddr_in serv_addr, cli_addr; int n; uint64_t tmp1,tmp2; @@ -218,7 +218,11 @@ void* server_task(void* e) { if (!(n%100)) kprintf("%d-",n); - send(newsockfd,buffer,sizeof(buffer),0); + if (send(newsockfd,buffer,sizeof(buffer),0) < 0); + { + kprintf("error on sending"); + break; + } // if (!(n%100)) // sleep(1); // udelay(100); From c7ffc411fde52caafa2aa721e9ad3aa2b4aa407c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 18:51:39 +0200 Subject: [PATCH 075/261] benchmarking --- kernel/tests.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 494b7c5a..c2d84c81 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -152,6 +152,7 @@ void* server_task(void* e) struct sockaddr_in serv_addr, cli_addr; int n; uint64_t tmp1,tmp2; + int err; /* First call to socket() function */ sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); @@ -218,9 +219,9 @@ void* server_task(void* e) { if (!(n%100)) kprintf("%d-",n); - if (send(newsockfd,buffer,sizeof(buffer),0) < 0); + if (err = send(newsockfd,buffer,sizeof(buffer),0) < 0); { - kprintf("error on sending"); + kprintf("error on sending: %d",err); break; } // if (!(n%100)) From d6074331b9ee1443041ffaa6dffaa1b25b94d14a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 18:53:00 +0200 Subject: [PATCH 076/261] benchmarking --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index c2d84c81..fb8679ff 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -148,7 +148,7 @@ __inline int get_core_no(void) void* server_task(void* e) { int sockfd, newsockfd, portno, clilen; - char buffer[512]; + char buffer[256]; struct sockaddr_in serv_addr, cli_addr; int n; uint64_t tmp1,tmp2; From cf93116041b5cd257bdafe7c9f83c6737c9b610c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 18:54:47 +0200 Subject: [PATCH 077/261] benchmarking --- kernel/tests.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index fb8679ff..81c50664 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -219,7 +219,8 @@ void* server_task(void* e) { if (!(n%100)) kprintf("%d-",n); - if (err = send(newsockfd,buffer,sizeof(buffer),0) < 0); + err = send(newsockfd,buffer,sizeof(buffer),0); + if (err < 0); { kprintf("error on sending: %d",err); break; From a6e421701a1e4a430bee16e23015c681461c4252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 18:57:28 +0200 Subject: [PATCH 078/261] benchmarking --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 81c50664..2acff0db 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -220,7 +220,7 @@ void* server_task(void* e) if (!(n%100)) kprintf("%d-",n); err = send(newsockfd,buffer,sizeof(buffer),0); - if (err < 0); + if (err == -1); { kprintf("error on sending: %d",err); break; From 91f68a062d7efa04079a89351ff55ac5ca6e483b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 18:59:04 +0200 Subject: [PATCH 079/261] benchmarking --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 2acff0db..bb57c6e3 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -220,7 +220,7 @@ void* server_task(void* e) if (!(n%100)) kprintf("%d-",n); err = send(newsockfd,buffer,sizeof(buffer),0); - if (err == -1); + if (err < 0) { kprintf("error on sending: %d",err); break; From 2e0e2a96ea46f5b7843d27b42b5c63e517b95f57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 18:59:55 +0200 Subject: [PATCH 080/261] benchmarking --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index bb57c6e3..ab6e5eed 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -148,7 +148,7 @@ __inline int get_core_no(void) void* server_task(void* e) { int sockfd, newsockfd, portno, clilen; - char buffer[256]; + char buffer[512]; struct sockaddr_in serv_addr, cli_addr; int n; uint64_t tmp1,tmp2; From 0c060119c28951515681a52697b9561bc2c32053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 19:04:25 +0200 Subject: [PATCH 081/261] benchmarking --- kernel/tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index ab6e5eed..610329c2 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -148,7 +148,7 @@ __inline int get_core_no(void) void* server_task(void* e) { int sockfd, newsockfd, portno, clilen; - char buffer[512]; + char buffer[1024]; struct sockaddr_in serv_addr, cli_addr; int n; uint64_t tmp1,tmp2; @@ -239,7 +239,7 @@ void* server_task(void* e) void* client_task(void* e) { - char dir[1024]; + char dir[2048]; int sd; struct sockaddr_in sin; struct sockaddr_in pin; From 21786ca6e468dccd20ff1ce2bedd400ef28b95af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 19:06:30 +0200 Subject: [PATCH 082/261] benchmarking --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 610329c2..81352a74 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -148,7 +148,7 @@ __inline int get_core_no(void) void* server_task(void* e) { int sockfd, newsockfd, portno, clilen; - char buffer[1024]; + char buffer[256]; struct sockaddr_in serv_addr, cli_addr; int n; uint64_t tmp1,tmp2; From ee6f278eda7b45dfcbd65e4b665048538ee104ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 19:06:44 +0200 Subject: [PATCH 083/261] benchmarking --- lwip/src/include/lwipopts.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index bf0d78d6..7da133db 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -100,7 +100,7 @@ #define TIMERS_DEBUG LWIP_DBG_OFF -#if 0 +#if 1 #define LWIP_TCPIP_CORE_LOCKING_INPUT 1 #define LWIP_TCPIP_CORE_LOCKING 1 #endif From 9166bb59e922ca7650b5c7debb23b72013d05d8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 19:07:56 +0200 Subject: [PATCH 084/261] benchmarking --- lwip/src/include/lwipopts.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index 7da133db..bf0d78d6 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -100,7 +100,7 @@ #define TIMERS_DEBUG LWIP_DBG_OFF -#if 1 +#if 0 #define LWIP_TCPIP_CORE_LOCKING_INPUT 1 #define LWIP_TCPIP_CORE_LOCKING 1 #endif From c96c4f4b4185949ceb158c0b22a3de9712bd1bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 19:12:12 +0200 Subject: [PATCH 085/261] benchmarking --- include/metalsvm/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/metalsvm/config.h b/include/metalsvm/config.h index f70fdd4c..15a222af 100644 --- a/include/metalsvm/config.h +++ b/include/metalsvm/config.h @@ -35,7 +35,7 @@ extern "C" { #define PAGE_SHIFT 12 #define CACHE_LINE 64 #define MAILBOX_SIZE 8 -#define TIMER_FREQ 100 /* in HZ */ +#define TIMER_FREQ 1000 /* in HZ */ #define CLOCK_TICK_RATE 1193182 /* 8254 chip's internal oscillator frequency */ #define INT_SYSCALL 0x80 #define KERNEL_SPACE (1*1024*1024*1024) From fafcee6d76b685cec2c9a74f43d284cd3f852afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 19:16:47 +0200 Subject: [PATCH 086/261] benchmarking --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 81352a74..e1065784 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -148,7 +148,7 @@ __inline int get_core_no(void) void* server_task(void* e) { int sockfd, newsockfd, portno, clilen; - char buffer[256]; + char buffer[512]; struct sockaddr_in serv_addr, cli_addr; int n; uint64_t tmp1,tmp2; From 35b47d2c0c410868382a529ac1bdd55f09e4ebcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 19:17:38 +0200 Subject: [PATCH 087/261] benchmarking --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index e1065784..e538c2eb 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -148,7 +148,7 @@ __inline int get_core_no(void) void* server_task(void* e) { int sockfd, newsockfd, portno, clilen; - char buffer[512]; + char buffer[792]; struct sockaddr_in serv_addr, cli_addr; int n; uint64_t tmp1,tmp2; From 2bd85cd82fc509eba764a65a3b8a5dca819beebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Fri, 8 Jul 2011 19:18:44 +0200 Subject: [PATCH 088/261] benchmarking --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index e538c2eb..e1065784 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -148,7 +148,7 @@ __inline int get_core_no(void) void* server_task(void* e) { int sockfd, newsockfd, portno, clilen; - char buffer[792]; + char buffer[512]; struct sockaddr_in serv_addr, cli_addr; int n; uint64_t tmp1,tmp2; From 0ff5546477ea9296f23a2bf7fc9a67243d1ec63f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=FCger?= Date: Sat, 9 Jul 2011 09:00:17 +0200 Subject: [PATCH 089/261] fix locking errors --- drivers/net/mmnif.c | 115 +++++++++++++++++++++++++++++--------------- 1 file changed, 76 insertions(+), 39 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 057ef9c9..5d21a9b6 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -23,7 +23,7 @@ #include /* struct iphdr*/ #include /* tcpip_input()*/ -//#define DEBUG_MMNIF +#define DEBUG_MMNIF #ifdef DEBUG_MMNIF #include "util.h" /* hex dump */ @@ -39,6 +39,8 @@ typedef bthread_t tid_t; /* "interrupt" of the other virutal network card*/ extern HANDLE remote_process_event; +extern HANDLE remote_process_mutex; +extern HANDLE own_process_mutex; /* HANDLE to the other Process (for WPM and RPM)*/ extern HANDLE hProc; @@ -69,9 +71,9 @@ extern HANDLE hProc; #define MMNIF_RX_BUFFERLEN 1792 #define MMNIF_TX_BUFFERLEN 1792 -#define MMNIF_CORES 2 +#define MMNIF_CORES 2 -#define MMNIF_WORKER_BUDGET 2 +#define MMNIF_WORKER_BUDGET 4 #define MMNIF_POLL_BUDGET 0x100000 #define MMNIF_WAIT_BUDGET 0x2 @@ -187,8 +189,8 @@ typedef struct mm_rx_buffer uint8_t iv_intr; -// sem_t lock; - spinlock_t lock; + sem_t lock; +// spinlock_t lock; // uint32_t timestamp[MMNIF_RX_QUEUELEN]; // uint32_t bitmap[MMNIF_RX_QUEUELEN]; @@ -538,15 +540,22 @@ __inline void* mmnif_shmalloc() __inline void mmnif_lock_rx_hdr(int dest_ip) { #ifdef WIN32 - mm_rx_buffer_t hdr; - if(disable_locking) return; - while(!ReadProcessMemory(hProc,(char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,&hdr,sizeof(hdr),NULL)); - sem_wait(&hdr.lock); +// mm_rx_buffer_t hdr; +// if(disable_locking) return; +// while(!ReadProcessMemory(hProc,(char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,&hdr,sizeof(hdr),NULL)); +// ReadProcessMemory(hProc,(char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,&hdr,sizeof(hdr),NULL); +// sem_wait(&hdr.lock); + + if (dest_ip != own_ip_address && 0xFF) + return WaitForSingleObject(remote_process_mutex,INFINITE); + else + return WaitForSingleObject(own_process_mutex,INFINITE); + #else if(disable_locking) return; mm_rx_buffer_t* hdr = (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size; // sem_wait(&hdr->lock); - spinlock_lock(&hdr->lock); + spinlock_lock(&hdr->lock); #endif } /* mmnif_unlock_rx_hdr(): unlock the header @@ -555,14 +564,20 @@ __inline void mmnif_lock_rx_hdr(int dest_ip) __inline void mmnif_unlock_rx_hdr(int dest_ip) { #ifdef WIN32 - mm_rx_buffer_t hdr; - if(disable_locking) return; - while(!ReadProcessMemory(hProc,(char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,&hdr,sizeof(hdr),NULL)); - sem_post(&hdr.lock); +// mm_rx_buffer_t hdr; +// if(disable_locking) return; +// while(!ReadProcessMemory(hProc,(char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,&hdr,sizeof(hdr),NULL)); +// ReadProcessMemory(hProc,(char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,&hdr,sizeof(hdr),NULL); +// sem_post(&hdr.lock); + if (dest_ip != own_ip_address && 0xFF) + return ReleaseMutex(remote_process_mutex); + else + return ReleaseMutex(own_process_mutex); #else if(disable_locking) return; mm_rx_buffer_t* hdr = (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size; - spinlock_unlock(&hdr->lock); +// sem_post(&hdr->lock); + spinlock_unlock(&hdr->lock); #endif } @@ -689,7 +704,9 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) uint8_t dest_intr = FALSE; uint32_t dest_ip = mmnif_get_destination(netif,p); +// mmnif_lock_rx_hdr(dest_ip); /* take a place in the tx_queue */ +// InterlockedIncrement(&mmnif->tx_queue); mmnif->tx_queue++; /* Perform serveral sanity checks on the packet and the buffers: @@ -701,7 +718,7 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) * just one thread is writing to pos and queue of the mm_rx_buff */ - if (mmnif->tx_queue >= MMNIF_TX_QUEUELEN) + if (mmnif->tx_queue > MMNIF_TX_QUEUELEN) { DEBUGPRINTF("mmnif_tx(): too many packets at once for tx_queue\n"); goto drop_packet; @@ -740,7 +757,8 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) /* because there is no copy operation to the tx_slots * we don't need a place in the queue anymore */ - mmnif->tx_queue--; +// mmnif->tx_queue--; +// InterlockedDecrement(&mmnif->tx_queue); } /* get the palce the router core is looking for the packet */ @@ -757,7 +775,7 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) mmnif_write_rx_pending(dest_ip,pending); /* and unlock the dest_ip mm_rx_buffer_hdr */ - mmnif_unlock_rx_hdr(dest_ip); + mmnif_unlock_rx_hdr(dest_ip); /* check if there is a space in the queue without overwriting another packet */ if ((queued + pending) > MMNIF_RX_QUEUELEN) @@ -778,7 +796,7 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) mmnif_write_rx_buffl(dest_ip, pos, p->payload,p->tot_len); /* like above ensure we are the only ones editing the hdr */ - mmnif_lock_rx_hdr(dest_ip); + mmnif_lock_rx_hdr(dest_ip); queued = mmnif_read_rx_queue(dest_ip); pending = mmnif_read_rx_pending(dest_ip); @@ -787,7 +805,7 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) dest_intr = mmnif_read_rx_inv_intr(dest_ip); -#ifdef DEBUG_MMNIF +#ifdef DEBUG_MMNIF_PACKET DEBUGPRINTF("\n SEND 0x%.8X with length: %d\n",(char*)mpb_start_address + (dest_ip -1)*mpb_size + pos * 1792,p->tot_len +2); hex_dump(p->tot_len, p->payload); #endif @@ -802,8 +820,9 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) mmnif_trigger_irq(dest_ip); /* free the transmid queue*/ - if(build_buff) - mmnif->tx_queue--; +// if(build_buff) + mmnif->tx_queue--; +// InterlockedDecrement(&mmnif->tx_queue); /* gather stats: * - firstly for lwip @@ -815,11 +834,18 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) mmnif->stats.tx++; mmnif->stats.tx_bytes += p->tot_len; +// mmnif_unlock_rx_hdr(dest_ip); return ERR_OK; drop_packet: /* packet is lost. clean up and gather stats */ - mmnif->tx_queue--; + mmnif_lock_rx_hdr(dest_ip); + + pending = mmnif_read_rx_pending(dest_ip); + pending--; + mmnif_write_rx_pending(dest_ip, pending); + + mmnif_unlock_rx_hdr(dest_ip); LINK_STATS_INC(link.drop); @@ -877,8 +903,8 @@ err_t mmnif_init(struct netif* netif) /* init the lock for the hdr */ -// sem_init(&mmnif->rx_buff->lock,1); - spinlock_init(&mmnif->rx_buff->lock); + sem_init(&mmnif->rx_buff->lock,1); + // spinlock_init(&mmnif->rx_buff->lock); /* init the sems for communication art */ @@ -980,7 +1006,9 @@ static void mmnif_rx(struct netif* netif) /* retrieve pointer to actual data array */ data = (char*) mmnif->rx_buff + sizeof(mm_rx_buffer_t); /* retrice position wich is needed to be worked on */ + mmnif_lock_rx_hdr(own_ip_address && 0xFF); pos = (mmnif->rx_buff->pos % MMNIF_RX_QUEUELEN) * MMNIF_RX_BUFFERLEN; +// mmnif_unlock_rx_hdr(own_ip_address && 0xFF); /* The packet length is stored in the first 2 bytes but does not include * the header. Check for reasonable sizes before processing the data to @@ -993,6 +1021,8 @@ static void mmnif_rx(struct netif* netif) { // mmnif->rx_buff->pos++; // mmnif->rx_buff->queued--; + DEBUGPRINTF("mmnif_rx(): empty packet error\n"); + mmnif_unlock_rx_hdr(own_ip_address & 0xFF); return; } if (length < sizeof(struct ip_hdr) ||length > netif->mtu) @@ -1006,7 +1036,7 @@ static void mmnif_rx(struct netif* netif) */ -#ifdef DEBUG_MMNIF +#ifdef DEBUG_MMNIF_PACKET DEBUGPRINTF("\n RECIEVED - 0x%.8X with legth: %d\n",data + pos,length+2); hex_dump(length+2,data + pos); #endif @@ -1036,12 +1066,18 @@ static void mmnif_rx(struct netif* netif) * the old one for new incoming packets */ - mmnif_lock_rx_hdr(own_ip_address & 0xFF); +// mmnif_lock_rx_hdr(own_ip_address & 0xFF); mmnif->rx_buff->pos++; mmnif->rx_buff->queued--; + if (mmnif->rx_buff->queued > MMNIF_RX_QUEUELEN) + { + DEBUGPRINTF("mmnif_rx(): integer underflow on mmnif->rx_buff->queued\n"); + mmnif->rx_buff->queued = 0; + } - mmnif_unlock_rx_hdr(own_ip_address & 0xFF); + +// mmnif_unlock_rx_hdr(own_ip_address & 0xFF); /* using the mailbox to hand the buffer to the incoming packet thread * so the "interrupt" itself is not taking to long @@ -1059,11 +1095,12 @@ static void mmnif_rx(struct netif* netif) else mmnif->stats.rx_poll++; + mmnif_unlock_rx_hdr(own_ip_address & 0xFF); return; drop_packet: /* packet is lost so gather stats and leave the rx handler*/ - mmnif_lock_rx_hdr(own_ip_address & 0xFF); + // mmnif_lock_rx_hdr(own_ip_address & 0xFF); mmnif->rx_buff->pos++; mmnif->rx_buff->queued--; @@ -1103,9 +1140,9 @@ static int mmnif_wait(struct netif* netif, uint32_t poll, int budget) */ if (mmnif->rx_buff->iv_intr == TRUE) { - mmnif_lock_rx_hdr(own_ip_address && 0xff); +// mmnif_lock_rx_hdr(own_ip_address && 0xff); mmnif->rx_buff->iv_intr = FALSE; - mmnif_unlock_rx_hdr(own_ip_address && 0xff); +// mmnif_unlock_rx_hdr(own_ip_address && 0xff); #ifdef DEBUG_MMNIF DEBUGPRINTF("mmnif_wait(): heuristical polling enables\n"); #endif @@ -1197,25 +1234,25 @@ int mmnif_poll(void* e) { while (!mmnif->rx_buff->queued) { - mmnif->stats.pll_empty++; + mmnif->stats.pll_empty++; if (mmnif->stats.pll_empty >= MMNIF_POLL_BUDGET) { /* enable interrupts and suspend polling * */ - mmnif_lock_rx_hdr(own_ip_address && 0xff); +// mmnif_lock_rx_hdr(own_ip_address && 0xff); mmnif->rx_buff->iv_intr = TRUE; - mmnif_unlock_rx_hdr(own_ip_address && 0xff); +// mmnif_unlock_rx_hdr(own_ip_address && 0xff); #ifdef DEBUG_MMNIF DEBUGPRINTF("mmnif_poll(): heuristical interrupts enabled\n"); #endif sem_wait(&mmnif->com_poll); } - /* uncomment this to test only polling - */ - //mmnif->stats.pll_empty = 0; + /* uncomment this to test only polling + */ + // mmnif->stats.pll_empty = 0; } - mmnif->stats.pll_empty=0; + mmnif->stats.pll_empty=0; mmnif_rx(mmnif_dev); if (instant_process) @@ -1245,7 +1282,7 @@ void mmnif_irqhandler() mmnif_rx(mmnif_dev); if (instant_process) - mmnif_wait(mmnif_dev,0,MMNIF_WORKER_BUDGET); + mmnif_wait(mmnif_dev,1,MMNIF_WORKER_BUDGET); } } From 77e01d28b0eb46c6a4a5b10b1430082f40912a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Sat, 9 Jul 2011 09:05:59 +0200 Subject: [PATCH 090/261] adding spinlock --- drivers/net/mmnif.c | 4 ++-- include/metalsvm/config.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 5d21a9b6..25589bf2 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -189,8 +189,8 @@ typedef struct mm_rx_buffer uint8_t iv_intr; - sem_t lock; -// spinlock_t lock; +// sem_t lock; + spinlock_t lock; // uint32_t timestamp[MMNIF_RX_QUEUELEN]; // uint32_t bitmap[MMNIF_RX_QUEUELEN]; diff --git a/include/metalsvm/config.h b/include/metalsvm/config.h index 15a222af..f70fdd4c 100644 --- a/include/metalsvm/config.h +++ b/include/metalsvm/config.h @@ -35,7 +35,7 @@ extern "C" { #define PAGE_SHIFT 12 #define CACHE_LINE 64 #define MAILBOX_SIZE 8 -#define TIMER_FREQ 1000 /* in HZ */ +#define TIMER_FREQ 100 /* in HZ */ #define CLOCK_TICK_RATE 1193182 /* 8254 chip's internal oscillator frequency */ #define INT_SYSCALL 0x80 #define KERNEL_SPACE (1*1024*1024*1024) From 74b206b2429dc2e8b1b82db77768d963deed3677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Sat, 9 Jul 2011 09:07:01 +0200 Subject: [PATCH 091/261] adding spinlock --- drivers/net/mmnif.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 25589bf2..e8250d01 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -903,8 +903,8 @@ err_t mmnif_init(struct netif* netif) /* init the lock for the hdr */ - sem_init(&mmnif->rx_buff->lock,1); - // spinlock_init(&mmnif->rx_buff->lock); +// sem_init(&mmnif->rx_buff->lock,1); + spinlock_init(&mmnif->rx_buff->lock); /* init the sems for communication art */ From 87cca25b8257716a5c0754ac9d35e3e059504d41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Sat, 9 Jul 2011 09:10:52 +0200 Subject: [PATCH 092/261] benchmarking --- kernel/tests.c | 2 +- lwip/src/include/lwipopts.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index e1065784..5339450a 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -215,7 +215,7 @@ void* server_task(void* e) tmp1 = get_clock_tick(); - for (n = 0; n < 1024*4 ; n++) + for (n = 0; n < 1024*256 ; n++) { if (!(n%100)) kprintf("%d-",n); diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index bf0d78d6..99678dbf 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -51,7 +51,7 @@ */ #define TCP_SND_BUF 1512 -#define TCP_SND_QUEUELEN 4 +#define TCP_SND_QUEUELEN 2 /** * LWIP_BROADCAST_PING==1: respond to broadcast pings (default is unicast only) From 8aa2dabd0cd5a499ab6d0f44578af011e6d7b79e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Sat, 9 Jul 2011 09:28:04 +0200 Subject: [PATCH 093/261] benchmarking --- drivers/net/mmnif.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index e8250d01..d3d1d2c1 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -511,6 +511,22 @@ __inline int mmnif_worker_schedule() return NULL; #endif } + +void* mmnif_retrigger(void* e) +{ + while(active) + { + sleep(1); + mmnif_irqhandler(); + } + return NULL; +} + +__inline int mmnif_retrigger_schedule() +{ + tid_t tmp; + create_kernel_task(&rtmp,mmnif_retrigger,NULL); +} /* Allocate Shared Memory for communication this could be: * - in Message Passing Buffer * - Shared Memory Address Space (0x8000000 + ) @@ -1352,6 +1368,9 @@ int mmnif_open() if (!instant_process) mmnif_worker_schedule(); + + mmnif_retrigger_schedule(); + #ifdef DEBUG_MMNIF DEBUGPRINTF("mmnif_dev is open\n"); #endif From 244e2377cedd9064391c48ea05e5e1b5bd63a29d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Sat, 9 Jul 2011 09:28:43 +0200 Subject: [PATCH 094/261] benchmarking --- drivers/net/mmnif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index d3d1d2c1..f960195d 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -525,7 +525,7 @@ void* mmnif_retrigger(void* e) __inline int mmnif_retrigger_schedule() { tid_t tmp; - create_kernel_task(&rtmp,mmnif_retrigger,NULL); + create_kernel_task(&tmp,mmnif_retrigger,NULL); } /* Allocate Shared Memory for communication this could be: * - in Message Passing Buffer From 76d9d833c42c59a8a5ea3140b3fe2720303014c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Sat, 9 Jul 2011 09:32:39 +0200 Subject: [PATCH 095/261] benchmarking --- include/metalsvm/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/metalsvm/config.h b/include/metalsvm/config.h index f70fdd4c..15a222af 100644 --- a/include/metalsvm/config.h +++ b/include/metalsvm/config.h @@ -35,7 +35,7 @@ extern "C" { #define PAGE_SHIFT 12 #define CACHE_LINE 64 #define MAILBOX_SIZE 8 -#define TIMER_FREQ 100 /* in HZ */ +#define TIMER_FREQ 1000 /* in HZ */ #define CLOCK_TICK_RATE 1193182 /* 8254 chip's internal oscillator frequency */ #define INT_SYSCALL 0x80 #define KERNEL_SPACE (1*1024*1024*1024) From 1fcab0adcb8e6290b19be5d9c0fc5d1dccf39a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Sat, 9 Jul 2011 09:35:22 +0200 Subject: [PATCH 096/261] benchmarking --- include/metalsvm/config.h | 2 +- lwip/src/include/lwipopts.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/metalsvm/config.h b/include/metalsvm/config.h index 15a222af..f70fdd4c 100644 --- a/include/metalsvm/config.h +++ b/include/metalsvm/config.h @@ -35,7 +35,7 @@ extern "C" { #define PAGE_SHIFT 12 #define CACHE_LINE 64 #define MAILBOX_SIZE 8 -#define TIMER_FREQ 1000 /* in HZ */ +#define TIMER_FREQ 100 /* in HZ */ #define CLOCK_TICK_RATE 1193182 /* 8254 chip's internal oscillator frequency */ #define INT_SYSCALL 0x80 #define KERNEL_SPACE (1*1024*1024*1024) diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index 99678dbf..bf0d78d6 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -51,7 +51,7 @@ */ #define TCP_SND_BUF 1512 -#define TCP_SND_QUEUELEN 2 +#define TCP_SND_QUEUELEN 4 /** * LWIP_BROADCAST_PING==1: respond to broadcast pings (default is unicast only) From 8c08e177701f6c3917c4ac3372cc8337313358f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Sat, 9 Jul 2011 09:44:16 +0200 Subject: [PATCH 097/261] benchmarking --- drivers/net/mmnif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index f960195d..24cc84ef 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -1272,7 +1272,7 @@ int mmnif_poll(void* e) mmnif_rx(mmnif_dev); if (instant_process) - mmnif_wait(mmnif_dev,0,MMNIF_WORKER_BUDGET); + mmnif_wait(mmnif_dev,1,MMNIF_WORKER_BUDGET); } return NULL; From 5af3077386db529313a3f425ca64dc66319090d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Sat, 9 Jul 2011 09:53:12 +0200 Subject: [PATCH 098/261] benchmarking --- drivers/net/mmnif.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 24cc84ef..6dbfba1a 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -71,7 +71,7 @@ extern HANDLE hProc; #define MMNIF_RX_BUFFERLEN 1792 #define MMNIF_TX_BUFFERLEN 1792 -#define MMNIF_CORES 2 +#define MMNIF_CORES 2 #define MMNIF_WORKER_BUDGET 4 @@ -517,6 +517,7 @@ void* mmnif_retrigger(void* e) while(active) { sleep(1); + DEBUGPRINTF("mmnif_retrigger(): \n"); mmnif_irqhandler(); } return NULL; @@ -1178,7 +1179,10 @@ static int mmnif_wait(struct netif* netif, uint32_t poll, int budget) { /* if there is no data return immeadieatly */ if (mailbox_ptr_tryfetch(&(mmnif->mbox), (void**) &p)) - return err; + { + DEBUGPRINTF("mmnif_wait(): fetched empty mailbox\n"); + return err; + } } else { From a7c1517e9bad7ff54fc9bf537f1559a8ee536c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Mon, 11 Jul 2011 13:15:10 +0200 Subject: [PATCH 099/261] benchmarking --- drivers/net/mmnif.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 6dbfba1a..d1409ba0 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -517,7 +517,6 @@ void* mmnif_retrigger(void* e) while(active) { sleep(1); - DEBUGPRINTF("mmnif_retrigger(): \n"); mmnif_irqhandler(); } return NULL; @@ -738,13 +737,15 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) if (mmnif->tx_queue > MMNIF_TX_QUEUELEN) { DEBUGPRINTF("mmnif_tx(): too many packets at once for tx_queue\n"); - goto drop_packet; + mmnif->tx_queue--; + goto drop_packet_fast; } if (p->tot_len > MMNIF_TX_BUFFERLEN) { DEBUGPRINTF("mmnif_tx(): packet is longer than 1792 bytes\n"); - goto drop_packet; + mmnif->tx_queue--; + goto drop_packet_fast; } /* check if the pbuf consists only of one element @@ -862,7 +863,8 @@ drop_packet: /* packet is lost. clean up and gather stats */ pending--; mmnif_write_rx_pending(dest_ip, pending); - mmnif_unlock_rx_hdr(dest_ip); + mmnif_unlock_rx_hdr(dest_ip); +drop_packet_fast: LINK_STATS_INC(link.drop); From b6ea3d50f4004b35f1fc558ef942f7f429a177f4 Mon Sep 17 00:00:00 2001 From: "U-MobileHooK\\Benedikt" Date: Mon, 11 Jul 2011 13:30:05 +0200 Subject: [PATCH 100/261] userspace socket support --- include/metalsvm/syscall.h | 12 ++++ kernel/syscall.c | 57 +++++++++++++++++++ newlib/src/compile | 0 newlib/src/config.guess | 0 newlib/src/config.rpath | 0 newlib/src/config.status | 0 newlib/src/config.sub | 0 newlib/src/config/acinclude.m4 | 0 newlib/src/configure | 0 newlib/src/depcomp | 0 newlib/src/etc/config.status | 0 newlib/src/etc/configure | 0 newlib/src/install-sh | 0 newlib/src/libgloss/bfin/configure | 0 newlib/src/libgloss/configure | 0 newlib/src/libgloss/cris/configure | 0 newlib/src/libgloss/crx/configure | 0 newlib/src/libgloss/d30v/configure | 0 newlib/src/libgloss/doc/configure | 0 newlib/src/libgloss/fr30/configure | 0 newlib/src/libgloss/frv/configure | 0 newlib/src/libgloss/hp74x/configure | 0 newlib/src/libgloss/i386/configure | 0 newlib/src/libgloss/i960/configure | 0 newlib/src/libgloss/iq2000/configure | 0 newlib/src/libgloss/libnosys/configure | 0 newlib/src/libgloss/lm32/configure | 0 newlib/src/libgloss/m32c/configure | 0 newlib/src/libgloss/m32r/configure | 0 newlib/src/libgloss/m68hc11/configure | 0 newlib/src/libgloss/m68k/configure | 0 newlib/src/libgloss/mcore/configure | 0 newlib/src/libgloss/mep/configure | 0 newlib/src/libgloss/metalsvm/Makefile.in | 3 +- newlib/src/libgloss/metalsvm/accept.c | 26 +++++++++ newlib/src/libgloss/metalsvm/bind.c | 26 +++++++++ newlib/src/libgloss/metalsvm/closesocket.c | 26 +++++++++ newlib/src/libgloss/metalsvm/configure | 0 newlib/src/libgloss/metalsvm/connect.c | 26 +++++++++ newlib/src/libgloss/metalsvm/listen.c | 26 +++++++++ newlib/src/libgloss/metalsvm/recv.c | 26 +++++++++ newlib/src/libgloss/metalsvm/send.c | 26 +++++++++ newlib/src/libgloss/metalsvm/socket.c | 26 +++++++++ newlib/src/libgloss/metalsvm/syscall.h | 12 ++++ newlib/src/libgloss/mips/configure | 0 newlib/src/libgloss/mn10200/configure | 0 newlib/src/libgloss/mn10300/configure | 0 newlib/src/libgloss/mt/configure | 0 newlib/src/libgloss/pa/configure | 0 newlib/src/libgloss/rs6000/configure | 0 newlib/src/libgloss/sparc/configure | 0 newlib/src/libgloss/sparc/libsys/configure | 0 newlib/src/libgloss/tic6x/configure | 0 newlib/src/libgloss/wince/configure | 0 newlib/src/libgloss/xc16x/configure | 0 newlib/src/libgloss/xstormy16/configure | 0 newlib/src/missing | 0 newlib/src/mkdep | 0 newlib/src/mkinstalldirs | 0 newlib/src/move-if-change | 0 newlib/src/newlib/configure | 0 newlib/src/newlib/doc/configure | 0 newlib/src/newlib/iconvdata/configure | 0 newlib/src/newlib/libc/configure | 0 newlib/src/newlib/libc/iconv/ccs/mktbl.pl | 0 newlib/src/newlib/libc/iconv/ces/mkdeps.pl | 0 newlib/src/newlib/libc/machine/a29k/configure | 0 newlib/src/newlib/libc/machine/arm/configure | 0 newlib/src/newlib/libc/machine/bfin/configure | 0 newlib/src/newlib/libc/machine/configure | 0 newlib/src/newlib/libc/machine/cris/configure | 0 newlib/src/newlib/libc/machine/crx/configure | 0 newlib/src/newlib/libc/machine/d10v/configure | 0 newlib/src/newlib/libc/machine/d30v/configure | 0 newlib/src/newlib/libc/machine/fr30/configure | 0 newlib/src/newlib/libc/machine/frv/configure | 0 .../src/newlib/libc/machine/h8300/configure | 0 .../src/newlib/libc/machine/h8500/configure | 0 newlib/src/newlib/libc/machine/hppa/configure | 0 newlib/src/newlib/libc/machine/i386/configure | 0 newlib/src/newlib/libc/machine/i960/configure | 0 .../src/newlib/libc/machine/iq2000/configure | 0 newlib/src/newlib/libc/machine/lm32/configure | 0 newlib/src/newlib/libc/machine/m32c/configure | 0 newlib/src/newlib/libc/machine/m32r/configure | 0 .../src/newlib/libc/machine/m68hc11/configure | 0 newlib/src/newlib/libc/machine/m68k/configure | 0 newlib/src/newlib/libc/machine/m88k/configure | 0 newlib/src/newlib/libc/machine/mep/configure | 0 newlib/src/newlib/libc/machine/mips/configure | 0 .../src/newlib/libc/machine/mn10200/configure | 0 .../src/newlib/libc/machine/mn10300/configure | 0 newlib/src/newlib/libc/machine/mt/configure | 0 .../src/newlib/libc/machine/necv70/configure | 0 .../src/newlib/libc/machine/powerpc/configure | 0 newlib/src/newlib/libc/machine/rx/configure | 0 newlib/src/newlib/libc/machine/sh/configure | 0 .../src/newlib/libc/machine/sparc/configure | 0 .../src/newlib/libc/machine/tic4x/configure | 0 .../src/newlib/libc/machine/tic6x/configure | 0 .../src/newlib/libc/machine/tic80/configure | 0 newlib/src/newlib/libc/machine/v850/configure | 0 newlib/src/newlib/libc/machine/w65/configure | 0 newlib/src/newlib/libc/machine/w65/lshrhi.S | 0 newlib/src/newlib/libc/machine/w65/sdivhi3.S | 0 newlib/src/newlib/libc/machine/w65/smulhi3.S | 0 newlib/src/newlib/libc/machine/w65/udivhi3.S | 0 newlib/src/newlib/libc/machine/w65/umodhi3.S | 0 .../src/newlib/libc/machine/x86_64/configure | 0 .../src/newlib/libc/machine/xscale/configure | 0 .../newlib/libc/machine/xstormy16/configure | 0 newlib/src/newlib/libc/machine/z8k/configure | 0 newlib/src/newlib/libc/sys/a29khif/configure | 0 newlib/src/newlib/libc/sys/arc/configure | 0 newlib/src/newlib/libc/sys/arm/configure | 0 newlib/src/newlib/libc/sys/configure | 0 newlib/src/newlib/libc/sys/d10v/configure | 0 .../src/newlib/libc/sys/decstation/configure | 0 newlib/src/newlib/libc/sys/h8300hms/configure | 0 newlib/src/newlib/libc/sys/h8500hms/configure | 0 newlib/src/newlib/libc/sys/linux/configure | 0 .../libc/sys/linux/linuxthreads/configure | 0 .../sys/linux/linuxthreads/machine/configure | 0 .../linux/linuxthreads/machine/i386/configure | 0 .../newlib/libc/sys/linux/machine/configure | 0 .../libc/sys/linux/machine/i386/configure | 0 newlib/src/newlib/libc/sys/m88kbug/configure | 0 newlib/src/newlib/libc/sys/mmixware/configure | 0 newlib/src/newlib/libc/sys/netware/configure | 0 newlib/src/newlib/libc/sys/rdos/chown.c | 0 newlib/src/newlib/libc/sys/rdos/configure | 0 newlib/src/newlib/libc/sys/rdos/fork.c | 0 newlib/src/newlib/libc/sys/rdos/fstat.c | 0 newlib/src/newlib/libc/sys/rdos/lseek.c | 0 newlib/src/newlib/libc/sys/rdos/open.c | 0 newlib/src/newlib/libc/sys/rdos/rdos.h | 0 newlib/src/newlib/libc/sys/rdos/readlink.c | 0 newlib/src/newlib/libc/sys/rdos/stat.c | 0 newlib/src/newlib/libc/sys/rdos/symlink.c | 0 newlib/src/newlib/libc/sys/rtems/configure | 0 newlib/src/newlib/libc/sys/sh/configure | 0 newlib/src/newlib/libc/sys/sparc64/configure | 0 newlib/src/newlib/libc/sys/sun4/configure | 0 newlib/src/newlib/libc/sys/sysmec/configure | 0 .../src/newlib/libc/sys/sysnec810/configure | 0 .../src/newlib/libc/sys/sysnecv850/configure | 0 newlib/src/newlib/libc/sys/sysvi386/configure | 0 .../src/newlib/libc/sys/sysvnecv70/configure | 0 newlib/src/newlib/libc/sys/tic80/configure | 0 newlib/src/newlib/libc/sys/w65/configure | 0 newlib/src/newlib/libc/sys/z8ksim/configure | 0 newlib/src/newlib/libm/configure | 0 newlib/src/newlib/libm/machine/configure | 0 newlib/src/newlib/libm/machine/i386/configure | 0 newlib/src/symlink-tree | 0 newlib/src/ylwrap | 0 tools/bootinfo.sh | 0 tools/prepare.sh | 0 158 files changed, 291 insertions(+), 1 deletion(-) mode change 100755 => 100644 newlib/src/compile mode change 100755 => 100644 newlib/src/config.guess mode change 100755 => 100644 newlib/src/config.rpath mode change 100755 => 100644 newlib/src/config.status mode change 100755 => 100644 newlib/src/config.sub mode change 100755 => 100644 newlib/src/config/acinclude.m4 mode change 100755 => 100644 newlib/src/configure mode change 100755 => 100644 newlib/src/depcomp mode change 100755 => 100644 newlib/src/etc/config.status mode change 100755 => 100644 newlib/src/etc/configure mode change 100755 => 100644 newlib/src/install-sh mode change 100755 => 100644 newlib/src/libgloss/bfin/configure mode change 100755 => 100644 newlib/src/libgloss/configure mode change 100755 => 100644 newlib/src/libgloss/cris/configure mode change 100755 => 100644 newlib/src/libgloss/crx/configure mode change 100755 => 100644 newlib/src/libgloss/d30v/configure mode change 100755 => 100644 newlib/src/libgloss/doc/configure mode change 100755 => 100644 newlib/src/libgloss/fr30/configure mode change 100755 => 100644 newlib/src/libgloss/frv/configure mode change 100755 => 100644 newlib/src/libgloss/hp74x/configure mode change 100755 => 100644 newlib/src/libgloss/i386/configure mode change 100755 => 100644 newlib/src/libgloss/i960/configure mode change 100755 => 100644 newlib/src/libgloss/iq2000/configure mode change 100755 => 100644 newlib/src/libgloss/libnosys/configure mode change 100755 => 100644 newlib/src/libgloss/lm32/configure mode change 100755 => 100644 newlib/src/libgloss/m32c/configure mode change 100755 => 100644 newlib/src/libgloss/m32r/configure mode change 100755 => 100644 newlib/src/libgloss/m68hc11/configure mode change 100755 => 100644 newlib/src/libgloss/m68k/configure mode change 100755 => 100644 newlib/src/libgloss/mcore/configure mode change 100755 => 100644 newlib/src/libgloss/mep/configure create mode 100644 newlib/src/libgloss/metalsvm/accept.c create mode 100644 newlib/src/libgloss/metalsvm/bind.c create mode 100644 newlib/src/libgloss/metalsvm/closesocket.c mode change 100755 => 100644 newlib/src/libgloss/metalsvm/configure create mode 100644 newlib/src/libgloss/metalsvm/connect.c create mode 100644 newlib/src/libgloss/metalsvm/listen.c create mode 100644 newlib/src/libgloss/metalsvm/recv.c create mode 100644 newlib/src/libgloss/metalsvm/send.c create mode 100644 newlib/src/libgloss/metalsvm/socket.c mode change 100755 => 100644 newlib/src/libgloss/mips/configure mode change 100755 => 100644 newlib/src/libgloss/mn10200/configure mode change 100755 => 100644 newlib/src/libgloss/mn10300/configure mode change 100755 => 100644 newlib/src/libgloss/mt/configure mode change 100755 => 100644 newlib/src/libgloss/pa/configure mode change 100755 => 100644 newlib/src/libgloss/rs6000/configure mode change 100755 => 100644 newlib/src/libgloss/sparc/configure mode change 100755 => 100644 newlib/src/libgloss/sparc/libsys/configure mode change 100755 => 100644 newlib/src/libgloss/tic6x/configure mode change 100755 => 100644 newlib/src/libgloss/wince/configure mode change 100755 => 100644 newlib/src/libgloss/xc16x/configure mode change 100755 => 100644 newlib/src/libgloss/xstormy16/configure mode change 100755 => 100644 newlib/src/missing mode change 100755 => 100644 newlib/src/mkdep mode change 100755 => 100644 newlib/src/mkinstalldirs mode change 100755 => 100644 newlib/src/move-if-change mode change 100755 => 100644 newlib/src/newlib/configure mode change 100755 => 100644 newlib/src/newlib/doc/configure mode change 100755 => 100644 newlib/src/newlib/iconvdata/configure mode change 100755 => 100644 newlib/src/newlib/libc/configure mode change 100755 => 100644 newlib/src/newlib/libc/iconv/ccs/mktbl.pl mode change 100755 => 100644 newlib/src/newlib/libc/iconv/ces/mkdeps.pl mode change 100755 => 100644 newlib/src/newlib/libc/machine/a29k/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/arm/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/bfin/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/cris/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/crx/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/d10v/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/d30v/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/fr30/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/frv/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/h8300/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/h8500/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/hppa/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/i386/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/i960/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/iq2000/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/lm32/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/m32c/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/m32r/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/m68hc11/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/m68k/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/m88k/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/mep/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/mips/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/mn10200/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/mn10300/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/mt/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/necv70/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/powerpc/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/rx/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/sh/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/sparc/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/tic4x/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/tic6x/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/tic80/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/v850/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/w65/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/w65/lshrhi.S mode change 100755 => 100644 newlib/src/newlib/libc/machine/w65/sdivhi3.S mode change 100755 => 100644 newlib/src/newlib/libc/machine/w65/smulhi3.S mode change 100755 => 100644 newlib/src/newlib/libc/machine/w65/udivhi3.S mode change 100755 => 100644 newlib/src/newlib/libc/machine/w65/umodhi3.S mode change 100755 => 100644 newlib/src/newlib/libc/machine/x86_64/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/xscale/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/xstormy16/configure mode change 100755 => 100644 newlib/src/newlib/libc/machine/z8k/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/a29khif/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/arc/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/arm/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/d10v/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/decstation/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/h8300hms/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/h8500hms/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/linux/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/linux/linuxthreads/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/linux/linuxthreads/machine/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/linux/linuxthreads/machine/i386/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/linux/machine/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/linux/machine/i386/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/m88kbug/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/mmixware/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/netware/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/rdos/chown.c mode change 100755 => 100644 newlib/src/newlib/libc/sys/rdos/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/rdos/fork.c mode change 100755 => 100644 newlib/src/newlib/libc/sys/rdos/fstat.c mode change 100755 => 100644 newlib/src/newlib/libc/sys/rdos/lseek.c mode change 100755 => 100644 newlib/src/newlib/libc/sys/rdos/open.c mode change 100755 => 100644 newlib/src/newlib/libc/sys/rdos/rdos.h mode change 100755 => 100644 newlib/src/newlib/libc/sys/rdos/readlink.c mode change 100755 => 100644 newlib/src/newlib/libc/sys/rdos/stat.c mode change 100755 => 100644 newlib/src/newlib/libc/sys/rdos/symlink.c mode change 100755 => 100644 newlib/src/newlib/libc/sys/rtems/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/sh/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/sparc64/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/sun4/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/sysmec/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/sysnec810/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/sysnecv850/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/sysvi386/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/sysvnecv70/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/tic80/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/w65/configure mode change 100755 => 100644 newlib/src/newlib/libc/sys/z8ksim/configure mode change 100755 => 100644 newlib/src/newlib/libm/configure mode change 100755 => 100644 newlib/src/newlib/libm/machine/configure mode change 100755 => 100644 newlib/src/newlib/libm/machine/i386/configure mode change 100755 => 100644 newlib/src/symlink-tree mode change 100755 => 100644 newlib/src/ylwrap mode change 100755 => 100644 tools/bootinfo.sh mode change 100755 => 100644 tools/prepare.sh diff --git a/include/metalsvm/syscall.h b/include/metalsvm/syscall.h index b47fc284..cc66bb76 100644 --- a/include/metalsvm/syscall.h +++ b/include/metalsvm/syscall.h @@ -51,6 +51,18 @@ extern "C" { #define __NR_execve 14 #define __NR_times 15 +/* networking + */ + +#define __NR_socket 16 +#define __NR_bind 17 +#define __NR_listen 18 +#define __NR_accept 19 +#define __NR_connect 20 +#define __NR_send 21 +#define __NR_recv 22 +#define __NR_closesocket 23 + #ifdef __cplusplus } #endif diff --git a/kernel/syscall.c b/kernel/syscall.c index d3eba333..ce9be02e 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -25,6 +25,8 @@ #include #include +#include + static int sys_write(int fildes, const char *buf, size_t len) { int i; @@ -127,6 +129,61 @@ int syscall_handler(uint32_t sys_nr, ...) ret = sys_times(buffer, clock); break; } + case __NR_socket: { + int domain= va_arg(v1,int); + int type = va_arg(v1,int); + int protocol = va_arg(v1,int); + ret = socket(domin,type,protocol); + break; + } + case __NR_bind: { + int s = va_arg(v1,int); + const struct sockaddr *name = va_arg(v1,(const struct sockaddr *)); + socklen_t namelen = va_arg(v1,socklen_t); + ret = bind(s,name,namelen); + break; + } + case __NR_listen: { + int s = va_arg(v1,int); + int backlog = va_arg(v1,int); + ret = listen(s,backlog); + break; + } + case __NR_accept: { + int s = va_arg(v1,int); + struct sockaddr *addr = va_arg(v1,(struct sockaddr *)); + socklen_t *addrlen = va_arg(v1,socklen_t*); + ret = accept(s,addr,addrlen); + break; + } + case __NR_connect: { + int s = va_arg(v1,int); + const struct sockaddr *name =va_arg(v1,(const struct sockaddr *)); + socklen_t namelen = va_arg(v1,socklen_t); + ret = connect(s,name,namelen); + break; + } + case __NR_send: { + int s = va_arg(v1,int); + const void *data = va_arg(v1,void*); + size_t size = va_arg(v1,size_t); + int flags = va_arg(v1,int); + ret = send(s,data,size,flags); + break; + } + case __NR_recv: { + int s = va_arg(v1,int); + const void *data = va_arg(v1,void*); + size_t size = va_arg(v1,size_t); + int flags = va_arg(v1,int); + ret = recv(s,data,size,flags); + break; + } + case __NR_closesocket: { + int s = va_arg(v1,int); + ret = closesocket(s); + break; + } default: kputs("invalid system call\n"); ret = -ENOSYS; diff --git a/newlib/src/compile b/newlib/src/compile old mode 100755 new mode 100644 diff --git a/newlib/src/config.guess b/newlib/src/config.guess old mode 100755 new mode 100644 diff --git a/newlib/src/config.rpath b/newlib/src/config.rpath old mode 100755 new mode 100644 diff --git a/newlib/src/config.status b/newlib/src/config.status old mode 100755 new mode 100644 diff --git a/newlib/src/config.sub b/newlib/src/config.sub old mode 100755 new mode 100644 diff --git a/newlib/src/config/acinclude.m4 b/newlib/src/config/acinclude.m4 old mode 100755 new mode 100644 diff --git a/newlib/src/configure b/newlib/src/configure old mode 100755 new mode 100644 diff --git a/newlib/src/depcomp b/newlib/src/depcomp old mode 100755 new mode 100644 diff --git a/newlib/src/etc/config.status b/newlib/src/etc/config.status old mode 100755 new mode 100644 diff --git a/newlib/src/etc/configure b/newlib/src/etc/configure old mode 100755 new mode 100644 diff --git a/newlib/src/install-sh b/newlib/src/install-sh old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/bfin/configure b/newlib/src/libgloss/bfin/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/configure b/newlib/src/libgloss/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/cris/configure b/newlib/src/libgloss/cris/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/crx/configure b/newlib/src/libgloss/crx/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/d30v/configure b/newlib/src/libgloss/d30v/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/doc/configure b/newlib/src/libgloss/doc/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/fr30/configure b/newlib/src/libgloss/fr30/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/frv/configure b/newlib/src/libgloss/frv/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/hp74x/configure b/newlib/src/libgloss/hp74x/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/i386/configure b/newlib/src/libgloss/i386/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/i960/configure b/newlib/src/libgloss/i960/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/iq2000/configure b/newlib/src/libgloss/iq2000/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/libnosys/configure b/newlib/src/libgloss/libnosys/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/lm32/configure b/newlib/src/libgloss/lm32/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/m32c/configure b/newlib/src/libgloss/m32c/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/m32r/configure b/newlib/src/libgloss/m32r/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/m68hc11/configure b/newlib/src/libgloss/m68hc11/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/m68k/configure b/newlib/src/libgloss/m68k/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/mcore/configure b/newlib/src/libgloss/mcore/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/mep/configure b/newlib/src/libgloss/mep/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/metalsvm/Makefile.in b/newlib/src/libgloss/metalsvm/Makefile.in index 8b83997b..6c5f410e 100644 --- a/newlib/src/libgloss/metalsvm/Makefile.in +++ b/newlib/src/libgloss/metalsvm/Makefile.in @@ -63,7 +63,8 @@ CRT0 = crt0.o METALSVM_BSP = libgloss.a METALSVM_OBJS = chown.o errno.o fork.o gettod.o kill.o open.o sbrk.o times.o write.o \ close.o execve.o fstat.o init.o link.o read.o stat.o unlink.o \ - environ.o _exit.o getpid.o isatty.o lseek.o readlink.o symlink.o wait.o + environ.o _exit.o getpid.o isatty.o lseek.o readlink.o symlink.o wait.o \ + socket.o bind.o listen.o accept.o connect.o send.o recv.o closesocket.o #### Host specific Makefile fragment comes in here. diff --git a/newlib/src/libgloss/metalsvm/accept.c b/newlib/src/libgloss/metalsvm/accept.c new file mode 100644 index 00000000..26ddbe06 --- /dev/null +++ b/newlib/src/libgloss/metalsvm/accept.c @@ -0,0 +1,26 @@ + +#include "config.h" +#include <_ansi.h> +#include <_syslist.h> +#include +#undef errno +extern int errno; +#include "warning.h" +#include "syscall.h" + +#include + +int +_DEFUN (accept, (s, addr, addrlen), + int s, struct sockaddr *addr, socklen_t *addrlen) +{ + int ret; + + ret = SYSCALL3(__NR_accept, s, addr, addrlen); + if (ret < 0) { + errno = -ret; + ret = -1; + } + + return ret; +} \ No newline at end of file diff --git a/newlib/src/libgloss/metalsvm/bind.c b/newlib/src/libgloss/metalsvm/bind.c new file mode 100644 index 00000000..55290bb2 --- /dev/null +++ b/newlib/src/libgloss/metalsvm/bind.c @@ -0,0 +1,26 @@ + +#include "config.h" +#include <_ansi.h> +#include <_syslist.h> +#include +#undef errno +extern int errno; +#include "warning.h" +#include "syscall.h" + +#include + +int +_DEFUN (bind, (s, name, namelen), + int s, const struct sockaddr *name, socklen_t namelen) +{ + int ret; + + ret = SYSCALL3(__NR_bind, s, name, namelen); + if (ret < 0) { + errno = -ret; + ret = -1; + } + + return ret; +} \ No newline at end of file diff --git a/newlib/src/libgloss/metalsvm/closesocket.c b/newlib/src/libgloss/metalsvm/closesocket.c new file mode 100644 index 00000000..14512d3a --- /dev/null +++ b/newlib/src/libgloss/metalsvm/closesocket.c @@ -0,0 +1,26 @@ + +#include "config.h" +#include <_ansi.h> +#include <_syslist.h> +#include +#undef errno +extern int errno; +#include "warning.h" +#include "syscall.h" + +#include + +int +_DEFUN (closesocket, (s), + int s) +{ + int ret; + + ret = SYSCALL1(__NR_closesocket, s); + if (ret < 0) { + errno = -ret; + ret = -1; + } + + return ret; +} \ No newline at end of file diff --git a/newlib/src/libgloss/metalsvm/configure b/newlib/src/libgloss/metalsvm/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/metalsvm/connect.c b/newlib/src/libgloss/metalsvm/connect.c new file mode 100644 index 00000000..261498b6 --- /dev/null +++ b/newlib/src/libgloss/metalsvm/connect.c @@ -0,0 +1,26 @@ + +#include "config.h" +#include <_ansi.h> +#include <_syslist.h> +#include +#undef errno +extern int errno; +#include "warning.h" +#include "syscall.h" + +#include + +int +_DEFUN (connect, (s, name, namelen), + int s, const struct sockaddr *name, socklen_t namelen) +{ + int ret; + + ret = SYSCALL3(__NR_connect, s, name, namelen); + if (ret < 0) { + errno = -ret; + ret = -1; + } + + return ret; +} \ No newline at end of file diff --git a/newlib/src/libgloss/metalsvm/listen.c b/newlib/src/libgloss/metalsvm/listen.c new file mode 100644 index 00000000..22023919 --- /dev/null +++ b/newlib/src/libgloss/metalsvm/listen.c @@ -0,0 +1,26 @@ + +#include "config.h" +#include <_ansi.h> +#include <_syslist.h> +#include +#undef errno +extern int errno; +#include "warning.h" +#include "syscall.h" + +#include + +int +_DEFUN (listen, (s, backlog), + int s, int backlog) +{ + int ret; + + ret = SYSCALL2(__NR_listen, s, backlog); + if (ret < 0) { + errno = -ret; + ret = -1; + } + + return ret; +} \ No newline at end of file diff --git a/newlib/src/libgloss/metalsvm/recv.c b/newlib/src/libgloss/metalsvm/recv.c new file mode 100644 index 00000000..972de6fd --- /dev/null +++ b/newlib/src/libgloss/metalsvm/recv.c @@ -0,0 +1,26 @@ + +#include "config.h" +#include <_ansi.h> +#include <_syslist.h> +#include +#undef errno +extern int errno; +#include "warning.h" +#include "syscall.h" + +#include + +int +_DEFUN (recv, (s, data, size,flags), + int s, const void *data, size_t size, int flags) +{ + int ret; + + ret = SYSCALL4(__NR_recv, s, data, size, flags); + if (ret < 0) { + errno = -ret; + ret = -1; + } + + return ret; +} \ No newline at end of file diff --git a/newlib/src/libgloss/metalsvm/send.c b/newlib/src/libgloss/metalsvm/send.c new file mode 100644 index 00000000..db06b79c --- /dev/null +++ b/newlib/src/libgloss/metalsvm/send.c @@ -0,0 +1,26 @@ + +#include "config.h" +#include <_ansi.h> +#include <_syslist.h> +#include +#undef errno +extern int errno; +#include "warning.h" +#include "syscall.h" + +#include + +int +_DEFUN (send, (s, data, size,flags), + int s, const void *data, size_t size, int flags) +{ + int ret; + + ret = SYSCALL4(__NR_send, s, data, size, flags); + if (ret < 0) { + errno = -ret; + ret = -1; + } + + return ret; +} \ No newline at end of file diff --git a/newlib/src/libgloss/metalsvm/socket.c b/newlib/src/libgloss/metalsvm/socket.c new file mode 100644 index 00000000..a88ab847 --- /dev/null +++ b/newlib/src/libgloss/metalsvm/socket.c @@ -0,0 +1,26 @@ + +#include "config.h" +#include <_ansi.h> +#include <_syslist.h> +#include +#undef errno +extern int errno; +#include "warning.h" +#include "syscall.h" + +#include + +int +_DEFUN (socket, (domain, type, protocol), + int domain, int type, int protocol) +{ + int ret; + + ret = SYSCALL3(__NR_socket, domain, type, protocol); + if (ret < 0) { + errno = -ret; + ret = -1; + } + + return ret; +} \ No newline at end of file diff --git a/newlib/src/libgloss/metalsvm/syscall.h b/newlib/src/libgloss/metalsvm/syscall.h index 6d137508..88eeeb75 100644 --- a/newlib/src/libgloss/metalsvm/syscall.h +++ b/newlib/src/libgloss/metalsvm/syscall.h @@ -40,6 +40,18 @@ extern "C" { #define __NR_execve 14 #define __NR_times 15 +/* networking + */ + +#define __NR_socket 16 +#define __NR_bind 17 +#define __NR_listen 18 +#define __NR_accept 19 +#define __NR_connect 20 +#define __NR_send 21 +#define __NR_recv 22 +#define __NR_closesocket 23 + #define _STR(token) #token #define _SYSCALLSTR(x) "int $" _STR(x) " " #define INT_SYSCALL 0x80 diff --git a/newlib/src/libgloss/mips/configure b/newlib/src/libgloss/mips/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/mn10200/configure b/newlib/src/libgloss/mn10200/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/mn10300/configure b/newlib/src/libgloss/mn10300/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/mt/configure b/newlib/src/libgloss/mt/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/pa/configure b/newlib/src/libgloss/pa/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/rs6000/configure b/newlib/src/libgloss/rs6000/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/sparc/configure b/newlib/src/libgloss/sparc/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/sparc/libsys/configure b/newlib/src/libgloss/sparc/libsys/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/tic6x/configure b/newlib/src/libgloss/tic6x/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/wince/configure b/newlib/src/libgloss/wince/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/xc16x/configure b/newlib/src/libgloss/xc16x/configure old mode 100755 new mode 100644 diff --git a/newlib/src/libgloss/xstormy16/configure b/newlib/src/libgloss/xstormy16/configure old mode 100755 new mode 100644 diff --git a/newlib/src/missing b/newlib/src/missing old mode 100755 new mode 100644 diff --git a/newlib/src/mkdep b/newlib/src/mkdep old mode 100755 new mode 100644 diff --git a/newlib/src/mkinstalldirs b/newlib/src/mkinstalldirs old mode 100755 new mode 100644 diff --git a/newlib/src/move-if-change b/newlib/src/move-if-change old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/configure b/newlib/src/newlib/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/doc/configure b/newlib/src/newlib/doc/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/iconvdata/configure b/newlib/src/newlib/iconvdata/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/configure b/newlib/src/newlib/libc/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/iconv/ccs/mktbl.pl b/newlib/src/newlib/libc/iconv/ccs/mktbl.pl old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/iconv/ces/mkdeps.pl b/newlib/src/newlib/libc/iconv/ces/mkdeps.pl old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/a29k/configure b/newlib/src/newlib/libc/machine/a29k/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/arm/configure b/newlib/src/newlib/libc/machine/arm/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/bfin/configure b/newlib/src/newlib/libc/machine/bfin/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/configure b/newlib/src/newlib/libc/machine/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/cris/configure b/newlib/src/newlib/libc/machine/cris/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/crx/configure b/newlib/src/newlib/libc/machine/crx/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/d10v/configure b/newlib/src/newlib/libc/machine/d10v/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/d30v/configure b/newlib/src/newlib/libc/machine/d30v/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/fr30/configure b/newlib/src/newlib/libc/machine/fr30/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/frv/configure b/newlib/src/newlib/libc/machine/frv/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/h8300/configure b/newlib/src/newlib/libc/machine/h8300/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/h8500/configure b/newlib/src/newlib/libc/machine/h8500/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/hppa/configure b/newlib/src/newlib/libc/machine/hppa/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/i386/configure b/newlib/src/newlib/libc/machine/i386/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/i960/configure b/newlib/src/newlib/libc/machine/i960/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/iq2000/configure b/newlib/src/newlib/libc/machine/iq2000/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/lm32/configure b/newlib/src/newlib/libc/machine/lm32/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/m32c/configure b/newlib/src/newlib/libc/machine/m32c/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/m32r/configure b/newlib/src/newlib/libc/machine/m32r/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/m68hc11/configure b/newlib/src/newlib/libc/machine/m68hc11/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/m68k/configure b/newlib/src/newlib/libc/machine/m68k/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/m88k/configure b/newlib/src/newlib/libc/machine/m88k/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/mep/configure b/newlib/src/newlib/libc/machine/mep/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/mips/configure b/newlib/src/newlib/libc/machine/mips/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/mn10200/configure b/newlib/src/newlib/libc/machine/mn10200/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/mn10300/configure b/newlib/src/newlib/libc/machine/mn10300/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/mt/configure b/newlib/src/newlib/libc/machine/mt/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/necv70/configure b/newlib/src/newlib/libc/machine/necv70/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/powerpc/configure b/newlib/src/newlib/libc/machine/powerpc/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/rx/configure b/newlib/src/newlib/libc/machine/rx/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/sh/configure b/newlib/src/newlib/libc/machine/sh/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/sparc/configure b/newlib/src/newlib/libc/machine/sparc/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/tic4x/configure b/newlib/src/newlib/libc/machine/tic4x/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/tic6x/configure b/newlib/src/newlib/libc/machine/tic6x/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/tic80/configure b/newlib/src/newlib/libc/machine/tic80/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/v850/configure b/newlib/src/newlib/libc/machine/v850/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/w65/configure b/newlib/src/newlib/libc/machine/w65/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/w65/lshrhi.S b/newlib/src/newlib/libc/machine/w65/lshrhi.S old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/w65/sdivhi3.S b/newlib/src/newlib/libc/machine/w65/sdivhi3.S old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/w65/smulhi3.S b/newlib/src/newlib/libc/machine/w65/smulhi3.S old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/w65/udivhi3.S b/newlib/src/newlib/libc/machine/w65/udivhi3.S old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/w65/umodhi3.S b/newlib/src/newlib/libc/machine/w65/umodhi3.S old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/x86_64/configure b/newlib/src/newlib/libc/machine/x86_64/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/xscale/configure b/newlib/src/newlib/libc/machine/xscale/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/xstormy16/configure b/newlib/src/newlib/libc/machine/xstormy16/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/machine/z8k/configure b/newlib/src/newlib/libc/machine/z8k/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/a29khif/configure b/newlib/src/newlib/libc/sys/a29khif/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/arc/configure b/newlib/src/newlib/libc/sys/arc/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/arm/configure b/newlib/src/newlib/libc/sys/arm/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/configure b/newlib/src/newlib/libc/sys/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/d10v/configure b/newlib/src/newlib/libc/sys/d10v/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/decstation/configure b/newlib/src/newlib/libc/sys/decstation/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/h8300hms/configure b/newlib/src/newlib/libc/sys/h8300hms/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/h8500hms/configure b/newlib/src/newlib/libc/sys/h8500hms/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/linux/configure b/newlib/src/newlib/libc/sys/linux/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/linux/linuxthreads/configure b/newlib/src/newlib/libc/sys/linux/linuxthreads/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/linux/linuxthreads/machine/configure b/newlib/src/newlib/libc/sys/linux/linuxthreads/machine/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/linux/linuxthreads/machine/i386/configure b/newlib/src/newlib/libc/sys/linux/linuxthreads/machine/i386/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/linux/machine/configure b/newlib/src/newlib/libc/sys/linux/machine/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/linux/machine/i386/configure b/newlib/src/newlib/libc/sys/linux/machine/i386/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/m88kbug/configure b/newlib/src/newlib/libc/sys/m88kbug/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/mmixware/configure b/newlib/src/newlib/libc/sys/mmixware/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/netware/configure b/newlib/src/newlib/libc/sys/netware/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/rdos/chown.c b/newlib/src/newlib/libc/sys/rdos/chown.c old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/rdos/configure b/newlib/src/newlib/libc/sys/rdos/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/rdos/fork.c b/newlib/src/newlib/libc/sys/rdos/fork.c old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/rdos/fstat.c b/newlib/src/newlib/libc/sys/rdos/fstat.c old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/rdos/lseek.c b/newlib/src/newlib/libc/sys/rdos/lseek.c old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/rdos/open.c b/newlib/src/newlib/libc/sys/rdos/open.c old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/rdos/rdos.h b/newlib/src/newlib/libc/sys/rdos/rdos.h old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/rdos/readlink.c b/newlib/src/newlib/libc/sys/rdos/readlink.c old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/rdos/stat.c b/newlib/src/newlib/libc/sys/rdos/stat.c old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/rdos/symlink.c b/newlib/src/newlib/libc/sys/rdos/symlink.c old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/rtems/configure b/newlib/src/newlib/libc/sys/rtems/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/sh/configure b/newlib/src/newlib/libc/sys/sh/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/sparc64/configure b/newlib/src/newlib/libc/sys/sparc64/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/sun4/configure b/newlib/src/newlib/libc/sys/sun4/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/sysmec/configure b/newlib/src/newlib/libc/sys/sysmec/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/sysnec810/configure b/newlib/src/newlib/libc/sys/sysnec810/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/sysnecv850/configure b/newlib/src/newlib/libc/sys/sysnecv850/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/sysvi386/configure b/newlib/src/newlib/libc/sys/sysvi386/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/sysvnecv70/configure b/newlib/src/newlib/libc/sys/sysvnecv70/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/tic80/configure b/newlib/src/newlib/libc/sys/tic80/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/w65/configure b/newlib/src/newlib/libc/sys/w65/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libc/sys/z8ksim/configure b/newlib/src/newlib/libc/sys/z8ksim/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libm/configure b/newlib/src/newlib/libm/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libm/machine/configure b/newlib/src/newlib/libm/machine/configure old mode 100755 new mode 100644 diff --git a/newlib/src/newlib/libm/machine/i386/configure b/newlib/src/newlib/libm/machine/i386/configure old mode 100755 new mode 100644 diff --git a/newlib/src/symlink-tree b/newlib/src/symlink-tree old mode 100755 new mode 100644 diff --git a/newlib/src/ylwrap b/newlib/src/ylwrap old mode 100755 new mode 100644 diff --git a/tools/bootinfo.sh b/tools/bootinfo.sh old mode 100755 new mode 100644 diff --git a/tools/prepare.sh b/tools/prepare.sh old mode 100755 new mode 100644 From f742e421648c39331719ae35e8a51b38e1f83ac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Mon, 11 Jul 2011 14:20:49 +0200 Subject: [PATCH 101/261] userspace sockets --- kernel/syscall.c | 50 +++++++++++----------- newlib/src/libgloss/metalsvm/accept.c | 5 +-- newlib/src/libgloss/metalsvm/bind.c | 5 +-- newlib/src/libgloss/metalsvm/closesocket.c | 3 +- newlib/src/libgloss/metalsvm/connect.c | 5 +-- newlib/src/libgloss/metalsvm/listen.c | 5 +-- newlib/src/libgloss/metalsvm/recv.c | 5 +-- newlib/src/libgloss/metalsvm/send.c | 5 +-- newlib/src/libgloss/metalsvm/socket.c | 5 +-- 9 files changed, 40 insertions(+), 48 deletions(-) diff --git a/kernel/syscall.c b/kernel/syscall.c index ce9be02e..9134ed2b 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -25,7 +25,7 @@ #include #include -#include +#include static int sys_write(int fildes, const char *buf, size_t len) { @@ -130,57 +130,57 @@ int syscall_handler(uint32_t sys_nr, ...) break; } case __NR_socket: { - int domain= va_arg(v1,int); - int type = va_arg(v1,int); - int protocol = va_arg(v1,int); - ret = socket(domin,type,protocol); + int domain= va_arg(vl,int); + int type = va_arg(vl,int); + int protocol = va_arg(vl,int); + ret = socket(domain,type,protocol); break; } case __NR_bind: { - int s = va_arg(v1,int); - const struct sockaddr *name = va_arg(v1,(const struct sockaddr *)); - socklen_t namelen = va_arg(v1,socklen_t); + int s = va_arg(vl,int); + const struct sockaddr *name = va_arg(vl,struct sockaddr *); + socklen_t namelen = va_arg(vl,socklen_t); ret = bind(s,name,namelen); break; } case __NR_listen: { - int s = va_arg(v1,int); - int backlog = va_arg(v1,int); + int s = va_arg(vl,int); + int backlog = va_arg(vl,int); ret = listen(s,backlog); break; } case __NR_accept: { - int s = va_arg(v1,int); - struct sockaddr *addr = va_arg(v1,(struct sockaddr *)); - socklen_t *addrlen = va_arg(v1,socklen_t*); + int s = va_arg(vl,int); + struct sockaddr *addr = va_arg(vl,struct sockaddr *); + socklen_t *addrlen = va_arg(vl,socklen_t*); ret = accept(s,addr,addrlen); break; } case __NR_connect: { - int s = va_arg(v1,int); - const struct sockaddr *name =va_arg(v1,(const struct sockaddr *)); - socklen_t namelen = va_arg(v1,socklen_t); + int s = va_arg(vl,int); + const struct sockaddr *name =va_arg(vl, struct sockaddr *); + socklen_t namelen = va_arg(vl,socklen_t); ret = connect(s,name,namelen); break; } case __NR_send: { - int s = va_arg(v1,int); - const void *data = va_arg(v1,void*); - size_t size = va_arg(v1,size_t); - int flags = va_arg(v1,int); + int s = va_arg(vl,int); + const void *data = va_arg(vl,void*); + size_t size = va_arg(vl,size_t); + int flags = va_arg(vl,int); ret = send(s,data,size,flags); break; } case __NR_recv: { - int s = va_arg(v1,int); - const void *data = va_arg(v1,void*); - size_t size = va_arg(v1,size_t); - int flags = va_arg(v1,int); + int s = va_arg(vl,int); + const void *data = va_arg(vl,void*); + size_t size = va_arg(vl,size_t); + int flags = va_arg(vl,int); ret = recv(s,data,size,flags); break; } case __NR_closesocket: { - int s = va_arg(v1,int); + int s = va_arg(vl,int); ret = closesocket(s); break; } diff --git a/newlib/src/libgloss/metalsvm/accept.c b/newlib/src/libgloss/metalsvm/accept.c index 26ddbe06..2b092f68 100644 --- a/newlib/src/libgloss/metalsvm/accept.c +++ b/newlib/src/libgloss/metalsvm/accept.c @@ -8,11 +8,10 @@ extern int errno; #include "warning.h" #include "syscall.h" -#include int _DEFUN (accept, (s, addr, addrlen), - int s, struct sockaddr *addr, socklen_t *addrlen) + int s _AND void *addr _AND void *addrlen) { int ret; @@ -23,4 +22,4 @@ _DEFUN (accept, (s, addr, addrlen), } return ret; -} \ No newline at end of file +} diff --git a/newlib/src/libgloss/metalsvm/bind.c b/newlib/src/libgloss/metalsvm/bind.c index 55290bb2..9c02b834 100644 --- a/newlib/src/libgloss/metalsvm/bind.c +++ b/newlib/src/libgloss/metalsvm/bind.c @@ -8,11 +8,10 @@ extern int errno; #include "warning.h" #include "syscall.h" -#include int _DEFUN (bind, (s, name, namelen), - int s, const struct sockaddr *name, socklen_t namelen) + int s _AND void *name _AND int namelen) { int ret; @@ -23,4 +22,4 @@ _DEFUN (bind, (s, name, namelen), } return ret; -} \ No newline at end of file +} diff --git a/newlib/src/libgloss/metalsvm/closesocket.c b/newlib/src/libgloss/metalsvm/closesocket.c index 14512d3a..e24ce3c6 100644 --- a/newlib/src/libgloss/metalsvm/closesocket.c +++ b/newlib/src/libgloss/metalsvm/closesocket.c @@ -8,7 +8,6 @@ extern int errno; #include "warning.h" #include "syscall.h" -#include int _DEFUN (closesocket, (s), @@ -23,4 +22,4 @@ _DEFUN (closesocket, (s), } return ret; -} \ No newline at end of file +} diff --git a/newlib/src/libgloss/metalsvm/connect.c b/newlib/src/libgloss/metalsvm/connect.c index 261498b6..ba3408e8 100644 --- a/newlib/src/libgloss/metalsvm/connect.c +++ b/newlib/src/libgloss/metalsvm/connect.c @@ -8,11 +8,10 @@ extern int errno; #include "warning.h" #include "syscall.h" -#include int _DEFUN (connect, (s, name, namelen), - int s, const struct sockaddr *name, socklen_t namelen) + int s _AND void *name _AND int namelen) { int ret; @@ -23,4 +22,4 @@ _DEFUN (connect, (s, name, namelen), } return ret; -} \ No newline at end of file +} diff --git a/newlib/src/libgloss/metalsvm/listen.c b/newlib/src/libgloss/metalsvm/listen.c index 22023919..7d75dfc2 100644 --- a/newlib/src/libgloss/metalsvm/listen.c +++ b/newlib/src/libgloss/metalsvm/listen.c @@ -8,11 +8,10 @@ extern int errno; #include "warning.h" #include "syscall.h" -#include int _DEFUN (listen, (s, backlog), - int s, int backlog) + int s _AND int backlog) { int ret; @@ -23,4 +22,4 @@ _DEFUN (listen, (s, backlog), } return ret; -} \ No newline at end of file +} diff --git a/newlib/src/libgloss/metalsvm/recv.c b/newlib/src/libgloss/metalsvm/recv.c index 972de6fd..d6159fbb 100644 --- a/newlib/src/libgloss/metalsvm/recv.c +++ b/newlib/src/libgloss/metalsvm/recv.c @@ -8,11 +8,10 @@ extern int errno; #include "warning.h" #include "syscall.h" -#include int _DEFUN (recv, (s, data, size,flags), - int s, const void *data, size_t size, int flags) + int s _AND void *data _AND int size _AND int flags) { int ret; @@ -23,4 +22,4 @@ _DEFUN (recv, (s, data, size,flags), } return ret; -} \ No newline at end of file +} diff --git a/newlib/src/libgloss/metalsvm/send.c b/newlib/src/libgloss/metalsvm/send.c index db06b79c..4da06e06 100644 --- a/newlib/src/libgloss/metalsvm/send.c +++ b/newlib/src/libgloss/metalsvm/send.c @@ -8,11 +8,10 @@ extern int errno; #include "warning.h" #include "syscall.h" -#include int _DEFUN (send, (s, data, size,flags), - int s, const void *data, size_t size, int flags) + int s _AND void *data _AND int size _AND int flags) { int ret; @@ -23,4 +22,4 @@ _DEFUN (send, (s, data, size,flags), } return ret; -} \ No newline at end of file +} diff --git a/newlib/src/libgloss/metalsvm/socket.c b/newlib/src/libgloss/metalsvm/socket.c index a88ab847..8aae8f67 100644 --- a/newlib/src/libgloss/metalsvm/socket.c +++ b/newlib/src/libgloss/metalsvm/socket.c @@ -8,11 +8,10 @@ extern int errno; #include "warning.h" #include "syscall.h" -#include int _DEFUN (socket, (domain, type, protocol), - int domain, int type, int protocol) + int domain _AND int type _AND int protocol) { int ret; @@ -23,4 +22,4 @@ _DEFUN (socket, (domain, type, protocol), } return ret; -} \ No newline at end of file +} From 86639c3e9fabd919b41c98e7f790f1d5afbb343b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 12:56:48 +0200 Subject: [PATCH 102/261] server & client test --- kernel/Makefile | 2 +- kernel/client.c | 118 +++++++++++++++++++++++++++++ kernel/client.h | 56 ++++++++++++++ kernel/server.c | 193 ++++++++++++++++++++++++++++++++++++++++++++++++ kernel/server.h | 67 +++++++++++++++++ kernel/tests.c | 113 ++++++++++++++++++++++++++++ 6 files changed, 548 insertions(+), 1 deletion(-) create mode 100644 kernel/client.c create mode 100644 kernel/client.h create mode 100644 kernel/server.c create mode 100644 kernel/server.h diff --git a/kernel/Makefile b/kernel/Makefile index fdddee71..82977931 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,4 +1,4 @@ -C_source := main.c tasks.c syscall.c tests.c echo.c ping.c init.c +C_source := main.c tasks.c syscall.c tests.c echo.c ping.c init.c server.c client.c MODULE := kernel include $(TOPDIR)/Makefile.inc diff --git a/kernel/client.c b/kernel/client.c new file mode 100644 index 00000000..248fbd8e --- /dev/null +++ b/kernel/client.c @@ -0,0 +1,118 @@ +#include "client.h" + +#include "../drivers/net/util.h" + +#define SOCKET_ERROR -1 + +int cli_sendBuffer(Client* cli,void* pBuffer, unsigned int bufferlen) +{ + int iResult; + ClientEventArgs e; + //abfragen ob client existiert!! wichtig + if (cli->sSocket != SOCKET_ERROR) + { + iResult= send(cli->sSocket,(char*)pBuffer,bufferlen,0); + if (cli->_OnWrite != 0) + { + e.dwLen = iResult; + e.pBuffer = pBuffer; + cli->_OnWrite(&e); + } + return iResult; + } + else + return -1; + } + +int cli_ConnectTo(Client* cli,char * pAdresse,unsigned short Port,int webAdresse) +{ + ClientEventArgs e; + cli->sSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); // Einen Socket erstellen + cli->wPort=Port; + cli->adAddr.sin_port = htons(cli->wPort); + + + if (webAdresse) //Fall es sich um eine Internet Adresse Handelt + return -1; + else //Fall es sich um eine LAN Adresse im 127.0.0.1 Stil handelt + cli->adAddr.sin_addr.s_addr = inet_addr(pAdresse); + + if (connect(cli->sSocket,(const struct sockaddr*)&cli->adAddr, sizeof(cli->adAddr))==0) + { + + create_kernel_task(&cli->bThread,cli_WaitForPacket,cli); + + if (cli->_OnConnect != 0) + { + e.dwLen = 0; + e.pBuffer = 0; + cli->_OnConnect(&e); + } + return 0; + } + else + return -1; +}; + +int cli_DisconnectFrom(Client* cli) +{ + shutdown(cli->sSocket,2); + closesocket(cli->sSocket); + cli->sSocket = SOCKET_ERROR; + return 0; +} + +void cli_WaitForPacket(Client* cli) +{ + int iResult=1; + char pTmpBuffer[DEF_BUFFERSIZE+1]; + ClientEventArgs e; + + while (iResult > 0) + { + iResult = recv(cli->sSocket ,pTmpBuffer, DEF_BUFFERSIZE, 0); + if (iResult > 0) + { + pTmpBuffer[iResult]='\0'; + if (cli->_OnRead != 0) + { + e.dwLen = iResult; + e.pBuffer = pTmpBuffer; + cli->_OnRead( &e); + } + } + else //Verbindung geschlossen + { + cli->sSocket=SOCKET_ERROR; + if (cli->_OnDisconnect != 0) + { + e.dwLen = 0; + e.pBuffer = 0; + cli->_OnDisconnect( &e); + } + } + + } +}; + + +int cli_init(Client* cli) +{ + + cli->_OnConnect = 0; + cli->_OnWrite = 0; + cli->_OnRead = 0; + cli->_OnDisconnect = 0; + + cli->adAddr.sin_addr.s_addr = INADDR_ANY; // IP'S die der Client annehmen soll + cli->adAddr.sin_family = AF_INET; // AdressFamilie (TCP/IP) +// adAddr.sin_port = htons(iPort); // Port auf dem der Client erreichbar seien soll + + return NULL; +} + +int cli_destroy(Client* cli) +{ + closesocket(cli->sSocket);; + return NULL; +} diff --git a/kernel/client.h b/kernel/client.h new file mode 100644 index 00000000..aee71c7f --- /dev/null +++ b/kernel/client.h @@ -0,0 +1,56 @@ +#ifndef __CLIENT__ +#define __CLIENT__ + +#define DEF_BUFFERSIZE 8192 // Buffergröße für ein Packet + +#ifndef LWIP_SOCKET +#include +#endif + +#ifndef SOCKET +#define SOCKET int +#endif + + +#include + + +typedef struct _ClientEventArgs +{ + unsigned int dwLen; + void* pBuffer; +} ClientEventArgs; + + +typedef void (*ClientEventHandler)(ClientEventArgs*); + + +typedef struct _Client +{ +//Connection Handling +SOCKET sSocket; + +struct sockaddr_in adAddr; + +//Output Interfacte +unsigned short wPort; + +tid_t bThread; + +// Eventhandling +ClientEventHandler _OnConnect; +ClientEventHandler _OnDisconnect; +ClientEventHandler _OnRead; +ClientEventHandler _OnWrite; +} Client; + +int cli_sendBuffer(Client* cli,void* pBuffer, unsigned int bufferlen); +int cli_ConnectTo(Client* cli,char * pAdresse,unsigned short Port,int webAdresse); +int cli_DisconnectFrom(Client* cli); +void cli_WaitForPacket(Client* cli); + +cli_init(Client* cli); +cli_destroy(Client* cli); + + +#endif diff --git a/kernel/server.c b/kernel/server.c new file mode 100644 index 00000000..e25e12db --- /dev/null +++ b/kernel/server.c @@ -0,0 +1,193 @@ +#include "server.h" + +typedef int UINT_PTR; +#define SOCKET_ERROR -1 + + +int srv_sendBuffer(Server* srv, unsigned int cli,void* pBuffer, unsigned int dwLen) +{ + int result; + ServerEventArgs e; + //abfragen ob client existiert!! wichtig + if (srv->sConnections[cli] != SOCKET_ERROR) + { + result= send(srv->sConnections[cli],(char*)pBuffer,dwLen,0); + if (srv->_OnWrite!=0) + { + e.ClientID = cli; + e.dwLen = dwLen; + e.pBuffer = pBuffer; + srv->_OnWrite(&e); + } + + return result; + } + else + return -1; +} + +void srv_DisconnectClient(Server* srv, unsigned int cli) +{ + ServerEventArgs e; + closesocket(srv->sConnections[cli]); + srv->sConnections[cli]=SOCKET_ERROR; + srv->dwConnections--; + if (srv->_OnDisconnect!=0) + { + e.ClientID = cli; + e.dwLen = 0; + e.pBuffer = 0; + srv->_OnDisconnect(&e); + } + + memset(&srv->ConnectionsAddr[cli],0,sizeof(struct sockaddr_in)); +} +void* srv_WaitForConnection(Server* srv) +{ + SOCKET tmpClient; + struct sockaddr_in tmpAddr; + int tmpAddrLen; + ServerEventArgs e; + ServerThreadArgs* t; + unsigned int i; + + + do + { + if (srv->dwConnections < srv->dwMaximumConnections) + { + tmpAddrLen = sizeof(struct sockaddr); + if ((tmpClient=accept(srv->sSocket,(struct sockaddr*)&tmpAddr,&tmpAddrLen)) != SOCKET_ERROR) + { + for(i=0;idwMaximumConnections;i++) + { + if (srv->sConnections[i] == SOCKET_ERROR) + { + srv->sConnections[i] = tmpClient; + srv->ConnectionsAddr[i] = tmpAddr; + srv->dwConnections++; + + if(srv->_OnConnect!=0) + { + e.ClientID = i; + e.dwLen = 0; + e.pBuffer =0; + srv->_OnConnect(&e); + } + + t = (ServerThreadArgs*) kmalloc(sizeof(ServerThreadArgs)); + t->ID = i; + t->srv = srv; + create_kernel_task(&srv->bThreads[i],srv_WaitForPacket,t); + + break; + } + } + } + } + else + { + } + }while(1); + + return NULL; + +} +void* srv_WaitForPacket(ServerThreadArgs* t) +{ + int iResult=1; + char pTmpBuffer[DEF_BUFFERSIZE+1]; + ServerEventArgs e; + Server* srv = t->srv; + int cli = t->ID; + + while (iResult > 0) + { + iResult = recv(srv->sConnections[cli] ,pTmpBuffer, DEF_BUFFERSIZE, 0); + if (iResult > 0) + { + pTmpBuffer[iResult]='\0'; + if(srv->_OnRead!=0) + { + e.ClientID = cli; + e.dwLen = iResult; + e.pBuffer = pTmpBuffer; + srv->_OnRead(&e); + } + } + else //Verbindung geschlossen + { + closesocket(srv->sConnections[cli]); + srv->sConnections[cli]=SOCKET_ERROR; + if(srv->_OnDisconnect!=0) + { + e.ClientID = cli; + e.dwLen = 0; + e.pBuffer = 0; + srv->_OnDisconnect(&e); + } + memset(&srv->ConnectionsAddr[cli],0,sizeof(struct sockaddr_in)); + srv->dwConnections--; + iResult=-1; + } + } + return NULL; +} + +int server_init(Server* srv, unsigned short Port, unsigned int dwMaxConnections) +{ + struct sockaddr_in tmpAddr; + int tmpAddrLen; + ServerThreadArgs t; + tmpAddrLen = sizeof(struct sockaddr); + + // Unregister Events + srv->_OnConnect=0; + srv->_OnRead=0; + srv->_OnDisconnect=0; + srv->_OnWrite=0; + + // Allocate needed Memory + srv->sConnections=(SOCKET*)kmalloc(sizeof(SOCKET)*srv->dwConnections); + srv->ConnectionsAddr =(struct sockaddr_in*) kmalloc(sizeof(struct sockaddr_in)*dwMaxConnections); + srv->bThreads = (tid_t*)kmalloc(sizeof(tid_t)*dwMaxConnections); + + srv->dwMaximumConnections=dwMaxConnections; + + memset(srv->sConnections,0xFF,sizeof(SOCKET)*dwMaxConnections); + memset(srv->ConnectionsAddr,0x00,sizeof(struct sockaddr_in)*dwMaxConnections); + + srv->dwConnections=0; + srv->wPort = Port; + + srv->adAddr.sin_addr.s_addr = INADDR_ANY; // IP'S die der Server annehmen soll + srv->adAddr.sin_family = AF_INET; // AdressFamilie (TCP/IP) + srv->adAddr.sin_port = htons(srv->wPort); // Port auf dem der server erreichbar seien soll + + srv->sSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); // Einen Socket erstellen + + bind( srv->sSocket,(const struct sockaddr *) &srv->adAddr, sizeof(srv->adAddr)); // Der Server an die Adresse binden; + listen(srv->sSocket,srv->dwMaximumConnections); // Den Server in listenig State versetzen + + create_kernel_task(&srv->bThread_listen,srv_WaitForConnection,srv); +// sConnections[0] = accept(sSocket,(struct sockaddr*)&tmpAddr,&tmpAddrLen); +// t.ID = 0; +// bthread_create(&bThreads[0],NULL,(start_routine) srv_WaitForPacket,&t); +} + +int server_destroy(Server* srv) +{ + unsigned int i; + for (i=0;idwMaximumConnections;i++) + { + if (srv->sConnections[i] != SOCKET_ERROR)closesocket(srv->sConnections[i]); + //bthread_terminate(&srv->bThreads[i],0x00); + } + closesocket(srv->sSocket); + //bthread_terminate(&srv->bThread_listen,0x00); + +// free(srv->sConnections); +// free(srv->ConnectionsAddr); +// free(srv->bThreads); + +} diff --git a/kernel/server.h b/kernel/server.h new file mode 100644 index 00000000..db3934f8 --- /dev/null +++ b/kernel/server.h @@ -0,0 +1,67 @@ +#ifndef __SERVER__ +#define __SERVER__ + + +#ifdef WIN32 +#include +#else +#include +#endif + +#ifndef LWIP_SOCKET +#include +#endif + + +typedef struct _ServerEventArgs +{ + unsigned int ClientID; + unsigned int dwLen; + void* pBuffer; +} ServerEventArgs; + +#define DEF_BUFFERSIZE 8192 + +typedef void (*ServerEventHandler)(ServerEventArgs*); + +#ifndef SOCKET +#define SOCKET int +#endif + + +typedef struct _Server +{ + SOCKET sSocket; + unsigned int* sConnections; + struct sockaddr_in adAddr; + unsigned short wPort; + unsigned int dwConnections; + unsigned int dwMaximumConnections; + + struct sockaddr_in* ConnectionsAddr; + + tid_t bThread_listen; + tid_t* bThreads; + + ServerEventHandler _OnConnect; + ServerEventHandler _OnDisconnect; + ServerEventHandler _OnRead; + ServerEventHandler _OnWrite; +} Server; + +typedef struct _ServerThreadArgs +{ + Server* srv; + unsigned int ID; +} ServerThreadArgs; + + +int srv_sendBuffer(Server* srv,unsigned int cli,void* pBuffer, unsigned int dwLen); +void srv_DisconnectClient(Server* srv,unsigned int cli); +void* srv_WaitForConnection(Server* srv); +void* srv_WaitForPacket(ServerThreadArgs* t); + +int server_init(Server* srv,unsigned short Port, unsigned int dwMaxConnections); +int server_destroy(Server* srv); + +#endif diff --git a/kernel/tests.c b/kernel/tests.c index 5339450a..96f0022a 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -36,6 +36,9 @@ #include #endif +#include "client.h" +#include "server.h" + static sem_t consuming, producing; static mailbox_int32_t mbox; static int val = 0; @@ -145,8 +148,70 @@ __inline int get_core_no(void) } +static int srv_cnt = 0; +void srv_on_read(ServerEventArgs* e) +{ + kprintf("%i:",srv_cnt); + hex_dump(e->dwLen,e->pBuffer); + srv_cnt++; +/* printf("%i:",cnt); + puts(e->pBuffer); + puts("\n"); + cnt++; + */ +} + +void srv_on_disc(ServerEventArgs*e ) +{ + kprintf("connection lost!!!\n"); +} + + void* server_task(void* e) { + + int i = 0; + int tmp1,tmp2; + char msg[7][60] ={"Hello you0 i have muc fun thogh!","Hello you1 here is a little smily for you!","Hello you2 whaaaaaaaaaaaaaaaaaaaaaaaaats uuuuuuuuuuuuuuuuuuuuuuuuuuuuup!","Hello you3! see this? this is fun ufun funfunfunfunf","Hello you4!" + ,"Hello you5! ogogogogoogoggoogogogogogog","Hello you6!AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa"}; + char buff[256]; + + Server srv; + + server_init(&srv,5555,2); + srv._OnRead = srv_on_read; + srv._OnDisconnect = srv_on_disc; + sleep(2); + srv_sendBuffer(&srv,0,"Hello you!",sizeof("Hello you!")); + sleep(1); + +#if 0 + while(1) + { + if (srv_sendBuffer(0,msg[i],sizeof(msg[i]))< 0) + { + kprintf("\nsending failed\n"); + return NULL; + } + i = (++i) % 7; + sleep(1); + } +#endif + tmp1 = get_clock_tick(); + for (i = 0; i < 1024*4*4*4; i++) + { + if (srv_sendBuffer(&srv,0,buff,sizeof(buff))< 0) + kprintf("dicker error!\n"); + kprintf("\r-%d-",i); + // Sleep(10); + } + tmp2 = get_clock_tick(); + + kprintf("send with %f kb/s", ((float)i*sizeof(buff))/(tmp2-tmp1)); + + return NULL; + +#if 0 int sockfd, newsockfd, portno, clilen; char buffer[512]; struct sockaddr_in serv_addr, cli_addr; @@ -234,11 +299,58 @@ void* server_task(void* e) kprintf("Send 1024*64 Bytes in : %d clock ticks",tmp2-tmp1); +#endif return 0; } +static int cli_cnt = 0; +void cli_on_read(ClientEventArgs* e) +{ + kprintf("\r-%d-",cli_cnt); + cli_cnt++; +// printf("%i:",cnt); +// hex_dump(e->dwLen,e->pBuffer); +// cnt++; +/* puts(e->pBuffer); + puts("\n"); + cnt++; +*/ +} + +void cli_on_disc(ClientEventArgs*e ) +{ + kprintf("connection lost!!!\n"); +} + + void* client_task(void* e) { + + Client cli; + char netbuffer[256]; + cli_init(&cli); + cli._OnRead = cli_on_read; + cli._OnDisconnect = cli_on_disc; + sleep(1); + while ( + cli_ConnectTo(&cli,"192.168.0.1",5555,0)); + sleep(1); + cli_sendBuffer(&cli,"Hallo Welt",sizeof("Hallo Welt")); + + while(1) + sleep(2); + + +#if 1 + while(1) + { + cli_sendBuffer(&cli,netbuffer,sizeof(netbuffer)); + sleep(1); + } +#endif + return NULL; + +#if 0 char dir[2048]; int sd; struct sockaddr_in sin; @@ -295,6 +407,7 @@ void* client_task(void* e) // close(sd); +#endif return NULL; } From b8a66f260e0ff28452545512f3d6bf02ebe1ee22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 13:04:43 +0200 Subject: [PATCH 103/261] server & client test --- kernel/tests.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 96f0022a..bff17c65 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -172,8 +172,6 @@ void* server_task(void* e) int i = 0; int tmp1,tmp2; - char msg[7][60] ={"Hello you0 i have muc fun thogh!","Hello you1 here is a little smily for you!","Hello you2 whaaaaaaaaaaaaaaaaaaaaaaaaats uuuuuuuuuuuuuuuuuuuuuuuuuuuuup!","Hello you3! see this? this is fun ufun funfunfunfunf","Hello you4!" - ,"Hello you5! ogogogogoogoggoogogogogogog","Hello you6!AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa"}; char buff[256]; Server srv; @@ -185,18 +183,6 @@ void* server_task(void* e) srv_sendBuffer(&srv,0,"Hello you!",sizeof("Hello you!")); sleep(1); -#if 0 - while(1) - { - if (srv_sendBuffer(0,msg[i],sizeof(msg[i]))< 0) - { - kprintf("\nsending failed\n"); - return NULL; - } - i = (++i) % 7; - sleep(1); - } -#endif tmp1 = get_clock_tick(); for (i = 0; i < 1024*4*4*4; i++) { From 7969eb06b0fb2e66b042214e9fed8c3d281a73bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 13:08:21 +0200 Subject: [PATCH 104/261] server & client test --- kernel/client.c | 40 ++++++++++++++++++++-------------------- kernel/client.h | 2 +- kernel/server.h | 2 +- kernel/tests.c | 2 ++ 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/kernel/client.c b/kernel/client.c index 248fbd8e..dd9fab03 100644 --- a/kernel/client.c +++ b/kernel/client.c @@ -26,32 +26,32 @@ int cli_sendBuffer(Client* cli,void* pBuffer, unsigned int bufferlen) int cli_ConnectTo(Client* cli,char * pAdresse,unsigned short Port,int webAdresse) { - ClientEventArgs e; - cli->sSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); // Einen Socket erstellen - cli->wPort=Port; - cli->adAddr.sin_port = htons(cli->wPort); + ClientEventArgs e; + cli->sSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); // Einen Socket erstellen + cli->wPort=Port; + cli->adAddr.sin_port = htons(cli->wPort); - if (webAdresse) //Fall es sich um eine Internet Adresse Handelt - return -1; - else //Fall es sich um eine LAN Adresse im 127.0.0.1 Stil handelt - cli->adAddr.sin_addr.s_addr = inet_addr(pAdresse); + if (webAdresse) //Fall es sich um eine Internet Adresse Handelt + return -1; + else //Fall es sich um eine LAN Adresse im 127.0.0.1 Stil handelt + cli->adAddr.sin_addr.s_addr = inet_addr(pAdresse); - if (connect(cli->sSocket,(const struct sockaddr*)&cli->adAddr, sizeof(cli->adAddr))==0) - { + if (connect(cli->sSocket,(const struct sockaddr*)&cli->adAddr, sizeof(cli->adAddr))==0) + { create_kernel_task(&cli->bThread,cli_WaitForPacket,cli); - if (cli->_OnConnect != 0) - { - e.dwLen = 0; - e.pBuffer = 0; - cli->_OnConnect(&e); - } - return 0; - } - else - return -1; + if (cli->_OnConnect != 0) + { + e.dwLen = 0; + e.pBuffer = 0; + cli->_OnConnect(&e); + } + return 0; + } + else + return -1; }; int cli_DisconnectFrom(Client* cli) diff --git a/kernel/client.h b/kernel/client.h index aee71c7f..1c686c4d 100644 --- a/kernel/client.h +++ b/kernel/client.h @@ -1,7 +1,7 @@ #ifndef __CLIENT__ #define __CLIENT__ -#define DEF_BUFFERSIZE 8192 // Buffergröße für ein Packet +#define DEF_BUFFERSIZE 2048 // Buffergröße für ein Packet #ifndef LWIP_SOCKET #include diff --git a/kernel/server.h b/kernel/server.h index db3934f8..c0ad344e 100644 --- a/kernel/server.h +++ b/kernel/server.h @@ -20,7 +20,7 @@ typedef struct _ServerEventArgs void* pBuffer; } ServerEventArgs; -#define DEF_BUFFERSIZE 8192 +#define DEF_BUFFERSIZE 2048 typedef void (*ServerEventHandler)(ServerEventArgs*); diff --git a/kernel/tests.c b/kernel/tests.c index bff17c65..d9bfd6a2 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -177,6 +177,7 @@ void* server_task(void* e) Server srv; server_init(&srv,5555,2); + kprintf("created server"); srv._OnRead = srv_on_read; srv._OnDisconnect = srv_on_disc; sleep(2); @@ -314,6 +315,7 @@ void* client_task(void* e) Client cli; char netbuffer[256]; + kprintf("created client"); cli_init(&cli); cli._OnRead = cli_on_read; cli._OnDisconnect = cli_on_disc; From 1fd296b60370d4e48c4b3de75404e9e29c5560c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 13:18:31 +0200 Subject: [PATCH 105/261] server & client test --- kernel/tests.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index d9bfd6a2..e36dc2f8 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -402,11 +402,12 @@ return NULL; int test_init(void) { + kprintf("start testing"); - if (!get_core_no()) - create_kernel_task(NULL,server_task,NULL); - else - create_kernel_task(NULL,client_task,NULL); +// if (!get_core_no()) +// create_kernel_task(NULL,server_task,NULL); +// else +// create_kernel_task(NULL,client_task,NULL); #if 0 From e1dae22cbf46a2bb268cfccb34f1d71b594289b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 13:27:33 +0200 Subject: [PATCH 106/261] server & client test --- kernel/tests.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index e36dc2f8..94a8e8be 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -404,10 +404,10 @@ int test_init(void) { kprintf("start testing"); -// if (!get_core_no()) -// create_kernel_task(NULL,server_task,NULL); -// else -// create_kernel_task(NULL,client_task,NULL); + if (!get_core_no()) + create_kernel_task(NULL,server_task,NULL); + else + create_kernel_task(NULL,client_task,NULL); #if 0 From 96d938286ecbd861ceb7f26763cadc0e50cdfa6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 13:31:23 +0200 Subject: [PATCH 107/261] server & client test --- kernel/server.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/server.c b/kernel/server.c index e25e12db..7427869e 100644 --- a/kernel/server.c +++ b/kernel/server.c @@ -152,6 +152,12 @@ int server_init(Server* srv, unsigned short Port, unsigned int dwMaxConnections) srv->ConnectionsAddr =(struct sockaddr_in*) kmalloc(sizeof(struct sockaddr_in)*dwMaxConnections); srv->bThreads = (tid_t*)kmalloc(sizeof(tid_t)*dwMaxConnections); + if (!srv->sConnections || !srv->ConnectionsAddr || !srv->bThreads) + { + kprintf("low on mem"); + return -1; + } + srv->dwMaximumConnections=dwMaxConnections; memset(srv->sConnections,0xFF,sizeof(SOCKET)*dwMaxConnections); From 73118044dcf92ca48d285529ea0cbbe93bd2816e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 13:33:51 +0200 Subject: [PATCH 108/261] server & client test --- kernel/server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/server.c b/kernel/server.c index 7427869e..fc6b6006 100644 --- a/kernel/server.c +++ b/kernel/server.c @@ -147,14 +147,14 @@ int server_init(Server* srv, unsigned short Port, unsigned int dwMaxConnections) srv->_OnDisconnect=0; srv->_OnWrite=0; - // Allocate needed Memory + // Allocate needed Memory srv->sConnections=(SOCKET*)kmalloc(sizeof(SOCKET)*srv->dwConnections); srv->ConnectionsAddr =(struct sockaddr_in*) kmalloc(sizeof(struct sockaddr_in)*dwMaxConnections); srv->bThreads = (tid_t*)kmalloc(sizeof(tid_t)*dwMaxConnections); if (!srv->sConnections || !srv->ConnectionsAddr || !srv->bThreads) { - kprintf("low on mem"); + kprintf("low on mem -%d- -%d- -%d-"); return -1; } From 5f5e7096ab2198cf9f77cd6ce0df5d2ae9c4143b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 13:35:21 +0200 Subject: [PATCH 109/261] server & client test --- kernel/server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/server.c b/kernel/server.c index fc6b6006..20433666 100644 --- a/kernel/server.c +++ b/kernel/server.c @@ -154,7 +154,7 @@ int server_init(Server* srv, unsigned short Port, unsigned int dwMaxConnections) if (!srv->sConnections || !srv->ConnectionsAddr || !srv->bThreads) { - kprintf("low on mem -%d- -%d- -%d-"); + kprintf("low on mem -%d- -%d- -%d-",srv->sConnections ,srv->ConnectionsAddr,srv->bThreads); return -1; } From 01da14b2c1dbe2044ceca7d95e41ca2084d30776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 13:37:26 +0200 Subject: [PATCH 110/261] server & client test --- kernel/server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/server.c b/kernel/server.c index 20433666..bd5c441a 100644 --- a/kernel/server.c +++ b/kernel/server.c @@ -148,7 +148,7 @@ int server_init(Server* srv, unsigned short Port, unsigned int dwMaxConnections) srv->_OnWrite=0; // Allocate needed Memory - srv->sConnections=(SOCKET*)kmalloc(sizeof(SOCKET)*srv->dwConnections); + srv->sConnections=(SOCKET*)kmalloc(sizeof(SOCKET)*dwMaxConnections); srv->ConnectionsAddr =(struct sockaddr_in*) kmalloc(sizeof(struct sockaddr_in)*dwMaxConnections); srv->bThreads = (tid_t*)kmalloc(sizeof(tid_t)*dwMaxConnections); From 58f89e225cd90104737bc9ce59c2dc742139f497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 13:39:29 +0200 Subject: [PATCH 111/261] server & client test --- kernel/tests.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 94a8e8be..37c0a503 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -151,9 +151,9 @@ __inline int get_core_no(void) static int srv_cnt = 0; void srv_on_read(ServerEventArgs* e) { - kprintf("%i:",srv_cnt); - hex_dump(e->dwLen,e->pBuffer); - srv_cnt++; + // kprintf("%i:",srv_cnt); + // hex_dump(e->dwLen,e->pBuffer); + // srv_cnt++; /* printf("%i:",cnt); puts(e->pBuffer); puts("\n"); From 5816fafa476ddeb3af1c4955b262abe7e37e9834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 13:42:06 +0200 Subject: [PATCH 112/261] server & client test --- kernel/tests.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/tests.c b/kernel/tests.c index 37c0a503..69f34ec3 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -166,6 +166,11 @@ void srv_on_disc(ServerEventArgs*e ) kprintf("connection lost!!!\n"); } +void srv_on_conn(ServerEventArgs* e) +{ + kprintf("someone finally connected\n"); +} + void* server_task(void* e) { @@ -180,6 +185,7 @@ void* server_task(void* e) kprintf("created server"); srv._OnRead = srv_on_read; srv._OnDisconnect = srv_on_disc; + srv._OnConnect = srv_on_conn; sleep(2); srv_sendBuffer(&srv,0,"Hello you!",sizeof("Hello you!")); sleep(1); From 055e7967f3c239dda5fcc10d9c93229bf5449222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 13:44:22 +0200 Subject: [PATCH 113/261] server & client test --- kernel/tests.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 69f34ec3..7e5a7dec 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -177,7 +177,7 @@ void* server_task(void* e) int i = 0; int tmp1,tmp2; - char buff[256]; + char buff[32]; Server srv; @@ -186,7 +186,8 @@ void* server_task(void* e) srv._OnRead = srv_on_read; srv._OnDisconnect = srv_on_disc; srv._OnConnect = srv_on_conn; - sleep(2); + sleep(5); + kpritnf("sending..."); srv_sendBuffer(&srv,0,"Hello you!",sizeof("Hello you!")); sleep(1); From 343834b0f6f98ac0ac0978db35c2657d85b84686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 13:45:05 +0200 Subject: [PATCH 114/261] server & client test --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 7e5a7dec..933dd277 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -187,7 +187,7 @@ void* server_task(void* e) srv._OnDisconnect = srv_on_disc; srv._OnConnect = srv_on_conn; sleep(5); - kpritnf("sending..."); + kprintf("sending..."); srv_sendBuffer(&srv,0,"Hello you!",sizeof("Hello you!")); sleep(1); From 902f07e125d5f3aff2210842b4d094ee46d98e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 13:46:12 +0200 Subject: [PATCH 115/261] server & client test --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 933dd277..cd9df240 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -196,7 +196,7 @@ void* server_task(void* e) { if (srv_sendBuffer(&srv,0,buff,sizeof(buff))< 0) kprintf("dicker error!\n"); - kprintf("\r-%d-",i); + // kprintf("\r-%d-",i); // Sleep(10); } tmp2 = get_clock_tick(); From 6a7c32351143c5d31a8b9d3f939c345a67d0efa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 13:54:46 +0200 Subject: [PATCH 116/261] server & client test --- kernel/tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index cd9df240..a3a3c19a 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -174,7 +174,6 @@ void srv_on_conn(ServerEventArgs* e) void* server_task(void* e) { - int i = 0; int tmp1,tmp2; char buff[32]; @@ -196,7 +195,8 @@ void* server_task(void* e) { if (srv_sendBuffer(&srv,0,buff,sizeof(buff))< 0) kprintf("dicker error!\n"); - // kprintf("\r-%d-",i); + if (!(i%100)) + kprintf("\r-%d-",i); // Sleep(10); } tmp2 = get_clock_tick(); From 9d51e282da919b91d376c39d8e030b3eddf690fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 14:39:23 +0200 Subject: [PATCH 117/261] server & client test --- kernel/init.c | 7 ++----- kernel/shell.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 kernel/shell.c diff --git a/kernel/init.c b/kernel/init.c index f12e8c4e..bb9aef76 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -153,13 +153,11 @@ int network_init(void) kprintf("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); mmnif_open(); kprintf("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - return 0; - -#if 0 + // return 0; #if defined(CONFIG_LWIP) // Initialize lwIP modules - lwip_init(); +// lwip_init(); #endif #if defined(CONFIG_LWIP) && (defined(CONFIG_PCI) || defined(CONFIG_ROCKCREEK)) @@ -167,5 +165,4 @@ int network_init(void) #else return 0; #endif -#endif } diff --git a/kernel/shell.c b/kernel/shell.c new file mode 100644 index 00000000..386464bb --- /dev/null +++ b/kernel/shell.c @@ -0,0 +1,48 @@ +#include "shell.h" + +#include "server.h" +#include "client.h" + +static Server srv; +static int emac_id = -1; + +static Client cli; + +void shell_on_connect(ServerEventArgs* e) +{ + if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr > 0xC0A80031 || srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr < 0xC0A80001) + emac_id = e->ClientID; + + kprintf("link engaged\n"); +} + +void shell_on_disconnect(ServerEventArgs* e) +{ + kpritnf("connection lost from %s:%d",inet_ntoa(sender->ConnectionsAddr[e->ClientID].sin_addr),ntohs(sender->ConnectionsAddr[e->ClientID].sin_port)); +} + +void shell_on_read(ServerEventArgs* e) +{ + if (emac_id != -1 && e->ClientID != emac_id) + srv_sendBuffer(&srv,emac_id,e->pBuffer,e->dwLen); + + // else commandos oder so +} + +void shell_init(int srv_or_cli) +{ + if (srv_or_cli) + { + server_init(&srv,5555,49); + srv._OnConnect = shell_on_connect; + srv._OnDisconnect = shell_on_disconnect; + srv._OnRead = shell_on_read; + } + else + { + cli_init(&cli); + while (cli_ConnectTo(&cli,"192.168.0.1",5555,0)); + sleep(1); + } + +} From 03cfdd12ad23685bb285a335a14b21a70049e1fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 15:01:10 +0200 Subject: [PATCH 118/261] shell test --- kernel/shell.c | 2 +- kernel/tests.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/kernel/shell.c b/kernel/shell.c index 386464bb..1e12477f 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -31,7 +31,7 @@ void shell_on_read(ServerEventArgs* e) void shell_init(int srv_or_cli) { - if (srv_or_cli) + if (!srv_or_cli) { server_init(&srv,5555,49); srv._OnConnect = shell_on_connect; diff --git a/kernel/tests.c b/kernel/tests.c index a3a3c19a..17a930e8 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -39,6 +39,8 @@ #include "client.h" #include "server.h" +#include "shell.h" + static sem_t consuming, producing; static mailbox_int32_t mbox; static int val = 0; @@ -411,10 +413,12 @@ int test_init(void) { kprintf("start testing"); - if (!get_core_no()) - create_kernel_task(NULL,server_task,NULL); - else - create_kernel_task(NULL,client_task,NULL); +// if (!get_core_no()) +// create_kernel_task(NULL,server_task,NULL); +// else +// create_kernel_task(NULL,client_task,NULL); + + shell_init(get_core_no()); #if 0 From 08c160dc01528d6f26d1a2fb2c86c7462b2d08b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 15:02:23 +0200 Subject: [PATCH 119/261] shell test --- kernel/shell.h | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 kernel/shell.h diff --git a/kernel/shell.h b/kernel/shell.h new file mode 100644 index 00000000..0e3607f5 --- /dev/null +++ b/kernel/shell.h @@ -0,0 +1,8 @@ +#ifndef SHELL_H +#define SHELL_H + +#define SHELLDEBUGPRINTF(x,...) cli_sendBuffer(x,##__VA_ARGS__); + +void shell_init(int srv_or_cli); + +#endif // SHELL_H From d302f6bbff5c382bc75c3d05227207e78165ce2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 15:03:02 +0200 Subject: [PATCH 120/261] shell test --- kernel/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/Makefile b/kernel/Makefile index 82977931..a5aa5b13 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,4 +1,4 @@ -C_source := main.c tasks.c syscall.c tests.c echo.c ping.c init.c server.c client.c +C_source := main.c tasks.c syscall.c tests.c echo.c ping.c init.c server.c client.c shell.c MODULE := kernel include $(TOPDIR)/Makefile.inc From e298694a96cf79b51443c7a1555d81e753b09389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 15:03:47 +0200 Subject: [PATCH 121/261] shell test --- kernel/shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/shell.c b/kernel/shell.c index 1e12477f..8ad7bb6f 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -18,7 +18,7 @@ void shell_on_connect(ServerEventArgs* e) void shell_on_disconnect(ServerEventArgs* e) { - kpritnf("connection lost from %s:%d",inet_ntoa(sender->ConnectionsAddr[e->ClientID].sin_addr),ntohs(sender->ConnectionsAddr[e->ClientID].sin_port)); + kpritnf("connection lost from %s:%d",inet_ntoa(srv->ConnectionsAddr[e->ClientID].sin_addr),ntohs(srv->ConnectionsAddr[e->ClientID].sin_port)); } void shell_on_read(ServerEventArgs* e) From fbbcb1dbd7501cac71f4acc89fb8b8b7165f920c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 15:04:06 +0200 Subject: [PATCH 122/261] shell test --- kernel/shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/shell.c b/kernel/shell.c index 8ad7bb6f..63685259 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -18,7 +18,7 @@ void shell_on_connect(ServerEventArgs* e) void shell_on_disconnect(ServerEventArgs* e) { - kpritnf("connection lost from %s:%d",inet_ntoa(srv->ConnectionsAddr[e->ClientID].sin_addr),ntohs(srv->ConnectionsAddr[e->ClientID].sin_port)); + kpritnf("connection lost from %s:%d",inet_ntoa(srv.ConnectionsAddr[e->ClientID].sin_addr),ntohs(srv.ConnectionsAddr[e->ClientID].sin_port)); } void shell_on_read(ServerEventArgs* e) From 1c93f988852fc7ff632675355887c0b96fb1ab1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 15:04:24 +0200 Subject: [PATCH 123/261] shell test --- kernel/shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/shell.c b/kernel/shell.c index 63685259..bbfd18f4 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -18,7 +18,7 @@ void shell_on_connect(ServerEventArgs* e) void shell_on_disconnect(ServerEventArgs* e) { - kpritnf("connection lost from %s:%d",inet_ntoa(srv.ConnectionsAddr[e->ClientID].sin_addr),ntohs(srv.ConnectionsAddr[e->ClientID].sin_port)); + kprintf("connection lost from %s:%d",inet_ntoa(srv.ConnectionsAddr[e->ClientID].sin_addr),ntohs(srv.ConnectionsAddr[e->ClientID].sin_port)); } void shell_on_read(ServerEventArgs* e) From 6fbe273b320ab7f5cd578734664afb47a56eda33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 15:04:43 +0200 Subject: [PATCH 124/261] shell test --- kernel/shell.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/shell.c b/kernel/shell.c index bbfd18f4..a7dbd14f 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -3,6 +3,8 @@ #include "server.h" #include "client.h" +#include + static Server srv; static int emac_id = -1; From d986385207a621f5e77c3b2776bdf6789fa2297e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 15:07:09 +0200 Subject: [PATCH 125/261] shell test --- kernel/shell.c | 3 +++ lwip/src/include/lwipopts.h | 1 + 2 files changed, 4 insertions(+) diff --git a/kernel/shell.c b/kernel/shell.c index a7dbd14f..1a912f1b 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -35,6 +35,7 @@ void shell_init(int srv_or_cli) { if (!srv_or_cli) { + kprintf("server init"); server_init(&srv,5555,49); srv._OnConnect = shell_on_connect; srv._OnDisconnect = shell_on_disconnect; @@ -42,6 +43,8 @@ void shell_init(int srv_or_cli) } else { + sleep(3); + kprintf("client init"); cli_init(&cli); while (cli_ConnectTo(&cli,"192.168.0.1",5555,0)); sleep(1); diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index bf0d78d6..e56da66c 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -99,6 +99,7 @@ #define NETIF_DEBUG LWIP_DBG_OFF #define TIMERS_DEBUG LWIP_DBG_OFF +#define IP_FORWARD 1 #if 0 #define LWIP_TCPIP_CORE_LOCKING_INPUT 1 From c220e33b66e47d266d842aad00ffc352005a68ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 15:09:48 +0200 Subject: [PATCH 126/261] shell test --- kernel/shell.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/shell.c b/kernel/shell.c index 1a912f1b..e2d44330 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -48,6 +48,11 @@ void shell_init(int srv_or_cli) cli_init(&cli); while (cli_ConnectTo(&cli,"192.168.0.1",5555,0)); sleep(1); + + sleep(5); + SHELLDEBUGPRINTF("sleeped 5 seconds\n"); + sleep(5); + SHELLDEBUGPRINTF("sleeped another 5 seconds\n") } } From 57975e19be0589e22086e271dfda68b946800977 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 15:15:55 +0200 Subject: [PATCH 127/261] shell test --- kernel/shell.c | 14 ++++++++++++++ kernel/shell.h | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/kernel/shell.c b/kernel/shell.c index e2d44330..48ef0c95 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -10,6 +10,19 @@ static int emac_id = -1; static Client cli; +static int iamsrv = 0; + + +#include + +void shelldebugprintf(char* x,...) +{ + if (iamsrv) + srv_sendBuffer(&srv,emac_id,x,strlen(x)); + else + cli_sendBuffer(&cli,x,srlen(x)); +} + void shell_on_connect(ServerEventArgs* e) { if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr > 0xC0A80031 || srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr < 0xC0A80001) @@ -35,6 +48,7 @@ void shell_init(int srv_or_cli) { if (!srv_or_cli) { + iamsrv = 1; kprintf("server init"); server_init(&srv,5555,49); srv._OnConnect = shell_on_connect; diff --git a/kernel/shell.h b/kernel/shell.h index 0e3607f5..553211d7 100644 --- a/kernel/shell.h +++ b/kernel/shell.h @@ -1,7 +1,7 @@ #ifndef SHELL_H #define SHELL_H -#define SHELLDEBUGPRINTF(x,...) cli_sendBuffer(x,##__VA_ARGS__); +void shelldebugprintf(char* x,...); void shell_init(int srv_or_cli); From bb1e7918606497efb10a2bd05c5ced098754b11f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 15:16:23 +0200 Subject: [PATCH 128/261] shell test --- kernel/shell.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/shell.c b/kernel/shell.c index 48ef0c95..fe61803c 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -64,9 +64,9 @@ void shell_init(int srv_or_cli) sleep(1); sleep(5); - SHELLDEBUGPRINTF("sleeped 5 seconds\n"); + shelldebugprintf("sleeped 5 seconds\n"); sleep(5); - SHELLDEBUGPRINTF("sleeped another 5 seconds\n") + shelldebugprintf("sleeped another 5 seconds\n") } } From 56f29640535e4cc1bebb33cb21c0c3a354e3a514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 15:16:37 +0200 Subject: [PATCH 129/261] shell test --- kernel/shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/shell.c b/kernel/shell.c index fe61803c..e2bd71af 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -20,7 +20,7 @@ void shelldebugprintf(char* x,...) if (iamsrv) srv_sendBuffer(&srv,emac_id,x,strlen(x)); else - cli_sendBuffer(&cli,x,srlen(x)); + cli_sendBuffer(&cli,x,strlen(x)); } void shell_on_connect(ServerEventArgs* e) From c6c5cb29a7572a02c58e13e7aaf755d0c71d4e01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 15:16:54 +0200 Subject: [PATCH 130/261] shell test --- kernel/shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/shell.c b/kernel/shell.c index e2bd71af..c7e68a08 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -66,7 +66,7 @@ void shell_init(int srv_or_cli) sleep(5); shelldebugprintf("sleeped 5 seconds\n"); sleep(5); - shelldebugprintf("sleeped another 5 seconds\n") + shelldebugprintf("sleeped another 5 seconds\n"); } } From fa5288b36640b8d41dd7a24bdba732da9d686c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 15:18:34 +0200 Subject: [PATCH 131/261] shell test --- kernel/shell.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/shell.c b/kernel/shell.c index c7e68a08..bfa346d1 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -17,6 +17,7 @@ static int iamsrv = 0; void shelldebugprintf(char* x,...) { + kprintf("debugprinting"); if (iamsrv) srv_sendBuffer(&srv,emac_id,x,strlen(x)); else From e7091822f7a77524bfe8d577909be8e266318df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 15:21:15 +0200 Subject: [PATCH 132/261] shell test --- kernel/shell.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/shell.c b/kernel/shell.c index bfa346d1..96bf767f 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -27,7 +27,10 @@ void shelldebugprintf(char* x,...) void shell_on_connect(ServerEventArgs* e) { if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr > 0xC0A80031 || srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr < 0xC0A80001) + { emac_id = e->ClientID; + kprintf("bmc connected"); + } kprintf("link engaged\n"); } @@ -51,7 +54,7 @@ void shell_init(int srv_or_cli) { iamsrv = 1; kprintf("server init"); - server_init(&srv,5555,49); + server_init(&srv,23,49); srv._OnConnect = shell_on_connect; srv._OnDisconnect = shell_on_disconnect; srv._OnRead = shell_on_read; @@ -61,7 +64,7 @@ void shell_init(int srv_or_cli) sleep(3); kprintf("client init"); cli_init(&cli); - while (cli_ConnectTo(&cli,"192.168.0.1",5555,0)); + while (cli_ConnectTo(&cli,"192.168.0.1",23,0)); sleep(1); sleep(5); From 0d1edfc8fbefd63919722a3951a79a929c7339f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 12 Jul 2011 15:47:00 +0200 Subject: [PATCH 133/261] shell test --- kernel/shell.c | 2 +- kernel/shell.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/shell.c b/kernel/shell.c index 96bf767f..825195ca 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -15,7 +15,7 @@ static int iamsrv = 0; #include -void shelldebugprintf(char* x,...) +void shelldebugprint(char* x) { kprintf("debugprinting"); if (iamsrv) diff --git a/kernel/shell.h b/kernel/shell.h index 553211d7..b44fcf91 100644 --- a/kernel/shell.h +++ b/kernel/shell.h @@ -1,7 +1,7 @@ #ifndef SHELL_H #define SHELL_H -void shelldebugprintf(char* x,...); +void shelldebugprint(char* x); void shell_init(int srv_or_cli); From f8d1ba1f69e0420d0ddc3f3f1993532cb094569d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 26 Jul 2011 11:55:43 +0200 Subject: [PATCH 134/261] shell test --- kernel/shell.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/shell.c b/kernel/shell.c index 825195ca..910671bd 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -68,9 +68,9 @@ void shell_init(int srv_or_cli) sleep(1); sleep(5); - shelldebugprintf("sleeped 5 seconds\n"); + shelldebugprint("sleeped 5 seconds\n"); sleep(5); - shelldebugprintf("sleeped another 5 seconds\n"); + shelldebugprint("sleeped another 5 seconds\n"); } } From 77af84f41638c0f58faf99ee84d377093880982f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 26 Jul 2011 12:12:21 +0200 Subject: [PATCH 135/261] shell test --- kernel/shell.c | 5 ----- kernel/tests.c | 9 +++++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/kernel/shell.c b/kernel/shell.c index 910671bd..0162f68a 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -66,11 +66,6 @@ void shell_init(int srv_or_cli) cli_init(&cli); while (cli_ConnectTo(&cli,"192.168.0.1",23,0)); sleep(1); - - sleep(5); - shelldebugprint("sleeped 5 seconds\n"); - sleep(5); - shelldebugprint("sleeped another 5 seconds\n"); } } diff --git a/kernel/tests.c b/kernel/tests.c index 17a930e8..74817e69 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -420,6 +420,15 @@ int test_init(void) shell_init(get_core_no()); + if (get_core_no()) + { + sleep(5); + shelldebugprint("sleeped 5 seconds\n"); + sleep(5); + shelldebugprint("sleeped another 5 seconds\n"); + shelldebugprint("This is so wonderfull!\nEverything is so well formated."); + } + #if 0 char* argv[] = {"/bin/tests", NULL}; From 118f0349cc1770dcce1815daab18d216c97f35dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 26 Jul 2011 14:22:37 +0200 Subject: [PATCH 136/261] shell test --- drivers/net/mmnif.c | 4 ---- kernel/shell.c | 7 +++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index d1409ba0..f7b3cb27 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -1403,10 +1403,6 @@ int mmnif_close() * - this will stop the polling thread i.e. */ - /* resources has to be freed here - * will be added soon ;) - */ - active = FALSE; #ifdef WIN32 free(mmnif->tx_buff); diff --git a/kernel/shell.c b/kernel/shell.c index 0162f68a..1b314545 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -12,9 +12,13 @@ static Client cli; static int iamsrv = 0; +char shellbuffer[512]; + #include +#define SHELLDEBUGPRINTF(x,...) ksprintf(shellbuffer,x,##__VA_ARGS__);shelldebugprint(shellbuffer); + void shelldebugprint(char* x) { kprintf("debugprinting"); @@ -66,6 +70,9 @@ void shell_init(int srv_or_cli) cli_init(&cli); while (cli_ConnectTo(&cli,"192.168.0.1",23,0)); sleep(1); + } + sleep(3); + SHELLDEBUGPRINTF("I AM CORE NO. %d",srv_or_cli); } From da239c6345d5925f32c391dfe2b86fa331d6de40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 26 Jul 2011 14:27:41 +0200 Subject: [PATCH 137/261] shell test --- kernel/shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/shell.c b/kernel/shell.c index 1b314545..cd5bdb8c 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -17,7 +17,7 @@ char shellbuffer[512]; #include -#define SHELLDEBUGPRINTF(x,...) ksprintf(shellbuffer,x,##__VA_ARGS__);shelldebugprint(shellbuffer); +#define SHELLDEBUGPRINTF(x,...) ksnprintf(shellbuffer,sizeof(shellbuffer),x,##__VA_ARGS__);shelldebugprint(shellbuffer); void shelldebugprint(char* x) { From 94fc627ccfb02f67db806b633ab674a34fe3f43a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 26 Jul 2011 14:28:32 +0200 Subject: [PATCH 138/261] shell test --- kernel/shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/shell.c b/kernel/shell.c index cd5bdb8c..88917e7f 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -72,7 +72,7 @@ void shell_init(int srv_or_cli) sleep(1); } - sleep(3); + sleep(12); SHELLDEBUGPRINTF("I AM CORE NO. %d",srv_or_cli); } From 0f1ace1ef206ef46ec17feda2b9a2e67842346eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 26 Jul 2011 14:30:16 +0200 Subject: [PATCH 139/261] shell test --- kernel/shell.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/shell.c b/kernel/shell.c index 88917e7f..f33fa256 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -72,7 +72,7 @@ void shell_init(int srv_or_cli) sleep(1); } - sleep(12); - SHELLDEBUGPRINTF("I AM CORE NO. %d",srv_or_cli); + sleep(5); + SHELLDEBUGPRINTF("I AM CORE NO. %d\n",srv_or_cli); } From b8da89d2504722dc4726b4b12bbd8f29a500b2dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 26 Jul 2011 14:31:26 +0200 Subject: [PATCH 140/261] shell test --- kernel/shell.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/shell.c b/kernel/shell.c index f33fa256..3e6e4440 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -72,7 +72,7 @@ void shell_init(int srv_or_cli) sleep(1); } - sleep(5); - SHELLDEBUGPRINTF("I AM CORE NO. %d\n",srv_or_cli); + sleep(10); + SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",srv_or_cli); } From b81429e542ca74a74ef8211550a37f624e4469b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 26 Jul 2011 14:34:06 +0200 Subject: [PATCH 141/261] shell test --- kernel/shell.c | 4 ---- kernel/shell.h | 6 ++++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/shell.c b/kernel/shell.c index 3e6e4440..30fa741b 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -15,10 +15,6 @@ static int iamsrv = 0; char shellbuffer[512]; -#include - -#define SHELLDEBUGPRINTF(x,...) ksnprintf(shellbuffer,sizeof(shellbuffer),x,##__VA_ARGS__);shelldebugprint(shellbuffer); - void shelldebugprint(char* x) { kprintf("debugprinting"); diff --git a/kernel/shell.h b/kernel/shell.h index b44fcf91..6924c567 100644 --- a/kernel/shell.h +++ b/kernel/shell.h @@ -1,8 +1,14 @@ #ifndef SHELL_H #define SHELL_H +#include + void shelldebugprint(char* x); void shell_init(int srv_or_cli); +extern char shellbuffer[512]; + +#define SHELLDEBUGPRINTF(x,...) ksnprintf(shellbuffer,sizeof(shellbuffer),x,##__VA_ARGS__);shelldebugprint(shellbuffer); + #endif // SHELL_H From 53b736e9251705d36199396af01a10a3586f5cc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 26 Jul 2011 14:35:55 +0200 Subject: [PATCH 142/261] shell test --- kernel/shell.c | 2 -- kernel/tests.c | 7 +++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/kernel/shell.c b/kernel/shell.c index 30fa741b..a7a8a51d 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -68,7 +68,5 @@ void shell_init(int srv_or_cli) sleep(1); } - sleep(10); - SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",srv_or_cli); } diff --git a/kernel/tests.c b/kernel/tests.c index 74817e69..c2952691 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -411,6 +411,7 @@ return NULL; int test_init(void) { + int i = 0; kprintf("start testing"); // if (!get_core_no()) @@ -420,6 +421,9 @@ int test_init(void) shell_init(get_core_no()); + sleep(10); + SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",srv_or_cli); + if (get_core_no()) { sleep(5); @@ -427,6 +431,9 @@ int test_init(void) sleep(5); shelldebugprint("sleeped another 5 seconds\n"); shelldebugprint("This is so wonderfull!\nEverything is so well formated."); + + for (i = 0; i < 10; i++) + SHELLDEBUGPRINTF("for-Schleife-no: %d\n",i); } #if 0 From 72b4cc0af8aa9a87285b1ba59305c4a187239103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 26 Jul 2011 14:36:41 +0200 Subject: [PATCH 143/261] shell test --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index c2952691..263ab697 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -422,7 +422,7 @@ int test_init(void) shell_init(get_core_no()); sleep(10); - SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",srv_or_cli); + SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",get_core_no()); if (get_core_no()) { From 233669377390822b7d02975a7b4d2b2fd671c426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 26 Jul 2011 14:38:07 +0200 Subject: [PATCH 144/261] shell test --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 263ab697..6802be72 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -430,7 +430,7 @@ int test_init(void) shelldebugprint("sleeped 5 seconds\n"); sleep(5); shelldebugprint("sleeped another 5 seconds\n"); - shelldebugprint("This is so wonderfull!\nEverything is so well formated."); + shelldebugprint("This is so wonderfull!\nEverything is so well formated.\n"); for (i = 0; i < 10; i++) SHELLDEBUGPRINTF("for-Schleife-no: %d\n",i); From 62713bc9d20f22f6a6df302ca9bd2b3dfa932223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 26 Jul 2011 14:39:48 +0200 Subject: [PATCH 145/261] shell test --- kernel/tests.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/tests.c b/kernel/tests.c index 6802be72..80af18eb 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -433,7 +433,9 @@ int test_init(void) shelldebugprint("This is so wonderfull!\nEverything is so well formated.\n"); for (i = 0; i < 10; i++) + { SHELLDEBUGPRINTF("for-Schleife-no: %d\n",i); + } } #if 0 From b35dfc1bd8c1fa5b284e5dd4eec19542f92ccabd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 26 Jul 2011 16:52:07 +0200 Subject: [PATCH 146/261] shell test --- kernel/tests.c | 66 ++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 80af18eb..0fca4e96 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -183,12 +183,12 @@ void* server_task(void* e) Server srv; server_init(&srv,5555,2); - kprintf("created server"); + SHELLDEBUGPRINTF("created server\n"); srv._OnRead = srv_on_read; srv._OnDisconnect = srv_on_disc; srv._OnConnect = srv_on_conn; sleep(5); - kprintf("sending..."); + SHELLDEBUGPRINTF("sending...\n"); srv_sendBuffer(&srv,0,"Hello you!",sizeof("Hello you!")); sleep(1); @@ -196,9 +196,9 @@ void* server_task(void* e) for (i = 0; i < 1024*4*4*4; i++) { if (srv_sendBuffer(&srv,0,buff,sizeof(buff))< 0) - kprintf("dicker error!\n"); + SHELLDEBUGPRINTF("dicker error!\n"); if (!(i%100)) - kprintf("\r-%d-",i); + SHELLDEBUGPRINTF("\r-%d-",i); // Sleep(10); } tmp2 = get_clock_tick(); @@ -219,7 +219,7 @@ void* server_task(void* e) sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (sockfd < 0) { - kprintf("ERROR opening socket"); + SHELLDEBUGPRINTF("ERROR opening socket"); return; } /* Initialize socket structure */ @@ -229,24 +229,24 @@ void* server_task(void* e) serv_addr.sin_addr.s_addr = INADDR_ANY; serv_addr.sin_port = htons(portno); - kprintf("binding"); + SHELLDEBUGPRINTF("binding"); /* Now bind the host address using bind() call.*/ if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) { - kprintf("ERROR on binding"); + SHELLDEBUGPRINTF("ERROR on binding"); return; } /* Now start listening for the clients, here process will * go in sleep mode and will wait for the incoming connection */ - kprintf("listening"); + SHELLDEBUGPRINTF("listening"); listen(sockfd,5); clilen = sizeof(cli_addr); /* Accept actual connection from the client */ - kprintf("accepting"); + SHELLDEBUGPRINTF("accepting"); newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr, &clilen); if (newsockfd < 0) @@ -256,21 +256,21 @@ void* server_task(void* e) } /* If connection is established then start communicating */ memset(buffer,0,256); - kprintf("recieving"); + SHELLDEBUGPRINTF("recieving"); n = recv( newsockfd,buffer,255,0 ); if (n < 0) { - kprintf("ERROR reading from socket"); + SHELLDEBUGPRINTF("ERROR reading from socket"); return; } - kprintf("Here is the message: %s\n",buffer); + SHELLDEBUGPRINTF("Here is the message: %s\n",buffer); /* Write a response to the client */ kprintf("writing"); n = send(newsockfd,"I got your message",18,0); if (n < 0) { - kprintf("ERROR writing to socket"); + SHELLDEBUGPRINTF("ERROR writing to socket"); return; } @@ -279,11 +279,11 @@ void* server_task(void* e) for (n = 0; n < 1024*256 ; n++) { if (!(n%100)) - kprintf("%d-",n); + SHELLDEBUGPRINTF("%d-",n); err = send(newsockfd,buffer,sizeof(buffer),0); if (err < 0) { - kprintf("error on sending: %d",err); + SHELLDEBUGPRINTF("error on sending: %d",err); break; } // if (!(n%100)) @@ -293,7 +293,7 @@ void* server_task(void* e) tmp2 = get_clock_tick(); - kprintf("Send 1024*64 Bytes in : %d clock ticks",tmp2-tmp1); + SHELLDEBUGPRINTF("Send 1024*256 Bytes in : %d clock ticks",tmp2-tmp1); #endif return 0; @@ -414,29 +414,31 @@ int test_init(void) int i = 0; kprintf("start testing"); -// if (!get_core_no()) -// create_kernel_task(NULL,server_task,NULL); -// else -// create_kernel_task(NULL,client_task,NULL); + shell_init(get_core_no()); sleep(10); SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",get_core_no()); - if (get_core_no()) - { - sleep(5); - shelldebugprint("sleeped 5 seconds\n"); - sleep(5); - shelldebugprint("sleeped another 5 seconds\n"); - shelldebugprint("This is so wonderfull!\nEverything is so well formated.\n"); +// if (get_core_no()) +// { +// sleep(5); +// shelldebugprint("sleeped 5 seconds\n"); +// sleep(5); +// shelldebugprint("sleeped another 5 seconds\n"); +// shelldebugprint("This is so wonderfull!\nEverything is so well formated.\n"); - for (i = 0; i < 10; i++) - { - SHELLDEBUGPRINTF("for-Schleife-no: %d\n",i); - } - } +// for (i = 0; i < 10; i++) +// { +// SHELLDEBUGPRINTF("for-Schleife-no: %d\n",i); +// } +// } + + if (!get_core_no()) + create_kernel_task(NULL,server_task,NULL); + else + create_kernel_task(NULL,client_task,NULL); #if 0 From 446297d2133bb0ea661b16003ab93deac643d923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 26 Jul 2011 16:53:59 +0200 Subject: [PATCH 147/261] shell test --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 0fca4e96..9ab3e413 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -196,7 +196,7 @@ void* server_task(void* e) for (i = 0; i < 1024*4*4*4; i++) { if (srv_sendBuffer(&srv,0,buff,sizeof(buff))< 0) - SHELLDEBUGPRINTF("dicker error!\n"); + SHELLDEBUGPRINTF("err"); if (!(i%100)) SHELLDEBUGPRINTF("\r-%d-",i); // Sleep(10); From 2535fbd83d4f021e803c79974a40dec8d2ba8b6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 26 Jul 2011 17:00:19 +0200 Subject: [PATCH 148/261] shell test --- kernel/tests.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/tests.c b/kernel/tests.c index 9ab3e413..850b8466 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -199,6 +199,7 @@ void* server_task(void* e) SHELLDEBUGPRINTF("err"); if (!(i%100)) SHELLDEBUGPRINTF("\r-%d-",i); + udelay(100); // Sleep(10); } tmp2 = get_clock_tick(); From 4d5150558a4853df8c29d03c15383232b18797c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 12:24:05 +0200 Subject: [PATCH 149/261] merge && test for master --- arch/x86/include/asm/apic.h | 1 + arch/x86/include/asm/atomic.h | 4 +- arch/x86/include/asm/iRCCE.h | 59 ++- arch/x86/include/asm/iRCCE_lib.h | 17 + arch/x86/include/asm/icc.h | 20 +- arch/x86/include/asm/idt.h | 7 +- arch/x86/include/asm/io.h | 34 ++ arch/x86/include/asm/processor.h | 14 + arch/x86/include/asm/stddef.h | 27 +- arch/x86/include/asm/tasks.h | 19 +- arch/x86/kernel/apic.c | 331 +++++++++--- arch/x86/kernel/entry.asm | 346 ++++++------- arch/x86/kernel/gdt.c | 17 +- arch/x86/kernel/idt.c | 39 +- arch/x86/kernel/irq.c | 69 +-- arch/x86/kernel/isrs.c | 71 +-- arch/x86/kernel/processor.c | 3 + arch/x86/kernel/timer.c | 13 +- arch/x86/mm/page.c | 14 +- arch/x86/scc/Makefile | 2 +- arch/x86/scc/iRCCE_admin.c | 66 ++- arch/x86/scc/iRCCE_irecv.c | 233 ++++++++- arch/x86/scc/iRCCE_isend.c | 137 +++-- arch/x86/scc/iRCCE_mailbox.c | 482 ++++++++++++++++++ arch/x86/scc/iRCCE_recv.c | 12 + arch/x86/scc/icc.c | 154 +++--- drivers/net/rckemac.c | 74 ++- drivers/net/rckemac.h | 10 - drivers/net/rtl8139.c | 54 +- drivers/net/rtl8139.h | 12 +- drivers/net/util.c | 22 +- drivers/net/util.h | 23 +- include/metalsvm/config.h.example | 9 +- include/metalsvm/spinlock.h | 8 +- include/metalsvm/stddef.h | 25 +- include/metalsvm/syscall.h | 12 - include/metalsvm/tasks.h | 24 +- include/metalsvm/tasks_types.h | 17 +- kernel/init.c | 117 +++-- kernel/main.c | 21 +- kernel/ping.c | 12 +- kernel/syscall.c | 57 --- kernel/tasks.c | 238 ++++++--- kernel/tests.c | 164 +++--- libkern/printf.c | 2 +- libkern/stdio.c | 14 +- lwip/src/arch/sys_arch.c | 28 +- lwip/src/include/arch/sys_arch.h | 21 + lwip/src/include/lwipopts.h | 37 +- mm/memory.c | 75 ++- .../{src/libgloss/metalsvm => net}/accept.c | 0 newlib/{src/libgloss/metalsvm => net}/bind.c | 0 .../libgloss/metalsvm => net}/closesocket.c | 0 .../{src/libgloss/metalsvm => net}/connect.c | 0 .../{src/libgloss/metalsvm => net}/listen.c | 0 newlib/{src/libgloss/metalsvm => net}/recv.c | 0 newlib/{src/libgloss/metalsvm => net}/send.c | 0 .../{src/libgloss/metalsvm => net}/socket.c | 0 newlib/net/syscall.h | 78 +++ newlib/src/compile | 0 newlib/src/config.guess | 0 newlib/src/config.rpath | 0 newlib/src/config.status | 0 newlib/src/config.sub | 0 newlib/src/config/acinclude.m4 | 0 newlib/src/configure | 0 newlib/src/depcomp | 0 newlib/src/etc/config.status | 0 newlib/src/etc/configure | 0 newlib/src/install-sh | 0 newlib/src/libgloss/bfin/configure | 0 newlib/src/libgloss/configure | 0 newlib/src/libgloss/cris/configure | 0 newlib/src/libgloss/crx/configure | 0 newlib/src/libgloss/d30v/configure | 0 newlib/src/libgloss/doc/configure | 0 newlib/src/libgloss/fr30/configure | 0 newlib/src/libgloss/frv/configure | 0 newlib/src/libgloss/hp74x/configure | 0 newlib/src/libgloss/i386/configure | 0 newlib/src/libgloss/i960/configure | 0 newlib/src/libgloss/iq2000/configure | 0 newlib/src/libgloss/libnosys/configure | 0 newlib/src/libgloss/lm32/configure | 0 newlib/src/libgloss/m32c/configure | 0 newlib/src/libgloss/m32r/configure | 0 newlib/src/libgloss/m68hc11/configure | 0 newlib/src/libgloss/m68k/configure | 0 newlib/src/libgloss/mcore/configure | 0 newlib/src/libgloss/mep/configure | 0 newlib/src/libgloss/metalsvm/Makefile.in | 3 +- newlib/src/libgloss/metalsvm/configure | 0 newlib/src/libgloss/metalsvm/syscall.h | 12 - newlib/src/libgloss/mips/configure | 0 newlib/src/libgloss/mn10200/configure | 0 newlib/src/libgloss/mn10300/configure | 0 newlib/src/libgloss/mt/configure | 0 newlib/src/libgloss/pa/configure | 0 newlib/src/libgloss/rs6000/configure | 0 newlib/src/libgloss/sparc/configure | 0 newlib/src/libgloss/sparc/libsys/configure | 0 newlib/src/libgloss/tic6x/configure | 0 newlib/src/libgloss/wince/configure | 0 newlib/src/libgloss/xc16x/configure | 0 newlib/src/libgloss/xstormy16/configure | 0 newlib/src/missing | 0 newlib/src/mkdep | 0 newlib/src/mkinstalldirs | 0 newlib/src/move-if-change | 0 newlib/src/newlib/configure | 0 newlib/src/newlib/doc/configure | 0 newlib/src/newlib/iconvdata/configure | 0 newlib/src/newlib/libc/configure | 0 newlib/src/newlib/libc/iconv/ccs/mktbl.pl | 0 newlib/src/newlib/libc/iconv/ces/mkdeps.pl | 0 newlib/src/newlib/libc/machine/a29k/configure | 0 newlib/src/newlib/libc/machine/arm/configure | 0 newlib/src/newlib/libc/machine/bfin/configure | 0 newlib/src/newlib/libc/machine/configure | 0 newlib/src/newlib/libc/machine/cris/configure | 0 newlib/src/newlib/libc/machine/crx/configure | 0 newlib/src/newlib/libc/machine/d10v/configure | 0 newlib/src/newlib/libc/machine/d30v/configure | 0 newlib/src/newlib/libc/machine/fr30/configure | 0 newlib/src/newlib/libc/machine/frv/configure | 0 .../src/newlib/libc/machine/h8300/configure | 0 .../src/newlib/libc/machine/h8500/configure | 0 newlib/src/newlib/libc/machine/hppa/configure | 0 newlib/src/newlib/libc/machine/i386/configure | 0 newlib/src/newlib/libc/machine/i960/configure | 0 .../src/newlib/libc/machine/iq2000/configure | 0 newlib/src/newlib/libc/machine/lm32/configure | 0 newlib/src/newlib/libc/machine/m32c/configure | 0 newlib/src/newlib/libc/machine/m32r/configure | 0 .../src/newlib/libc/machine/m68hc11/configure | 0 newlib/src/newlib/libc/machine/m68k/configure | 0 newlib/src/newlib/libc/machine/m88k/configure | 0 newlib/src/newlib/libc/machine/mep/configure | 0 newlib/src/newlib/libc/machine/mips/configure | 0 .../src/newlib/libc/machine/mn10200/configure | 0 .../src/newlib/libc/machine/mn10300/configure | 0 newlib/src/newlib/libc/machine/mt/configure | 0 .../src/newlib/libc/machine/necv70/configure | 0 .../src/newlib/libc/machine/powerpc/configure | 0 newlib/src/newlib/libc/machine/rx/configure | 0 newlib/src/newlib/libc/machine/sh/configure | 0 .../src/newlib/libc/machine/sparc/configure | 0 .../src/newlib/libc/machine/tic4x/configure | 0 .../src/newlib/libc/machine/tic6x/configure | 0 .../src/newlib/libc/machine/tic80/configure | 0 newlib/src/newlib/libc/machine/v850/configure | 0 newlib/src/newlib/libc/machine/w65/configure | 0 newlib/src/newlib/libc/machine/w65/lshrhi.S | 0 newlib/src/newlib/libc/machine/w65/sdivhi3.S | 0 newlib/src/newlib/libc/machine/w65/smulhi3.S | 0 newlib/src/newlib/libc/machine/w65/udivhi3.S | 0 newlib/src/newlib/libc/machine/w65/umodhi3.S | 0 .../src/newlib/libc/machine/x86_64/configure | 0 .../src/newlib/libc/machine/xscale/configure | 0 .../newlib/libc/machine/xstormy16/configure | 0 newlib/src/newlib/libc/machine/z8k/configure | 0 newlib/src/newlib/libc/sys/a29khif/configure | 0 newlib/src/newlib/libc/sys/arc/configure | 0 newlib/src/newlib/libc/sys/arm/configure | 0 newlib/src/newlib/libc/sys/configure | 0 newlib/src/newlib/libc/sys/d10v/configure | 0 .../src/newlib/libc/sys/decstation/configure | 0 newlib/src/newlib/libc/sys/h8300hms/configure | 0 newlib/src/newlib/libc/sys/h8500hms/configure | 0 newlib/src/newlib/libc/sys/linux/configure | 0 .../libc/sys/linux/linuxthreads/configure | 0 .../sys/linux/linuxthreads/machine/configure | 0 .../linux/linuxthreads/machine/i386/configure | 0 .../newlib/libc/sys/linux/machine/configure | 0 .../libc/sys/linux/machine/i386/configure | 0 newlib/src/newlib/libc/sys/m88kbug/configure | 0 newlib/src/newlib/libc/sys/mmixware/configure | 0 newlib/src/newlib/libc/sys/netware/configure | 0 newlib/src/newlib/libc/sys/rdos/chown.c | 0 newlib/src/newlib/libc/sys/rdos/configure | 0 newlib/src/newlib/libc/sys/rdos/fork.c | 0 newlib/src/newlib/libc/sys/rdos/fstat.c | 0 newlib/src/newlib/libc/sys/rdos/lseek.c | 0 newlib/src/newlib/libc/sys/rdos/open.c | 0 newlib/src/newlib/libc/sys/rdos/rdos.h | 0 newlib/src/newlib/libc/sys/rdos/readlink.c | 0 newlib/src/newlib/libc/sys/rdos/stat.c | 0 newlib/src/newlib/libc/sys/rdos/symlink.c | 0 newlib/src/newlib/libc/sys/rtems/configure | 0 newlib/src/newlib/libc/sys/sh/configure | 0 newlib/src/newlib/libc/sys/sparc64/configure | 0 newlib/src/newlib/libc/sys/sun4/configure | 0 newlib/src/newlib/libc/sys/sysmec/configure | 0 .../src/newlib/libc/sys/sysnec810/configure | 0 .../src/newlib/libc/sys/sysnecv850/configure | 0 newlib/src/newlib/libc/sys/sysvi386/configure | 0 .../src/newlib/libc/sys/sysvnecv70/configure | 0 newlib/src/newlib/libc/sys/tic80/configure | 0 newlib/src/newlib/libc/sys/w65/configure | 0 newlib/src/newlib/libc/sys/z8ksim/configure | 0 newlib/src/newlib/libm/configure | 0 newlib/src/newlib/libm/machine/configure | 0 newlib/src/newlib/libm/machine/i386/configure | 0 newlib/src/symlink-tree | 0 newlib/src/ylwrap | 0 tools/Makefile | 2 +- tools/bootinfo.sh | 0 tools/prepare.sh | 0 tools/scc_setup.asm | 2 +- tools/smp_setup.asm | 96 ++-- 210 files changed, 2340 insertions(+), 1120 deletions(-) create mode 100644 arch/x86/scc/iRCCE_mailbox.c rename newlib/{src/libgloss/metalsvm => net}/accept.c (100%) rename newlib/{src/libgloss/metalsvm => net}/bind.c (100%) rename newlib/{src/libgloss/metalsvm => net}/closesocket.c (100%) rename newlib/{src/libgloss/metalsvm => net}/connect.c (100%) rename newlib/{src/libgloss/metalsvm => net}/listen.c (100%) rename newlib/{src/libgloss/metalsvm => net}/recv.c (100%) rename newlib/{src/libgloss/metalsvm => net}/send.c (100%) rename newlib/{src/libgloss/metalsvm => net}/socket.c (100%) create mode 100644 newlib/net/syscall.h mode change 100644 => 100755 newlib/src/compile mode change 100644 => 100755 newlib/src/config.guess mode change 100644 => 100755 newlib/src/config.rpath mode change 100644 => 100755 newlib/src/config.status mode change 100644 => 100755 newlib/src/config.sub mode change 100644 => 100755 newlib/src/config/acinclude.m4 mode change 100644 => 100755 newlib/src/configure mode change 100644 => 100755 newlib/src/depcomp mode change 100644 => 100755 newlib/src/etc/config.status mode change 100644 => 100755 newlib/src/etc/configure mode change 100644 => 100755 newlib/src/install-sh mode change 100644 => 100755 newlib/src/libgloss/bfin/configure mode change 100644 => 100755 newlib/src/libgloss/configure mode change 100644 => 100755 newlib/src/libgloss/cris/configure mode change 100644 => 100755 newlib/src/libgloss/crx/configure mode change 100644 => 100755 newlib/src/libgloss/d30v/configure mode change 100644 => 100755 newlib/src/libgloss/doc/configure mode change 100644 => 100755 newlib/src/libgloss/fr30/configure mode change 100644 => 100755 newlib/src/libgloss/frv/configure mode change 100644 => 100755 newlib/src/libgloss/hp74x/configure mode change 100644 => 100755 newlib/src/libgloss/i386/configure mode change 100644 => 100755 newlib/src/libgloss/i960/configure mode change 100644 => 100755 newlib/src/libgloss/iq2000/configure mode change 100644 => 100755 newlib/src/libgloss/libnosys/configure mode change 100644 => 100755 newlib/src/libgloss/lm32/configure mode change 100644 => 100755 newlib/src/libgloss/m32c/configure mode change 100644 => 100755 newlib/src/libgloss/m32r/configure mode change 100644 => 100755 newlib/src/libgloss/m68hc11/configure mode change 100644 => 100755 newlib/src/libgloss/m68k/configure mode change 100644 => 100755 newlib/src/libgloss/mcore/configure mode change 100644 => 100755 newlib/src/libgloss/mep/configure mode change 100644 => 100755 newlib/src/libgloss/metalsvm/configure mode change 100644 => 100755 newlib/src/libgloss/mips/configure mode change 100644 => 100755 newlib/src/libgloss/mn10200/configure mode change 100644 => 100755 newlib/src/libgloss/mn10300/configure mode change 100644 => 100755 newlib/src/libgloss/mt/configure mode change 100644 => 100755 newlib/src/libgloss/pa/configure mode change 100644 => 100755 newlib/src/libgloss/rs6000/configure mode change 100644 => 100755 newlib/src/libgloss/sparc/configure mode change 100644 => 100755 newlib/src/libgloss/sparc/libsys/configure mode change 100644 => 100755 newlib/src/libgloss/tic6x/configure mode change 100644 => 100755 newlib/src/libgloss/wince/configure mode change 100644 => 100755 newlib/src/libgloss/xc16x/configure mode change 100644 => 100755 newlib/src/libgloss/xstormy16/configure mode change 100644 => 100755 newlib/src/missing mode change 100644 => 100755 newlib/src/mkdep mode change 100644 => 100755 newlib/src/mkinstalldirs mode change 100644 => 100755 newlib/src/move-if-change mode change 100644 => 100755 newlib/src/newlib/configure mode change 100644 => 100755 newlib/src/newlib/doc/configure mode change 100644 => 100755 newlib/src/newlib/iconvdata/configure mode change 100644 => 100755 newlib/src/newlib/libc/configure mode change 100644 => 100755 newlib/src/newlib/libc/iconv/ccs/mktbl.pl mode change 100644 => 100755 newlib/src/newlib/libc/iconv/ces/mkdeps.pl mode change 100644 => 100755 newlib/src/newlib/libc/machine/a29k/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/arm/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/bfin/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/cris/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/crx/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/d10v/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/d30v/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/fr30/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/frv/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/h8300/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/h8500/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/hppa/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/i386/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/i960/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/iq2000/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/lm32/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/m32c/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/m32r/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/m68hc11/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/m68k/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/m88k/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/mep/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/mips/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/mn10200/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/mn10300/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/mt/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/necv70/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/powerpc/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/rx/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/sh/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/sparc/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/tic4x/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/tic6x/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/tic80/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/v850/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/w65/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/w65/lshrhi.S mode change 100644 => 100755 newlib/src/newlib/libc/machine/w65/sdivhi3.S mode change 100644 => 100755 newlib/src/newlib/libc/machine/w65/smulhi3.S mode change 100644 => 100755 newlib/src/newlib/libc/machine/w65/udivhi3.S mode change 100644 => 100755 newlib/src/newlib/libc/machine/w65/umodhi3.S mode change 100644 => 100755 newlib/src/newlib/libc/machine/x86_64/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/xscale/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/xstormy16/configure mode change 100644 => 100755 newlib/src/newlib/libc/machine/z8k/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/a29khif/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/arc/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/arm/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/d10v/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/decstation/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/h8300hms/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/h8500hms/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/linux/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/linux/linuxthreads/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/linux/linuxthreads/machine/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/linux/linuxthreads/machine/i386/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/linux/machine/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/linux/machine/i386/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/m88kbug/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/mmixware/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/netware/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/rdos/chown.c mode change 100644 => 100755 newlib/src/newlib/libc/sys/rdos/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/rdos/fork.c mode change 100644 => 100755 newlib/src/newlib/libc/sys/rdos/fstat.c mode change 100644 => 100755 newlib/src/newlib/libc/sys/rdos/lseek.c mode change 100644 => 100755 newlib/src/newlib/libc/sys/rdos/open.c mode change 100644 => 100755 newlib/src/newlib/libc/sys/rdos/rdos.h mode change 100644 => 100755 newlib/src/newlib/libc/sys/rdos/readlink.c mode change 100644 => 100755 newlib/src/newlib/libc/sys/rdos/stat.c mode change 100644 => 100755 newlib/src/newlib/libc/sys/rdos/symlink.c mode change 100644 => 100755 newlib/src/newlib/libc/sys/rtems/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/sh/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/sparc64/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/sun4/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/sysmec/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/sysnec810/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/sysnecv850/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/sysvi386/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/sysvnecv70/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/tic80/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/w65/configure mode change 100644 => 100755 newlib/src/newlib/libc/sys/z8ksim/configure mode change 100644 => 100755 newlib/src/newlib/libm/configure mode change 100644 => 100755 newlib/src/newlib/libm/machine/configure mode change 100644 => 100755 newlib/src/newlib/libm/machine/i386/configure mode change 100644 => 100755 newlib/src/symlink-tree mode change 100644 => 100755 newlib/src/ylwrap mode change 100644 => 100755 tools/bootinfo.sh mode change 100644 => 100755 tools/prepare.sh diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h index f649a479..017f782d 100644 --- a/arch/x86/include/asm/apic.h +++ b/arch/x86/include/asm/apic.h @@ -195,6 +195,7 @@ int has_apic(void); int apic_is_enabled(void); int ioapic_inton(uint8_t irq, uint8_t apicid); int ioapic_intoff(uint8_t irq, uint8_t apicid); +int map_apic(void); #ifdef __cplusplus } diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h index c3407fee..fbb5e558 100644 --- a/arch/x86/include/asm/atomic.h +++ b/arch/x86/include/asm/atomic.h @@ -88,7 +88,7 @@ inline static int32_t atomic_int32_test_and_set(atomic_int32_t* d, int32_t ret) inline static int32_t atomic_int32_add(atomic_int32_t *d, int32_t i) { int32_t res = i; - asm volatile(LOCK "xaddl %0, %1" : "=r"(i) : "m"(d->counter), "0"(i)); + asm volatile(LOCK "xaddl %0, %1" : "=r"(i) : "m"(d->counter), "0"(i) : "memory"); return res+i; } @@ -152,7 +152,7 @@ inline static int32_t atomic_int32_read(atomic_int32_t *d) { * @param v The value to set */ inline static void atomic_int32_set(atomic_int32_t *d, int32_t v) { - d->counter = v; + atomic_int32_test_and_set(d, v); } #ifdef __cplusplus diff --git a/arch/x86/include/asm/iRCCE.h b/arch/x86/include/asm/iRCCE.h index 8b878bfd..7c071d5b 100644 --- a/arch/x86/include/asm/iRCCE.h +++ b/arch/x86/include/asm/iRCCE.h @@ -30,12 +30,29 @@ #ifndef IRCCE_H #define IRCCE_H -#include +#include "RCCE.h" #define iRCCE_SUCCESS RCCE_SUCCESS -#define iRCCE_PENDING -1 -#define iRCCE_RESERVED -2 -#define iRCCE_NOT_ENQUEUED -3 +#define iRCCE_PENDING -1 +#define iRCCE_RESERVED -2 +#define iRCCE_NOT_ENQUEUED -3 + +#define iRCCE_ANY_SOURCE -1 + +#define iRCCE_PRIOS 5 +#define iRCCE_MAILBOX_EMPTY -2 +#define iRCCE_LAST_MAILS_NOT_RECV -3 +#define iRCCE_MAILBOX_ALL -4 +#define iRCCE_MAILBOX_OPEN 0 +#define iRCCE_MAILBOX_CLOSED 1 + +// iRCCE-mailbox-system tags +#define iRCCE_LAST_MAIL -1 +#define iRCCE_ANYLENGTH -2 +#define iRCCE_ANYLENGTH_PIGGYBACK -3 + + +typedef volatile char iRCCE_SHORT_FLAG; typedef struct _iRCCE_SEND_REQUEST { char *privbuf; // source buffer in local private memory (send buffer) @@ -94,15 +111,33 @@ typedef struct _iRCCE_WAIT_LIST { } iRCCE_WAIT_LIST; +#define iRCCE_MAIL_HEADER_PAYLOAD 13 +typedef struct _iRCCE_MAIL_HEADER { + int source; // UE that will send the header + size_t size; // size of the message which will be send/received + int tag; // tag indicating which kind of message we have + struct _iRCCE_MAIL_HEADER* next;// pointer for queue - could be replaced by list-object + char prio; // priority of the mail + iRCCE_SHORT_FLAG sent; // flag indicating that header is new + iRCCE_SHORT_FLAG closed; // flag indication that mailbox is closed + char payload[iRCCE_MAIL_HEADER_PAYLOAD]; // payload for small messages +} iRCCE_MAIL_HEADER; + +typedef struct _iRCCE_MAIL_TRASH_BIN { + iRCCE_MAIL_HEADER* first; + iRCCE_MAIL_HEADER* last; +} iRCCE_MAIL_TRASH_BIN; + /////////////////////////////////////////////////////////////// // // THE iRCCE API: // -// Initialize function: +// Initialize/Finalize functions: int iRCCE_init(void); +int iRCCE_finalize(void); // // Non-blocking send/recv functions: -int iRCCE_isend(char *, size_t, int, iRCCE_SEND_REQUEST *); +int iRCCE_isend(char *, ssize_t, int, iRCCE_SEND_REQUEST *); int iRCCE_isend_test(iRCCE_SEND_REQUEST *, int *); int iRCCE_isend_wait(iRCCE_SEND_REQUEST *); int iRCCE_isend_push(void); @@ -133,6 +168,18 @@ int iRCCE_wait_any(iRCCE_WAIT_LIST*, iRCCE_SEND_REQUEST **, iRCCE_RECV_REQUEST int iRCCE_isend_cancel(iRCCE_SEND_REQUEST *, int *); int iRCCE_irecv_cancel(iRCCE_RECV_REQUEST *, int *); // +// Blocking send/recv functions for mailbox system +int iRCCE_mail_send(size_t, int, char, char*, int); +int iRCCE_mail_recv(iRCCE_MAIL_HEADER**); +// +// functions to empty mailbox-queue and to check for last mails: +int iRCCE_mail_release(iRCCE_MAIL_HEADER**); +int iRCCE_last_mail_recv(void); +int iRCCE_mailbox_wait(void); +int iRCCE_mailbox_flush(void); +int iRCCE_mailbox_close(int); +void iRCCE_mailbox_print_header(iRCCE_MAIL_HEADER*); +// /////////////////////////////////////////////////////////////// // // Just for for convenience: diff --git a/arch/x86/include/asm/iRCCE_lib.h b/arch/x86/include/asm/iRCCE_lib.h index 0d8b4e16..372b9cdd 100644 --- a/arch/x86/include/asm/iRCCE_lib.h +++ b/arch/x86/include/asm/iRCCE_lib.h @@ -29,6 +29,23 @@ extern iRCCE_SEND_REQUEST* iRCCE_isend_queue; extern iRCCE_RECV_REQUEST* iRCCE_irecv_queue[RCCE_MAXNP]; +extern iRCCE_RECV_REQUEST* iRCCE_irecv_any_source_queue; + +// pointer to MPB-mailbox-space +extern volatile iRCCE_MAIL_HEADER* iRCCE_mailbox_send[RCCE_MAXNP]; +extern volatile iRCCE_MAIL_HEADER* iRCCE_mailbox_recv[RCCE_MAXNP]; + +// queue for received headers +extern iRCCE_MAIL_HEADER* iRCCE_mailbox_recv_queue[iRCCE_PRIOS]; + +// flags for last mail +extern iRCCE_SHORT_FLAG iRCCE_last_mail[RCCE_MAXNP]; + +// field to store open/closed status of mailboxes +extern iRCCE_SHORT_FLAG iRCCE_mailbox_status[RCCE_MAXNP]; + +// garbage collection for mailbox +extern iRCCE_MAIL_TRASH_BIN iRCCE_mail_garbage; #ifdef _OPENMP #pragma omp threadprivate (iRCCE_isend_queue, iRCCE_irecv_queue) #endif diff --git a/arch/x86/include/asm/icc.h b/arch/x86/include/asm/icc.h index dfc69302..9cca3390 100644 --- a/arch/x86/include/asm/icc.h +++ b/arch/x86/include/asm/icc.h @@ -39,21 +39,17 @@ typedef struct { extern bootinfo_t* bootinfo; -typedef struct { - uint8_t type; - uint8_t tag; - uint32_t length; -} icc_header_t; - -#define ICC_TYPE_IP (1 << 0) -#define ICC_TYPE_SVM (1 << 1) -#define ICC_TYPE_PINGREQUEST (1 << 2) -#define ICC_TYPE_PINGRESPONSE (1 << 3) +#define ICC_TAG_IP 0 +#define ICC_TAG_SVM 1 +#define ICC_TAG_PINGREQUEST 2 +#define ICC_TAG_PINGRESPONSE 3 int icc_init(void); -int icc_ping(int ue); -void icc_check(void); int icc_halt(void); +int icc_send_irq(int ue); +void icc_mail_check(void); +int icc_mail_ping(void); + #endif #ifdef __cplusplus diff --git a/arch/x86/include/asm/idt.h b/arch/x86/include/asm/idt.h index 28fde65a..a30cddb1 100644 --- a/arch/x86/include/asm/idt.h +++ b/arch/x86/include/asm/idt.h @@ -82,7 +82,6 @@ typedef struct { unsigned short base_hi; } __attribute__ ((packed)) idt_entry_t; - /** @brief Defines the idt pointer structure. * * This structure keeps information about @@ -95,8 +94,6 @@ typedef struct { unsigned int base; } __attribute__ ((packed)) idt_ptr_t; - - /** @brief Installs IDT * * The installation involves the following steps: @@ -113,7 +110,7 @@ void idt_install(void); * @param sel Segment the IDT will use * @param flags Flags this entry will have */ -void idt_set_gate(unsigned char num, unsigned long base, unsigned short sel, +void idt_set_gate(unsigned char num, size_t base, unsigned short sel, unsigned char flags); /** @brief Configures and returns a IDT entry with chosen attributes @@ -123,7 +120,7 @@ void idt_set_gate(unsigned char num, unsigned long base, unsigned short sel, * * @return a preconfigured idt descriptor */ -idt_entry_t configure_idt_entry(unsigned long base, unsigned short sel, +idt_entry_t configure_idt_entry(size_t base, unsigned short sel, unsigned char flags); #ifdef __cplusplus diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index 8443ec0a..0a97a187 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h @@ -32,6 +32,13 @@ extern "C" { #endif +#ifndef CMOS_PORT_ADDRESS +#define CMOS_PORT_ADDRESS 0x70 +#endif +#ifndef CMOS_PORT_DATA +#define CMOS_PORT_DATA 0x71 +#endif + /** @brief Read a byte from an IO port * * @param _port The port you want to read from @@ -93,6 +100,33 @@ inline static void outportl(unsigned short _port, unsigned int _data) asm volatile("outl %1, %0"::"dN"(_port), "a"(_data)); } +inline static void uart_putchar(unsigned char _data) +{ + outportb(0x2F8, _data); +} + +/** + * read a byte from CMOS + * @param offset CMOS offset + * @return value you want to read + */ +inline static uint8_t cmos_read(uint8_t offset) +{ + outportb(CMOS_PORT_ADDRESS, offset); + return inportb(CMOS_PORT_DATA); +} + +/** + * write a byte in CMOS + * @param offset CMOS offset + * @param val the value you want wto write + */ +inline static void cmos_write(uint8_t offset, uint8_t val) +{ + outportb(CMOS_PORT_ADDRESS, offset); + outportb(CMOS_PORT_DATA, val); +} + #ifdef __cplusplus } #endif diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index cbab6148..91f30387 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -227,12 +227,23 @@ static inline void write_cr4(uint32_t val) { asm volatile("mov %0, %%cr4" : : "r"(val)); } +int ipi_tlb_flush(void); + /** @brief Flush a specific page entry in TLB * @param addr The (virtual) address of the page to flush */ static inline void tlb_flush_one_page(uint32_t addr) { asm volatile("invlpg (%0)" : : "r"(addr) : "memory"); +#if MAX_CORES > 1 + /* + * Currently, we didn't support user-level threads. + * => User-level applications run only on one + * and we didn't flush the TLB of the other cores + */ + if (addr <= KERNEL_SPACE) + ipi_tlb_flush(); +#endif } /** @brief Invalidate the whole TLB @@ -245,6 +256,9 @@ static inline void tlb_flush(void) if (val) write_cr3(val); +#if MAX_CORES > 1 + ipi_tlb_flush(); +#endif } /** @brief Read EFLAGS diff --git a/arch/x86/include/asm/stddef.h b/arch/x86/include/asm/stddef.h index f7d6d499..f3ef4468 100644 --- a/arch/x86/include/asm/stddef.h +++ b/arch/x86/include/asm/stddef.h @@ -70,16 +70,6 @@ typedef unsigned int wint_t; * All the interrupt handler routines use this type for their only parameter. */ struct state { - /* - * We switched from software- to hardwaree-based multitasking - * Therefore, we do not longer save the registers by hand. - */ - /*unsigned int gs, fs, es, ds; */ /* pushed the segs last */ - /* - * Commented this out to write it out in a longer form for HTML-documentation - */ - //unsigned int edi, esi, ebp, esp, ebx, edx, ecx, eax; /* pushed by 'pusha' */ - //unsigned int int_no, err_code; /* our 'push byte #' and ecodes do this */ /// EDI register unsigned int edi; /// ESI register @@ -99,18 +89,19 @@ struct state { /// Interrupt number unsigned int int_no; - /// Error code - unsigned int err_code; /* our 'push byte #' and ecodes do this */ - /*unsigned int eip, cs, eflags, useresp, ss;*/ /* pushed by the processor automatically */ + + // pushed by the processor automatically + unsigned int error; + unsigned int eip; + unsigned int cs; + unsigned int eflags; + unsigned int useresp; + unsigned int ss; }; -/** @brief Read out APIC CPU ID - * @return The APIC CPU ID - */ uint32_t apic_cpu_id(void); -/// Convenience-define constant -#define LOGICAL_CPUID apic_cpu_id() +#define smp_id apic_cpu_id #ifdef __cplusplus } diff --git a/arch/x86/include/asm/tasks.h b/arch/x86/include/asm/tasks.h index 8a1f25a2..c12f946a 100644 --- a/arch/x86/include/asm/tasks.h +++ b/arch/x86/include/asm/tasks.h @@ -45,6 +45,11 @@ extern "C" { */ int arch_fork(task_t* task); +/** @brieff Switch to new task + * @param id Task Id + */ +void switch_task(uint32_t id); + /** @brief Setup a default frame for a new task * * @param task Pointer to the task structure @@ -54,7 +59,7 @@ int arch_fork(task_t* task); * - 0 on success * - -EINVAL (-22) on failure */ -int create_default_frame(task_t* task, entry_point_t ep, void* arg); +int create_default_frame(task_t* task, internal_entry_point_t ep, void* arg); /** @brief Register a task's TSS at GDT * @@ -65,12 +70,6 @@ int create_default_frame(task_t* task, entry_point_t ep, void* arg); */ int register_task(task_t* task); -/** @brief Call to rescheduling - * - * This is a purely assembled procedure for rescheduling - */ -void reschedule(void); - /** @brief Jump back to user code * * This function runs the user code after stopping it just as if @@ -87,6 +86,12 @@ static inline int jump_to_user_code(uint32_t ep, uint32_t stack) return 0; } +/** @brief determines the stack of a specific task + * + * @return start address of a specific task + */ +size_t get_stack(uint32_t id); + #ifdef __cplusplus } #endif diff --git a/arch/x86/kernel/apic.c b/arch/x86/kernel/apic.c index d35ae989..0f0ee985 100644 --- a/arch/x86/kernel/apic.c +++ b/arch/x86/kernel/apic.c @@ -28,7 +28,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -36,12 +38,9 @@ #include #endif -/* disable optimization for the following functions */ -//static int apic_send_ipi(uint32_t id, uint32_t mode, uint32_t vector) __attribute__((optimize(0))); -static int wakeup_all_aps(uint32_t start_eip) __attribute__((optimize(0))); -//int apic_calibration(void) __attribute__((optimize(0))); -//int ioapic_intoff(uint8_t irq, uint8_t apicid) __attribute__((optimize(0))); -//int ioapic_inton(uint8_t irq, uint8_t apicid) __attribute__((optimize(0))); +#if defined(CONFIG_ROCKCREEK) && (MAX_CORES > 1) +#error RockCreek is not a SMP system +#endif // IO APIC MMIO structure: write reg, then read or write data. typedef struct { @@ -60,12 +59,15 @@ static uint32_t icr = 0; static uint32_t ncores = 1; static uint8_t irq_redirect[16] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF}; #if MAX_CORES > 1 -static uint8_t boot_code[] = {0xE9, 0x1E, 0x00, 0x17, 0x00, 0x09, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x9A, 0xCF, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x92, 0xCF, 0x00, 0x0F, 0x01, 0x16, 0x03, 0x00, 0x0F, 0x20, 0xC0, 0x0C, 0x01, 0x0F, 0x22, 0xC0, 0x66, 0xEA, 0x36, 0x00, 0x01, 0x00, 0x08, 0x00, 0xFA, 0x31, 0xC0, 0x66, 0xB8, 0x10, 0x00, 0x8E, 0xD8, 0x8E, 0xC0, 0x8E, 0xE0, 0x8E, 0xE8, 0x8E, 0xD0, 0x0F, 0x20, 0xC0, 0x25, 0xFF, 0xFF, 0xFF, 0x9F, 0x0D, 0x20, 0x00, 0x00, 0x00, 0x0F, 0x22, 0xC0, 0x31, 0xC0, 0x0F, 0x22, 0xD8, 0xBC, 0xEF, 0xBE, 0xAD, 0xDE, 0x31, 0xC0, 0x31, 0xDB, 0xEA, 0xDE, 0xC0, 0xAD, 0xDE, 0x08, 0x00}; +static uint8_t boot_code[] = { 0xFA, 0x0F, 0x01, 0x16, 0x3B, 0x70, 0x0F, 0x20, 0xC0, 0x0C, 0x01, 0x0F, 0x22, 0xC0, 0x66, 0xEA, 0x16, 0x70, 0x00, 0x00, 0x08, 0x00, 0x31, 0xC0, 0x66, 0xB8, 0x10, 0x00, 0x8E, 0xD8, 0x8E, 0xC0, 0x8E, 0xE0, 0x8E, 0xE8, 0x8E, 0xD0, 0xBC, 0xEF, 0xBE, 0xAD, 0xDE, 0x68, 0xAD, 0xDE, 0xAD, 0xDE, 0x6A, 0x00, 0xEA, 0xDE, 0xC0, 0xAD, 0xDE, 0x08, 0x00, 0xEB, 0xFE, 0x17, 0x00, 0x41, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x9A, 0xCF, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x92, 0xCF, 0x00}; +static atomic_int32_t cpu_online = ATOMIC_INIT(1); #endif static uint8_t initialized = 0; -static atomic_int32_t cpu_online = ATOMIC_INIT(1); spinlock_t bootlock = SPINLOCK_INIT; +// forward declaration +static int lapic_reset(void); + static inline uint32_t lapic_read(uint32_t addr) { return *((volatile uint32_t*) (lapic+addr)); @@ -110,6 +112,12 @@ uint32_t apic_cpu_id(void) return 0; } +static inline void apic_set_cpu_id(uint32_t id) +{ + if (lapic && initialized) + lapic_write(APIC_ID, id << 24); +} + static inline uint32_t apic_version(void) { if (lapic) @@ -137,6 +145,53 @@ int apic_is_enabled(void) } #if MAX_CORES > 1 +static inline void set_ipi_dest(uint32_t cpu_id) { + uint32_t tmp; + tmp = lapic_read(APIC_ICR2); + tmp &= 0x00FFFFFF; + tmp |= (cpu_id << 24); + lapic_write(APIC_ICR2, tmp); +} + +int ipi_tlb_flush(void) +{ + uint32_t flags; + uint32_t i, j; + + if (atomic_int32_read(&cpu_online) == 1) + return 0; + + if (lapic_read(APIC_ICR1) & APIC_ICR_BUSY) { + kputs("ERROR: previous send not complete"); + return -EIO; + } + + flags = irq_nested_disable(); + if (atomic_int32_read(&cpu_online) == ncores) { + lapic_write(APIC_ICR1, APIC_INT_ASSERT|APIC_DEST_ALLBUT|APIC_DM_FIXED|124); + + j = 0; + while((lapic_read(APIC_ICR1) & APIC_ICR_BUSY) && (j < 1000)) + j++; // wait for it to finish, give up eventualy tho + } else { + for(i=0; i> 4; + *((volatile unsigned short *) reset_vector) = 0x00; + + if (lapic_read(APIC_ICR1) & APIC_ICR_BUSY) { + kputs("ERROR: previous send not complete"); return -EIO; } - vga_puts("Send IPI\n"); - // send out INIT to all aps - lapic_write(APIC_ICR1, APIC_INT_ASSERT|APIC_DEST_ALLBUT|APIC_DM_INIT); + //kputs("Send IPI\n"); + // send out INIT to AP + set_ipi_dest(id); + lapic_write(APIC_ICR1, APIC_INT_LEVELTRIG|APIC_INT_ASSERT|APIC_DM_INIT); + udelay(200); + // reset INIT + lapic_write(APIC_ICR1, APIC_INT_LEVELTRIG|APIC_DM_INIT); udelay(10000); // send out the startup - lapic_write(APIC_ICR1, APIC_INT_ASSERT|APIC_DEST_ALLBUT|APIC_DM_STARTUP|(start_eip >> 12)); + set_ipi_dest(id); + lapic_write(APIC_ICR1, APIC_DM_STARTUP|(start_eip >> 12)); udelay(200); // do it again - lapic_write(APIC_ICR1, APIC_INT_ASSERT|APIC_DEST_ALLBUT|APIC_DM_STARTUP|(start_eip >> 12)); + set_ipi_dest(id); + lapic_write(APIC_ICR1, APIC_DM_STARTUP|(start_eip >> 12)); udelay(200); - vga_puts("IPI done...\n"); + //kputs("IPI done...\n"); i = 0; while((lapic_read(APIC_ICR1) & APIC_ICR_BUSY) && (i < 1000)) @@ -187,20 +263,70 @@ static int wakeup_all_aps(uint32_t start_eip) return ((lapic_read(APIC_ICR1) & APIC_ICR_BUSY) ? -EIO : 0); // did it fail (still delivering) or succeed ? } -#endif -#if MAX_CORES > 1 -static void smp_main(void) +/* + * This is defined in entry.asm. We use this to properly reload + * the new segment registers + */ +extern void gdt_flush(void); + +/* + * This is defined in entry.asm and initialized the processors. + */ +extern void cpu_init(void); + +/* + * platform independent entry point of the application processors + */ +extern int smp_main(void); + +void smp_start(uint32_t id) { - vga_puts("JJAJAJAJAJAJA\n"); - lowlevel_init(); + uint32_t i; + atomic_int32_inc(&cpu_online); - kputs("JAJAJAJ\n"); + + // reset APIC and set id + lapic_reset(); + apic_set_cpu_id(id); + + kprintf("Application processor %d is entering its idle task\n", apic_cpu_id()); + + // initialize default cpu features + cpu_init(); + + // use the same gdt like the boot processors + gdt_flush(); + + // install IDT + idt_install(); + + // enable additional cpu features + cpu_detection(); + + /* enable paging */ + write_cr3((uint32_t)get_boot_pgd()); + i = read_cr0(); + i = i | (1 << 31); + write_cr0(i); + + // reset APIC and set id + lapic_reset(); // sets also the timer interrupt + apic_set_cpu_id(id); + + /* + * we turned on paging + * => now, we are able to register our task for Task State Switching + */ + register_task(per_core(current_task)); + + smp_main(); + + // idle loop while(1) ; } #endif -#ifndef CONFIG_MULTIBOOT static unsigned int* search_apic(unsigned int base, unsigned int limit) { uint32_t* ptr; @@ -213,42 +339,63 @@ static unsigned int* search_apic(unsigned int base, unsigned int limit) { return NULL; } -#endif #if MAX_CORES > 1 int smp_init(void) { - uint32_t i; - size_t bootaddr; + uint32_t i, j; + char* bootaddr; int err; if (ncores <= 1) return -EINVAL; - /* - * dirty hack: Copy 16bit startup code (see tools/smp_setup.asm) - * to a 16bit address. Wakeup the other cores via IPI. They start - * at this address in real mode, switch to protected and finally - * they jump to smp_main. - */ - bootaddr = 0x10000; - map_region(bootaddr, get_pages(1), 1, MAP_KERNEL_SPACE); - for(i=0; i 1 - //smp_init(); -#endif if (ioapic) { // now, we don't longer need the IOAPIC timer and turn it off @@ -391,6 +545,9 @@ int apic_calibration(void) ioapic_inton(i, apic_processors[boot_processor]->id); } initialized = 1; +#if MAX_CORES > 1 + smp_init(); +#endif irq_nested_enable(flags); return 0; @@ -402,9 +559,16 @@ static int apic_probe(void) uint32_t i, count; int isa_bus = -1; + apic_mp = (apic_mp_t*) search_apic(0xF0000, 0x100000); + if (apic_mp) + goto found_mp; + apic_mp = (apic_mp_t*) search_apic(0x9F000, 0xA0000); + if (apic_mp) + goto found_mp; + // searching MP signature in the reserved memory areas #ifdef CONFIG_MULTIBOOT - if (mb_info && (mb_info->flags & (1 << 6))) { + if (mb_info && (mb_info->flags & MULTIBOOT_INFO_MEM_MAP)) { multiboot_memory_map_t* mmap = (multiboot_memory_map_t*) mb_info->mmap_addr; multiboot_memory_map_t* mmap_end = (void*) ((size_t) mb_info->mmap_addr + mb_info->mmap_length); @@ -412,7 +576,7 @@ static int apic_probe(void) if (mmap->type == MULTIBOOT_MEMORY_RESERVED) { addr = mmap->addr; - for(i=0; ilen; i++, addr++) { + for(i=0; ilen-sizeof(uint32_t); i++, addr++) { if (*((uint32_t*) addr) == MP_FLT_SIGNATURE) { apic_mp = (apic_mp_t*) addr; if (!(apic_mp->version > 4) && apic_mp->features[0]) @@ -424,13 +588,8 @@ static int apic_probe(void) mmap++; } } -found_mp: -#else - apic_mp = (apic_mp_t*) search_apic(0xF0000, 0x100000); - if (!apic_mp) - apic_mp = (apic_mp_t*) search_apic(0x9F000, 0xA0000); #endif - +found_mp: if (!apic_mp) goto no_mp; @@ -555,6 +714,16 @@ no_mp: goto check_lapic; } +#if MAX_CORES > 1 +static void apic_tlb_handler(struct state *s) +{ + uint32_t val = read_cr3(); + + if (val) + write_cr3(val); +} +#endif + static void apic_err_handler(struct state *s) { kprintf("Got APIC error 0x%x\n", lapic_read(APIC_ESR)); @@ -563,27 +732,33 @@ static void apic_err_handler(struct state *s) int apic_init(void) { int ret; - uint8_t i; ret = apic_probe(); - if (!ret) + if (ret) return ret; // set APIC error handler irq_install_handler(126, apic_err_handler); +#if MAX_CORES > 1 + irq_install_handler(124, apic_tlb_handler); +#endif +#if 0 // initialize local apic ret = lapic_reset(); - if (!ret) + if (ret) return ret; if (ioapic) { + uint32_t i; + // enable timer interrupt ioapic_inton(0, apic_processors[boot_processor]->id); // now lets turn everything else off for(i=1; i<24; i++) ioapic_intoff(i, apic_processors[boot_processor]->id); } +#endif return 0; } diff --git a/arch/x86/kernel/entry.asm b/arch/x86/kernel/entry.asm index 6fb00652..e2e2d84a 100644 --- a/arch/x86/kernel/entry.asm +++ b/arch/x86/kernel/entry.asm @@ -64,6 +64,21 @@ ALIGN 4 stublet: ; initialize stack pointer. mov esp, default_stack_pointer +; initialize cpu features + call cpu_init +; interpret multiboot information + extern multiboot_init + push ebx + call multiboot_init + add esp, 4 + +; jump to the boot processors's C code + extern main + call main + jmp $ + +global cpu_init +cpu_init: mov eax, cr0 ; enable caching, disable paging and fpu emulation and eax, 0x1ffffffb @@ -77,16 +92,7 @@ stublet: mov eax, cr4 and eax, 0xfffbf9ff mov cr4, eax -; interpret multiboot information - extern multiboot_init - push ebx - call multiboot_init - add esp, 4 - -; jump to the boot processors's C code - extern main - call main - jmp $ + ret ; This will set up our new segment registers. We need to do ; something special in order to set CS. We do what is called a @@ -154,72 +160,72 @@ isr0: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli + push byte 0 ; pseudo error code push byte 0 - push byte 0 - jmp irq_common_stub + jmp common_stub ; 1: Debug Exception isr1: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 1 - jmp irq_common_stub + jmp common_stub ; 2: Non Maskable Interrupt Exception isr2: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 2 - jmp irq_common_stub + jmp common_stub ; 3: Int 3 Exception isr3: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 3 - jmp irq_common_stub + jmp common_stub ; 4: INTO Exception isr4: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 4 - jmp irq_common_stub + jmp common_stub ; 5: Out of Bounds Exception isr5: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 5 - jmp irq_common_stub + jmp common_stub ; 6: Invalid Opcode Exception isr6: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 6 - jmp irq_common_stub + jmp common_stub ; 7: Coprocessor Not Available Exception isr7: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 7 - jmp irq_common_stub + jmp common_stub ; 8: Double Fault Exception (With Error Code!) isr8: @@ -227,16 +233,16 @@ isr8: ; Therefore, the interrupt flag (IF) is already cleared. ; cli push byte 8 - jmp irq_common_stub + jmp common_stub ; 9: Coprocessor Segment Overrun Exception isr9: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 9 - jmp irq_common_stub + jmp common_stub ; 10: Bad TSS Exception (With Error Code!) isr10: @@ -244,7 +250,7 @@ isr10: ; Therefore, the interrupt flag (IF) is already cleared. ; cli push byte 10 - jmp irq_common_stub + jmp common_stub ; 11: Segment Not Present Exception (With Error Code!) isr11: @@ -252,7 +258,7 @@ isr11: ; Therefore, the interrupt flag (IF) is already cleared. ; cli push byte 11 - jmp irq_common_stub + jmp common_stub ; 12: Stack Fault Exception (With Error Code!) isr12: @@ -260,7 +266,7 @@ isr12: ; Therefore, the interrupt flag (IF) is already cleared. ; cli push byte 12 - jmp irq_common_stub + jmp common_stub ; 13: General Protection Fault Exception (With Error Code!) isr13: @@ -268,7 +274,7 @@ isr13: ; Therefore, the interrupt flag (IF) is already cleared. ; cli push byte 13 - jmp irq_common_stub + jmp common_stub ; 14: Page Fault Exception (With Error Code!) isr14: @@ -276,169 +282,168 @@ isr14: ; Therefore, the interrupt flag (IF) is already cleared. ; cli push byte 14 - jmp irq_common_stub + jmp common_stub ; 15: Reserved Exception isr15: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 15 - jmp irq_common_stub + jmp common_stub ; 16: Floating Point Exception isr16: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 16 - jmp irq_common_stub + jmp common_stub ; 17: Alignment Check Exception isr17: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 push byte 17 - jmp irq_common_stub + jmp common_stub ; 18: Machine Check Exception isr18: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 18 - jmp irq_common_stub + jmp common_stub ; 19: Reserved isr19: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 19 - jmp irq_common_stub + jmp common_stub ; 20: Reserved isr20: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 20 - jmp irq_common_stub + jmp common_stub ; 21: Reserved isr21: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 21 - jmp irq_common_stub + jmp common_stub ; 22: Reserved isr22: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 22 - jmp irq_common_stub + jmp common_stub ; 23: Reserved isr23: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 23 - jmp irq_common_stub + jmp common_stub ; 24: Reserved isr24: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 24 - jmp irq_common_stub + jmp common_stub ; 25: Reserved isr25: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 25 - jmp irq_common_stub + jmp common_stub ; 26: Reserved isr26: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 26 - jmp irq_common_stub + jmp common_stub ; 27: Reserved isr27: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 27 - jmp irq_common_stub + jmp common_stub ; 28: Reserved isr28: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 28 - jmp irq_common_stub + jmp common_stub ; 29: Reserved isr29: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 29 - jmp irq_common_stub + jmp common_stub ; 30: Reserved isr30: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 30 - jmp irq_common_stub + jmp common_stub ; 31: Reserved isr31: ; isr0 - isr31 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 31 - jmp irq_common_stub + jmp common_stub extern syscall_handler ; used to realize system calls isrsyscall: - push ds - push fs - push gs - push es + ;push ds + ;push fs + ;push gs + ;push es push ebp push edi push esi @@ -455,10 +460,10 @@ isrsyscall: pop esi pop edi pop ebp - pop es - pop gs - pop fs - pop ds + ;pop es + ;pop gs + ;pop fs + ;pop ds iret global irq0 @@ -491,324 +496,279 @@ global apic_lint1 global apic_error global apic_svr -extern irq_handler -extern get_current_task -extern scheduler - -global reschedule -reschedule: - cli - ; eax could change across a function call - ; => so we don't have to save the original eax value - push ebx - - call get_current_task - push eax - call scheduler - call get_current_task - pop ebx - cmp eax, ebx - je no_task_switch1 - - mov eax, [eax] - add ax, WORD 5 - mov bx, WORD 8 - mul bx - mov [hack1+5], ax -hack1: - jmp 0x00 : 0xDEADBEAF - -no_task_switch1: - pop ebx - sti - ret +global switch_task +switch_task: + mov eax, [esp+4] + add ax, WORD 5 + mov bx, WORD 8 + mul bx + mov [hack+5], ax +hack: + jmp 0x00 : 0xDEADBEAF + ret ; 32: IRQ0 irq0: ; irq0 - irq15 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 32 - -Lirq0: - pusha - push esp - call irq_handler - add esp, 4 - - call get_current_task - push eax - call scheduler - call get_current_task - pop ebx - cmp eax, ebx - je no_task_switch2 - - mov eax, [eax] - add ax, WORD 5 - mov bx, WORD 8 - mul bx - mov [hack2+5], ax -hack2: - jmp 0x00 : 0xDEADBEAF - -no_task_switch2: - popa - add esp, 8 - iret + jmp common_stub ; 33: IRQ1 irq1: ; irq0 - irq15 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 33 - jmp irq_common_stub + jmp common_stub ; 34: IRQ2 irq2: ; irq0 - irq15 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 34 - jmp irq_common_stub + jmp common_stub ; 35: IRQ3 irq3: ; irq0 - irq15 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 35 - jmp irq_common_stub + jmp common_stub ; 36: IRQ4 irq4: ; irq0 - irq15 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 36 - jmp irq_common_stub + jmp common_stub ; 37: IRQ5 irq5: ; irq0 - irq15 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 37 - jmp irq_common_stub + jmp common_stub ; 38: IRQ6 irq6: ; irq0 - irq15 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 38 - jmp irq_common_stub + jmp common_stub ; 39: IRQ7 irq7: ; irq0 - irq15 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 39 - jmp irq_common_stub + jmp common_stub ; 40: IRQ8 irq8: ; irq0 - irq15 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 40 - jmp irq_common_stub + jmp common_stub ; 41: IRQ9 irq9: ; irq0 - irq15 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 41 - jmp irq_common_stub + jmp common_stub ; 42: IRQ10 irq10: ; irq0 - irq15 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 42 - jmp irq_common_stub + jmp common_stub ; 43: IRQ11 irq11: ; irq0 - irq15 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 43 - jmp irq_common_stub + jmp common_stub ; 44: IRQ12 irq12: ; irq0 - irq15 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 44 - jmp irq_common_stub + jmp common_stub ; 45: IRQ13 irq13: ; irq0 - irq15 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 45 - jmp irq_common_stub + jmp common_stub ; 46: IRQ14 irq14: ; irq0 - irq15 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 46 - jmp irq_common_stub + jmp common_stub ; 47: IRQ15 irq15: ; irq0 - irq15 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 47 - jmp irq_common_stub + jmp common_stub ; 48: IRQ16 irq16: ; irq16 - irq23 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 48 - jmp irq_common_stub + jmp common_stub ; 49: IRQ17 irq17: ; irq16- irq23 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 49 - jmp irq_common_stub + jmp common_stub ; 50: IRQ18 irq18: ; irq16 - irq23 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 50 - jmp irq_common_stub + jmp common_stub ; 51: IRQ19 irq19: ; irq16 - irq23 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 51 - jmp irq_common_stub + jmp common_stub ; 52: IRQ20 irq20: ; irq16- irq23 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 52 - jmp irq_common_stub + jmp common_stub ; 53: IRQ21 irq21: ; irq16 - irq23 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; error code push byte 53 - jmp irq_common_stub + jmp common_stub ; 54: IRQ22 irq22: ; irq16- irq23 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 54 - jmp irq_common_stub + jmp common_stub ; 55: IRQ23 irq23: ; irq16 - irq23 are registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 55 - jmp irq_common_stub + jmp common_stub apic_timer: ; apic timer is registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 123 - ; we reuse code of the "traditional" timer interrupt (PIC) - jmp Lirq0 + jmp common_stub apic_lint0: ; lint0 is registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 124 - jmp irq_common_stub + jmp common_stub apic_lint1: ; lint1 is registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 125 - jmp irq_common_stub + jmp common_stub apic_error: ; LVT error interrupt is registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 126 - jmp irq_common_stub + jmp common_stub apic_svr: ; SVR is registered as "Interrupt Gate" ; Therefore, the interrupt flag (IF) is already cleared. ; cli - push byte 0 + push byte 0 ; pseudo error code push byte 127 - jmp irq_common_stub + jmp common_stub -irq_common_stub: +extern irq_handler + +common_stub: pusha + ; use the same handler for interrupts and exceptions push esp call irq_handler add esp, 4 diff --git a/arch/x86/kernel/gdt.c b/arch/x86/kernel/gdt.c index ed863eaa..9441410a 100644 --- a/arch/x86/kernel/gdt.c +++ b/arch/x86/kernel/gdt.c @@ -34,11 +34,24 @@ static gdt_entry_t gdt[GDT_ENTRIES] = {[0 ... GDT_ENTRIES-1] = {0, 0, 0, 0, 0, unsigned char* default_stack_pointer __attribute__ ((section (".data"))) = kstacks[0] + KERNEL_STACK_SIZE - sizeof(size_t); /* - * This is in start.asm. We use this to properly reload + * This is defined in entry.asm. We use this to properly reload * the new segment registers */ extern void gdt_flush(void); +/* + * This is defined in entry.asm. We use this for a + * hardware-based task switch. + */ +extern void tss_switch(uint32_t id); + +size_t get_stack(uint32_t id) +{ + if (BUILTIN_EXPECT(id >= MAX_TASKS, 0)) + return -EINVAL; + return (size_t) kstacks[id] + KERNEL_STACK_SIZE - sizeof(size_t); +} + int register_task(task_t* task) { uint16_t sel; uint32_t id = task->id; @@ -112,7 +125,7 @@ int arch_fork(task_t* task) return 0; } -int create_default_frame(task_t* task, entry_point_t ep, void* arg) +int create_default_frame(task_t* task, internal_entry_point_t ep, void* arg) { uint16_t cs = 0x08; uint16_t ds = 0x10; diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c index fe3b2bf4..af7fec6f 100644 --- a/arch/x86/kernel/idt.c +++ b/arch/x86/kernel/idt.c @@ -41,17 +41,8 @@ */ static idt_entry_t idt[256] = {[0 ... 255] = {0, 0, 0, 0, 0}}; static idt_ptr_t idtp; -/* - * Use this function to set an entry in the IDT. Alot simpler - * than twiddling with the GDT ;) - */ -void idt_set_gate(unsigned char num, unsigned long base, unsigned short sel, - unsigned char flags) -{ - idt[num] = configure_idt_entry(base, sel, flags); -} -idt_entry_t configure_idt_entry(unsigned long base, unsigned short sel, +idt_entry_t configure_idt_entry(size_t base, unsigned short sel, unsigned char flags) { idt_entry_t desc; @@ -69,18 +60,34 @@ idt_entry_t configure_idt_entry(unsigned long base, unsigned short sel, return desc; } +/* + * Use this function to set an entry in the IDT. Alot simpler + * than twiddling with the GDT ;) + */ +void idt_set_gate(unsigned char num, size_t base, unsigned short sel, + unsigned char flags) +{ + idt[num] = configure_idt_entry(base, sel, flags); +} + extern void isrsyscall(void); /* Installs the IDT */ void idt_install(void) { - /* Sets the special IDT pointer up, just like in 'gdt.c' */ - idtp.limit = (sizeof(idt_entry_t) * 256) - 1; - idtp.base = (unsigned int)&idt; + static int initialized = 0; - /* Add any new ISRs to the IDT here using idt_set_gate */ - idt_set_gate(INT_SYSCALL, (unsigned int)isrsyscall, KERNEL_CODE_SELECTOR, - IDT_FLAG_PRESENT|IDT_FLAG_RING3|IDT_FLAG_32BIT|IDT_FLAG_TRAPGATE); + if (!initialized) { + initialized = 1; + + /* Sets the special IDT pointer up, just like in 'gdt.c' */ + idtp.limit = (sizeof(idt_entry_t) * 256) - 1; + idtp.base = (unsigned int)&idt; + + /* Add any new ISRs to the IDT here using idt_set_gate */ + idt_set_gate(INT_SYSCALL, (size_t)isrsyscall, KERNEL_CODE_SELECTOR, + IDT_FLAG_PRESENT|IDT_FLAG_RING3|IDT_FLAG_32BIT|IDT_FLAG_TRAPGATE); + } /* Points the processor's internal register to the new IDT */ asm volatile("lidt %0" : : "m" (idtp)); diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c index 3c4b621f..04ddecf4 100644 --- a/arch/x86/kernel/irq.c +++ b/arch/x86/kernel/irq.c @@ -138,66 +138,66 @@ static int irq_install(void) { irq_remap(); - idt_set_gate(32, (unsigned)irq0, KERNEL_CODE_SELECTOR, + idt_set_gate(32, (size_t)irq0, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(33, (unsigned)irq1, KERNEL_CODE_SELECTOR, + idt_set_gate(33, (size_t)irq1, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(34, (unsigned)irq2, KERNEL_CODE_SELECTOR, + idt_set_gate(34, (size_t)irq2, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(35, (unsigned)irq3, KERNEL_CODE_SELECTOR, + idt_set_gate(35, (size_t)irq3, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(36, (unsigned)irq4, KERNEL_CODE_SELECTOR, + idt_set_gate(36, (size_t)irq4, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(37, (unsigned)irq5, KERNEL_CODE_SELECTOR, + idt_set_gate(37, (size_t)irq5, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(38, (unsigned)irq6, KERNEL_CODE_SELECTOR, + idt_set_gate(38, (size_t)irq6, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(39, (unsigned)irq7, KERNEL_CODE_SELECTOR, + idt_set_gate(39, (size_t)irq7, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(40, (unsigned)irq8, KERNEL_CODE_SELECTOR, + idt_set_gate(40, (size_t)irq8, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(41, (unsigned)irq9, KERNEL_CODE_SELECTOR, + idt_set_gate(41, (size_t)irq9, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(42, (unsigned)irq10, KERNEL_CODE_SELECTOR, + idt_set_gate(42, (size_t)irq10, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(43, (unsigned)irq11, KERNEL_CODE_SELECTOR, + idt_set_gate(43, (size_t)irq11, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(44, (unsigned)irq12, KERNEL_CODE_SELECTOR, + idt_set_gate(44, (size_t)irq12, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(45, (unsigned)irq13, KERNEL_CODE_SELECTOR, + idt_set_gate(45, (size_t)irq13, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(46, (unsigned)irq14, KERNEL_CODE_SELECTOR, + idt_set_gate(46, (size_t)irq14, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(47, (unsigned)irq15, KERNEL_CODE_SELECTOR, + idt_set_gate(47, (size_t)irq15, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); if (has_apic()) { - idt_set_gate(48, (unsigned)irq16, KERNEL_CODE_SELECTOR, + idt_set_gate(48, (size_t)irq16, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(49, (unsigned)irq17, KERNEL_CODE_SELECTOR, + idt_set_gate(49, (size_t)irq17, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(50, (unsigned)irq18, KERNEL_CODE_SELECTOR, + idt_set_gate(50, (size_t)irq18, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(51, (unsigned)irq19, KERNEL_CODE_SELECTOR, + idt_set_gate(51, (size_t)irq19, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(52, (unsigned)irq20, KERNEL_CODE_SELECTOR, + idt_set_gate(52, (size_t)irq20, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(53, (unsigned)irq21, KERNEL_CODE_SELECTOR, + idt_set_gate(53, (size_t)irq21, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(54, (unsigned)irq22, KERNEL_CODE_SELECTOR, + idt_set_gate(54, (size_t)irq22, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(55, (unsigned)irq23, KERNEL_CODE_SELECTOR, + idt_set_gate(55, (size_t)irq23, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(123, (unsigned)apic_timer, KERNEL_CODE_SELECTOR, + idt_set_gate(123, (size_t)apic_timer, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(124, (unsigned)apic_lint0, KERNEL_CODE_SELECTOR, + idt_set_gate(124, (size_t)apic_lint0, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(125, (unsigned)apic_lint1, KERNEL_CODE_SELECTOR, + idt_set_gate(125, (size_t)apic_lint1, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(126, (unsigned)apic_error, KERNEL_CODE_SELECTOR, + idt_set_gate(126, (size_t)apic_error, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(127, (unsigned)apic_svr, KERNEL_CODE_SELECTOR, + idt_set_gate(127, (size_t)apic_svr, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); } @@ -253,9 +253,10 @@ void irq_handler(struct state *s) */ if (apic_is_enabled() || s->int_no >= 123) { apic_eoi(); - return; + goto leave_handler; } +#ifndef CONFIG_ROCKCREEK /* * If the IDT entry that was invoked was greater-than-or-equal to 40 * and lower than 48 (meaning IRQ8 - 15), then we need to @@ -269,4 +270,12 @@ void irq_handler(struct state *s) * interrupt controller of the PIC, too */ outportb(0x20, 0x20); +#else + kprintf("Upps, RockCreek uses IRQs below 123!\n"); +#endif + +leave_handler: + // timer interrupt? + if ((s->int_no == 32) || (s->int_no == 123)) + scheduler(); // switch to a new task } diff --git a/arch/x86/kernel/isrs.c b/arch/x86/kernel/isrs.c index ed0d6792..f1e2d9cc 100644 --- a/arch/x86/kernel/isrs.c +++ b/arch/x86/kernel/isrs.c @@ -91,69 +91,69 @@ void isrs_install(void) { int i; - idt_set_gate(0, (unsigned)isr0, KERNEL_CODE_SELECTOR, + idt_set_gate(0, (size_t)isr0, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(1, (unsigned)isr1, KERNEL_CODE_SELECTOR, + idt_set_gate(1, (size_t)isr1, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(2, (unsigned)isr2, KERNEL_CODE_SELECTOR, + idt_set_gate(2, (size_t)isr2, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(3, (unsigned)isr3, KERNEL_CODE_SELECTOR, + idt_set_gate(3, (size_t)isr3, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(4, (unsigned)isr4, KERNEL_CODE_SELECTOR, + idt_set_gate(4, (size_t)isr4, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(5, (unsigned)isr5, KERNEL_CODE_SELECTOR, + idt_set_gate(5, (size_t)isr5, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(6, (unsigned)isr6, KERNEL_CODE_SELECTOR, + idt_set_gate(6, (size_t)isr6, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(7, (unsigned)isr7, KERNEL_CODE_SELECTOR, + idt_set_gate(7, (size_t)isr7, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(8, (unsigned)isr8, KERNEL_CODE_SELECTOR, + idt_set_gate(8, (size_t)isr8, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(9, (unsigned)isr9, KERNEL_CODE_SELECTOR, + idt_set_gate(9, (size_t)isr9, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(10, (unsigned)isr10, KERNEL_CODE_SELECTOR, + idt_set_gate(10, (size_t)isr10, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(11, (unsigned)isr11, KERNEL_CODE_SELECTOR, + idt_set_gate(11, (size_t)isr11, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(12, (unsigned)isr12, KERNEL_CODE_SELECTOR, + idt_set_gate(12, (size_t)isr12, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(13, (unsigned)isr13, KERNEL_CODE_SELECTOR, + idt_set_gate(13, (size_t)isr13, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(14, (unsigned)isr14, KERNEL_CODE_SELECTOR, + idt_set_gate(14, (size_t)isr14, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(15, (unsigned)isr15, KERNEL_CODE_SELECTOR, + idt_set_gate(15, (size_t)isr15, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(16, (unsigned)isr16, KERNEL_CODE_SELECTOR, + idt_set_gate(16, (size_t)isr16, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(17, (unsigned)isr17, KERNEL_CODE_SELECTOR, + idt_set_gate(17, (size_t)isr17, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(18, (unsigned)isr18, KERNEL_CODE_SELECTOR, + idt_set_gate(18, (size_t)isr18, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(19, (unsigned)isr19, KERNEL_CODE_SELECTOR, + idt_set_gate(19, (size_t)isr19, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(20, (unsigned)isr20, KERNEL_CODE_SELECTOR, + idt_set_gate(20, (size_t)isr20, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(21, (unsigned)isr21, KERNEL_CODE_SELECTOR, + idt_set_gate(21, (size_t)isr21, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(22, (unsigned)isr22, KERNEL_CODE_SELECTOR, + idt_set_gate(22, (size_t)isr22, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(23, (unsigned)isr23, KERNEL_CODE_SELECTOR, + idt_set_gate(23, (size_t)isr23, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(24, (unsigned)isr24, KERNEL_CODE_SELECTOR, + idt_set_gate(24, (size_t)isr24, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(25, (unsigned)isr25, KERNEL_CODE_SELECTOR, + idt_set_gate(25, (size_t)isr25, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(26, (unsigned)isr26, KERNEL_CODE_SELECTOR, + idt_set_gate(26, (size_t)isr26, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(27, (unsigned)isr27, KERNEL_CODE_SELECTOR, + idt_set_gate(27, (size_t)isr27, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(28, (unsigned)isr28, KERNEL_CODE_SELECTOR, + idt_set_gate(28, (size_t)isr28, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(29, (unsigned)isr29, KERNEL_CODE_SELECTOR, + idt_set_gate(29, (size_t)isr29, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(30, (unsigned)isr30, KERNEL_CODE_SELECTOR, + idt_set_gate(30, (size_t)isr30, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); - idt_set_gate(31, (unsigned)isr31, KERNEL_CODE_SELECTOR, + idt_set_gate(31, (size_t)isr31, KERNEL_CODE_SELECTOR, IDT_FLAG_PRESENT|IDT_FLAG_RING0|IDT_FLAG_32BIT|IDT_FLAG_INTTRAP); // install the default handler @@ -172,7 +172,7 @@ static void fpu_init(union fpu_state* fpu) memset(fx, 0, sizeof(union fpu_state)); fx->cwd = 0x37f; - if (has_xmm) + if (has_xmm()) fx->mxcsr = 0x1f80; } else { i387_fsave_t *fp = &fpu->fsave; @@ -229,12 +229,13 @@ static void fault_handler(struct state *s) { if (s->int_no < 32) { kputs(exception_messages[s->int_no]); - kprintf(" Exception. (%d)\n", s->int_no); + kprintf(" Exception (%d) at 0x%x:0x%x on core %u, error code 0x%x, eflags 0x%x\n", + s->int_no, s->cs, s->eip, CORE_ID, s->error, s->eflags); /* Now, we signalize that we have handled the interrupt */ if (apic_is_enabled()) apic_eoi(); - else + else outportb(0x20, 0x20); irq_enable(); diff --git a/arch/x86/kernel/processor.c b/arch/x86/kernel/processor.c index 4210c38f..93e5f540 100644 --- a/arch/x86/kernel/processor.c +++ b/arch/x86/kernel/processor.c @@ -21,6 +21,7 @@ #include #include #include +#include #ifdef CONFIG_ROCKCREEK #include #endif @@ -104,6 +105,8 @@ void udelay(uint32_t usecs) mb(); end = rdtsc(); diff = end > start ? end - start : start - end; + if ((diff < deadline) && (deadline - diff > 50000)) + check_workqueues(); } while(diff < deadline); } diff --git a/arch/x86/kernel/timer.c b/arch/x86/kernel/timer.c index 73c83a51..251f71f8 100644 --- a/arch/x86/kernel/timer.c +++ b/arch/x86/kernel/timer.c @@ -33,7 +33,7 @@ * This will keep track of how many ticks the system * has been running for */ -static volatile uint64_t timer_ticks = 0; +static volatile uint64_t timer_ticks __attribute__ ((aligned (CACHE_LINE))) = 0; uint64_t get_clock_tick(void) { @@ -61,12 +61,17 @@ int sys_times(struct tms* buffer, clock_t* clock) static void timer_handler(struct state *s) { /* Increment our 'tick counter' */ +#if MAX_CORES > 1 + if (smp_id() == 0) + timer_ticks++; +#else timer_ticks++; +#endif /* - * Every TIMER_FREQ clocks (approximately 1 second), we will + * Every TIMER_FREQ clocks (approximately 1 second), we will * display a message on the screen - */ + */ /*if (timer_ticks % TIMER_FREQ == 0) { vga_puts("One second has passed\n"); }*/ @@ -105,7 +110,7 @@ int timer_init(void) * Installs 'timer_handler' for the PIC and APIC timer, * only one handler will be later used. */ - irq_install_handler(0+32, timer_handler); + irq_install_handler(32, timer_handler); irq_install_handler(123, timer_handler); /* diff --git a/arch/x86/mm/page.c b/arch/x86/mm/page.c index 4551edc1..50631b49 100644 --- a/arch/x86/mm/page.c +++ b/arch/x86/mm/page.c @@ -30,6 +30,7 @@ #include #include #include +#include #ifdef CONFIG_ROCKCREEK #include #include @@ -264,7 +265,7 @@ size_t map_region(size_t viraddr, size_t phyaddr, uint32_t npages, uint32_t flag size_t index, i; size_t ret; - if (BUILTIN_EXPECT(!task || !task->pgd || !phyaddr, 0)) + if (BUILTIN_EXPECT(!task || !task->pgd, 0)) return 0; if (BUILTIN_EXPECT(!paging_enabled && (viraddr != phyaddr), 0)) @@ -667,6 +668,14 @@ int arch_paging_init(void) npages++; map_region((size_t)&kernel_start, (size_t)&kernel_start, npages, MAP_KERNEL_SPACE); +#if MAX_CORES > 1 + // Reserve page for smp boot code + if (!map_region(SMP_SETUP_ADDR, SMP_SETUP_ADDR, 1, MAP_KERNEL_SPACE|MAP_NO_CACHE)) { + kputs("could not reserve page for smp boot code\n"); + return -ENOMEM; + } +#endif + #ifdef CONFIG_VGA // map the video memory into the kernel space map_region(VIDEO_MEM_ADDR, VIDEO_MEM_ADDR, 1, MAP_KERNEL_SPACE|MAP_NO_CACHE); @@ -752,6 +761,9 @@ int arch_paging_init(void) */ register_task(per_core(current_task)); + // APIC registers into the kernel address space + map_apic(); + return 0; } diff --git a/arch/x86/scc/Makefile b/arch/x86/scc/Makefile index 2003a259..74d355a4 100644 --- a/arch/x86/scc/Makefile +++ b/arch/x86/scc/Makefile @@ -1,4 +1,4 @@ -C_source := icc.c SCC_API.c iRCCE_admin.c iRCCE_send.c iRCCE_isend.c iRCCE_irecv.c iRCCE_recv.c iRCCE_get.c iRCCE_put.c iRCCE_synch.c RCCE_malloc.c RCCE_shmalloc.c RCCE_debug.c RCCE_qsort.c RCCE_DCMflush.c RCCE_send.c RCCE_recv.c RCCE_flags.c RCCE_comm.c RCCE_put.c RCCE_get.c RCCE_synch.c RCCE_bcast.c RCCE_admin.c # RCCE_power_management.c +C_source := icc.c SCC_API.c iRCCE_admin.c iRCCE_send.c iRCCE_isend.c iRCCE_irecv.c iRCCE_recv.c iRCCE_get.c iRCCE_put.c iRCCE_synch.c iRCCE_mailbox.c RCCE_malloc.c RCCE_shmalloc.c RCCE_debug.c RCCE_qsort.c RCCE_DCMflush.c RCCE_send.c RCCE_recv.c RCCE_flags.c RCCE_comm.c RCCE_put.c RCCE_get.c RCCE_synch.c RCCE_bcast.c RCCE_admin.c # RCCE_power_management.c ASM_source := MODULE := arch_x86_scc diff --git a/arch/x86/scc/iRCCE_admin.c b/arch/x86/scc/iRCCE_admin.c index c61d66b9..2a28f09e 100644 --- a/arch/x86/scc/iRCCE_admin.c +++ b/arch/x86/scc/iRCCE_admin.c @@ -47,6 +47,27 @@ iRCCE_SEND_REQUEST* iRCCE_isend_queue; // recv request queue iRCCE_RECV_REQUEST* iRCCE_irecv_queue[RCCE_MAXNP]; +// recv request queue for those with source = iRCCE_ANY_SOURCE: +iRCCE_RECV_REQUEST* iRCCE_irecv_any_source_queue; + +// mailbox in MPB +volatile iRCCE_MAIL_HEADER* iRCCE_mailbox_recv[RCCE_MAXNP]; // store addresses for receiving headers +volatile iRCCE_MAIL_HEADER* iRCCE_mailbox_send[RCCE_MAXNP]; // store addresses for sending headeres + +// mailbox recv queue +iRCCE_MAIL_HEADER* iRCCE_mailbox_recv_queue[iRCCE_PRIOS]; + +// mail garbage queue +iRCCE_MAIL_TRASH_BIN iRCCE_mail_garbage; + +// flag indicating if last header was received +iRCCE_SHORT_FLAG iRCCE_last_mail[RCCE_MAXNP]; + +// field to store open/closed status of mailboxes +iRCCE_SHORT_FLAG iRCCE_mailbox_status[RCCE_MAXNP]; + + + //-------------------------------------------------------------------------------------- // FUNCTION: iRCCE_init //-------------------------------------------------------------------------------------- @@ -56,12 +77,55 @@ int iRCCE_init(void) { int i; for(i=0; inext; + kfree( erase_header, sizeof(iRCCE_MAIL_HEADER) ); + } + + iRCCE_mail_garbage.first = iRCCE_mail_garbage.last = NULL; + return iRCCE_SUCCESS; +} #endif diff --git a/arch/x86/scc/iRCCE_irecv.c b/arch/x86/scc/iRCCE_irecv.c index e7d5ad1d..4af79efb 100644 --- a/arch/x86/scc/iRCCE_irecv.c +++ b/arch/x86/scc/iRCCE_irecv.c @@ -50,7 +50,9 @@ static int iRCCE_push_recv_request(iRCCE_RECV_REQUEST *request) { char padline[RCCE_LINE_SIZE]; // copy buffer, used if message not multiple of line size int test; // flag for calling iRCCE_test_flag() - if(request->finished) return(iRCCE_SUCCESS); + if(request->finished) { + return(iRCCE_SUCCESS); + } if(request->label == 1) goto label1; if(request->label == 2) goto label2; @@ -167,6 +169,25 @@ static void iRCCE_init_recv_request( return; } +int iRCCE_irecv_search_source() { + int i, j; + int res =iRCCE_ANY_SOURCE; + + for( i=0; inext == NULL ) { + iRCCE_irecv_any_source_queue->next = request; + } + else { + iRCCE_RECV_REQUEST* run = iRCCE_irecv_any_source_queue; + while( run->next != NULL ) run = run->next; + run->next = request; + } + } + return iRCCE_RESERVED; + } + } if (source<0 || source >= RCCE_NP) return(RCCE_error_return(RCCE_debug_comm,RCCE_ERROR_ID)); @@ -211,10 +273,10 @@ int iRCCE_irecv(char *privbuf, size_t size, int source, iRCCE_RECV_REQUEST *requ run->next = request; } - if(request == &blocking_irecv_request) { - iRCCE_irecv_wait(request); - return(iRCCE_SUCCESS); - } + if(request == &blocking_irecv_request) { + iRCCE_irecv_wait(request); + return(iRCCE_SUCCESS); + } return(iRCCE_RESERVED); } @@ -243,29 +305,98 @@ int iRCCE_irecv_test(iRCCE_RECV_REQUEST *request, int *test) { } } - source = request->source; + // does request still have no source? + if( request->source == iRCCE_ANY_SOURCE ) { + request->source = iRCCE_irecv_search_source(); - if(request->finished) { - if (test) (*test) = 1; - return(iRCCE_SUCCESS); + if( request->source == iRCCE_ANY_SOURCE ) { + if (test) (*test) = 0; + return iRCCE_RESERVED; + } + else { // take request out of wait_any_source-list + + // find request in queue + if( request == iRCCE_irecv_any_source_queue ) { + iRCCE_irecv_any_source_queue = iRCCE_irecv_any_source_queue->next; + } + else { + iRCCE_RECV_REQUEST* run = iRCCE_irecv_any_source_queue; + while( run->next != request ) run = run->next; + run->next = request->next; + } + + request->next = NULL; + request->sent = &RCCE_sent_flag[request->source]; // set senders flag + source = request->source; + + // queue request in iRCCE_irecv_queue + if(iRCCE_irecv_queue[source] == NULL) { + + if(iRCCE_push_recv_request(request) == iRCCE_SUCCESS) { + if (test) (*test) = 1; + return(iRCCE_SUCCESS); + } + else { + iRCCE_irecv_queue[source] = request; + + if(request == &blocking_irecv_request) { + iRCCE_irecv_wait(request); + if (test) (*test) = 1; + return(iRCCE_SUCCESS); + } + if (test) (*test) = 0; + return(iRCCE_PENDING); + } + } + else { + if(iRCCE_irecv_queue[source]->next == NULL) { + iRCCE_irecv_queue[source]->next = request; + } + else { + iRCCE_RECV_REQUEST *run = iRCCE_irecv_queue[source]; + while(run->next != NULL) run = run->next; + run->next = request; + } + + if(request == &blocking_irecv_request) { + iRCCE_irecv_wait(request); + if (test) (*test) = 1; + return(iRCCE_SUCCESS); + } + + if (test) (*test) = 1; + return(iRCCE_RESERVED); + } + + + } } + else { + + source = request->source; + + if(request->finished) { + if (test) (*test) = 1; + return(iRCCE_SUCCESS); + } + + if(iRCCE_irecv_queue[source] != request) { + if (test) (*test) = 0; + return(iRCCE_RESERVED); + } + + iRCCE_push_recv_request(request); + + if(request->finished) { + iRCCE_irecv_queue[source] = request->next; + + if (test) (*test) = 1; + return(iRCCE_SUCCESS); + } - if(iRCCE_irecv_queue[source] != request) { if (test) (*test) = 0; - return(iRCCE_RESERVED); + return(iRCCE_PENDING); } - - iRCCE_push_recv_request(request); - - if(request->finished) { - iRCCE_irecv_queue[source] = request->next; - - if (test) (*test) = 1; - return(iRCCE_SUCCESS); - } - - if (test) (*test) = 0; - return(iRCCE_PENDING); } @@ -297,6 +428,40 @@ static int iRCCE_irecv_push_source(int source) { } int iRCCE_irecv_push(void) { + iRCCE_RECV_REQUEST* help_request; + + // first check sourceless requests + if( iRCCE_irecv_any_source_queue != NULL) { + while( iRCCE_irecv_any_source_queue != NULL ) { + iRCCE_irecv_any_source_queue->source = iRCCE_irecv_search_source(); + + if( iRCCE_irecv_any_source_queue->source == iRCCE_ANY_SOURCE ) { + + break; + } + // source found for first request in iRCCE_irecv_any_source_queue + else { + // set senders flag + iRCCE_irecv_any_source_queue->sent = &RCCE_sent_flag[iRCCE_irecv_any_source_queue->source]; + + // take request out of irecv_any_source_queue + help_request = iRCCE_irecv_any_source_queue; + iRCCE_irecv_any_source_queue = iRCCE_irecv_any_source_queue->next; + help_request->next = NULL; + + // put request into irecv_queue + if(iRCCE_irecv_queue[help_request->source] == NULL) { + iRCCE_irecv_queue[help_request->source] = help_request; + } + else { + iRCCE_RECV_REQUEST *run = iRCCE_irecv_queue[help_request->source]; + while(run->next != NULL) run = run->next; + run->next = help_request; + } + } + } + + } int i, j; int retval = iRCCE_SUCCESS; @@ -310,7 +475,7 @@ int iRCCE_irecv_push(void) { } } - return retval; + return (iRCCE_irecv_any_source_queue == NULL)? retval : iRCCE_RESERVED; } //-------------------------------------------------------------------------------------- @@ -352,6 +517,24 @@ int iRCCE_irecv_cancel(iRCCE_RECV_REQUEST *request, int *test) { return iRCCE_NOT_ENQUEUED; } + + // does request have any source specified? + if( request->source == iRCCE_ANY_SOURCE ) { + for( run = iRCCE_irecv_any_source_queue; run->next != NULL; run = run->next ) { + if( run->next == request ) { + run->next = run->next->next; + + if (test) (*test) = 1; + return iRCCE_SUCCESS; + } + } + + if (test) (*test) = 0; + return iRCCE_NOT_ENQUEUED; + } + + + source = request->source; if(iRCCE_irecv_queue[source] == NULL) { diff --git a/arch/x86/scc/iRCCE_isend.c b/arch/x86/scc/iRCCE_isend.c index 18c9dca0..042de0ce 100644 --- a/arch/x86/scc/iRCCE_isend.c +++ b/arch/x86/scc/iRCCE_isend.c @@ -1,12 +1,12 @@ -//*************************************************************************************** +//****************************************************************************** // Non-blocking send routines. -//*************************************************************************************** +//****************************************************************************** // // Author: Rob F. Van der Wijngaart // Intel Corporation // Date: 008/30/2010 // -//*************************************************************************************** +//****************************************************************************** // // Copyright 2010 Intel Corporation // @@ -34,6 +34,8 @@ // [2010-12-09] added cancel functions for non-blocking send/recv requests // by Carsten Clauss // +// [2011-06-29] added the support of using IPIs +// by Simon Pickartz, Stefan Lankes #include #include @@ -41,6 +43,8 @@ #ifdef CONFIG_ROCKCREEK #include +#include +#include static int iRCCE_push_send_request(iRCCE_SEND_REQUEST *request) { @@ -158,56 +162,121 @@ static void iRCCE_init_send_request( } //-------------------------------------------------------------------------------------- -// FUNCTION: iRCCE_isend +// FUNCTION: iRCCE_isend_general //-------------------------------------------------------------------------------------- // non-blocking send function; returns a handle of type iRCCE_SEND_REQUEST //-------------------------------------------------------------------------------------- static iRCCE_SEND_REQUEST blocking_isend_request; -int iRCCE_isend(char *privbuf, size_t size, int dest, iRCCE_SEND_REQUEST *request) { +static int iRCCE_isend_general(char *privbuf, size_t size, int dest, iRCCE_SEND_REQUEST *request) { - if(request == NULL) request = &blocking_isend_request; - if (dest<0 || dest >= RCCE_NP) - return(RCCE_error_return(RCCE_debug_comm,RCCE_ERROR_ID)); - else { - iRCCE_init_send_request(privbuf, RCCE_buff_ptr, RCCE_chunk, - &RCCE_ready_flag[dest], &RCCE_sent_flag[RCCE_IAM], - size, dest, request); - if(iRCCE_isend_queue == NULL) { + iRCCE_init_send_request(privbuf, RCCE_buff_ptr, RCCE_chunk, + &RCCE_ready_flag[dest], &RCCE_sent_flag[RCCE_IAM], + size, dest, request); - if(iRCCE_push_send_request(request) == iRCCE_SUCCESS) { - return(iRCCE_SUCCESS); - } - else { - iRCCE_isend_queue = request; + if(iRCCE_isend_queue == NULL) { - if(request == &blocking_isend_request) { - iRCCE_isend_wait(request); - return(iRCCE_SUCCESS); - } - - return(iRCCE_PENDING); - } + if(iRCCE_push_send_request(request) == iRCCE_SUCCESS) { + return(iRCCE_SUCCESS); } else { - if(iRCCE_isend_queue->next == NULL) { - iRCCE_isend_queue->next = request; - } - else { - iRCCE_SEND_REQUEST *run = iRCCE_isend_queue; - while(run->next != NULL) run = run->next; - run->next = request; - } + iRCCE_isend_queue = request; if(request == &blocking_isend_request) { iRCCE_isend_wait(request); return(iRCCE_SUCCESS); } - return(iRCCE_RESERVED); + return(iRCCE_PENDING); } } + else { + if(iRCCE_isend_queue->next == NULL) { + iRCCE_isend_queue->next = request; + } + else { + iRCCE_SEND_REQUEST *run = iRCCE_isend_queue; + while(run->next != NULL) run = run->next; + run->next = request; + } + + if(request == &blocking_isend_request) { + iRCCE_isend_wait(request); + return(iRCCE_SUCCESS); + } + + return(iRCCE_RESERVED); + } +} + +//------------------------------------------------------------------------------ +// FUNCTION: iRCCE_isend +//------------------------------------------------------------------------------ +// wrapper function to differentiate between anylength and normal call +//------------------------------------------------------------------------------ +static iRCCE_SEND_REQUEST blocking_isend_request; +int iRCCE_isend( + char *privbuf, + ssize_t size, + int dest, + iRCCE_SEND_REQUEST *request + ) { + if(request == NULL) request = &blocking_isend_request; + + if (dest<0 || dest >= RCCE_NP) { + return(RCCE_error_return(RCCE_debug_comm,RCCE_ERROR_ID)); + } + else { + // anylength call + if( size < 0 ){ + // convert size to positive range */ + int send_size = -size; + + // use header payload + if( send_size <= iRCCE_MAIL_HEADER_PAYLOAD ) { + iRCCE_init_send_request(privbuf, RCCE_buff_ptr, + RCCE_chunk, &RCCE_ready_flag[dest], + &RCCE_sent_flag[RCCE_IAM], + send_size, dest, request); + request->finished = 1; + + iRCCE_mail_send( send_size, + iRCCE_ANYLENGTH_PIGGYBACK, + 0, privbuf, dest ); + NOP8; + NOP8; + icc_send_irq( dest ); + return iRCCE_SUCCESS; + } + // we need an extra isend-call + else { + iRCCE_mail_send( send_size, iRCCE_ANYLENGTH, + 0, NULL, dest ); + NOP8; + NOP8; + icc_send_irq( dest ); + return iRCCE_isend_general( privbuf, send_size, + dest, request ); + } + } + // normal call + else if( size > 0 ) { + return iRCCE_isend_general( privbuf, size, + dest, request ); + } + // do nothing + else { + iRCCE_init_send_request(privbuf, RCCE_buff_ptr, + RCCE_chunk, &RCCE_ready_flag[dest], + &RCCE_sent_flag[RCCE_IAM], + size, dest, request); + request->finished = 1; + return(iRCCE_SUCCESS); + } + + } + } //-------------------------------------------------------------------------------------- diff --git a/arch/x86/scc/iRCCE_mailbox.c b/arch/x86/scc/iRCCE_mailbox.c new file mode 100644 index 00000000..257a12c9 --- /dev/null +++ b/arch/x86/scc/iRCCE_mailbox.c @@ -0,0 +1,482 @@ +/* + * Copyright 2011 Simon Pickartz, Chair for Operating Systems, + * RWTH Aachen University + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of MetalSVM. + */ + +/* + * Mailbox system + * + * [2011-05-08] implemented mailbox send/recv routines + * by Simon Pickartz, Chair for Operating Systems, + * RWTH Aachen University + */ + +#include +#include + +#ifdef CONFIG_ROCKCREEK +#include + +/** + * + * @file contains implementation of the mailbox system + * @author Simon Pickartz + * + * + */ + + +// forward declaration +static int iRCCE_mailbox_close_one(int rank, int check); + +//------------------------------------------------------------------------------ +// FUNCTION: iRCCE_mailbox_print_header +//------------------------------------------------------------------------------ +// routine for printing given header (debugging purpose) +//------------------------------------------------------------------------------ +/** + * @brief routine for printing a given header + * @param header is a pointer to a given iRCCE_MAIL_HEADER structure +*/ + +void iRCCE_mailbox_print_header(iRCCE_MAIL_HEADER* header) { + + kprintf( "\n" + "-------------------------\n" + "| RCK%d\n" + "-------------------------\n" + "| Sender\t: %d\t\n" + "| Size\t\t: %d\t\n" + "| Tag\t\t: %d\t\n" + "| Prio\t\t: %d\t\n" + "| Payload\t: %s\n" + "-------------------------\n\n", + RCCE_IAM, header->source, + header->size, header->tag, + header->prio, header->payload); +} + +//------------------------------------------------------------------------------ +// FUNCTION: iRCCE_mail_fetch +//------------------------------------------------------------------------------ +/** + * @brief routine to check for new mail in a given mailbox + * @param rank is the ID of the ranks mailbox to be emptied + * + * The function checks if the mailbox has new mail for a given rank. In case of + * new mail it needs memory for the received header. Either there is memory + * in the internal garbage collection or it has to allocated. The next step is + * to check wheter a last-mail was received or a normal one. A last-mail is + * indicated by the iRCCE_LAST_MAIL tag. A last-mail entails the appropriate + * flag in the iRCCE_last_mail array to be set. Otherwise the header has to be + * enqueued in the mailbox_recv_queue accordingly to the priority field. + */ +//------------------------------------------------------------------------------ +static int iRCCE_mail_fetch( + int rank // rank from whom to empty mailbox + ) { + + iRCCE_MAIL_HEADER* header; + + // check for memory in garbage collection or allocate new + if( iRCCE_mail_garbage.first ) { + header = iRCCE_mail_garbage.first; + iRCCE_mail_garbage.first = + iRCCE_mail_garbage.first->next; + + header->next = NULL; + if( iRCCE_mail_garbage.first == NULL ) { + iRCCE_mail_garbage.last = NULL; + } + } + else { + header = (iRCCE_MAIL_HEADER*)kmalloc(sizeof(iRCCE_MAIL_HEADER)); + } + + + // copy header to allocated memory + RC_cache_invalidate(); + iRCCE_memcpy_get( (void*)header, (void*)iRCCE_mailbox_recv[rank], + RCCE_LINE_SIZE ); + + // check if received a last-mail + if( header->tag == iRCCE_LAST_MAIL ) { + iRCCE_last_mail[rank] = 1; + iRCCE_mailbox_close_one( rank, 0 ); // we can close respective mailbox + iRCCE_mail_release( &header ); + } + else { + // check mail priority + int prio = header->prio; + + // enqueue accordingly + if( iRCCE_mailbox_recv_queue[prio] == NULL ) { + iRCCE_mailbox_recv_queue[prio] = header; + } + else { + iRCCE_MAIL_HEADER* run = iRCCE_mailbox_recv_queue[prio]; + while( run->next != NULL ) run = run->next; + run->next = header; + } + } + + + return iRCCE_SUCCESS; +} + + +//------------------------------------------------------------------------------ +// FUNCTION: iRCCE_mailbox_check +//------------------------------------------------------------------------------ +/** + * @brief routine to check for new mail in mailboxes + * + * This function has to be called from time to time. It empties all mailboxes of + * the participating cores if the corresponding sent-flag is set and the mailbox + * is not closed. After calling iRCCE_mail_fetch the sent-flag has to be reset. + * Here we have to use a little trick because we can only write to the MPB in + * cacheline granularity. We set the appropriate flag to zero and afterwords + * touch the MPB on another cacheline. That causes the write combine buffer to + * write out the data. + */ +//------------------------------------------------------------------------------ +static int iRCCE_mailbox_check() { + int i; + + for( i=0; isent ) { + iRCCE_mail_fetch(i); + + // reset senders flag + RC_cache_invalidate(); + iRCCE_mailbox_recv[i]->sent = RCCE_FLAG_UNSET; + *(int *)RCCE_fool_write_combine_buffer = 1; + } + } + } + + return iRCCE_SUCCESS; +} + +//------------------------------------------------------------------------------ +// FUNCTION: iRCCE_mail_recv +//------------------------------------------------------------------------------ +/** + * @brief routine for fetching received headers out of iRCCE_mailbox_recv_queue + * @param header is the address of a pointer to an iRCCE_MAIL_HEADER structure + * @return iRCCE_SUCCESS if there was new mail; iRCCE_MAILBOX_EMPTY else + * @todo implement fairer dequeue mechanism + * + * The function checks if the receive queue with highest priority (priority 0) + * contains any mail headers. In this case we pop the first element of that list + * in a FIFO maner. Otherwise iRCCE_mailbox_check() has to be called. Afterwards + * the first element of a non-empty receive queue with highest priority is + * returned. + */ +//------------------------------------------------------------------------------ +int iRCCE_mail_recv( + iRCCE_MAIL_HEADER** header // pointer to incoming header + ) { // (memory allocated by iRCCE) + + int i; + + // if there is no mail, check for incoming + if ( !iRCCE_mailbox_recv_queue[0] ) { + iRCCE_mailbox_check(); + } + + // check priority queues + for( i=0; inext; + help_header->next = NULL; + + *header = help_header; + return iRCCE_SUCCESS; + } + } + + // no mail queued + *header = NULL; + return iRCCE_MAILBOX_EMPTY; + +} + +//------------------------------------------------------------------------------ +// FUNCTION: iRCCE_mail_release +//------------------------------------------------------------------------------ +/** + * @brief routine to store released header by user in garbage collection + * @param header is the address of a pointer to an iRCCE_MAIL_HEADER structure + * @return iRCCE_SUCCESS in any case + * + * This function enqueus a pointer to memory for an iRCCE_MAIL_HEADER structure + * that is not used by the user program anymore. 'header' points to NULL by + * return of the function. + */ +//------------------------------------------------------------------------------ +int iRCCE_mail_release( + iRCCE_MAIL_HEADER** header + ) { + // put header in garbage collection + if( (iRCCE_mail_garbage.first == NULL) + && (iRCCE_mail_garbage.last == NULL ) ) { + + iRCCE_mail_garbage.first = *header; + iRCCE_mail_garbage.last = *header; + } + else { + iRCCE_mail_garbage.last->next = *header; + iRCCE_mail_garbage.last = *header; + } + iRCCE_mail_garbage.last->next = NULL; + + // reset header + *header = NULL; + return iRCCE_SUCCESS; +} + +//------------------------------------------------------------------------------ +// FUNCTION: iRCCE_mail_send +//------------------------------------------------------------------------------ +/** + * @brief routine to send a mail to a given destination (blocking) + * @param size is the size of the following message. This message may be + * contained in the payload or send by an isend()-call + * @param tag is an integer value to distinguish between different mail types + * @param prio indicates the priority of the mail. 0 is the highest priority + * whereas 4 is the lowest. + * @param payload is a pointer to byte array with a size of + * iRCCE_MAIL_HEADER_PAYLOAD. If NULL is passed nothing is done, otherwise array + * pointed by payload is copied into the header. + * @param dest indicates the destination of the mail in terms of the ID of + * one of the participating ranks + * @return iRCCE_SUCCESS if send was successful. If target mailbox is closed + * iRCCE_MAILBOX_CLOESD is returned. + * + * First it has to be checked if the target mailbox still contains an unread mail. + * If this is the case there is time to empty the own mailboxes. It blocks until + * the receiver has emptied its mailbox. The next step is to acquire the lock + * for the target mailbox to be sure that the mailbox is not closed by the + * receiver while the mail is delivered. After locking the mailbox an + * iRCCE_MAIL_HEADER is generated according with the parameters (but with a + * sent-flag set to zero)and is copied into the target mailbox. After all data + * beeing written the appropropriate sent-flag has to be set with the same trick + * already used in iRCCE_mail_check(). Now the lock can be released. + */ +//------------------------------------------------------------------------------ +int iRCCE_mail_send( + size_t size, // size of following message expected to be send/received + int tag, // tag to indicate message type + char prio, // mail priority + char* payload, // pointer to buffer for header payload + int dest // UE that will receive the header + ) { + + // if dest mailbox is full, check for incoming mail + RC_cache_invalidate(); + while( iRCCE_mailbox_send[dest]->sent ) { + iRCCE_mailbox_check(); + RC_cache_invalidate(); + } + + // check if mailbox is closed + RCCE_acquire_lock( dest ); + RC_cache_invalidate(); + if( iRCCE_mailbox_send[dest]->closed ) { + RCCE_release_lock( dest ); + return iRCCE_MAILBOX_CLOSED; + } + + // prepare header + iRCCE_MAIL_HEADER header = { RCCE_IAM, size, tag, NULL, prio, + RCCE_FLAG_UNSET, RCCE_FLAG_UNSET, + {[0 ... iRCCE_MAIL_HEADER_PAYLOAD-1] = 0} }; + + // payload within the header? + if( payload ) { + memcpy( header.payload, payload, iRCCE_MAIL_HEADER_PAYLOAD ); + } + + // do the actual copy to MPB + RC_cache_invalidate(); + iRCCE_memcpy_put( (void*)iRCCE_mailbox_send[dest], + (void*)&header, RCCE_LINE_SIZE ); + + // set senders flag + RC_cache_invalidate(); + iRCCE_mailbox_send[dest]->sent = RCCE_FLAG_SET; + *(int *)RCCE_fool_write_combine_buffer = 1; + RC_cache_invalidate(); + + RCCE_release_lock( dest ); + + return iRCCE_SUCCESS; +} + +//------------------------------------------------------------------------------ +// FUNCTION: iRCCE_last_mail_recv +//------------------------------------------------------------------------------ +/** + * @brief check if all final headers are received from all UEs + * @return iRCCE_SUCCES if all last-mails arrive iRCCE_LAST_MAILS_NOT_RECV + * otherwise + * + * This functions is used to determine if all last-mails arrived at the calling + * UE. Therefore it checks the iRCCE_last_mail array if all flags are set. + */ +//------------------------------------------------------------------------------ +int iRCCE_last_mail_recv(void) { + int i; + int res = iRCCE_SUCCESS; + + for( i=0; inext; + kfree( erase_header, sizeof(iRCCE_MAIL_HEADER) ); + erase_header = iRCCE_mailbox_recv_queue[i]; + } + } + return iRCCE_SUCCESS; +} + +//------------------------------------------------------------------------------ +// FUNCTION: iRCCE_mailbox_close_one +//------------------------------------------------------------------------------ +/** + * @brief routine to close one mailbox + * @return iRCCE_SUCCESS + * @param rank is the ID of the ranks mailbox to be closed + * @param check is a flag indicating wether the mailbox has to be emptied before + * closing or not. This is required for a close-call as a result of a received + * last-mail. + * + * This function closes a mailbox of the given rank. If the check flag is set + * an iRCCE_mail_check()-call is performed. The close procedure has to be locked + * to be sure that no UE sends any mail while closing the mailbox. + */ +//------------------------------------------------------------------------------ +static int iRCCE_mailbox_close_one(int rank, int check) { + RCCE_acquire_lock( RCCE_IAM ); + + // check if it contains new mail + RC_cache_invalidate(); + if( check && iRCCE_mailbox_recv[rank]->sent ) { + iRCCE_mail_fetch(rank); + + } + + // close mailbox + iRCCE_MAIL_HEADER help_header = { 0, 0, 0, NULL, 0, RCCE_FLAG_UNSET, + RCCE_FLAG_SET, {[0 ... iRCCE_MAIL_HEADER_PAYLOAD-1] = 0} }; + + RC_cache_invalidate(); + iRCCE_memcpy_put( (void*)iRCCE_mailbox_recv[rank], + &help_header, RCCE_LINE_SIZE ); + + RCCE_release_lock( RCCE_IAM ); + + iRCCE_mailbox_status[rank] = iRCCE_MAILBOX_CLOSED; + + return iRCCE_SUCCESS; +} + + +//------------------------------------------------------------------------------ +// FUNCTION: iRCCE_mailbox_close() +//------------------------------------------------------------------------------ +/** + * @brief routine to close one or all mailboxes + * @param rank is the ID of the UEs mailbox to be closed if iRCCE_MAILBOX_ALL + * is passed all mailboxes are closed by the calling UE + * @return iRCCE_SUCCESS + * + * This functions closed one or all mailboxes of the calling UE. This is done by + * calling iRCCE_mailbox_close_one for one or all mailboxes. + */ +//------------------------------------------------------------------------------ +int iRCCE_mailbox_close(int rank) { + if( rank == iRCCE_MAILBOX_ALL ) { + int i; + for( i=0; i= RCCE_NP) return(RCCE_error_return(RCCE_debug_comm,RCCE_ERROR_ID)); else { diff --git a/arch/x86/scc/icc.c b/arch/x86/scc/icc.c index 9845754d..75bfdc78 100644 --- a/arch/x86/scc/icc.c +++ b/arch/x86/scc/icc.c @@ -82,7 +82,9 @@ static void intr_handler(struct state *s) // reset appropriate bit in the core configuration register int tmp, z; +#ifdef CONFIG_LWIP mmnif_irqhandler(); +#endif z = Z_PID(RC_COREID[my_ue]); tmp=ReadConfigReg(CRB_OWN + (z==0 ? GLCFG0 : GLCFG1)); @@ -172,7 +174,7 @@ int icc_init(void) return 0; } -inline int icc_send_irq(int ue) +int icc_send_irq(int ue) { int tmp, x, y, z, addr; @@ -195,123 +197,103 @@ inline int icc_send_irq(int ue) int icc_halt(void) { uint32_t flags; +#if 0 uint32_t do_send = 1; do { // iRCCE is not thread save => disable interrupts flags = irq_nested_disable(); - if (do_send) + if (do_send) { do_send = (iRCCE_isend_push() == iRCCE_PENDING); - icc_check(); + iRCCE_irecv_push(); + } + icc_mail_check(); irq_nested_enable(flags); - } while(do_send); - HALT; + NOP1; + } while(do_send); +#else + // iRCCE is not thread save => disable interrupts + flags = irq_nested_disable(); + icc_mail_check(); + irq_nested_enable(flags); + NOP1; +#endif + //HALT; return 0; } -static volatile uint64_t ping_start = 0; -static icc_header_t ping_request = {ICC_TYPE_PINGREQUEST, 0, 0}; -static icc_header_t ping_response = {ICC_TYPE_PINGRESPONSE, 0, 0}; - -int icc_ping(int ue) -{ +int icc_mail_ping( void ) +{ uint32_t flags; + int remote_rank = (my_ue+1)%2; + uint8_t payload[iRCCE_MAIL_HEADER_PAYLOAD]; + uint64_t* timer = (uint64_t*) payload; - if (BUILTIN_EXPECT(ue == my_ue, 0)) - return -EINVAL; - if (BUILTIN_EXPECT((ue < 0) || (ue >= num_ues), 0)) - return -EINVAL; - - while(ping_start) { - NOP8; - } - - ping_start = rdtsc(); - - // iRCCE is not thread save => disable interrupts + if (my_ue) + return -1; + + kprintf( "Hello from mail_ping ... \n" ); + + // disable interrupts flags = irq_nested_disable(); - iRCCE_isend((char*) &ping_request, sizeof(icc_header_t), ue, NULL); + // start timer + *timer = rdtsc(); + + /* send ping request */ + iRCCE_mail_send(sizeof(uint64_t), ICC_TAG_PINGREQUEST, 0, payload, remote_rank); - // wait some time NOP8; + icc_send_irq(remote_rank); - // wake up receiver - icc_send_irq(ue); + /* check for incoming messages */ + icc_mail_check(); + // enable interrupts irq_nested_enable(flags); return 0; } -static void interpret_header(icc_header_t* header, int recv_ue) +void icc_mail_check(void) { - //kprintf("Got ICC message %d from %d\n", header->type, recv_ue); + iRCCE_MAIL_HEADER* header = NULL; + int res; + uint64_t timer; + //char* recv_buffer; - switch(header->type) - { - case ICC_TYPE_PINGREQUEST: { - - iRCCE_isend((char*) &ping_response, sizeof(icc_header_t), recv_ue, NULL); - - // wait some time + // empty mailbox and interpret headers + while( (res = iRCCE_mail_recv( &header )) == iRCCE_SUCCESS ) { + switch(header->tag) + { + case ICC_TAG_PINGREQUEST: + iRCCE_mail_send( header->size, ICC_TAG_PINGRESPONSE, 0, header->payload, header->source ); NOP8; - - // wake up remote core - icc_send_irq(recv_ue); + icc_send_irq( header->source ); + break; + case ICC_TAG_PINGRESPONSE: + timer = rdtsc() - *((uint64_t*) header->payload); + kprintf( "Response received in %d ticks!\n", timer ); + break; + default: + kprintf("Invalid mail: tag = %d\n", header->tag); + break; + } + /*else if( header->tag == iRCCE_ANYLENGTH ) { + recv_buffer = (char*)kmalloc( header->size ); + iRCCE_irecv( recv_buffer, header->size, header->source, NULL ); + iRCCE_mail_send( 0, 2, 0, NULL, header->source ); } - break; - case ICC_TYPE_PINGRESPONSE: - kprintf("Receive ping response. Ticks: %d\n", rdtsc()-ping_start); - ping_start = 0; - break; - default: - kprintf("Receive unknown ICC message (%d)\n", header->type); + else if( header->tag == iRCCE_ANYLENGTH_PIGGYBACK ) { + iRCCE_mail_send( 0, 2, 0, NULL, header->source ); + }*/ + + iRCCE_mail_release( &header ); } } -/* - * By entering this function, interrupts are already disables - * => No race by using the static variables - */ -void icc_check(void) -{ - static icc_header_t header[MAX_SCC_CORES]; - static iRCCE_RECV_REQUEST request[MAX_SCC_CORES]; - static int8_t first_call = 1; - int i, ret; - - if (first_call) { - first_call = 0; - - for(i=0; ipayload; + + switch (htons(ethhdr->type)) { + /* IP or ARP packet? */ + case ETHTYPE_ARP: + case ETHTYPE_IP: +#if PPPOE_SUPPORT + /* PPPoE packet? */ + case ETHTYPE_PPPOEDISC: + case ETHTYPE_PPPOE: +#endif /* PPPOE_SUPPORT */ + /* full packet send to tcpip_thread to process */ + if (mynetif->input(p, mynetif) != ERR_OK) { + LWIP_DEBUGF(NETIF_DEBUG, ("rtl8139if_input: IP input error\n")); + pbuf_free(p); + } + break; + default: + pbuf_free(p); + break; + } +} + static void rckemacif_rx_handler(struct netif* netif, unsigned int write_offset) { rckemacif_t* rckemacif = netif->state; @@ -372,7 +400,7 @@ out: #if ETH_PAD_SIZE pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */ #endif - mailbox_ptr_post(&rckemacif->mbox, (void*)p); + rckemacif_input(netif, p); LINK_STATS_INC(link.recv); } else { LWIP_DEBUGF(NETIF_DEBUG, ("rckemacif_rx_inthandler: not enough memory!\n")); @@ -422,48 +450,6 @@ nexttry: *((volatile unsigned*) (FPGA_BASE + IRQ_RESET + rckemacif->core * 2 * 4)) = (1 << rckemacif->num_emac); } -err_t rckemacif_wait(struct netif* netif, uint32_t poll) -{ - rckemacif_t* rckemacif = netif->state; - struct eth_hdr *ethhdr; - struct pbuf *p = NULL; - err_t err = ERR_OK; - - if (poll) { - if (mailbox_ptr_tryfetch(&(rckemacif->mbox), (void**) &p)) - return err; - } else { - mailbox_ptr_fetch(&(rckemacif->mbox), (void**) &p); - } - - /* points to packet payload, which starts with an Ethernet header */ - ethhdr = p->payload; - - //LWIP_DEBUGF(NETIF_DEBUG, ("Got packet of type 0x%x!\n", htons(ethhdr->type))); - - switch (htons(ethhdr->type)) { - /* IP or ARP packet? */ - case ETHTYPE_ARP: - case ETHTYPE_IP: -#if PPPOE_SUPPORT - /* PPPoE packet? */ - case ETHTYPE_PPPOEDISC: - case ETHTYPE_PPPOE: -#endif /* PPPOE_SUPPORT */ - /* full packet send to tcpip_thread to process */ - if ((err = mynetif->input(p, mynetif)) != ERR_OK) { - LWIP_DEBUGF(NETIF_DEBUG, ("rckemacif_poll: IP input error\n")); - pbuf_free(p); - } - break; - default: - pbuf_free(p); - break; - } - - return err; -} - err_t rckemacif_init(struct netif* netif) { rckemacif_t* rckemacif; @@ -516,8 +502,6 @@ err_t rckemacif_init(struct netif* netif) memset(rckemacif->tx_buffer, 0x00, 0x20); memset(rckemacif->tx_buffer + 0x20, 0xDA, BUFFER_SIZE - 0x20); rckemacif->tx_buffer_max = CLINE_PACKETS(BUFFER_SIZE) - 1; - - mailbox_ptr_init(&rckemacif->mbox); netif->state = rckemacif; /* Depending on core location read own private data diff --git a/drivers/net/rckemac.h b/drivers/net/rckemac.h index 2c53523f..2796f14d 100644 --- a/drivers/net/rckemac.h +++ b/drivers/net/rckemac.h @@ -21,7 +21,6 @@ #define __HAVE_RCKEMAC_H__ #include -#include #if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK) @@ -40,17 +39,8 @@ typedef struct rckemacif { void* irq_address; uint32_t core; uint32_t num_emac; - mailbox_ptr_t mbox; } rckemacif_t; -/* - * Wait for incoming messages. - * - * poll = 0 : wait blocks until a message is received - * poll != 0: non-blocking wait - */ -err_t rckemacif_wait(struct netif* netif, uint32_t poll); - /* * Initialize the eMAC network driver */ diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c index 4fbf150a..1afc6a10 100644 --- a/drivers/net/rtl8139.c +++ b/drivers/net/rtl8139.c @@ -110,8 +110,7 @@ static err_t rtl8139if_output(struct netif* netif, struct pbuf* p) return ERR_OK; } -#if 0 -void rtl8139if_input(struct netif* netif, struct pbuf* p) +static void rtl8139if_input(struct netif* netif, struct pbuf* p) { struct eth_hdr *ethhdr; @@ -138,7 +137,6 @@ void rtl8139if_input(struct netif* netif, struct pbuf* p) break; } } -#endif static void rtl_rx_inthandler(struct netif* netif) { @@ -175,8 +173,7 @@ static void rtl_rx_inthandler(struct netif* netif) #if ETH_PAD_SIZE pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */ #endif - mailbox_ptr_post(&rtl8139if->mbox, (void*)p); - //rtl8139if_input(netif, p); + rtl8139if_input(netif, p); LINK_STATS_INC(link.recv); } else { LWIP_DEBUGF(NETIF_DEBUG, ("rtl8139if_rx_inthandler: not enough memory!\n")); @@ -237,7 +234,7 @@ static void rtl8139if_handler(struct state* s) uint16_t isr_contents; while (1) { - isr_contents = inportw(rtl8139if->iobase + ISR); + isr_contents = inportw(rtl8139if->iobase + ISR); if (isr_contents == 0) break; @@ -268,46 +265,6 @@ static void rtl8139if_handler(struct state* s) } } -err_t rtl8139if_wait(struct netif* netif, uint32_t poll) -{ - rtl1839if_t* rtl8139if = netif->state; - struct eth_hdr *ethhdr; - struct pbuf *p = NULL; - err_t err = ERR_OK; - - if (poll) { - if (mailbox_ptr_tryfetch(&(rtl8139if->mbox), (void**) &p)) - return err; - } else { - mailbox_ptr_fetch(&(rtl8139if->mbox), (void**) &p); - } - - /* points to packet payload, which starts with an Ethernet header */ - ethhdr = p->payload; - - switch (htons(ethhdr->type)) { - /* IP or ARP packet? */ - case ETHTYPE_ARP: - case ETHTYPE_IP: -#if PPPOE_SUPPORT - /* PPPoE packet? */ - case ETHTYPE_PPPOEDISC: - case ETHTYPE_PPPOE: -#endif /* PPPOE_SUPPORT */ - /* full packet send to tcpip_thread to process */ - if ((err = mynetif->input(p, mynetif)) != ERR_OK) { - LWIP_DEBUGF(NETIF_DEBUG, ("rtl8139if_poll: IP input error\n")); - pbuf_free(p); - } - break; - default: - pbuf_free(p); - break; - } - - return err; -} - err_t rtl8139if_init(struct netif* netif) { rtl1839if_t* rtl8139if; @@ -348,7 +305,6 @@ err_t rtl8139if_init(struct netif* netif) rtl8139if->tx_buffer[2] = rtl8139if->tx_buffer[1] + 4096; rtl8139if->tx_buffer[3] = rtl8139if->tx_buffer[2] + 4096; - mailbox_ptr_init(&rtl8139if->mbox); netif->state = rtl8139if; mynetif = netif; @@ -398,7 +354,7 @@ err_t rtl8139if_init(struct netif* netif) } if (!tmp16) { - // it seems not to work + // it seems not to work kprintf("RTL8139 reset failed\n"); return ERR_ARG; } @@ -416,7 +372,7 @@ err_t rtl8139if_init(struct netif* netif) outportb(rtl8139if->iobase + CONFIG1, (inportb(rtl8139if->iobase + CONFIG1) & ~(CONFIG1_DVRLOAD | CONFIG1_LWACT)) | CONFIG1_DVRLOAD); - // unlock config register + // unlock config register outportb(rtl8139if->iobase + CR9346, 0); /* diff --git a/drivers/net/rtl8139.h b/drivers/net/rtl8139.h index 43bd6fe4..962f5232 100644 --- a/drivers/net/rtl8139.h +++ b/drivers/net/rtl8139.h @@ -23,7 +23,8 @@ #define __HAVE_RTL8139_H__ #include -#include +#include + #if defined(CONFIG_LWIP) && defined(CONFIG_PCI) // the registers are at the following places @@ -226,17 +227,8 @@ typedef struct rtl1839if { uint32_t tx_complete; uint16_t rx_pos; uint8_t tx_inuse[4]; - mailbox_ptr_t mbox; } rtl1839if_t; -/* - * Wait for incoming messages. - * - * poll = 0 : wait blocks until a message is received - * poll != 0: non-blocking wait - */ -err_t rtl8139if_wait(struct netif* netif, uint32_t poll); - /* * Initialize the network driver for the RealTek RTL8139 family */ diff --git a/drivers/net/util.c b/drivers/net/util.c index 6a56716f..cf06fdd6 100644 --- a/drivers/net/util.c +++ b/drivers/net/util.c @@ -1,3 +1,22 @@ +/* + * Copyright 2011 Carl-Benedikt Krueger, Chair for Operating Systems, + * RWTH Aachen University + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of MetalSVM. + */ + #include "util.h" @@ -10,7 +29,8 @@ __inline int isprint(char e) // hex_dumb display network packets in a good way void hex_dump(unsigned n, const unsigned char* buf) { -int on_this_line = 0; + int on_this_line = 0; + while (n-- > 0) { kprintf("%02X ", *buf++); diff --git a/drivers/net/util.h b/drivers/net/util.h index 610f78f5..f35b7428 100644 --- a/drivers/net/util.h +++ b/drivers/net/util.h @@ -1,9 +1,26 @@ +/* + * Copyright 2011 Carl-Benedikt Krueger, Chair for Operating Systems, + * RWTH Aachen University + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is part of MetalSVM. + */ + #ifndef __UTIL__ #define __UTIL__ - // hex_dumb display network packets in a good way void hex_dump(unsigned n, const unsigned char* buf); - -#endif \ No newline at end of file +#endif diff --git a/include/metalsvm/config.h.example b/include/metalsvm/config.h.example index f5b35948..bd4c0b73 100644 --- a/include/metalsvm/config.h.example +++ b/include/metalsvm/config.h.example @@ -26,7 +26,7 @@ extern "C" { #define METALSVM_VERSION "0.1" #define MAX_TASKS 16 -#define MAX_CORES 4 +#define MAX_CORES 1 #define MAX_FNAME 128 #define DEFAULT_STACK_SIZE (32*1024) #define KERNEL_STACK_SIZE 8192 @@ -40,6 +40,7 @@ extern "C" { #define INT_SYSCALL 0x80 #define KERNEL_SPACE (1*1024*1024*1024) #define VIDEO_MEM_ADDR 0xB8000 // the video memora address +#define SMP_SETUP_ADDR 0x07000 #define BYTE_ORDER LITTLE_ENDIAN @@ -52,6 +53,7 @@ extern "C" { #define CONFIG_PCI #define CONFIG_LWIP #define CONFIG_VGA +//#define CONFIG_UART #define CONFIG_KEYBOARD #define CONFIG_MULTIBOOT //#define CONFIG_ROCKCREEK @@ -63,11 +65,6 @@ extern "C" { #define SHMADD #define SHMDBG //#define SHMADD_CACHEABLE -/* default values for 16 GB system */ -#define PRIVATE_MEM1_START 0x00000000 -#define PRIVATE_MEM1_END 0x13FFFFFF -#define PRIVATE_MEM2_START 0xFF000000 -#define PRIVATE_MEM2_END 0xFFFFFFFF #define SCC_BOOTINFO 0x80000 #define BUILTIN_EXPECT(exp, b) __builtin_expect((exp), (b)) diff --git a/include/metalsvm/spinlock.h b/include/metalsvm/spinlock.h index 701762aa..50909bf8 100644 --- a/include/metalsvm/spinlock.h +++ b/include/metalsvm/spinlock.h @@ -81,11 +81,13 @@ inline static int spinlock_destroy(spinlock_t* s) { */ inline static int spinlock_lock(spinlock_t* s) { int32_t ticket; + task_t* curr_task; if (BUILTIN_EXPECT(!s, 0)) return -EINVAL; - if (s->owner == per_core(current_task)->id) { + curr_task = per_core(current_task); + if (s->owner == curr_task->id) { s->counter++; return 0; } @@ -94,7 +96,7 @@ inline static int spinlock_lock(spinlock_t* s) { while(atomic_int32_read(&s->dequeue) != ticket) { NOP1; } - s->owner = per_core(current_task)->id; + s->owner = curr_task->id; s->counter = 1; return 0; @@ -181,7 +183,7 @@ inline static int spinlock_irqsave_lock(spinlock_irqsave_t* s) { s->coreid = CORE_ID; s->flags = flags; s->counter = 1; - + return 0; } diff --git a/include/metalsvm/stddef.h b/include/metalsvm/stddef.h index 07d3ed27..725365e2 100644 --- a/include/metalsvm/stddef.h +++ b/include/metalsvm/stddef.h @@ -22,6 +22,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -35,15 +36,33 @@ typedef unsigned int tid_t; #define per_core(name) name #define DECLARE_PER_CORE(type, name) extern type name; #define DEFINE_PER_CORE(type, name, def_value) type name = def_value; +#define DEFINE_PER_CORE_STATIC(type, name, def_value) static type name = def_value; #define CORE_ID 0 #else -#define per_core(name) name[LOGICAL_CPUID].var +#define per_core(name) (*__get_percore_##name()) #define DECLARE_PER_CORE(type, name) \ typedef struct { type var __attribute__ ((aligned (CACHE_LINE))); } aligned_##name;\ - extern aligned_##name name[MAX_CORES]; + extern aligned_##name name[MAX_CORES];\ + inline static type* __get_percore_##name(void) {\ + type* ret; \ + uint32_t flags = irq_nested_disable(); \ + ret = &(name[smp_id()].var); \ + irq_nested_enable(flags);\ + return ret; \ + } #define DEFINE_PER_CORE(type, name, def_value) \ aligned_##name name[MAX_CORES] = {[0 ... MAX_CORES-1] = {def_value}}; -#define CORE_ID LOGICAL_CPUID +#define DEFINE_PER_CORE_STATIC(type, name, def_value) \ + typedef struct { type var __attribute__ ((aligned (CACHE_LINE))); } aligned_##name;\ + static aligned_##name name[MAX_CORES] = {[0 ... MAX_CORES-1] = {def_value}}; \ + inline static type* __get_percore_##name(void) {\ + type* ret; \ + uint32_t flags = irq_nested_disable(); \ + ret = &(name[smp_id()].var); \ + irq_nested_enable(flags);\ + return ret; \ + } +#define CORE_ID smp_id() #endif /* needed to find the task, which is currently running on this core */ diff --git a/include/metalsvm/syscall.h b/include/metalsvm/syscall.h index cc66bb76..b47fc284 100644 --- a/include/metalsvm/syscall.h +++ b/include/metalsvm/syscall.h @@ -51,18 +51,6 @@ extern "C" { #define __NR_execve 14 #define __NR_times 15 -/* networking - */ - -#define __NR_socket 16 -#define __NR_bind 17 -#define __NR_listen 18 -#define __NR_accept 19 -#define __NR_connect 20 -#define __NR_send 21 -#define __NR_recv 22 -#define __NR_closesocket 23 - #ifdef __cplusplus } #endif diff --git a/include/metalsvm/tasks.h b/include/metalsvm/tasks.h index 5329fc61..c4e68991 100644 --- a/include/metalsvm/tasks.h +++ b/include/metalsvm/tasks.h @@ -126,6 +126,16 @@ void NORETURN sys_exit(int); * */ int sys_fork(void); +/** @brief Reserve an idel task for an additional core + * + * @param id core number + * + * return + * - address of the stack (< KERNEL_SPACE) + * - -ENIVAL (-22) on failure + */ +size_t get_idle_task(uint32_t id); + /** @brief System call to execute a program * * @param fname Filename of the executable @@ -138,15 +148,19 @@ int sys_fork(void); */ int sys_execve(const char* fname, char** argv, char** env); +/** @brief Call to rescheduling + * + * This is a purely assembled procedure for rescheduling + */ +void reschedule(void); + static inline void check_workqueues(void) { - uint32_t flags = irq_nested_disable(); - #ifdef CONFIG_ROCKCREEK - icc_check(); -#endif - + uint32_t flags = irq_nested_disable(); + icc_mail_check(); irq_nested_enable(flags); +#endif } #ifdef __cplusplus diff --git a/include/metalsvm/tasks_types.h b/include/metalsvm/tasks_types.h index e607dc3c..9725454b 100644 --- a/include/metalsvm/tasks_types.h +++ b/include/metalsvm/tasks_types.h @@ -41,17 +41,18 @@ extern "C" { #endif #define TASK_INVALID 0 -#define TASK_READY 1 +#define TASK_READY 1 #define TASK_RUNNING 2 #define TASK_BLOCKED 3 #define TASK_FINISHED 4 -#define TASK_IDLE 5 +#define TASK_IDLE 5 -#define TASK_DEFAULT_FLAGS 0 -#define TASK_FPU_INIT (1 << 0) -#define TASK_FPU_USED (1 << 1) +#define TASK_DEFAULT_FLAGS 0 +#define TASK_FPU_INIT (1 << 0) +#define TASK_FPU_USED (1 << 1) -typedef int (STDCALL *entry_point_t)(void*); +typedef int (*entry_point_t)(void*); +typedef int (STDCALL *internal_entry_point_t)(void*); struct page_dir; /* @brief The task_t structure */ @@ -59,9 +60,9 @@ typedef struct task { /// Task id = position in the task table tid_t id; /// Task status (INVALID, READY, RUNNING, ...) - uint32_t status; + uint32_t status; /// Usage in number of pages - atomic_int32_t user_usage; + atomic_int32_t user_usage; /// Avoids concurrent access to the page directory spinlock_t pgd_lock; /// pointer to the page directory diff --git a/kernel/init.c b/kernel/init.c index bb9aef76..28301787 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -38,6 +39,7 @@ #endif #include #include +#include #ifdef CONFIG_ROCKCREEK #include #include @@ -46,8 +48,6 @@ void echo_init(void); void ping_init(void); -static volatile int done = 0; - /* * Note that linker symbols are not variables, they have no memory allocated for * maintaining a value, rather their address is their value. @@ -68,17 +68,42 @@ int lowlevel_init(void) } #if defined(CONFIG_LWIP) && (defined(CONFIG_PCI) || defined(CONFIG_ROCKCREEK)) -static tid_t netid; +static struct netif* default_netif = NULL; +static volatile uint32_t lwip_initialized = 0; -int STDCALL network_task(void* arg) +static void tcp_init_ok(void* e) { - struct netif netif; + kputs("TCP/IP init COMPLETE!!\n"); + lwip_initialized = 1; +} +#endif + +int network_init(void) +{ +#if defined(CONFIG_LWIP) && (defined(CONFIG_PCI) || defined(CONFIG_ROCKCREEK)) struct ip_addr ipaddr; struct ip_addr netmask; struct ip_addr gw; - kputs("Network task is started\n"); + kputs("Initialize network...\n"); + // Initialize lwIP modules + tcpip_init(tcp_init_ok, NULL); + + while(!lwip_initialized) { + reschedule(); + } + + // Set up the lwIP network interface + // Allocate and configure netif + default_netif = (struct netif *) mem_malloc(sizeof(struct netif)); + if(default_netif == NULL) + { + kprintf("ERROR: Out of memory for default netif\n"); + return -ENOMEM; + } + + memset(default_netif, 0x00, sizeof(struct netif)); #ifdef CONFIG_ROCKCREEK /* Set network address variables */ IP4_ADDR(&gw, 192,168,4,254); @@ -86,7 +111,7 @@ int STDCALL network_task(void* arg) IP4_ADDR(&netmask, 255,255,255,0); /* Bring up the network interface */ - if (!netif_add(&netif, &ipaddr, &netmask, &gw, NULL, rckemacif_init, ethernet_input)) { + if (!netif_add(default_netif, &ipaddr, &netmask, &gw, NULL, rckemacif_init, tcpip_input)) { #else /* Clear network address because we use DHCP to get an ip address */ IP4_ADDR(&gw, 0,0,0,0); @@ -94,75 +119,61 @@ int STDCALL network_task(void* arg) IP4_ADDR(&netmask, 0,0,0,0); /* Bring up the network interface */ - if (!netif_add(&netif, &ipaddr, &netmask, &gw, NULL, rtl8139if_init, ethernet_input)) { + if (!netif_add(default_netif, &ipaddr, &netmask, &gw, NULL, rtl8139if_init, tcpip_input)) { #endif kputs("Unable to add network interface\n"); - return -ENXIO; + return -ENODEV; } - netif_set_default(&netif); - netif_set_up(&netif); + netif_set_default(default_netif); + netif_set_up(default_netif); + + /* test if interface is really up */ + if (!netif_is_up(default_netif)) { + kputs("network interface is not up\n"); + return -ENODEV; + } #ifndef CONFIG_ROCKCREEK kprintf("Starting DHCPCD...\n"); - dhcp_start(&netif); + dhcp_start(default_netif); + int mscnt = 0; /* wait for ip address */ - while(!netif.ip_addr.addr) { - rtl8139if_wait(&netif, 1); - udelay(500000); + while(!default_netif->ip_addr.addr) { + sys_msleep(DHCP_FINE_TIMER_MSECS); + dhcp_fine_tmr(); + mscnt += DHCP_FINE_TIMER_MSECS; + if (mscnt >= DHCP_COARSE_TIMER_SECS*1000) { + dhcp_coarse_tmr(); + mscnt = 0; + } } +#else + //mmnif_open(); #endif // start echo and ping server echo_init(); - //ping_init(); - - while(!done) { -#ifdef CONFIG_PCI - rtl8139if_wait(&netif, 0); -#elif defined(CONFIG_ROCKCREEK) - rckemacif_wait(&netif, 0); -#endif - } - -#ifndef CONFIG_ROCKCREEK - dhcp_release(&netif); - dhcp_stop(&netif); + ping_init(); #endif return 0; } -#endif int network_shutdown(void) { - done = 1; +#if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK) + //mmnif_close(); +#elif defined(CONFIG_LWIP) && defined(CONFIG_PCI) + dhcp_release(default_netif); + dhcp_stop(default_netif); +#endif + + mem_free(default_netif); + default_netif = NULL; return 0; } -void tcp_init_ok(void* e) -{ - kprintf("TCP/IP init COMPLETE!!!!!!"); -} -int network_init(void) -{ - tcpip_init(tcp_init_ok,NULL); - kprintf("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - mmnif_open(); - kprintf("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); - // return 0; - -#if defined(CONFIG_LWIP) - // Initialize lwIP modules -// lwip_init(); -#endif - -#if defined(CONFIG_LWIP) && (defined(CONFIG_PCI) || defined(CONFIG_ROCKCREEK)) - return create_kernel_task(&netid, network_task, NULL); -#else - return 0; -#endif -} diff --git a/kernel/main.c b/kernel/main.c index 75fffb0c..86646610 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -78,6 +78,20 @@ static void list_root(void) { list_fs(fs_root, 1); } +#if MAX_CORES > 1 +// idle loop of the application processors +int smp_main(void) +{ + irq_enable(); + + while(1) { + HALT; + } + + return 0; +} +#endif + int main(void) { lowlevel_init(); @@ -86,7 +100,6 @@ int main(void) kprintf("This is MetalSVM %s Build %u, %u\n", METALSVM_VERSION, &__BUILD_DATE, &__BUILD_TIME); popbg(); - system_init(); irq_init(); timer_init(); @@ -103,7 +116,6 @@ int main(void) irq_enable(); kprintf("Kernel starts at %p and ends at %p\n", &kernel_start, &kernel_end); - system_calibration(); network_init(); @@ -112,10 +124,9 @@ int main(void) kprintf("Current allocated memory: %u KBytes\n", atomic_int32_read(&total_allocated_pages)*(PAGE_SIZE/1024)); kprintf("Current available memory: %u MBytes\n", atomic_int32_read(&total_available_pages)/((1024*1024)/PAGE_SIZE)); -// sleep(5); -// list_root(); + sleep(5); + list_root(); test_init(); - per_core(current_task)->status = TASK_IDLE; reschedule(); diff --git a/kernel/ping.c b/kernel/ping.c index 98398300..7d81500f 100644 --- a/kernel/ping.c +++ b/kernel/ping.c @@ -43,7 +43,7 @@ #include #include -#if LWIP_RAW /* don't build if not configured for use in lwipopts.h */ +#if LWIP_RAW || LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */ #include #include @@ -52,6 +52,7 @@ #include #include #include +#include #if LWIP_SOCKET #define PING_USE_SOCKETS 1 @@ -198,23 +199,24 @@ ping_recv(int s) static void ping_thread(void *arg) { - int s; + int s, i; int timeout = PING_RCV_TIMEO; ip_addr_t ping_target; LWIP_UNUSED_ARG(arg); if ((s = lwip_socket(AF_INET, SOCK_RAW, IP_PROTO_ICMP)) < 0) { + LWIP_DEBUGF( PING_DEBUG, ("ping: invalid socket\n")); return; } lwip_setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)); - while (1) { + for(i=0; i<5; i++) { ping_target = PING_TARGET; if (ping_send(s, &ping_target) == ERR_OK) { - LWIP_DEBUGF( PING_DEBUG, ("ping: send ")); + LWIP_DEBUGF( PING_DEBUG, ("ping: send on core %d to " , CORE_ID)); ip_addr_debug_print(PING_DEBUG, &ping_target); LWIP_DEBUGF( PING_DEBUG, ("\n")); @@ -227,6 +229,8 @@ ping_thread(void *arg) } sys_msleep(PING_DELAY); } + + lwip_close(s); } #else /* PING_USE_SOCKETS */ diff --git a/kernel/syscall.c b/kernel/syscall.c index 9134ed2b..d3eba333 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -25,8 +25,6 @@ #include #include -#include - static int sys_write(int fildes, const char *buf, size_t len) { int i; @@ -129,61 +127,6 @@ int syscall_handler(uint32_t sys_nr, ...) ret = sys_times(buffer, clock); break; } - case __NR_socket: { - int domain= va_arg(vl,int); - int type = va_arg(vl,int); - int protocol = va_arg(vl,int); - ret = socket(domain,type,protocol); - break; - } - case __NR_bind: { - int s = va_arg(vl,int); - const struct sockaddr *name = va_arg(vl,struct sockaddr *); - socklen_t namelen = va_arg(vl,socklen_t); - ret = bind(s,name,namelen); - break; - } - case __NR_listen: { - int s = va_arg(vl,int); - int backlog = va_arg(vl,int); - ret = listen(s,backlog); - break; - } - case __NR_accept: { - int s = va_arg(vl,int); - struct sockaddr *addr = va_arg(vl,struct sockaddr *); - socklen_t *addrlen = va_arg(vl,socklen_t*); - ret = accept(s,addr,addrlen); - break; - } - case __NR_connect: { - int s = va_arg(vl,int); - const struct sockaddr *name =va_arg(vl, struct sockaddr *); - socklen_t namelen = va_arg(vl,socklen_t); - ret = connect(s,name,namelen); - break; - } - case __NR_send: { - int s = va_arg(vl,int); - const void *data = va_arg(vl,void*); - size_t size = va_arg(vl,size_t); - int flags = va_arg(vl,int); - ret = send(s,data,size,flags); - break; - } - case __NR_recv: { - int s = va_arg(vl,int); - const void *data = va_arg(vl,void*); - size_t size = va_arg(vl,size_t); - int flags = va_arg(vl,int); - ret = recv(s,data,size,flags); - break; - } - case __NR_closesocket: { - int s = va_arg(vl,int); - ret = closesocket(s); - break; - } default: kputs("invalid system call\n"); ret = -ENOSYS; diff --git a/kernel/tasks.c b/kernel/tasks.c index 26774de7..6800e662 100644 --- a/kernel/tasks.c +++ b/kernel/tasks.c @@ -42,16 +42,20 @@ #include #include -DEFINE_PER_CORE(task_t*, current_task, NULL); - /** @brief Array of task structures * * A task's id will be its position in this array. */ -static task_t task_table[MAX_TASKS] = {[0 ... MAX_TASKS-1] = {0, TASK_INVALID, ATOMIC_INIT(0), \ - SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0, 0}}; +static task_t task_table[MAX_TASKS] = { \ + [0] = {0, TASK_RUNNING, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0, 0}, \ + [1 ... MAX_TASKS-1] = {0, TASK_INVALID, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0, 0}}; static spinlock_irqsave_t table_lock = SPINLOCK_IRQSAVE_INIT; +DEFINE_PER_CORE(task_t*, current_task, task_table+0); +#if MAX_CORES > 1 +DEFINE_PER_CORE_STATIC(task_t*, old_task, NULL); +#endif + /** @brief helper function for the assembly code to determine the current task * @return Pointer to the task_t structure of current task */ @@ -60,14 +64,10 @@ task_t* get_current_task(void) { } int multitasking_init(void) { - if (task_table[0].status == TASK_INVALID) { - task_table[0].id = 0; - task_table[0].status = TASK_RUNNING; - atomic_int32_set(&task_table[0].user_usage, 0); + if (BUILTIN_EXPECT(task_table[0].status == TASK_RUNNING, 1)) { mailbox_wait_msg_init(&task_table[0].inbox); memset(task_table[0].outbox, 0x00, sizeof(mailbox_wait_msg_t*)*MAX_TASKS); - per_core(current_task) = task_table+0; - per_core(current_task)->pgd = get_boot_pgd(); + task_table[0].pgd = get_boot_pgd(); task_table[0].flags = TASK_DEFAULT_FLAGS; return 0; } @@ -75,22 +75,44 @@ int multitasking_init(void) { return -ENOMEM; } +size_t get_idle_task(uint32_t id) +{ +#if MAX_CORES > 1 + if (BUILTIN_EXPECT((id >= MAX_TASKS) || (task_table[id].status != TASK_INVALID), 0)) + return -EINVAL; + + task_table[id].id = id; + task_table[id].status = TASK_IDLE; + atomic_int32_set(&task_table[id].user_usage, 0); + mailbox_wait_msg_init(&task_table[id].inbox); + memset(task_table[id].outbox, 0x00, sizeof(mailbox_wait_msg_t*)*MAX_TASKS); + task_table[id].pgd = get_boot_pgd(); + task_table[id].flags = TASK_DEFAULT_FLAGS; + current_task[id].var = task_table+id; + + return get_stack(id); +#else + return -EINVAL; +#endif +} + /** @brief Wakeup tasks which are waiting for a message from the current one * * @param result Current task's resulting return value */ static void wakeup_blocked_tasks(int result) { - wait_msg_t tmp = { per_core(current_task)->id, result }; + task_t* curr_task = per_core(current_task); + wait_msg_t tmp = { curr_task->id, result }; unsigned int i; spinlock_irqsave_lock(&table_lock); /* wake up blocked tasks */ for(i=0; ioutbox[i]) { - mailbox_wait_msg_post(per_core(current_task)->outbox[i], tmp); - per_core(current_task)->outbox[i] = NULL; + if (curr_task->outbox[i]) { + mailbox_wait_msg_post(curr_task->outbox[i], tmp); + curr_task->outbox[i] = NULL; } } @@ -101,32 +123,33 @@ static void wakeup_blocked_tasks(int result) * procedures which are called by exiting tasks. */ static void NORETURN do_exit(int arg) { vma_t* tmp; + task_t* curr_task = per_core(current_task); - kprintf("Terminate task: %u, return value %d\n", per_core(current_task)->id, arg); + kprintf("Terminate task: %u, return value %d\n", curr_task->id, arg); wakeup_blocked_tasks(arg); - //vma_dump(per_core(current_task)); - spinlock_lock(&(per_core(current_task)->vma_lock)); + //vma_dump(curr_task); + spinlock_lock(&curr_task->vma_lock); // remove memory regions - while((tmp = per_core(current_task)->vma_list) != NULL) { + while((tmp = curr_task->vma_list) != NULL) { kfree((void*) tmp->start, tmp->end - tmp->start + 1); - per_core(current_task)->vma_list = tmp->next; + curr_task->vma_list = tmp->next; kfree((void*) tmp, sizeof(vma_t)); } - spinlock_unlock(&(per_core(current_task)->vma_lock)); + spinlock_unlock(&curr_task->vma_lock); drop_pgd(); // delete page directory and its page tables - if (atomic_int32_read(&per_core(current_task)->user_usage)) + if (atomic_int32_read(&curr_task->user_usage)) kprintf("Memory leak! Task %d did not release %d pages\n", - per_core(current_task)->id, atomic_int32_read(&per_core(current_task)->user_usage)); - per_core(current_task)->status = TASK_FINISHED; + curr_task->id, atomic_int32_read(&curr_task->user_usage)); + curr_task->status = TASK_FINISHED; reschedule(); - kputs("Kernel panic: scheduler found no valid task\n"); + kprintf("Kernel panic: scheduler on core %d found no valid task\n", CORE_ID); while(1) { HALT; } @@ -150,6 +173,17 @@ void NORETURN abort(void) { do_exit(-1); } +/* + * @brief: if the task gets the first time slice, + * the table_lock is hold and have to be released. + */ +inline static void start_first_time_slice(void) +{ +#if MAX_CORES > 1 + spinlock_irqsave_unlock(&table_lock); +#endif +} + /** @brief Create a task with a specific entry point * * @param id Pointer to a tid_t struct were the id shall be set @@ -159,8 +193,9 @@ void NORETURN abort(void) { * - 0 on success * - -ENOMEM (-12) or -EINVAL (-22) on failure */ -static int create_task(tid_t* id, entry_point_t ep, void* arg) +static int create_task(tid_t* id, internal_entry_point_t ep, void* arg) { + task_t* curr_task; int ret = -ENOMEM; unsigned int i; @@ -169,6 +204,8 @@ static int create_task(tid_t* id, entry_point_t ep, void* arg) spinlock_irqsave_lock(&table_lock); + curr_task = per_core(current_task); + for(i=0; iid] = &per_core(current_task)->inbox; + task_table[i].outbox[curr_task->id] = &curr_task->inbox; if (id) *id = i; @@ -206,7 +243,6 @@ create_task_out: return ret; } - int sys_fork(void) { int ret = -ENOMEM; @@ -216,7 +252,7 @@ int sys_fork(void) vma_t* parent; vma_t* tmp; - spinlock_lock(&per_core(current_task)->vma_lock); + spinlock_lock(&parent_task->vma_lock); spinlock_irqsave_lock(&table_lock); for(i=0; ivma_list; + parent = parent_task->vma_list; tmp = NULL; while(parent) { @@ -255,9 +291,9 @@ int sys_fork(void) mailbox_wait_msg_init(&task_table[i].inbox); memset(task_table[i].outbox, 0x00, sizeof(mailbox_wait_msg_t*)*MAX_TASKS); - task_table[i].outbox[per_core(current_task)->id] = &per_core(current_task)->inbox; - task_table[i].flags = per_core(current_task)->flags; - memcpy(&(task_table[i].fpu), &(per_core(current_task)->fpu), sizeof(union fpu_state)); + task_table[i].outbox[parent_task->id] = &parent_task->inbox; + task_table[i].flags = parent_task->flags; + memcpy(&(task_table[i].fpu), &(parent_task->fpu), sizeof(union fpu_state)); task_table[i].start_tick = get_clock_tick(); task_table[i].start_heap = 0; task_table[i].end_heap = 0; @@ -269,6 +305,7 @@ int sys_fork(void) // Leave the function without releasing the locks // because the locks are already released // by the parent task! + start_first_time_slice(); return 0; } @@ -282,20 +319,57 @@ int sys_fork(void) create_task_out: spinlock_irqsave_unlock(&table_lock); - spinlock_unlock(&per_core(current_task)->vma_lock); + spinlock_unlock(&parent_task->vma_lock); return ret; } -int create_kernel_task(tid_t* id, entry_point_t ep, void* arg) +/** @brief Structure which keeps all + * relevant data for a new kernel task to start */ +typedef struct { + /// entry point of the kernel task + entry_point_t func; + /// arguments + void* args; +} kernel_args_t; + +/** @brief This call is used to adapt create_task calls + * which want to have a start function and argument list */ +static int STDCALL kernel_entry(void* args) { - return create_task(id, ep, arg); + int ret; + kernel_args_t* kernel_args = (kernel_args_t*) args; + + start_first_time_slice(); + + if (BUILTIN_EXPECT(!kernel_args, 0)) + return -EINVAL; + + ret = kernel_args->func(kernel_args->args); + + kfree(kernel_args, sizeof(kernel_args_t)); + + return ret; +} + +int create_kernel_task(tid_t* id, entry_point_t ep, void* args) +{ + kernel_args_t* kernel_args; + + kernel_args = kmalloc(sizeof(kernel_args_t)); + if (BUILTIN_EXPECT(!kernel_args, 0)) + return -ENOMEM; + + kernel_args->func = ep; + kernel_args->args = args; + + return create_task(id, kernel_entry, kernel_args); } #define MAX_ARGS (PAGE_SIZE - 2*sizeof(int) - sizeof(vfs_node_t*)) /** @brief Structure which keeps all - * relevant data for a new task to start */ + * relevant data for a new user task to start */ typedef struct { /// Points to the node with the executable in the file system vfs_node_t* node; @@ -320,6 +394,7 @@ static int load_task(load_args_t* largs) elf_program_header_t prog_header; //elf_section_header_t sec_header; vfs_node_t* node; + task_t* curr_task = per_core(current_task); if (!largs) return -EINVAL; @@ -378,8 +453,8 @@ static int load_task(load_args_t* largs) memset((void*) prog_header.virt_addr, 0, npages*PAGE_SIZE); // set starting point of the heap - if (per_core(current_task)->start_heap < prog_header.virt_addr+prog_header.mem_size) - per_core(current_task)->start_heap = per_core(current_task)->end_heap = prog_header.virt_addr+prog_header.mem_size; + if (curr_task->start_heap < prog_header.virt_addr+prog_header.mem_size) + curr_task->start_heap = curr_task->end_heap = prog_header.virt_addr+prog_header.mem_size; // load program read_fs(node, (uint8_t*)prog_header.virt_addr, prog_header.file_size, prog_header.offset); @@ -391,7 +466,7 @@ static int load_task(load_args_t* largs) flags |= VMA_WRITE; if (prog_header.flags & PF_X) flags |= VMA_EXECUTE; - vma_add(per_core(current_task), prog_header.virt_addr, prog_header.virt_addr+npages*PAGE_SIZE-1, flags); + vma_add(curr_task, prog_header.virt_addr, prog_header.virt_addr+npages*PAGE_SIZE-1, flags); if (!(prog_header.flags & PF_W)) change_page_permissions(prog_header.virt_addr, prog_header.virt_addr+npages*PAGE_SIZE-1, flags); @@ -420,7 +495,7 @@ static int load_task(load_args_t* largs) flags |= VMA_WRITE; if (prog_header.flags & PF_X) flags |= VMA_EXECUTE; - vma_add(per_core(current_task), stack, stack+npages*PAGE_SIZE-1, flags); + vma_add(curr_task, stack, stack+npages*PAGE_SIZE-1, flags); break; } } @@ -488,7 +563,7 @@ static int load_task(load_args_t* largs) kfree(largs, sizeof(load_args_t)); // clear fpu state - per_core(current_task)->flags &= ~(TASK_FPU_USED|TASK_FPU_INIT); + curr_task->flags &= ~(TASK_FPU_USED|TASK_FPU_INIT); jump_to_user_code(header.entry, stack+offset); @@ -504,7 +579,18 @@ invalid: * which want to have a start function and argument list */ static int STDCALL user_entry(void* arg) { - return load_task((load_args_t*) arg); + int ret; + + start_first_time_slice(); + + if (BUILTIN_EXPECT(!arg, 0)) + return -EINVAL; + + ret = load_task((load_args_t*) arg); + + kfree(arg, sizeof(load_args_t)); + + return ret; } /** @brief Luxus-edition of create_user_task functions. Just call with an exe name @@ -566,6 +652,7 @@ int sys_execve(const char* fname, char** argv, char** env) char *dest, *src; int ret, argc = 0; int envc = 0; + task_t* curr_task = per_core(current_task); node = findnode_fs((char*) fname); if (!node || !(node->type == FS_FILE)) @@ -608,16 +695,16 @@ int sys_execve(const char* fname, char** argv, char** env) while ((*dest++ = *src++) != 0); } - spinlock_lock(&(per_core(current_task)->vma_lock)); + spinlock_lock(&curr_task->vma_lock); // remove old program - while((tmp = per_core(current_task)->vma_list) != NULL) { + while((tmp = curr_task->vma_list) != NULL) { kfree((void*) tmp->start, tmp->end - tmp->start + 1); - per_core(current_task)->vma_list = tmp->next; + curr_task->vma_list = tmp->next; kfree((void*) tmp, sizeof(vma_t)); } - spinlock_unlock(&(per_core(current_task)->vma_lock)); + spinlock_unlock(&curr_task->vma_lock); /* * we use a trap gate to enter the kernel @@ -637,16 +724,17 @@ int sys_execve(const char* fname, char** argv, char** env) * return value. */ tid_t wait(int32_t* result) { + task_t* curr_task = per_core(current_task); wait_msg_t tmp = { -1, -1}; /* * idle tasks are not allowed to wait for another task * they should always run... */ - if (BUILTIN_EXPECT(per_core(current_task)->status == TASK_IDLE, 0)) + if (BUILTIN_EXPECT(curr_task->status == TASK_IDLE, 0)) return -EINVAL; - mailbox_wait_msg_fetch(&per_core(current_task)->inbox, &tmp); + mailbox_wait_msg_fetch(&curr_task->inbox, &tmp); if (result) *result = tmp.result; @@ -691,14 +779,14 @@ int block_task(tid_t id) spinlock_irqsave_lock(&table_lock); - if ((task_table[id].status == TASK_RUNNING) || (task_table[id].status == TASK_READY)) { + if ((task_table[id].status == TASK_RUNNING) || (task_table[id].status == TASK_READY)) { task_table[id].status = TASK_BLOCKED; ret = 0; } else kprintf("Unable to block task %d!\n", id); - spinlock_irqsave_unlock(&table_lock); + spinlock_irqsave_unlock(&table_lock); - return ret; + return ret; } /** @brief _The_ scheduler procedure @@ -707,6 +795,8 @@ int block_task(tid_t id) */ void scheduler(void) { + task_t* orig_task; + task_t* curr_task; unsigned int i; unsigned int new_id; @@ -714,47 +804,55 @@ void scheduler(void) spinlock_irqsave_lock(&table_lock); #endif - /* signalize that this task could be reused */ - if (per_core(current_task)->status == TASK_FINISHED) - per_core(current_task)->status = TASK_INVALID; + orig_task = curr_task = per_core(current_task); + + /* signalizes that this task could be reused */ + if (curr_task->status == TASK_FINISHED) + curr_task->status = TASK_INVALID; /* if the task is using the FPU, we need to save the FPU context */ - if (per_core(current_task)->flags & TASK_FPU_USED) { - save_fpu_state(&(per_core(current_task)->fpu)); - per_core(current_task)->flags &= ~TASK_FPU_USED; + if (curr_task->flags & TASK_FPU_USED) { + save_fpu_state(&(curr_task->fpu)); + curr_task->flags &= ~TASK_FPU_USED; } - for(i=1, new_id=(per_core(current_task)->id + 1) % MAX_TASKS; + for(i=1, new_id=(curr_task->id + 1) % MAX_TASKS; istatus == TASK_RUNNING) - per_core(current_task)->status = TASK_READY; + if (curr_task->status == TASK_RUNNING) + curr_task->status = TASK_READY; task_table[new_id].status = TASK_RUNNING; - per_core(current_task) = task_table+new_id; + curr_task = per_core(current_task) = task_table+new_id; goto get_task_out; } } - if ((per_core(current_task)->status == TASK_RUNNING) || (per_core(current_task)->status == TASK_IDLE)) + if ((curr_task->status == TASK_RUNNING) || (curr_task->status == TASK_IDLE)) goto get_task_out; /* * we switch to the idle task, if the current task terminates * and no other is ready */ - for(i=0; iid, smp_id()); + + if (curr_task != orig_task) + switch_task(new_id); + #if MAX_CORES > 1 spinlock_irqsave_unlock(&table_lock); -#else - return; #endif } + +void reschedule(void) +{ + uint32_t flags = irq_nested_disable(); + scheduler(); + irq_nested_enable(flags); +} diff --git a/kernel/tests.c b/kernel/tests.c index 850b8466..f417fd42 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -26,7 +26,6 @@ #include #ifdef CONFIG_ROCKCREEK #include -#include #include #include #include @@ -34,18 +33,19 @@ #include #include -#endif #include "client.h" #include "server.h" #include "shell.h" +#endif + static sem_t consuming, producing; static mailbox_int32_t mbox; static int val = 0; -static int STDCALL consumer(void* arg) +static int consumer(void* arg) { int i, m = 0; @@ -64,7 +64,7 @@ static int STDCALL consumer(void* arg) return 0; } -static int STDCALL producer(void* arg) +static int producer(void* arg) { int i; int mail[5] = {1, 2, 3, 4, 5}; @@ -84,7 +84,7 @@ static int STDCALL producer(void* arg) return 0; } -static int STDCALL foo(void* arg) +static int foo(void* arg) { int i; @@ -92,7 +92,7 @@ static int STDCALL foo(void* arg) return 0; for(i=0; i<5; i++) { - kputs((char*) arg); + kprintf("Message from core %d: %s\n", smp_id(), (char*) arg); sleep(1); } @@ -100,25 +100,25 @@ static int STDCALL foo(void* arg) } #ifdef CONFIG_ROCKCREEK -static int STDCALL ping(void* arg) -{ +int mail_ping(void* arg) { int i; for(i=0; i<20; i++) { - icc_ping(1); - HALT; + if (BUILTIN_EXPECT(icc_mail_ping(), 0)) + return -1; + udelay(500000); } return 0; } #endif -static int STDCALL join_test(void* arg) +static int join_test(void* arg) { tid_t id, ret; int result = -1234; - create_kernel_task(&id, foo, "Hello from foo2\n"); + create_kernel_task(&id, foo, "Hello from foo2"); kprintf("Wait for child %u\n", id); do { @@ -130,26 +130,7 @@ static int STDCALL join_test(void* arg) return 0; } -void ping_send_now(); - -__inline int get_core_no(void) -{ - unsigned int tmp; - unsigned int pid; - unsigned int x,y,z; - /* Determine the local IP address from the core number in the - * tile ID register - */ - tmp = ReadConfigReg(0xF8000000 + 0x100); - x = (tmp>>3) & 0x0f; /* bits 06:03 */ - y = (tmp>>7) & 0x0f; /* bits 10:07 */ - z = (tmp ) & 0x07; /* bits 02:00 */ - pid = 12*y + 2*x + z; - /* Add 1 to the processor ID to avoid *.*.*.0 IP addresses */ - return pid; -} - - +#if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK) static int srv_cnt = 0; void srv_on_read(ServerEventArgs* e) { @@ -218,7 +199,7 @@ void* server_task(void* e) /* First call to socket() function */ sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (sockfd < 0) + if (sockfd < 0) { SHELLDEBUGPRINTF("ERROR opening socket"); return; @@ -229,7 +210,7 @@ void* server_task(void* e) serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = INADDR_ANY; serv_addr.sin_port = htons(portno); - + SHELLDEBUGPRINTF("binding"); /* Now bind the host address using bind() call.*/ if (bind(sockfd, (struct sockaddr *) &serv_addr, @@ -248,9 +229,9 @@ void* server_task(void* e) /* Accept actual connection from the client */ SHELLDEBUGPRINTF("accepting"); - newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr, + newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr, &clilen); - if (newsockfd < 0) + if (newsockfd < 0) { kprintf("ERROR on accept"); return; @@ -297,7 +278,7 @@ void* server_task(void* e) SHELLDEBUGPRINTF("Send 1024*256 Bytes in : %d clock ticks",tmp2-tmp1); #endif - return 0; + return 0; } static int cli_cnt = 0; @@ -350,44 +331,44 @@ void* client_task(void* e) #if 0 char dir[2048]; - int sd; - struct sockaddr_in sin; - struct sockaddr_in pin; - struct hostent *hp; + int sd; + struct sockaddr_in sin; + struct sockaddr_in pin; + struct hostent *hp; int n; int on = 1; - sleep(1); + sleep(1); - /* fill in the socket structure with host information */ - memset(&pin, 0, sizeof(pin)); - pin.sin_family = AF_INET; + /* fill in the socket structure with host information */ + memset(&pin, 0, sizeof(pin)); + pin.sin_family = AF_INET; pin.sin_addr.s_addr = inet_addr("192.168.0.1"); - pin.sin_port = htons(5001); + pin.sin_port = htons(5001); - /* grab an Internet domain socket */ - if ((sd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) { - kprintf("socketfail"); - return; - } + /* grab an Internet domain socket */ + if ((sd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) { + kprintf("socketfail"); + return; + } // setsockopt( sd, IPPROTO_TCP, TCP_NODELAY, (char *) &on, sizeof( on)); - kprintf("connecting with socket nr : %d",sd); - /* connect to PORT on HOST */ + kprintf("connecting with socket nr : %d",sd); + /* connect to PORT on HOST */ - if (connect(sd,(struct sockaddr *) &pin, sizeof(pin)) == -1) { - kprintf("connectfail"); - return; - } - kprintf("sending"); - /* send a message to the server PORT on machine HOST */ - if (send(sd, "HELLO THERE", strlen("HELLO THERE"), 0) == -1) { - kprintf("sendfail"); - return; - } - kprintf("recieving"); + if (connect(sd,(struct sockaddr *) &pin, sizeof(pin)) == -1) { + kprintf("connectfail"); + return; + } + kprintf("sending"); + /* send a message to the server PORT on machine HOST */ + if (send(sd, "HELLO THERE", strlen("HELLO THERE"), 0) == -1) { + kprintf("sendfail"); + return; + } + kprintf("recieving"); /* wait for a message to come back from the server */ if (recv(sd, dir, 256, 0) == -1) { kprintf("recvfail"); @@ -408,57 +389,38 @@ void* client_task(void* e) #endif return NULL; } - +#endif int test_init(void) { - int i = 0; - kprintf("start testing"); +// char* argv[] = {"/bin/tests", NULL}; +// sem_init(&producing, 1); +// sem_init(&consuming, 0); +// mailbox_int32_init(&mbox); +#if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK) - shell_init(get_core_no()); + shell_init(RCCE_ue()); - sleep(10); - SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",get_core_no()); + sleep(10); + SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",get_core_no()); -// if (get_core_no()) -// { -// sleep(5); -// shelldebugprint("sleeped 5 seconds\n"); -// sleep(5); -// shelldebugprint("sleeped another 5 seconds\n"); -// shelldebugprint("This is so wonderfull!\nEverything is so well formated.\n"); + if (!RCCE_ue()) + create_kernel_task(NULL,server_task,NULL); + else + create_kernel_task(NULL,client_task,NULL); +#endif -// for (i = 0; i < 10; i++) -// { -// SHELLDEBUGPRINTF("for-Schleife-no: %d\n",i); -// } -// } - - if (!get_core_no()) - create_kernel_task(NULL,server_task,NULL); - else - create_kernel_task(NULL,client_task,NULL); - -#if 0 - - char* argv[] = {"/bin/tests", NULL}; - - sem_init(&producing, 1); - sem_init(&consuming, 0); - mailbox_int32_init(&mbox); - - create_kernel_task(NULL, foo, "Hello from foo1\n"); - //create_kernel_task(NULL, join_test, NULL); +// create_kernel_task(NULL, foo, "Hello from foo1"); +// create_kernel_task(NULL, join_test, NULL); //create_kernel_task(NULL, producer, NULL); //create_kernel_task(NULL, consumer, NULL); - //create_kernel_task(NULL, ping, NULL); + //create_kernel_task(NULL, mail_ping, NULL); //create_user_task(NULL, "/bin/hello", argv); - create_user_task(NULL, "/bin/tests", argv); +// create_user_task(NULL, "/bin/tests", argv); //create_user_task(NULL, "/bin/jacobi", argv); //create_user_task(NULL, "/bin/jacobi", argv); -#endif return 0; } diff --git a/libkern/printf.c b/libkern/printf.c index defa303f..0cdca565 100644 --- a/libkern/printf.c +++ b/libkern/printf.c @@ -36,7 +36,7 @@ /* - * eduOS's printf implementation is based on a implementation which was + * MetalSVM's printf implementation is based on a implementation which was * published at http://www.pagetable.com/?p=298. * The authors built a full-featured standalone version of printf(). The * base code has been taken from FreeBSD (sys/kern/subr_prf.c) and is diff --git a/libkern/stdio.c b/libkern/stdio.c index a8bdc9de..281fe11d 100644 --- a/libkern/stdio.c +++ b/libkern/stdio.c @@ -24,15 +24,19 @@ #include #include #include +#include #ifdef CONFIG_VGA #include #endif #define NO_EARLY_PRINT 0 #define VGA_EARLY_PRINT 1 +#define UART_EARLY_PRINT 2 #ifdef CONFIG_VGA static uint32_t early_print = VGA_EARLY_PRINT; +#elif defined(CONFIG_UART) +static uint32_t early_print = UART_EARLY_PRINT; #else static uint32_t early_print = NO_EARLY_PRINT; #endif @@ -56,8 +60,12 @@ int kputchar(int c) kmessages[pos % KMSG_SIZE] = (unsigned char) c; #ifdef CONFIG_VGA if (early_print == VGA_EARLY_PRINT) - vga_putchar(c); + vga_putchar(c); #endif +#ifdef CONFIG_UART + if (early_print == UART_EARLY_PRINT) + uart_putchar(c); +#endif return 1; } @@ -73,6 +81,10 @@ int kputs(const char *str) #ifdef CONFIG_VGA if (early_print == VGA_EARLY_PRINT) vga_putchar(str[i]); +#endif +#ifdef CONFIG_UART + if (early_print == UART_EARLY_PRINT) + uart_putchar(str[i]); #endif } diff --git a/lwip/src/arch/sys_arch.c b/lwip/src/arch/sys_arch.c index 80930cd8..47c6e6ec 100644 --- a/lwip/src/arch/sys_arch.c +++ b/lwip/src/arch/sys_arch.c @@ -74,13 +74,16 @@ sys_msleep(u32_t ms) } } -/* sys_thread_new(): Spawns a new thread with given attributes as supportet +/* sys_thread_new(): Spawns a new thread with given attributes as supported * Note: In MetalSVM this is realized as kernel tasks */ sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio) { tid_t tmp; + + kprintf("Create LWIP task %s\n", name); create_kernel_task(&tmp,thread,arg); + return tmp; } @@ -139,8 +142,8 @@ u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout) while (timeout) { err = sem_trywait(&sem->sem); - if (err == 0) - return err; + if (err != -1) + return err; udelay(1000); timeout--; } @@ -232,7 +235,7 @@ void sys_mbox_post(sys_mbox_t* mbox,void* msg) */ void sys_mutex_lock(sys_mutex_t* mutex) { - sem_wait(mutex); + sem_wait(mutex); } /* sys_mutex_unlock(): unlock the given mutex @@ -252,4 +255,21 @@ err_t sys_mutex_new(sys_mutex_t * mutex) return 0; } +#if SYS_LIGHTWEIGHT_PROT +#if MAX_CORES > 1 +static spinlock_irqsave_t lwprot_lock = SPINLOCK_IRQSAVE_INIT; + +sys_prot_t sys_arch_protect(void) +{ + spinlock_irqsave_lock(&lwprot_lock); + return 0; +} + +void sys_arch_unprotect(sys_prot_t pval) +{ + spinlock_irqsave_unlock(&lwprot_lock); +} +#endif +#endif + #endif /* !NO_SYS */ diff --git a/lwip/src/include/arch/sys_arch.h b/lwip/src/include/arch/sys_arch.h index fde4fbc2..eab88cb5 100644 --- a/lwip/src/include/arch/sys_arch.h +++ b/lwip/src/include/arch/sys_arch.h @@ -4,6 +4,7 @@ #include #include #include +#include #define EWOULDBLOCK EAGAIN /* Operation would block */ @@ -22,4 +23,24 @@ typedef struct typedef tid_t* sys_thread_t; +#if SYS_LIGHTWEIGHT_PROT +#if MAX_CORES > 1 +typedef uint32_t sys_prot_t; +sys_prot_t sys_arch_protect(void); +void sys_arch_unprotect(sys_prot_t pval); +#else +typedef uint32_t sys_prot_t; + +static inline sys_prot_t sys_arch_protect(void) +{ + return irq_nested_disable(); +} + +static inline void sys_arch_unprotect(sys_prot_t pval) +{ + irq_nested_enable(pval); +} +#endif +#endif + #endif /* __ARCH_SYS_ARCH_H__ */ diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index e56da66c..4be7eb4c 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -3,12 +3,25 @@ #ifndef __LWIPOPTS_H__ #define __LWIPOPTS_H_ +/** + * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain + * critical regions during buffer allocation, deallocation and memory + * allocation and deallocation. + */ +#define SYS_LIGHTWEIGHT_PROT 1 + /** * NO_SYS==1: Provides VERY minimal functionality. Otherwise, * use lwIP facilities. */ #define NO_SYS 0 +/** + * LWIP_RAW==1: Enable application layer to hook into the IP layer itself. + * LWIP_RAW==0: speeds up input processing + */ +#define LWIP_RAW 1 + /** * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c) */ @@ -49,9 +62,7 @@ /** * TCP_SND_BUF: TCP sender buffer space (bytes). */ -#define TCP_SND_BUF 1512 - -#define TCP_SND_QUEUELEN 4 +#define TCP_SND_BUF 2048 /** * LWIP_BROADCAST_PING==1: respond to broadcast pings (default is unicast only) @@ -86,8 +97,15 @@ */ #define LWIP_CHECKSUM_ON_COPY 1 +/** + * IP_FORWARD==1: Enables the ability to forward IP packets across network + * interfaces. If you are going to run lwIP on a device with only one network + * interface, define this to 0. + */ +#define IP_FORWARD 1 + /* DEBUG options */ -#define LWIP_DEBUG 0 +#define LWIP_DEBUG 1 #define DHCP_DEBUG LWIP_DBG_OFF #define ETHARP_DEBUG LWIP_DBG_OFF #define TCPIP_DEBUG LWIP_DBG_OFF @@ -96,15 +114,8 @@ #define MEM_DEBUG LWIP_DBG_OFF #define IP_DEBUG LWIP_DBG_OFF #define INET_DEBUG LWIP_DBG_OFF -#define NETIF_DEBUG LWIP_DBG_OFF +#define NETIF_DEBUG LWIP_DBG_ON #define TIMERS_DEBUG LWIP_DBG_OFF - -#define IP_FORWARD 1 - -#if 0 -#define LWIP_TCPIP_CORE_LOCKING_INPUT 1 -#define LWIP_TCPIP_CORE_LOCKING 1 -#endif - +#define SOCKETS_DEBUG LWIP_DBG_OFF #endif diff --git a/mm/memory.c b/mm/memory.c index ad29aedd..8b12f4f3 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -30,6 +30,9 @@ #include #endif #ifdef CONFIG_ROCKCREEK +#include +#include +#include #include #endif @@ -53,23 +56,23 @@ atomic_int32_t total_available_pages = ATOMIC_INIT(0); extern const void kernel_start; extern const void kernel_end; -inline static int page_marked(unsigned int i) +inline static int page_marked(size_t i) { - unsigned int index = i >> 3; - unsigned int mod = i & 0x7; + size_t index = i >> 3; + size_t mod = i & 0x7; return (bitmap[index] & (1 << mod)); } -inline static int page_unmarked(unsigned int i) +inline static int page_unmarked(size_t i) { return !page_marked(i); } -inline static void page_set_mark(unsigned int i) +inline static void page_set_mark(size_t i) { - unsigned int index = i >> 3; - unsigned int mod = i & 0x7; + size_t index = i >> 3; + size_t mod = i & 0x7; //if (page_marked(i)) // kprintf("page %u is alread marked\n", i); @@ -77,10 +80,10 @@ inline static void page_set_mark(unsigned int i) bitmap[index] = bitmap[index] | (1 << mod); } -inline static void page_clear_mark(unsigned int i) +inline static void page_clear_mark(size_t i) { - unsigned int index = i / 8; - unsigned int mod = i % 8; + size_t index = i / 8; + size_t mod = i % 8; if (page_unmarked(i)) kprintf("page %u is already unmarked\n", i); @@ -93,6 +96,7 @@ int mmu_init(void) size_t kernel_size; unsigned int i; size_t addr; + int ret; // at first, set default value of the bitmap memset(bitmap, 0xFF, sizeof(uint8_t)*BITMAP_SIZE); @@ -148,15 +152,8 @@ int mmu_init(void) } } #elif defined(CONFIG_ROCKCREEK) - for(addr=PRIVATE_MEM1_START; addr> PAGE_SHIFT); - if (addr > addr + PAGE_SIZE) - break; - atomic_int32_inc(&total_pages); - atomic_int32_inc(&total_available_pages); - } - - for(addr=PRIVATE_MEM2_START; addr> PAGE_SHIFT); if (addr > addr + PAGE_SIZE) break; @@ -164,6 +161,15 @@ int mmu_init(void) atomic_int32_inc(&total_available_pages); } + // Note: The last slot belongs always to the private memory. + for(addr=0xFF000000; addr<0xFFFFFFFF; addr+=PAGE_SIZE) { + page_clear_mark(addr >> PAGE_SHIFT); + if (addr > addr + PAGE_SIZE) + break; + atomic_int32_inc(&total_pages); + atomic_int32_inc(&total_available_pages); + } + /* * Mark the bootinfo as used. */ @@ -200,7 +206,36 @@ int mmu_init(void) if ((size_t) &kernel_end & (PAGE_SIZE-1)) alloc_start++; - return paging_init(); +#if MAX_CORES > 1 + // reserve physical page for SMP boot code + page_set_mark(SMP_SETUP_ADDR >> PAGE_SHIFT); + atomic_int32_add(&total_allocated_pages, 1); + atomic_int32_sub(&total_available_pages, 1); +#endif + ret = paging_init(); + +#ifdef CONFIG_ROCKCREEK + /* + * Now, we are able to read the FPGA registers and to + * determine the number of slots for private memory. + */ + uint32_t slots = *((volatile uint32_t*) (FPGA_BASE + 0x8244)); + if (slots == 0) + slots = 21; + + kprintf("MetalSVM use %d slots for private memory\n", slots); + + // define the residual private slots as free + for(addr=20*0x1000000; addr<(slots-1)*0x1000000; addr+=PAGE_SIZE) { + page_clear_mark(addr >> PAGE_SHIFT); + if (addr > addr + PAGE_SIZE) + break; + atomic_int32_inc(&total_pages); + atomic_int32_inc(&total_available_pages); + } +#endif + + return ret; } /* diff --git a/newlib/src/libgloss/metalsvm/accept.c b/newlib/net/accept.c similarity index 100% rename from newlib/src/libgloss/metalsvm/accept.c rename to newlib/net/accept.c diff --git a/newlib/src/libgloss/metalsvm/bind.c b/newlib/net/bind.c similarity index 100% rename from newlib/src/libgloss/metalsvm/bind.c rename to newlib/net/bind.c diff --git a/newlib/src/libgloss/metalsvm/closesocket.c b/newlib/net/closesocket.c similarity index 100% rename from newlib/src/libgloss/metalsvm/closesocket.c rename to newlib/net/closesocket.c diff --git a/newlib/src/libgloss/metalsvm/connect.c b/newlib/net/connect.c similarity index 100% rename from newlib/src/libgloss/metalsvm/connect.c rename to newlib/net/connect.c diff --git a/newlib/src/libgloss/metalsvm/listen.c b/newlib/net/listen.c similarity index 100% rename from newlib/src/libgloss/metalsvm/listen.c rename to newlib/net/listen.c diff --git a/newlib/src/libgloss/metalsvm/recv.c b/newlib/net/recv.c similarity index 100% rename from newlib/src/libgloss/metalsvm/recv.c rename to newlib/net/recv.c diff --git a/newlib/src/libgloss/metalsvm/send.c b/newlib/net/send.c similarity index 100% rename from newlib/src/libgloss/metalsvm/send.c rename to newlib/net/send.c diff --git a/newlib/src/libgloss/metalsvm/socket.c b/newlib/net/socket.c similarity index 100% rename from newlib/src/libgloss/metalsvm/socket.c rename to newlib/net/socket.c diff --git a/newlib/net/syscall.h b/newlib/net/syscall.h new file mode 100644 index 00000000..6d137508 --- /dev/null +++ b/newlib/net/syscall.h @@ -0,0 +1,78 @@ +/* + * Copyright 2010 Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Standard x86 syscalls for user programs running under MetalSVM + */ + +#ifndef __SYSCALL_H__ +#define __SYSCALL_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define __NR_exit 0 +#define __NR_write 1 +#define __NR_open 2 +#define __NR_close 3 +#define __NR_read 4 +#define __NR_lseek 6 +#define __NR_unlink 7 +#define __NR_getpid 8 +#define __NR_kill 9 +#define __NR_fstat 10 +#define __NR_sbrk 11 +#define __NR_fork 12 +#define __NR_wait 13 +#define __NR_execve 14 +#define __NR_times 15 + +#define _STR(token) #token +#define _SYSCALLSTR(x) "int $" _STR(x) " " +#define INT_SYSCALL 0x80 + +inline static long +syscall(int nr, unsigned long arg0, unsigned long arg1, unsigned long arg2, + unsigned long arg3, unsigned long arg4) +{ + long res; + + asm volatile (_SYSCALLSTR(INT_SYSCALL) + : "=a" (res) + : "0" (nr), "b" (arg0), "c" (arg1), "d" (arg2), "S" (arg3), "D" (arg4) + : "memory", "cc"); + + return res; +} + +#define SYSCALL0(NR) \ + syscall(NR, 0, 0, 0, 0, 0) +#define SYSCALL1(NR, ARG1) \ + syscall(NR, (unsigned long)ARG1, 0, 0, 0, 0) +#define SYSCALL2(NR, ARG1, ARG2) \ + syscall(NR, (unsigned long)ARG1, (unsigned long)ARG2, 0, 0, 0) +#define SYSCALL3(NR, ARG1, ARG2, ARG3) \ + syscall(NR, (unsigned long)ARG1, (unsigned long)ARG2, (unsigned long)ARG3, 0, 0) +#define SYSCALL4(NR, ARG1, ARG2, ARG3, ARG4) \ + syscall(NR, (unsigned long)ARG1, (unsigned long)ARG2, (unsigned long)ARG3, (unsigned long) ARG4, 0) +#define SYSCALL5(NR, ARG1, ARG2, ARG3, ARG4) \ + syscall(NR, (unsigned long)ARG1, (unsigned long)ARG2, (unsigned long)ARG3, (unsigned long) ARG4, (unsigned long) ARG5) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/newlib/src/compile b/newlib/src/compile old mode 100644 new mode 100755 diff --git a/newlib/src/config.guess b/newlib/src/config.guess old mode 100644 new mode 100755 diff --git a/newlib/src/config.rpath b/newlib/src/config.rpath old mode 100644 new mode 100755 diff --git a/newlib/src/config.status b/newlib/src/config.status old mode 100644 new mode 100755 diff --git a/newlib/src/config.sub b/newlib/src/config.sub old mode 100644 new mode 100755 diff --git a/newlib/src/config/acinclude.m4 b/newlib/src/config/acinclude.m4 old mode 100644 new mode 100755 diff --git a/newlib/src/configure b/newlib/src/configure old mode 100644 new mode 100755 diff --git a/newlib/src/depcomp b/newlib/src/depcomp old mode 100644 new mode 100755 diff --git a/newlib/src/etc/config.status b/newlib/src/etc/config.status old mode 100644 new mode 100755 diff --git a/newlib/src/etc/configure b/newlib/src/etc/configure old mode 100644 new mode 100755 diff --git a/newlib/src/install-sh b/newlib/src/install-sh old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/bfin/configure b/newlib/src/libgloss/bfin/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/configure b/newlib/src/libgloss/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/cris/configure b/newlib/src/libgloss/cris/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/crx/configure b/newlib/src/libgloss/crx/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/d30v/configure b/newlib/src/libgloss/d30v/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/doc/configure b/newlib/src/libgloss/doc/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/fr30/configure b/newlib/src/libgloss/fr30/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/frv/configure b/newlib/src/libgloss/frv/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/hp74x/configure b/newlib/src/libgloss/hp74x/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/i386/configure b/newlib/src/libgloss/i386/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/i960/configure b/newlib/src/libgloss/i960/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/iq2000/configure b/newlib/src/libgloss/iq2000/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/libnosys/configure b/newlib/src/libgloss/libnosys/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/lm32/configure b/newlib/src/libgloss/lm32/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/m32c/configure b/newlib/src/libgloss/m32c/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/m32r/configure b/newlib/src/libgloss/m32r/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/m68hc11/configure b/newlib/src/libgloss/m68hc11/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/m68k/configure b/newlib/src/libgloss/m68k/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/mcore/configure b/newlib/src/libgloss/mcore/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/mep/configure b/newlib/src/libgloss/mep/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/metalsvm/Makefile.in b/newlib/src/libgloss/metalsvm/Makefile.in index 6c5f410e..8b83997b 100644 --- a/newlib/src/libgloss/metalsvm/Makefile.in +++ b/newlib/src/libgloss/metalsvm/Makefile.in @@ -63,8 +63,7 @@ CRT0 = crt0.o METALSVM_BSP = libgloss.a METALSVM_OBJS = chown.o errno.o fork.o gettod.o kill.o open.o sbrk.o times.o write.o \ close.o execve.o fstat.o init.o link.o read.o stat.o unlink.o \ - environ.o _exit.o getpid.o isatty.o lseek.o readlink.o symlink.o wait.o \ - socket.o bind.o listen.o accept.o connect.o send.o recv.o closesocket.o + environ.o _exit.o getpid.o isatty.o lseek.o readlink.o symlink.o wait.o #### Host specific Makefile fragment comes in here. diff --git a/newlib/src/libgloss/metalsvm/configure b/newlib/src/libgloss/metalsvm/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/metalsvm/syscall.h b/newlib/src/libgloss/metalsvm/syscall.h index 88eeeb75..6d137508 100644 --- a/newlib/src/libgloss/metalsvm/syscall.h +++ b/newlib/src/libgloss/metalsvm/syscall.h @@ -40,18 +40,6 @@ extern "C" { #define __NR_execve 14 #define __NR_times 15 -/* networking - */ - -#define __NR_socket 16 -#define __NR_bind 17 -#define __NR_listen 18 -#define __NR_accept 19 -#define __NR_connect 20 -#define __NR_send 21 -#define __NR_recv 22 -#define __NR_closesocket 23 - #define _STR(token) #token #define _SYSCALLSTR(x) "int $" _STR(x) " " #define INT_SYSCALL 0x80 diff --git a/newlib/src/libgloss/mips/configure b/newlib/src/libgloss/mips/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/mn10200/configure b/newlib/src/libgloss/mn10200/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/mn10300/configure b/newlib/src/libgloss/mn10300/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/mt/configure b/newlib/src/libgloss/mt/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/pa/configure b/newlib/src/libgloss/pa/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/rs6000/configure b/newlib/src/libgloss/rs6000/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/sparc/configure b/newlib/src/libgloss/sparc/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/sparc/libsys/configure b/newlib/src/libgloss/sparc/libsys/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/tic6x/configure b/newlib/src/libgloss/tic6x/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/wince/configure b/newlib/src/libgloss/wince/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/xc16x/configure b/newlib/src/libgloss/xc16x/configure old mode 100644 new mode 100755 diff --git a/newlib/src/libgloss/xstormy16/configure b/newlib/src/libgloss/xstormy16/configure old mode 100644 new mode 100755 diff --git a/newlib/src/missing b/newlib/src/missing old mode 100644 new mode 100755 diff --git a/newlib/src/mkdep b/newlib/src/mkdep old mode 100644 new mode 100755 diff --git a/newlib/src/mkinstalldirs b/newlib/src/mkinstalldirs old mode 100644 new mode 100755 diff --git a/newlib/src/move-if-change b/newlib/src/move-if-change old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/configure b/newlib/src/newlib/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/doc/configure b/newlib/src/newlib/doc/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/iconvdata/configure b/newlib/src/newlib/iconvdata/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/configure b/newlib/src/newlib/libc/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/iconv/ccs/mktbl.pl b/newlib/src/newlib/libc/iconv/ccs/mktbl.pl old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/iconv/ces/mkdeps.pl b/newlib/src/newlib/libc/iconv/ces/mkdeps.pl old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/a29k/configure b/newlib/src/newlib/libc/machine/a29k/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/arm/configure b/newlib/src/newlib/libc/machine/arm/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/bfin/configure b/newlib/src/newlib/libc/machine/bfin/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/configure b/newlib/src/newlib/libc/machine/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/cris/configure b/newlib/src/newlib/libc/machine/cris/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/crx/configure b/newlib/src/newlib/libc/machine/crx/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/d10v/configure b/newlib/src/newlib/libc/machine/d10v/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/d30v/configure b/newlib/src/newlib/libc/machine/d30v/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/fr30/configure b/newlib/src/newlib/libc/machine/fr30/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/frv/configure b/newlib/src/newlib/libc/machine/frv/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/h8300/configure b/newlib/src/newlib/libc/machine/h8300/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/h8500/configure b/newlib/src/newlib/libc/machine/h8500/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/hppa/configure b/newlib/src/newlib/libc/machine/hppa/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/i386/configure b/newlib/src/newlib/libc/machine/i386/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/i960/configure b/newlib/src/newlib/libc/machine/i960/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/iq2000/configure b/newlib/src/newlib/libc/machine/iq2000/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/lm32/configure b/newlib/src/newlib/libc/machine/lm32/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/m32c/configure b/newlib/src/newlib/libc/machine/m32c/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/m32r/configure b/newlib/src/newlib/libc/machine/m32r/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/m68hc11/configure b/newlib/src/newlib/libc/machine/m68hc11/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/m68k/configure b/newlib/src/newlib/libc/machine/m68k/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/m88k/configure b/newlib/src/newlib/libc/machine/m88k/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/mep/configure b/newlib/src/newlib/libc/machine/mep/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/mips/configure b/newlib/src/newlib/libc/machine/mips/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/mn10200/configure b/newlib/src/newlib/libc/machine/mn10200/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/mn10300/configure b/newlib/src/newlib/libc/machine/mn10300/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/mt/configure b/newlib/src/newlib/libc/machine/mt/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/necv70/configure b/newlib/src/newlib/libc/machine/necv70/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/powerpc/configure b/newlib/src/newlib/libc/machine/powerpc/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/rx/configure b/newlib/src/newlib/libc/machine/rx/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/sh/configure b/newlib/src/newlib/libc/machine/sh/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/sparc/configure b/newlib/src/newlib/libc/machine/sparc/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/tic4x/configure b/newlib/src/newlib/libc/machine/tic4x/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/tic6x/configure b/newlib/src/newlib/libc/machine/tic6x/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/tic80/configure b/newlib/src/newlib/libc/machine/tic80/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/v850/configure b/newlib/src/newlib/libc/machine/v850/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/w65/configure b/newlib/src/newlib/libc/machine/w65/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/w65/lshrhi.S b/newlib/src/newlib/libc/machine/w65/lshrhi.S old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/w65/sdivhi3.S b/newlib/src/newlib/libc/machine/w65/sdivhi3.S old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/w65/smulhi3.S b/newlib/src/newlib/libc/machine/w65/smulhi3.S old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/w65/udivhi3.S b/newlib/src/newlib/libc/machine/w65/udivhi3.S old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/w65/umodhi3.S b/newlib/src/newlib/libc/machine/w65/umodhi3.S old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/x86_64/configure b/newlib/src/newlib/libc/machine/x86_64/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/xscale/configure b/newlib/src/newlib/libc/machine/xscale/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/xstormy16/configure b/newlib/src/newlib/libc/machine/xstormy16/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/machine/z8k/configure b/newlib/src/newlib/libc/machine/z8k/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/a29khif/configure b/newlib/src/newlib/libc/sys/a29khif/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/arc/configure b/newlib/src/newlib/libc/sys/arc/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/arm/configure b/newlib/src/newlib/libc/sys/arm/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/configure b/newlib/src/newlib/libc/sys/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/d10v/configure b/newlib/src/newlib/libc/sys/d10v/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/decstation/configure b/newlib/src/newlib/libc/sys/decstation/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/h8300hms/configure b/newlib/src/newlib/libc/sys/h8300hms/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/h8500hms/configure b/newlib/src/newlib/libc/sys/h8500hms/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/linux/configure b/newlib/src/newlib/libc/sys/linux/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/linux/linuxthreads/configure b/newlib/src/newlib/libc/sys/linux/linuxthreads/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/linux/linuxthreads/machine/configure b/newlib/src/newlib/libc/sys/linux/linuxthreads/machine/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/linux/linuxthreads/machine/i386/configure b/newlib/src/newlib/libc/sys/linux/linuxthreads/machine/i386/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/linux/machine/configure b/newlib/src/newlib/libc/sys/linux/machine/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/linux/machine/i386/configure b/newlib/src/newlib/libc/sys/linux/machine/i386/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/m88kbug/configure b/newlib/src/newlib/libc/sys/m88kbug/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/mmixware/configure b/newlib/src/newlib/libc/sys/mmixware/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/netware/configure b/newlib/src/newlib/libc/sys/netware/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/rdos/chown.c b/newlib/src/newlib/libc/sys/rdos/chown.c old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/rdos/configure b/newlib/src/newlib/libc/sys/rdos/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/rdos/fork.c b/newlib/src/newlib/libc/sys/rdos/fork.c old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/rdos/fstat.c b/newlib/src/newlib/libc/sys/rdos/fstat.c old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/rdos/lseek.c b/newlib/src/newlib/libc/sys/rdos/lseek.c old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/rdos/open.c b/newlib/src/newlib/libc/sys/rdos/open.c old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/rdos/rdos.h b/newlib/src/newlib/libc/sys/rdos/rdos.h old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/rdos/readlink.c b/newlib/src/newlib/libc/sys/rdos/readlink.c old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/rdos/stat.c b/newlib/src/newlib/libc/sys/rdos/stat.c old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/rdos/symlink.c b/newlib/src/newlib/libc/sys/rdos/symlink.c old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/rtems/configure b/newlib/src/newlib/libc/sys/rtems/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/sh/configure b/newlib/src/newlib/libc/sys/sh/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/sparc64/configure b/newlib/src/newlib/libc/sys/sparc64/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/sun4/configure b/newlib/src/newlib/libc/sys/sun4/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/sysmec/configure b/newlib/src/newlib/libc/sys/sysmec/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/sysnec810/configure b/newlib/src/newlib/libc/sys/sysnec810/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/sysnecv850/configure b/newlib/src/newlib/libc/sys/sysnecv850/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/sysvi386/configure b/newlib/src/newlib/libc/sys/sysvi386/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/sysvnecv70/configure b/newlib/src/newlib/libc/sys/sysvnecv70/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/tic80/configure b/newlib/src/newlib/libc/sys/tic80/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/w65/configure b/newlib/src/newlib/libc/sys/w65/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libc/sys/z8ksim/configure b/newlib/src/newlib/libc/sys/z8ksim/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libm/configure b/newlib/src/newlib/libm/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libm/machine/configure b/newlib/src/newlib/libm/machine/configure old mode 100644 new mode 100755 diff --git a/newlib/src/newlib/libm/machine/i386/configure b/newlib/src/newlib/libm/machine/i386/configure old mode 100644 new mode 100755 diff --git a/newlib/src/symlink-tree b/newlib/src/symlink-tree old mode 100644 new mode 100755 diff --git a/newlib/src/ylwrap b/newlib/src/ylwrap old mode 100644 new mode 100755 diff --git a/tools/Makefile b/tools/Makefile index fb77c026..baf8febe 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -24,7 +24,7 @@ make_initrd: make_initrd.o $(CC) $(CFLAGS) -o make_initrd $< $(LDFLAGS) smp_setup.bin: smp_setup.asm - $(ASM) $(ASMFLAGS) -o $@ $< + $(NASM) $(NASMFLAGS) -o $@ $< smp_setup.hex: smp_setup.bin hexdump -v -e '"0x" 1/1 "%02X" ", "' $< > $@ diff --git a/tools/bootinfo.sh b/tools/bootinfo.sh old mode 100644 new mode 100755 diff --git a/tools/prepare.sh b/tools/prepare.sh old mode 100644 new mode 100755 diff --git a/tools/scc_setup.asm b/tools/scc_setup.asm index aacf105e..dc8a1dca 100644 --- a/tools/scc_setup.asm +++ b/tools/scc_setup.asm @@ -14,7 +14,7 @@ ; See the License for the specific language governing permissions and ; limitations under the License. ; -; This file is part of metalsvm. +; This file is part of MetalSVM. ; This is the kernel's entry point. We switch to the protected mode ; and jump to our kernel. diff --git a/tools/smp_setup.asm b/tools/smp_setup.asm index 744fe159..7398029c 100644 --- a/tools/smp_setup.asm +++ b/tools/smp_setup.asm @@ -22,55 +22,10 @@ [BITS 16] SECTION .text GLOBAL _start -ORG 0x10000 +ORG 0x7000 _start: - jmp _realstart - - struc GDT_STR - s0_15: resw 1 - b0_15: resw 1 - b16_23: resb 1 - flags: resb 1 - access: resb 1 - b24_31: resb 1 - endstruc - - gdt_start dw gdt_size - gdt_ptr dd dummy_descriptor - - dummy_descriptor: istruc GDT_STR - at s0_15, dw 0 - at b0_15, dw 0 - at b16_23, db 0 - at flags, db 0 - at access, db 0 - at b24_31, db 0 - iend - - ; 4GB 32-bit code , 9ah = 10011010b = Present, DPL 00,No System, Code Exec/Read. - code32_descriptor: istruc GDT_STR - at s0_15, dw 0x0ffff - at b0_15, dw 0 - at b16_23, db 0 - at flags, db 0x9a - at access, db 0xcf - at b24_31, db 0 - iend - - ; 4GB 32-bit data, 92h = 10010010b = Present, DPL 00, No System, Data Read/Write - data32_descriptor: istruc GDT_STR - at s0_15, dw 0x0ffff - at b0_15, dw 0 - at b16_23, db 0 - at flags, db 0x92 - at access, db 0xcf - at b24_31, db 0 - iend - - gdt_size equ $ - (dummy_descriptor) - 1 - -_realstart: - lgdt [gdt_start] + cli + lgdt [gdtr] ; switch to protected mode by setting PE bit mov eax, cr0 @@ -78,28 +33,41 @@ _realstart: mov cr0, eax ; far jump to the 32bit code - jmp dword 0x08 : _pmstart + jmp dword codesel : _pmstart [BITS 32] _pmstart: - cli xor eax, eax - mov ax, 0x10 + mov ax, datasel mov ds, ax mov es, ax mov fs, ax mov gs, ax mov ss, ax - ; enable cache and turn on FPU exceptions - mov eax, cr0 - and eax, 0x9fffffff - or eax, 0x20 - mov cr0, eax - ; clear the current pgd entry - xor eax, eax - mov cr3, eax - ; set stack pointer - mov esp, 0xDEADBEEF - xor eax, eax - xor ebx, ebx - jmp 0x08 : 0xDEADC0DE + mov esp, 0xDEADBEEF + push DWORD 0xDEADDEAD + push DWORD 0x00 ; dummy value + jmp codesel : 0xDEADC0DE + jmp $ + +gdtr: ; descritor table + dw gdt_end-gdt-1 ; limit + dd gdt ; base adresse +gdt: + dd 0,0 ; null descriptor +codesel equ $-gdt + dw 0xFFFF ; segment size 0..15 + dw 0x0000 ; segment address 0..15 + db 0x00 ; segment address 16..23 + db 0x9A ; access permissions und type + db 0xCF ; additional information and segment size 16...19 + db 0x00 ; segment address 24..31 +datasel equ $-gdt + dw 0xFFFF ; segment size 0..15 + dw 0x0000 ; segment address 0..15 + db 0x00 ; segment address 16..23 + db 0x92 ; access permissions and type + db 0xCF ; additional informationen and degment size 16...19 + db 0x00 ; segment address 24..31 +gdt_end: + From be7a5ff2697f73194da9007b048b9930c37eea75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 12:32:41 +0200 Subject: [PATCH 150/261] merge && test for master --- kernel/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/init.c b/kernel/init.c index 28301787..10ca88cc 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -150,7 +150,7 @@ int network_init(void) } } #else - //mmnif_open(); + mmnif_open(); #endif // start echo and ping server @@ -164,7 +164,7 @@ int network_init(void) int network_shutdown(void) { #if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK) - //mmnif_close(); + mmnif_close(); #elif defined(CONFIG_LWIP) && defined(CONFIG_PCI) dhcp_release(default_netif); dhcp_stop(default_netif); From f73f98ad0ac0f4fc35160ca76c6f795c9124c051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 12:41:13 +0200 Subject: [PATCH 151/261] merge && test for master --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index f417fd42..672dbd91 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -404,7 +404,7 @@ int test_init(void) shell_init(RCCE_ue()); sleep(10); - SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",get_core_no()); + SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",RCCE_ue()); if (!RCCE_ue()) create_kernel_task(NULL,server_task,NULL); From 5bef5eb03bdf2db575943f06a8f0dcbe3b744aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 12:43:53 +0200 Subject: [PATCH 152/261] merge && test for master --- drivers/net/mmnif.c | 39 +++------------------------------------ 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index f7b3cb27..cb7d947d 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -229,39 +229,6 @@ typedef struct mmnif }mmnif_t; -#ifdef WIN32 - -__inline int get_my_core_no(void) -{ -#ifndef RECV - return 1; -#else - return 0; -#endif -} - -#else - -__inline int get_my_core_no(void) -{ - unsigned int tmp; - unsigned int pid; - unsigned int x,y,z; - /* Determine the local IP address from the core number in the - * tile ID register - */ - tmp = ReadConfigReg(local_crb + RCK_TILEID); - x = (tmp>>3) & 0x0f; /* bits 06:03 */ - y = (tmp>>7) & 0x0f; /* bits 10:07 */ - z = (tmp ) & 0x07; /* bits 02:00 */ - pid = 12*y + 2*x + z; - /* Add 1 to the processor ID to avoid *.*.*.0 IP addresses */ - return pid; -} - -#endif - - /* * memory maped interface helper functions */ @@ -973,7 +940,7 @@ err_t mmnif_init(struct netif* netif) /* Generate MAC address */ mmnif_dev->hwaddr[0] = 0x11;mmnif_dev->hwaddr[1] = 0x22;mmnif_dev->hwaddr[2] = 0x33; - mmnif_dev->hwaddr[3] = 0x44;mmnif_dev->hwaddr[4] = 0x55;mmnif_dev->hwaddr[5] = get_my_core_no()*0x11 +0x66; + mmnif_dev->hwaddr[3] = 0x44;mmnif_dev->hwaddr[4] = 0x55;mmnif_dev->hwaddr[5] = RCCE_UE()*0x11 +0x66; /* * Initialize the snmp variables and counters inside the struct netif. @@ -1321,10 +1288,10 @@ int mmnif_open() * Note: core 1 is the router core */ IP4_ADDR(&gw, 0,0,0,0); - IP4_ADDR(&ipaddr, 192,168,0,get_my_core_no() +1); + IP4_ADDR(&ipaddr, 192,168,0,RCCE_UE() +1); IP4_ADDR(&netmask, 255,255,255,0); - own_ip_address+= get_my_core_no() +1; + own_ip_address+= RCCE_UE() +1; #ifdef WIN32 mmnif_dev = malloc(sizeof(struct netif)); From 3310c8b9870c2ef2d80382ccc94f7023f48c7393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 12:46:41 +0200 Subject: [PATCH 153/261] merge && test for master --- drivers/net/mmnif.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index cb7d947d..cf818bf0 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -52,7 +52,6 @@ extern HANDLE hProc; #include #include -#include #include #include #include @@ -229,6 +228,19 @@ typedef struct mmnif }mmnif_t; +#ifdef WIN32 + +__inline int RCCE_ue(void) +{ +#ifndef RECV + return 1; +#else + return 0; +#endif +} + +#endif + /* * memory maped interface helper functions */ @@ -940,7 +952,7 @@ err_t mmnif_init(struct netif* netif) /* Generate MAC address */ mmnif_dev->hwaddr[0] = 0x11;mmnif_dev->hwaddr[1] = 0x22;mmnif_dev->hwaddr[2] = 0x33; - mmnif_dev->hwaddr[3] = 0x44;mmnif_dev->hwaddr[4] = 0x55;mmnif_dev->hwaddr[5] = RCCE_UE()*0x11 +0x66; + mmnif_dev->hwaddr[3] = 0x44;mmnif_dev->hwaddr[4] = 0x55;mmnif_dev->hwaddr[5] = RCCE_ue()*0x11 +0x66; /* * Initialize the snmp variables and counters inside the struct netif. @@ -1288,10 +1300,10 @@ int mmnif_open() * Note: core 1 is the router core */ IP4_ADDR(&gw, 0,0,0,0); - IP4_ADDR(&ipaddr, 192,168,0,RCCE_UE() +1); + IP4_ADDR(&ipaddr, 192,168,0,RCCE_ue() +1); IP4_ADDR(&netmask, 255,255,255,0); - own_ip_address+= RCCE_UE() +1; + own_ip_address+= RCCE_ue() +1; #ifdef WIN32 mmnif_dev = malloc(sizeof(struct netif)); From e20d3482fd56ceab653755517790e56183b2d30d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 12:51:56 +0200 Subject: [PATCH 154/261] merge && test for master --- kernel/shell.c | 2 +- kernel/tests.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/shell.c b/kernel/shell.c index a7a8a51d..2e4a0f2a 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -17,7 +17,7 @@ char shellbuffer[512]; void shelldebugprint(char* x) { - kprintf("debugprinting"); + kprintf("debugprinting : %s",x); if (iamsrv) srv_sendBuffer(&srv,emac_id,x,strlen(x)); else diff --git a/kernel/tests.c b/kernel/tests.c index 672dbd91..44316419 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -164,7 +164,7 @@ void* server_task(void* e) Server srv; server_init(&srv,5555,2); - SHELLDEBUGPRINTF("created server\n"); + kprintf("created server\n"); srv._OnRead = srv_on_read; srv._OnDisconnect = srv_on_disc; srv._OnConnect = srv_on_conn; From 920a4088f703f4bafa2084fd56acbb1c2b93058b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 12:56:47 +0200 Subject: [PATCH 155/261] merge && test for master --- kernel/tests.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/tests.c b/kernel/tests.c index 44316419..f0144ec6 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -154,6 +154,7 @@ void srv_on_conn(ServerEventArgs* e) kprintf("someone finally connected\n"); } +#define SHELLDEBUGPRINTF(x,...) kprintf(x,##__VA_ARGS__); void* server_task(void* e) { From 5ef210c4698111cab99209c6b247291586556d76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 13:04:02 +0200 Subject: [PATCH 156/261] merge && test for master --- kernel/tests.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index f0144ec6..a761ef95 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -177,11 +177,14 @@ void* server_task(void* e) tmp1 = get_clock_tick(); for (i = 0; i < 1024*4*4*4; i++) { + udelay(1000); + if (srv_sendBuffer(&srv,0,buff,sizeof(buff))< 0) SHELLDEBUGPRINTF("err"); + if (!(i%100)) SHELLDEBUGPRINTF("\r-%d-",i); - udelay(100); + // Sleep(10); } tmp2 = get_clock_tick(); From 8bf03aaa61dfe530be62acdc88d52a65879998c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 13:10:15 +0200 Subject: [PATCH 157/261] merge && test for master --- kernel/tests.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index a761ef95..fe4ae8ac 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -158,7 +158,7 @@ void srv_on_conn(ServerEventArgs* e) void* server_task(void* e) { - int i = 0; + int i = 0, err = 0; int tmp1,tmp2; char buff[32]; @@ -177,10 +177,11 @@ void* server_task(void* e) tmp1 = get_clock_tick(); for (i = 0; i < 1024*4*4*4; i++) { - udelay(1000); + sleep(1); - if (srv_sendBuffer(&srv,0,buff,sizeof(buff))< 0) - SHELLDEBUGPRINTF("err"); + err = srv_sendBuffer(&srv,0,buff,sizeof(buff)); + if ( err < 0) + SHELLDEBUGPRINTF("err: % d", err); if (!(i%100)) SHELLDEBUGPRINTF("\r-%d-",i); From 20300fb7457bce7f4682038588c98cf984cda99d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 13:11:44 +0200 Subject: [PATCH 158/261] merge && test for master --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index fe4ae8ac..6f1fb2af 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -181,7 +181,7 @@ void* server_task(void* e) err = srv_sendBuffer(&srv,0,buff,sizeof(buff)); if ( err < 0) - SHELLDEBUGPRINTF("err: % d", err); + SHELLDEBUGPRINTF("err: %d", err); if (!(i%100)) SHELLDEBUGPRINTF("\r-%d-",i); From 1ec632145bcc70954701e2c0663722023d165a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 13:14:23 +0200 Subject: [PATCH 159/261] merge && test for master --- drivers/net/mmnif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index cf818bf0..f8b2afbf 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -849,7 +849,7 @@ drop_packet_fast: mmnif->stats.tx_err++; - return ERR_IF; + return ERR_OK; } /* mmnif_link_layer(): wrapper function called by ip_output() From c8badae6ad83f175b62e7762a37f0b5eb6d18a07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 13:19:12 +0200 Subject: [PATCH 160/261] merge && test for master --- kernel/tests.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 6f1fb2af..f4518198 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -150,36 +150,19 @@ void srv_on_disc(ServerEventArgs*e ) } void srv_on_conn(ServerEventArgs* e) -{ - kprintf("someone finally connected\n"); -} - -#define SHELLDEBUGPRINTF(x,...) kprintf(x,##__VA_ARGS__); - -void* server_task(void* e) { int i = 0, err = 0; int tmp1,tmp2; char buff[32]; - Server srv; - - server_init(&srv,5555,2); - kprintf("created server\n"); - srv._OnRead = srv_on_read; - srv._OnDisconnect = srv_on_disc; - srv._OnConnect = srv_on_conn; - sleep(5); - SHELLDEBUGPRINTF("sending...\n"); - srv_sendBuffer(&srv,0,"Hello you!",sizeof("Hello you!")); - sleep(1); + kprintf("someone finally connected\n"); tmp1 = get_clock_tick(); for (i = 0; i < 1024*4*4*4; i++) { sleep(1); - err = srv_sendBuffer(&srv,0,buff,sizeof(buff)); + err = srv_sendBuffer(&srv,e->ClientID,buff,sizeof(buff)); if ( err < 0) SHELLDEBUGPRINTF("err: %d", err); @@ -191,6 +174,22 @@ void* server_task(void* e) tmp2 = get_clock_tick(); kprintf("send with %f kb/s", ((float)i*sizeof(buff))/(tmp2-tmp1)); +} + +#define SHELLDEBUGPRINTF(x,...) kprintf(x,##__VA_ARGS__); + +void* server_task(void* e) +{ + Server srv; + + server_init(&srv,5555,2); + kprintf("created server\n"); + srv._OnRead = srv_on_read; + srv._OnDisconnect = srv_on_disc; + srv._OnConnect = srv_on_conn; + + while(1) + sleep(2); return NULL; From 3936fa5a26663310bc3d1a9084b12356f64979c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 13:20:06 +0200 Subject: [PATCH 161/261] merge && test for master --- drivers/net/mmnif.c | 2 +- kernel/tests.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index f8b2afbf..5408ac1b 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -849,7 +849,7 @@ drop_packet_fast: mmnif->stats.tx_err++; - return ERR_OK; + return ERR_IF; } /* mmnif_link_layer(): wrapper function called by ip_output() diff --git a/kernel/tests.c b/kernel/tests.c index f4518198..05c201db 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -132,6 +132,7 @@ static int join_test(void* arg) #if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK) static int srv_cnt = 0; +static Server srv; void srv_on_read(ServerEventArgs* e) { // kprintf("%i:",srv_cnt); @@ -180,7 +181,7 @@ void srv_on_conn(ServerEventArgs* e) void* server_task(void* e) { - Server srv; + server_init(&srv,5555,2); kprintf("created server\n"); From e88881a756cb412d16402fa2e2fbb7d76f2dca7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 13:22:55 +0200 Subject: [PATCH 162/261] merge && test for master --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 05c201db..fb073fd6 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -315,7 +315,7 @@ void* client_task(void* e) cli_init(&cli); cli._OnRead = cli_on_read; cli._OnDisconnect = cli_on_disc; - sleep(1); + sleep(5); while ( cli_ConnectTo(&cli,"192.168.0.1",5555,0)); sleep(1); From b7d0ec5cf5c476da9c81ed65d9e1f7afa4d995d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 13:29:26 +0200 Subject: [PATCH 163/261] merge && test for master --- kernel/tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index fb073fd6..1f3f9d45 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -317,7 +317,7 @@ void* client_task(void* e) cli._OnDisconnect = cli_on_disc; sleep(5); while ( - cli_ConnectTo(&cli,"192.168.0.1",5555,0)); + cli_ConnectTo(&cli,"192.168.0.2",5555,0)); sleep(1); cli_sendBuffer(&cli,"Hallo Welt",sizeof("Hallo Welt")); @@ -411,7 +411,7 @@ int test_init(void) sleep(10); SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",RCCE_ue()); - if (!RCCE_ue()) + if (RCCE_ue()) create_kernel_task(NULL,server_task,NULL); else create_kernel_task(NULL,client_task,NULL); From 015f425075467e87ac4edf5d4b2eecbc87802d3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 13:34:31 +0200 Subject: [PATCH 164/261] merge && test for master --- drivers/net/mmnif.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 5408ac1b..4e0d4b8a 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -760,7 +760,7 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) /* get the palce the router core is looking for the packet */ /* lock the dest_ip mm_rx_buffer_hdr */ - mmnif_lock_rx_hdr(dest_ip); +retry: mmnif_lock_rx_hdr(dest_ip); /* read and edit needed values */ queued = mmnif_read_rx_queue(dest_ip); @@ -772,13 +772,13 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) mmnif_write_rx_pending(dest_ip,pending); /* and unlock the dest_ip mm_rx_buffer_hdr */ - mmnif_unlock_rx_hdr(dest_ip); + mmnif_unlock_rx_hdr(dest_ip); /* check if there is a space in the queue without overwriting another packet */ if ((queued + pending) > MMNIF_RX_QUEUELEN) { DEBUGPRINTF("mmnif_tx(): too many packet's at once for the remote queue : q:%d p:%d\n",queued , pending); - goto drop_packet; + goto retry; } pos = (pos + queued + pending -1) % MMNIF_RX_QUEUELEN; From 2d34553c2cc7d6df2ba8a923fe62049b2328d73c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 14:53:41 +0200 Subject: [PATCH 165/261] merge && test for master --- drivers/net/mmnif.c | 3 ++- kernel/tests.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 4e0d4b8a..907b4768 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -771,7 +771,8 @@ retry: mmnif_lock_rx_hdr(dest_ip); pending++; mmnif_write_rx_pending(dest_ip,pending); - /* and unlock the dest_ip mm_rx_buffer_hdr */ + /* and unlock the dest_ip mm_rx_buffer_hdr */ + mmnif_unlock_rx_hdr(dest_ip); /* check if there is a space in the queue without overwriting another packet */ diff --git a/kernel/tests.c b/kernel/tests.c index 1f3f9d45..c066629f 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -177,7 +177,7 @@ void srv_on_conn(ServerEventArgs* e) kprintf("send with %f kb/s", ((float)i*sizeof(buff))/(tmp2-tmp1)); } -#define SHELLDEBUGPRINTF(x,...) kprintf(x,##__VA_ARGS__); +//#define SHELLDEBUGPRINTF(x,...) kprintf(x,##__VA_ARGS__); void* server_task(void* e) { @@ -411,7 +411,7 @@ int test_init(void) sleep(10); SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",RCCE_ue()); - if (RCCE_ue()) + if (!RCCE_ue()) create_kernel_task(NULL,server_task,NULL); else create_kernel_task(NULL,client_task,NULL); From 82161fc53c8f20d556654e6827a3e64e4e1732b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 14:59:14 +0200 Subject: [PATCH 166/261] merge && test for master --- kernel/shell.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/shell.c b/kernel/shell.c index 2e4a0f2a..4e72b9db 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -31,8 +31,8 @@ void shell_on_connect(ServerEventArgs* e) emac_id = e->ClientID; kprintf("bmc connected"); } - - kprintf("link engaged\n"); + else + kprintf("link engaged\n"); } void shell_on_disconnect(ServerEventArgs* e) From d16fbb31c201ae0cd2d8eca8311235ad0370bc7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 15:01:40 +0200 Subject: [PATCH 167/261] merge && test for master --- kernel/tests.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index c066629f..bd9c733a 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -189,6 +189,8 @@ void* server_task(void* e) srv._OnDisconnect = srv_on_disc; srv._OnConnect = srv_on_conn; + SHELLDEBUGPRINTF("Server is ready..."); + while(1) sleep(2); @@ -316,8 +318,11 @@ void* client_task(void* e) cli._OnRead = cli_on_read; cli._OnDisconnect = cli_on_disc; sleep(5); + + SHELLDEBUGPRINTF("Client is ready..."); + while ( - cli_ConnectTo(&cli,"192.168.0.2",5555,0)); + cli_ConnectTo(&cli,"192.168.0.1",5555,0)); sleep(1); cli_sendBuffer(&cli,"Hallo Welt",sizeof("Hallo Welt")); From 5f258240350e49c5ea288f7d1cdc4911ab82f88e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 15:07:43 +0200 Subject: [PATCH 168/261] merge && test for master --- lwip/src/include/lwipopts.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index 4be7eb4c..a0ada57c 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -105,7 +105,7 @@ #define IP_FORWARD 1 /* DEBUG options */ -#define LWIP_DEBUG 1 +#define LWIP_DEBUG 0 #define DHCP_DEBUG LWIP_DBG_OFF #define ETHARP_DEBUG LWIP_DBG_OFF #define TCPIP_DEBUG LWIP_DBG_OFF @@ -114,7 +114,7 @@ #define MEM_DEBUG LWIP_DBG_OFF #define IP_DEBUG LWIP_DBG_OFF #define INET_DEBUG LWIP_DBG_OFF -#define NETIF_DEBUG LWIP_DBG_ON +#define NETIF_DEBUG LWIP_DBG_OFF #define TIMERS_DEBUG LWIP_DBG_OFF #define SOCKETS_DEBUG LWIP_DBG_OFF From 6c9d0f6b08163e5e3bfcc878876ab2652a05fcb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 15:10:48 +0200 Subject: [PATCH 169/261] merge && test for master --- drivers/net/mmnif.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 907b4768..3f3df57b 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -24,6 +24,7 @@ #include /* tcpip_input()*/ #define DEBUG_MMNIF +#define DEBUG_MMNIF_PACKET #ifdef DEBUG_MMNIF #include "util.h" /* hex dump */ From d963bb694cd720447210bc3f74896fb119b2a305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 15:13:20 +0200 Subject: [PATCH 170/261] merge && test for master --- kernel/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/init.c b/kernel/init.c index 10ca88cc..38da94b8 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -154,8 +154,8 @@ int network_init(void) #endif // start echo and ping server - echo_init(); - ping_init(); +// echo_init(); +// ping_init(); #endif return 0; From a44c26c6cead9be77af13032a1c5f0f07c874c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 15:33:48 +0200 Subject: [PATCH 171/261] merge && test for master --- drivers/net/mmnif.c | 8 ++++---- kernel/init.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 3f3df57b..96632200 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -761,7 +761,7 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) /* get the palce the router core is looking for the packet */ /* lock the dest_ip mm_rx_buffer_hdr */ -retry: mmnif_lock_rx_hdr(dest_ip); + mmnif_lock_rx_hdr(dest_ip); /* read and edit needed values */ queued = mmnif_read_rx_queue(dest_ip); @@ -780,7 +780,7 @@ retry: mmnif_lock_rx_hdr(dest_ip); if ((queued + pending) > MMNIF_RX_QUEUELEN) { DEBUGPRINTF("mmnif_tx(): too many packet's at once for the remote queue : q:%d p:%d\n",queued , pending); - goto retry; + goto drop_packet; } pos = (pos + queued + pending -1) % MMNIF_RX_QUEUELEN; @@ -1330,7 +1330,7 @@ int mmnif_open() } /* set our network interface to the default interface for lwip*/ - netif_set_default(mmnif_dev); +// netif_set_default(mmnif_dev); /* tell lwip all initialization is done and we want to set it ab*/ netif_set_up(mmnif_dev); @@ -1356,7 +1356,7 @@ int mmnif_open() mmnif_worker_schedule(); - mmnif_retrigger_schedule(); +// mmnif_retrigger_schedule(); #ifdef DEBUG_MMNIF DEBUGPRINTF("mmnif_dev is open\n"); diff --git a/kernel/init.c b/kernel/init.c index 38da94b8..7475d2c9 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -154,8 +154,8 @@ int network_init(void) #endif // start echo and ping server -// echo_init(); -// ping_init(); + echo_init(); + ping_init(); #endif return 0; From 5e33d9c1a30ab679d07440bb4f4dd09814009694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 15:35:57 +0200 Subject: [PATCH 172/261] merge && test for master --- kernel/tests.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index bd9c733a..429fc3d0 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -177,7 +177,7 @@ void srv_on_conn(ServerEventArgs* e) kprintf("send with %f kb/s", ((float)i*sizeof(buff))/(tmp2-tmp1)); } -//#define SHELLDEBUGPRINTF(x,...) kprintf(x,##__VA_ARGS__); +#define SHELLDEBUGPRINTF(x,...) kprintf(x,##__VA_ARGS__); void* server_task(void* e) { @@ -411,10 +411,10 @@ int test_init(void) #if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK) - shell_init(RCCE_ue()); + // shell_init(RCCE_ue()); - sleep(10); - SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",RCCE_ue()); +// sleep(10); +// SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",RCCE_ue()); if (!RCCE_ue()) create_kernel_task(NULL,server_task,NULL); From fbc09784622aeb98ad029fabe96edf071f0f3b94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 15:38:40 +0200 Subject: [PATCH 173/261] merge && test for master --- drivers/net/mmnif.c | 2 +- kernel/init.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 96632200..b7b43231 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -1330,7 +1330,7 @@ int mmnif_open() } /* set our network interface to the default interface for lwip*/ -// netif_set_default(mmnif_dev); + netif_set_default(mmnif_dev); /* tell lwip all initialization is done and we want to set it ab*/ netif_set_up(mmnif_dev); diff --git a/kernel/init.c b/kernel/init.c index 7475d2c9..7b987d4a 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -154,8 +154,8 @@ int network_init(void) #endif // start echo and ping server - echo_init(); - ping_init(); + // echo_init(); + // ping_init(); #endif return 0; From a4d5d661d476a8ebeb6712fe935bc2e8eff33269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 15:40:19 +0200 Subject: [PATCH 174/261] merge && test for master --- kernel/tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 429fc3d0..1f1febfe 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -322,7 +322,7 @@ void* client_task(void* e) SHELLDEBUGPRINTF("Client is ready..."); while ( - cli_ConnectTo(&cli,"192.168.0.1",5555,0)); + cli_ConnectTo(&cli,"192.168.0.2",5555,0)); sleep(1); cli_sendBuffer(&cli,"Hallo Welt",sizeof("Hallo Welt")); @@ -416,7 +416,7 @@ int test_init(void) // sleep(10); // SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",RCCE_ue()); - if (!RCCE_ue()) + if (RCCE_ue()) create_kernel_task(NULL,server_task,NULL); else create_kernel_task(NULL,client_task,NULL); From 46ada07578b606c07f8414b4ba3a335e2a4f959d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 15:43:22 +0200 Subject: [PATCH 175/261] merge && test for master --- kernel/init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/init.c b/kernel/init.c index 7b987d4a..e1c4c7f0 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -94,6 +94,8 @@ int network_init(void) reschedule(); } + mmnif_open(); + // Set up the lwIP network interface // Allocate and configure netif default_netif = (struct netif *) mem_malloc(sizeof(struct netif)); @@ -150,7 +152,7 @@ int network_init(void) } } #else - mmnif_open(); +// mmnif_open(); #endif // start echo and ping server From 863c5bf64dc7348a471cf1834d9b05113b7a5b08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 15:49:23 +0200 Subject: [PATCH 176/261] merge && test for master --- kernel/init.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/kernel/init.c b/kernel/init.c index e1c4c7f0..7475d2c9 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -94,8 +94,6 @@ int network_init(void) reschedule(); } - mmnif_open(); - // Set up the lwIP network interface // Allocate and configure netif default_netif = (struct netif *) mem_malloc(sizeof(struct netif)); @@ -152,12 +150,12 @@ int network_init(void) } } #else -// mmnif_open(); + mmnif_open(); #endif // start echo and ping server - // echo_init(); - // ping_init(); + echo_init(); + ping_init(); #endif return 0; From d2f5149fb8b3040c05f886bedf8d0050fa53fa4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 15:56:58 +0200 Subject: [PATCH 177/261] ... --- kernel/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/init.c b/kernel/init.c index 7475d2c9..44f96d71 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -150,7 +150,7 @@ int network_init(void) } } #else - mmnif_open(); +// mmnif_open(); #endif // start echo and ping server From 5ae9d126e39556f3de07344a7763bf610d028efb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 16:00:32 +0200 Subject: [PATCH 178/261] ... --- kernel/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/init.c b/kernel/init.c index 44f96d71..7475d2c9 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -150,7 +150,7 @@ int network_init(void) } } #else -// mmnif_open(); + mmnif_open(); #endif // start echo and ping server From 3f738461d17c892a2063ad29d94c4edaffb544c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 16:02:37 +0200 Subject: [PATCH 179/261] ... --- drivers/net/mmnif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index b7b43231..74d1ab92 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -1301,7 +1301,7 @@ int mmnif_open() /* calculate my own ip address from core number * Note: core 1 is the router core */ - IP4_ADDR(&gw, 0,0,0,0); + IP4_ADDR(&gw, 192,168,4,254); IP4_ADDR(&ipaddr, 192,168,0,RCCE_ue() +1); IP4_ADDR(&netmask, 255,255,255,0); From 07e62905814e3beade4fbd47955e3db0d121b0fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 16:16:53 +0200 Subject: [PATCH 180/261] ... --- drivers/net/mmnif.c | 2 +- kernel/tests.c | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 74d1ab92..f4e398b5 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -1301,7 +1301,7 @@ int mmnif_open() /* calculate my own ip address from core number * Note: core 1 is the router core */ - IP4_ADDR(&gw, 192,168,4,254); + IP4_ADDR(&gw, 0,0,0,0); IP4_ADDR(&ipaddr, 192,168,0,RCCE_ue() +1); IP4_ADDR(&netmask, 255,255,255,0); diff --git a/kernel/tests.c b/kernel/tests.c index 1f1febfe..6557e275 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -177,7 +177,7 @@ void srv_on_conn(ServerEventArgs* e) kprintf("send with %f kb/s", ((float)i*sizeof(buff))/(tmp2-tmp1)); } -#define SHELLDEBUGPRINTF(x,...) kprintf(x,##__VA_ARGS__); +//#define SHELLDEBUGPRINTF(x,...) kprintf(x,##__VA_ARGS__); void* server_task(void* e) { @@ -322,7 +322,7 @@ void* client_task(void* e) SHELLDEBUGPRINTF("Client is ready..."); while ( - cli_ConnectTo(&cli,"192.168.0.2",5555,0)); + cli_ConnectTo(&cli,"192.168.0.1",5555,0)); sleep(1); cli_sendBuffer(&cli,"Hallo Welt",sizeof("Hallo Welt")); @@ -411,15 +411,16 @@ int test_init(void) #if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK) - // shell_init(RCCE_ue()); + shell_init(RCCE_ue()); -// sleep(10); -// SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",RCCE_ue()); + sleep(10); + SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",RCCE_ue()); + + if (!RCCE_ue()) + create_kernel_task(NULL,server_task,NULL); + else + create_kernel_task(NULL,client_task,NULL); - if (RCCE_ue()) - create_kernel_task(NULL,server_task,NULL); - else - create_kernel_task(NULL,client_task,NULL); #endif // create_kernel_task(NULL, foo, "Hello from foo1"); From e474cd4fe61db33025679ec5a745dc679e293857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 16:30:25 +0200 Subject: [PATCH 181/261] ... --- kernel/init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/init.c b/kernel/init.c index 7475d2c9..df935abe 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -94,6 +94,8 @@ int network_init(void) reschedule(); } + mmnif_open(); + // Set up the lwIP network interface // Allocate and configure netif default_netif = (struct netif *) mem_malloc(sizeof(struct netif)); @@ -150,7 +152,7 @@ int network_init(void) } } #else - mmnif_open(); + // mmnif_open(); #endif // start echo and ping server From eb25d1ceccba1643126a2fb2a48c0ae5e208a75f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 16:39:04 +0200 Subject: [PATCH 182/261] ... --- kernel/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/init.c b/kernel/init.c index df935abe..8ca2b327 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -156,8 +156,8 @@ int network_init(void) #endif // start echo and ping server - echo_init(); - ping_init(); + // echo_init(); + // ping_init(); #endif return 0; From 37127cc5f247936d4bf4c47f44af9609b5d5f4c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 16:42:45 +0200 Subject: [PATCH 183/261] ... --- drivers/net/mmnif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index f4e398b5..d43d06cc 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -24,7 +24,7 @@ #include /* tcpip_input()*/ #define DEBUG_MMNIF -#define DEBUG_MMNIF_PACKET +//#define DEBUG_MMNIF_PACKET #ifdef DEBUG_MMNIF #include "util.h" /* hex dump */ From cf8f64fc6b64d1addc842930be272d24c98054b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 16:45:27 +0200 Subject: [PATCH 184/261] ... --- drivers/net/mmnif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index d43d06cc..f4e398b5 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -24,7 +24,7 @@ #include /* tcpip_input()*/ #define DEBUG_MMNIF -//#define DEBUG_MMNIF_PACKET +#define DEBUG_MMNIF_PACKET #ifdef DEBUG_MMNIF #include "util.h" /* hex dump */ From 12634a27a5b71185ced070af9d5751c7843cb1cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 16:47:45 +0200 Subject: [PATCH 185/261] ... --- drivers/net/mmnif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index f4e398b5..d43d06cc 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -24,7 +24,7 @@ #include /* tcpip_input()*/ #define DEBUG_MMNIF -#define DEBUG_MMNIF_PACKET +//#define DEBUG_MMNIF_PACKET #ifdef DEBUG_MMNIF #include "util.h" /* hex dump */ From dd1581c0e97bf3d2b30411c4aedb4e6427f9939e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 16:50:50 +0200 Subject: [PATCH 186/261] ... --- kernel/shell.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/shell.c b/kernel/shell.c index 4e72b9db..3c7c40a5 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -26,7 +26,8 @@ void shelldebugprint(char* x) void shell_on_connect(ServerEventArgs* e) { - if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr > 0xC0A80031 || srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr < 0xC0A80001) + // if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr > 0xC0A80031 || srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr < 0xC0A80001) + if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr != 0xC0A80002 ) { emac_id = e->ClientID; kprintf("bmc connected"); From 6444969e21e892040a116df388d9b9e044f5d0ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 16:51:48 +0200 Subject: [PATCH 187/261] ... --- kernel/shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/shell.c b/kernel/shell.c index 3c7c40a5..ee7663d6 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -27,7 +27,7 @@ void shelldebugprint(char* x) void shell_on_connect(ServerEventArgs* e) { // if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr > 0xC0A80031 || srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr < 0xC0A80001) - if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr != 0xC0A80002 ) + if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr != 0xC0A80402 ) { emac_id = e->ClientID; kprintf("bmc connected"); From ecc5087a7647849e8ee040b75289c4e53bbbeea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 16:54:19 +0200 Subject: [PATCH 188/261] ... --- kernel/shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/shell.c b/kernel/shell.c index ee7663d6..cbd444e7 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -27,7 +27,7 @@ void shelldebugprint(char* x) void shell_on_connect(ServerEventArgs* e) { // if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr > 0xC0A80031 || srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr < 0xC0A80001) - if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr != 0xC0A80402 ) + if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr == 0xC0A804FE ) { emac_id = e->ClientID; kprintf("bmc connected"); From f63bf4212e769c538ee1b355b9ce6d999860ba05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 16:57:56 +0200 Subject: [PATCH 189/261] ... --- kernel/shell.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/shell.c b/kernel/shell.c index cbd444e7..6de61dc6 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -26,8 +26,9 @@ void shelldebugprint(char* x) void shell_on_connect(ServerEventArgs* e) { + kprintf("connection from %s:%d",inet_ntoa(srv.ConnectionsAddr[e->ClientID].sin_addr),ntohs(srv.ConnectionsAddr[e->ClientID].sin_port)); // if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr > 0xC0A80031 || srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr < 0xC0A80001) - if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr == 0xC0A804FE ) + if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr == 0xC0A804FF ) { emac_id = e->ClientID; kprintf("bmc connected"); From 1eee6a584cd86938d350341281894a5cfb4be30b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 16:59:34 +0200 Subject: [PATCH 190/261] ... --- kernel/shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/shell.c b/kernel/shell.c index 6de61dc6..09f806fd 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -28,7 +28,7 @@ void shell_on_connect(ServerEventArgs* e) { kprintf("connection from %s:%d",inet_ntoa(srv.ConnectionsAddr[e->ClientID].sin_addr),ntohs(srv.ConnectionsAddr[e->ClientID].sin_port)); // if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr > 0xC0A80031 || srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr < 0xC0A80001) - if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr == 0xC0A804FF ) + if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr == 0xC0A804FE ) { emac_id = e->ClientID; kprintf("bmc connected"); From df7b18fe828b2d4048a069e5d58358edc7cc1e18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 17:01:34 +0200 Subject: [PATCH 191/261] ... --- kernel/shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/shell.c b/kernel/shell.c index 09f806fd..f7cc7171 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -28,7 +28,7 @@ void shell_on_connect(ServerEventArgs* e) { kprintf("connection from %s:%d",inet_ntoa(srv.ConnectionsAddr[e->ClientID].sin_addr),ntohs(srv.ConnectionsAddr[e->ClientID].sin_port)); // if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr > 0xC0A80031 || srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr < 0xC0A80001) - if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr == 0xC0A804FE ) + if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr == 0xC0A804FE) { emac_id = e->ClientID; kprintf("bmc connected"); From 5f5fc245617aa263de2f5c51e3a58a1a5f305a52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 17:04:31 +0200 Subject: [PATCH 192/261] ... --- kernel/shell.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/shell.c b/kernel/shell.c index f7cc7171..138d6574 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -27,6 +27,7 @@ void shelldebugprint(char* x) void shell_on_connect(ServerEventArgs* e) { kprintf("connection from %s:%d",inet_ntoa(srv.ConnectionsAddr[e->ClientID].sin_addr),ntohs(srv.ConnectionsAddr[e->ClientID].sin_port)); + kprintf("connehx: 0x%.8X",srv.ConnectionsAddr[e->ClientID].sin_addr); // if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr > 0xC0A80031 || srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr < 0xC0A80001) if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr == 0xC0A804FE) { From 88136238c3c57ce0aebdcf02a43df4a79d959591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 17:05:44 +0200 Subject: [PATCH 193/261] ... --- kernel/shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/shell.c b/kernel/shell.c index 138d6574..0b822d35 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -29,7 +29,7 @@ void shell_on_connect(ServerEventArgs* e) kprintf("connection from %s:%d",inet_ntoa(srv.ConnectionsAddr[e->ClientID].sin_addr),ntohs(srv.ConnectionsAddr[e->ClientID].sin_port)); kprintf("connehx: 0x%.8X",srv.ConnectionsAddr[e->ClientID].sin_addr); // if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr > 0xC0A80031 || srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr < 0xC0A80001) - if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr == 0xC0A804FE) + if (srv.ConnectionsAddr[e->ClientID].sin_addr.s_addr == 0xFE04A8C0) { emac_id = e->ClientID; kprintf("bmc connected"); From 3bbe2894a2fa3e02c1117a42fd2122cf1bc4ad34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 17:08:13 +0200 Subject: [PATCH 194/261] ... --- kernel/tests.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 6557e275..69c05685 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -156,7 +156,7 @@ void srv_on_conn(ServerEventArgs* e) int tmp1,tmp2; char buff[32]; - kprintf("someone finally connected\n"); + SHELLDEBUGPRINTF("someone finally connected\n"); tmp1 = get_clock_tick(); for (i = 0; i < 1024*4*4*4; i++) @@ -167,7 +167,7 @@ void srv_on_conn(ServerEventArgs* e) if ( err < 0) SHELLDEBUGPRINTF("err: %d", err); - if (!(i%100)) + if (!(i%1)) SHELLDEBUGPRINTF("\r-%d-",i); // Sleep(10); @@ -189,7 +189,7 @@ void* server_task(void* e) srv._OnDisconnect = srv_on_disc; srv._OnConnect = srv_on_conn; - SHELLDEBUGPRINTF("Server is ready..."); + SHELLDEBUGPRINTF("Server is ready...\n"); while(1) sleep(2); @@ -319,7 +319,7 @@ void* client_task(void* e) cli._OnDisconnect = cli_on_disc; sleep(5); - SHELLDEBUGPRINTF("Client is ready..."); + SHELLDEBUGPRINTF("Client is ready...\n"); while ( cli_ConnectTo(&cli,"192.168.0.1",5555,0)); From 49ca88cf2167d50effb36ecbee0c070f00db03fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 17:11:32 +0200 Subject: [PATCH 195/261] ... --- kernel/tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 69c05685..5bd8407e 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -321,8 +321,8 @@ void* client_task(void* e) SHELLDEBUGPRINTF("Client is ready...\n"); - while ( - cli_ConnectTo(&cli,"192.168.0.1",5555,0)); + while (cli_ConnectTo(&cli,"192.168.0.1",5555,0)) + SHELLDEBUGPRINTF("retry connect\n"); sleep(1); cli_sendBuffer(&cli,"Hallo Welt",sizeof("Hallo Welt")); From c9b07ee579b1240ff9affcc476ac19912cb3756e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 17:13:08 +0200 Subject: [PATCH 196/261] ... --- kernel/tests.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/tests.c b/kernel/tests.c index 5bd8407e..dd7d6839 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -322,7 +322,9 @@ void* client_task(void* e) SHELLDEBUGPRINTF("Client is ready...\n"); while (cli_ConnectTo(&cli,"192.168.0.1",5555,0)) + { SHELLDEBUGPRINTF("retry connect\n"); + } sleep(1); cli_sendBuffer(&cli,"Hallo Welt",sizeof("Hallo Welt")); From 80728c19c5b61b1a1b9e22864f604649d108b8d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 17:15:57 +0200 Subject: [PATCH 197/261] ... --- kernel/tests.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/tests.c b/kernel/tests.c index dd7d6839..6b0bfbb2 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -325,6 +325,7 @@ void* client_task(void* e) { SHELLDEBUGPRINTF("retry connect\n"); } + SHELLDEBUGPRINTF("connected\n"); sleep(1); cli_sendBuffer(&cli,"Hallo Welt",sizeof("Hallo Welt")); From 9cb2b8afa50b512cf3d81d2d19606a9e2679fb63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 17:21:45 +0200 Subject: [PATCH 198/261] ... --- kernel/tests.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/tests.c b/kernel/tests.c index 6b0bfbb2..1d4093a3 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -156,6 +156,7 @@ void srv_on_conn(ServerEventArgs* e) int tmp1,tmp2; char buff[32]; + kprintf("someone finally connected\n"); SHELLDEBUGPRINTF("someone finally connected\n"); tmp1 = get_clock_tick(); From 825f180141bf327d9692ee70f4b461eee500fb95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 17:26:18 +0200 Subject: [PATCH 199/261] ... --- kernel/shell.c | 1 + kernel/tests.c | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/kernel/shell.c b/kernel/shell.c index 0b822d35..d955c5ea 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -49,6 +49,7 @@ void shell_on_read(ServerEventArgs* e) srv_sendBuffer(&srv,emac_id,e->pBuffer,e->dwLen); // else commandos oder so + srv_sendBuffer(&srv,emac_id,e->pBuffer,e->dwLen); } void shell_init(int srv_or_cli) diff --git a/kernel/tests.c b/kernel/tests.c index 1d4093a3..677dd537 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -157,7 +157,7 @@ void srv_on_conn(ServerEventArgs* e) char buff[32]; kprintf("someone finally connected\n"); - SHELLDEBUGPRINTF("someone finally connected\n"); + shelldebugprint("someone finally connected\n"); tmp1 = get_clock_tick(); for (i = 0; i < 1024*4*4*4; i++) @@ -190,7 +190,7 @@ void* server_task(void* e) srv._OnDisconnect = srv_on_disc; srv._OnConnect = srv_on_conn; - SHELLDEBUGPRINTF("Server is ready...\n"); + shelldebugprint("Server is ready...\n"); while(1) sleep(2); @@ -320,16 +320,16 @@ void* client_task(void* e) cli._OnDisconnect = cli_on_disc; sleep(5); - SHELLDEBUGPRINTF("Client is ready...\n"); + shelldebugprint("Client is ready...\n"); while (cli_ConnectTo(&cli,"192.168.0.1",5555,0)) { - SHELLDEBUGPRINTF("retry connect\n"); + shelldebugprint("retry connect\n"); } - SHELLDEBUGPRINTF("connected\n"); + shelldebugprint("connected\n"); sleep(1); cli_sendBuffer(&cli,"Hallo Welt",sizeof("Hallo Welt")); - + shelldebugprint("send message\n"); while(1) sleep(2); From ce95bd3b7c9984e45578d5c4539c744003be2cd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 17:29:11 +0200 Subject: [PATCH 200/261] ... --- kernel/tests.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 677dd537..cd530bc4 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -182,14 +182,13 @@ void srv_on_conn(ServerEventArgs* e) void* server_task(void* e) { - - - server_init(&srv,5555,2); kprintf("created server\n"); srv._OnRead = srv_on_read; srv._OnDisconnect = srv_on_disc; srv._OnConnect = srv_on_conn; + server_init(&srv,5555,2); + shelldebugprint("Server is ready...\n"); while(1) From c68844575ca579df2df272e9ced46d692c48a1df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 17:33:44 +0200 Subject: [PATCH 201/261] ... --- kernel/tests.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index cd530bc4..0aa1ec03 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -310,7 +310,7 @@ void cli_on_disc(ClientEventArgs*e ) void* client_task(void* e) { - + int err = 0; Client cli; char netbuffer[256]; kprintf("created client"); @@ -319,16 +319,16 @@ void* client_task(void* e) cli._OnDisconnect = cli_on_disc; sleep(5); - shelldebugprint("Client is ready...\n"); + SHELLDEBUGPRINTF("Client is ready...\n"); while (cli_ConnectTo(&cli,"192.168.0.1",5555,0)) { - shelldebugprint("retry connect\n"); + SHELLDEBUGPRINTF("retry connect\n"); } - shelldebugprint("connected\n"); + SHELLDEBUGPRINTF("connected\n"); sleep(1); - cli_sendBuffer(&cli,"Hallo Welt",sizeof("Hallo Welt")); - shelldebugprint("send message\n"); + err = cli_sendBuffer(&cli,"Hallo Welt",sizeof("Hallo Welt")); + SHELLDEBUGPRINTF("send message err = %d\n",err); while(1) sleep(2); From 1ac47406c15b112488342f397e9e5c59fa5bd6c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 17:35:30 +0200 Subject: [PATCH 202/261] ... --- kernel/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/client.c b/kernel/client.c index dd9fab03..876e883b 100644 --- a/kernel/client.c +++ b/kernel/client.c @@ -21,7 +21,7 @@ int cli_sendBuffer(Client* cli,void* pBuffer, unsigned int bufferlen) return iResult; } else - return -1; + return -2; } int cli_ConnectTo(Client* cli,char * pAdresse,unsigned short Port,int webAdresse) From fafb24235fd2b80a040dccd69ad6b80e0743a578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 17:37:20 +0200 Subject: [PATCH 203/261] ... --- kernel/client.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/client.c b/kernel/client.c index 876e883b..b88a0c69 100644 --- a/kernel/client.c +++ b/kernel/client.c @@ -31,6 +31,8 @@ int cli_ConnectTo(Client* cli,char * pAdresse,unsigned short Port,int webAdresse cli->wPort=Port; cli->adAddr.sin_port = htons(cli->wPort); + if (cli->sSocket == SOCKET_ERROR) + return -2; if (webAdresse) //Fall es sich um eine Internet Adresse Handelt return -1; From 7c015f53c3065f6bd532d5a028793c919ce88a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 17:43:36 +0200 Subject: [PATCH 204/261] ... --- kernel/shell.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/shell.c b/kernel/shell.c index d955c5ea..b7df2362 100644 --- a/kernel/shell.c +++ b/kernel/shell.c @@ -47,9 +47,9 @@ void shell_on_read(ServerEventArgs* e) { if (emac_id != -1 && e->ClientID != emac_id) srv_sendBuffer(&srv,emac_id,e->pBuffer,e->dwLen); - + else // else commandos oder so - srv_sendBuffer(&srv,emac_id,e->pBuffer,e->dwLen); + srv_sendBuffer(&srv,emac_id,e->pBuffer,e->dwLen); } void shell_init(int srv_or_cli) From 5d2b31e198ea0aea817fcd6c88bba86b98774e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Tue, 2 Aug 2011 17:47:23 +0200 Subject: [PATCH 205/261] ... --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 0aa1ec03..81347215 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -321,7 +321,7 @@ void* client_task(void* e) SHELLDEBUGPRINTF("Client is ready...\n"); - while (cli_ConnectTo(&cli,"192.168.0.1",5555,0)) + while (cli_ConnectTo(&cli,"192.168.0.1",5555,0) != 0) { SHELLDEBUGPRINTF("retry connect\n"); } From 577300919c6bb2a92ebc8f7178f250b4ac623fb8 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 3 Aug 2011 07:37:57 +0200 Subject: [PATCH 206/261] fix bug in search_apic and uses function to find the MP Config Table --- arch/x86/kernel/apic.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/apic.c b/arch/x86/kernel/apic.c index a916222c..29033d0e 100644 --- a/arch/x86/kernel/apic.c +++ b/arch/x86/kernel/apic.c @@ -327,14 +327,17 @@ void smp_start(uint32_t id) } #endif -#ifndef CONFIG_MULTIBOOT +#if 1 static apic_mp_t* search_apic(size_t base, size_t limit) { size_t ptr; + apic_mp_t* tmp; for (ptr=base; ptr<=limit-sizeof(uint32_t); ptr++) { - if (*((uint32_t*) ptr) == MP_FLT_SIGNATURE) { - if (!(((apic_mp_t*)ptr)->version > 4) && ((apic_mp_t*)ptr)->features[0]) - return (apic_mp_t*) ptr; + tmp = (apic_mp_t*) ptr; + + if (tmp->signature == MP_FLT_SIGNATURE) { + if (!((tmp->version > 4) || tmp->features[0])) + return tmp; } } @@ -561,7 +564,7 @@ static int apic_probe(void) uint32_t i, count; int isa_bus = -1; -#ifndef CONFIG_MULTIBOOT +#if 1 apic_mp = search_apic(0xF0000, 0x100000); if (apic_mp) goto found_mp; @@ -590,7 +593,7 @@ static int apic_probe(void) for(i=0; (ilen-sizeof(uint32_t)) && (addr < 0x0FFFFF); i++, addr++) { if (*((uint32_t*) addr) == MP_FLT_SIGNATURE) { apic_mp = (apic_mp_t*) addr; - if (!(apic_mp->version > 4) && apic_mp->features[0]) + if (!((apic_mp->version > 4) || apic_mp->features[0])) goto found_mp; } } From aef29d7484899351f52601b6981359ffdd130df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Wed, 3 Aug 2011 13:36:46 +0200 Subject: [PATCH 207/261] ... --- kernel/tests.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 81347215..7058ea96 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -183,11 +183,14 @@ void srv_on_conn(ServerEventArgs* e) void* server_task(void* e) { kprintf("created server\n"); + + + server_init(&srv,5555,2); + srv._OnRead = srv_on_read; srv._OnDisconnect = srv_on_disc; srv._OnConnect = srv_on_conn; - server_init(&srv,5555,2); shelldebugprint("Server is ready...\n"); From b33ee0bdf4f260370d69b61de6f6432c9312e105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Wed, 3 Aug 2011 13:43:50 +0200 Subject: [PATCH 208/261] ... --- kernel/tests.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 7058ea96..70484a4c 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -313,7 +313,7 @@ void cli_on_disc(ClientEventArgs*e ) void* client_task(void* e) { - int err = 0; + int err = -2; Client cli; char netbuffer[256]; kprintf("created client"); @@ -324,9 +324,10 @@ void* client_task(void* e) SHELLDEBUGPRINTF("Client is ready...\n"); - while (cli_ConnectTo(&cli,"192.168.0.1",5555,0) != 0) + while (err) { - SHELLDEBUGPRINTF("retry connect\n"); + SHELLDEBUGPRINTF("retry connect err = %d\n",err); + err = cli_ConnectTo(&cli,"192.168.0.1",5555,0); } SHELLDEBUGPRINTF("connected\n"); sleep(1); From 15d479862fcf6166c544a96c8f9633a65ecee0e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Wed, 3 Aug 2011 13:47:06 +0200 Subject: [PATCH 209/261] ... --- kernel/client.c | 4 ++-- kernel/tests.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/client.c b/kernel/client.c index b88a0c69..3206a2bd 100644 --- a/kernel/client.c +++ b/kernel/client.c @@ -21,8 +21,8 @@ int cli_sendBuffer(Client* cli,void* pBuffer, unsigned int bufferlen) return iResult; } else - return -2; - } + return -3; +} int cli_ConnectTo(Client* cli,char * pAdresse,unsigned short Port,int webAdresse) { diff --git a/kernel/tests.c b/kernel/tests.c index 70484a4c..d890e302 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -326,8 +326,8 @@ void* client_task(void* e) while (err) { - SHELLDEBUGPRINTF("retry connect err = %d\n",err); err = cli_ConnectTo(&cli,"192.168.0.1",5555,0); + SHELLDEBUGPRINTF("retry connect err = %d socket: %d\n",err,cli.sSocket); } SHELLDEBUGPRINTF("connected\n"); sleep(1); From c121c38912d75bdcafd51e290a2f0b48267b9f1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Wed, 3 Aug 2011 13:52:15 +0200 Subject: [PATCH 210/261] ... --- kernel/client.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/client.c b/kernel/client.c index 3206a2bd..c4c9f120 100644 --- a/kernel/client.c +++ b/kernel/client.c @@ -9,8 +9,8 @@ int cli_sendBuffer(Client* cli,void* pBuffer, unsigned int bufferlen) int iResult; ClientEventArgs e; //abfragen ob client existiert!! wichtig - if (cli->sSocket != SOCKET_ERROR) - { +// if (cli->sSocket != SOCKET_ERROR) +// { iResult= send(cli->sSocket,(char*)pBuffer,bufferlen,0); if (cli->_OnWrite != 0) { @@ -19,9 +19,9 @@ int cli_sendBuffer(Client* cli,void* pBuffer, unsigned int bufferlen) cli->_OnWrite(&e); } return iResult; - } - else - return -3; +// } +// else +// return -3; } int cli_ConnectTo(Client* cli,char * pAdresse,unsigned short Port,int webAdresse) From b89c4096a598202425258af5009d84ba519c33a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Wed, 3 Aug 2011 13:54:36 +0200 Subject: [PATCH 211/261] ... --- kernel/client.c | 12 ++++++------ kernel/tests.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/kernel/client.c b/kernel/client.c index c4c9f120..386e69a7 100644 --- a/kernel/client.c +++ b/kernel/client.c @@ -9,9 +9,9 @@ int cli_sendBuffer(Client* cli,void* pBuffer, unsigned int bufferlen) int iResult; ClientEventArgs e; //abfragen ob client existiert!! wichtig -// if (cli->sSocket != SOCKET_ERROR) -// { - iResult= send(cli->sSocket,(char*)pBuffer,bufferlen,0); + if (cli->sSocket != SOCKET_ERROR) + { + iResult= send(cli->sSocket,(char*)pBuffer,bufferlen,0); if (cli->_OnWrite != 0) { e.dwLen = iResult; @@ -19,9 +19,9 @@ int cli_sendBuffer(Client* cli,void* pBuffer, unsigned int bufferlen) cli->_OnWrite(&e); } return iResult; -// } -// else -// return -3; + } + else + return -3; } int cli_ConnectTo(Client* cli,char * pAdresse,unsigned short Port,int webAdresse) diff --git a/kernel/tests.c b/kernel/tests.c index d890e302..7af0cc1a 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -326,7 +326,7 @@ void* client_task(void* e) while (err) { - err = cli_ConnectTo(&cli,"192.168.0.1",5555,0); + err = cli_ConnectTo(&cli,"192.168.0.2",5555,0); SHELLDEBUGPRINTF("retry connect err = %d socket: %d\n",err,cli.sSocket); } SHELLDEBUGPRINTF("connected\n"); @@ -423,7 +423,7 @@ int test_init(void) sleep(10); SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",RCCE_ue()); - if (!RCCE_ue()) + if (RCCE_ue()) create_kernel_task(NULL,server_task,NULL); else create_kernel_task(NULL,client_task,NULL); From 8c666c22e1ee5b3c4b80e375648fa0bee5bc6253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Wed, 3 Aug 2011 13:58:44 +0200 Subject: [PATCH 212/261] ... --- drivers/net/mmnif.c | 2 +- kernel/tests.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index d43d06cc..494f83d6 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -1356,7 +1356,7 @@ int mmnif_open() mmnif_worker_schedule(); -// mmnif_retrigger_schedule(); + mmnif_retrigger_schedule(); #ifdef DEBUG_MMNIF DEBUGPRINTF("mmnif_dev is open\n"); diff --git a/kernel/tests.c b/kernel/tests.c index 7af0cc1a..0bb08aa0 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -162,13 +162,13 @@ void srv_on_conn(ServerEventArgs* e) tmp1 = get_clock_tick(); for (i = 0; i < 1024*4*4*4; i++) { - sleep(1); +// sleep(1); err = srv_sendBuffer(&srv,e->ClientID,buff,sizeof(buff)); if ( err < 0) SHELLDEBUGPRINTF("err: %d", err); - if (!(i%1)) + if (!(i%10)) SHELLDEBUGPRINTF("\r-%d-",i); // Sleep(10); From 9fd0cbd57c89e8bf62d2c166cff8a1df052a8665 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Wed, 3 Aug 2011 14:03:06 +0200 Subject: [PATCH 213/261] ... --- kernel/tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 0bb08aa0..c4dacce5 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -154,7 +154,7 @@ void srv_on_conn(ServerEventArgs* e) { int i = 0, err = 0; int tmp1,tmp2; - char buff[32]; + char buff[1024]; kprintf("someone finally connected\n"); shelldebugprint("someone finally connected\n"); @@ -206,7 +206,7 @@ void* server_task(void* e) int n; uint64_t tmp1,tmp2; int err; - +t /* First call to socket() function */ sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (sockfd < 0) From fd69e3705bc9af2597069826505687e43917a773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Wed, 3 Aug 2011 14:17:10 +0200 Subject: [PATCH 214/261] ... --- kernel/tests.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index c4dacce5..9885c567 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -157,7 +157,7 @@ void srv_on_conn(ServerEventArgs* e) char buff[1024]; kprintf("someone finally connected\n"); - shelldebugprint("someone finally connected\n"); +// shelldebugprint("someone finally connected\n"); tmp1 = get_clock_tick(); for (i = 0; i < 1024*4*4*4; i++) @@ -166,10 +166,12 @@ void srv_on_conn(ServerEventArgs* e) err = srv_sendBuffer(&srv,e->ClientID,buff,sizeof(buff)); if ( err < 0) - SHELLDEBUGPRINTF("err: %d", err); +// SHELLDEBUGPRINTF("err: %d", err); + kprintf("err: %d", err); if (!(i%10)) - SHELLDEBUGPRINTF("\r-%d-",i); +// SHELLDEBUGPRINTF("\r-%d-",i); + kprintf("\r-%d-",i); // Sleep(10); } @@ -192,7 +194,7 @@ void* server_task(void* e) srv._OnConnect = srv_on_conn; - shelldebugprint("Server is ready...\n"); +// shelldebugprint("Server is ready...\n"); while(1) sleep(2); @@ -322,17 +324,21 @@ void* client_task(void* e) cli._OnDisconnect = cli_on_disc; sleep(5); - SHELLDEBUGPRINTF("Client is ready...\n"); + // SHELLDEBUGPRINTF("Client is ready...\n"); + SHELLDEBUGPRINTF("Client is ready...\n"); while (err) { - err = cli_ConnectTo(&cli,"192.168.0.2",5555,0); - SHELLDEBUGPRINTF("retry connect err = %d socket: %d\n",err,cli.sSocket); + err = cli_ConnectTo(&cli,"192.168.0.1",5555,0); + // SHELLDEBUGPRINTF("retry connect err = %d socket: %d\n",err,cli.sSocket); + kprintf("Client is ready...\n"); } - SHELLDEBUGPRINTF("connected\n"); +// SHELLDEBUGPRINTF("connected\n"); + kprintf("Client is ready...\n"); sleep(1); err = cli_sendBuffer(&cli,"Hallo Welt",sizeof("Hallo Welt")); - SHELLDEBUGPRINTF("send message err = %d\n",err); +// SHELLDEBUGPRINTF("send message err = %d\n",err); + kprintf("Client is ready...\n"); while(1) sleep(2); @@ -418,12 +424,12 @@ int test_init(void) #if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK) - shell_init(RCCE_ue()); +// shell_init(RCCE_ue()); - sleep(10); - SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",RCCE_ue()); + // sleep(10); + // SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",RCCE_ue()); - if (RCCE_ue()) + if (!RCCE_ue()) create_kernel_task(NULL,server_task,NULL); else create_kernel_task(NULL,client_task,NULL); From f2fc8c73b3dc120f5f626870f24554205e625a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Wed, 3 Aug 2011 14:19:43 +0200 Subject: [PATCH 215/261] ... --- kernel/tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 9885c567..5d33dd1b 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -154,13 +154,13 @@ void srv_on_conn(ServerEventArgs* e) { int i = 0, err = 0; int tmp1,tmp2; - char buff[1024]; + char buff[256]; kprintf("someone finally connected\n"); // shelldebugprint("someone finally connected\n"); tmp1 = get_clock_tick(); - for (i = 0; i < 1024*4*4*4; i++) + for (i = 0; i < 1024*4; i++) { // sleep(1); From 22dab5969937a8512eb73e883cec5366e01df428 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 3 Aug 2011 15:10:58 +0200 Subject: [PATCH 216/261] minor changes in the scheduler routine to relalize a fair round-robin scheduling --- kernel/tasks.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/kernel/tasks.c b/kernel/tasks.c index 6800e662..00e23098 100644 --- a/kernel/tasks.c +++ b/kernel/tasks.c @@ -789,6 +789,15 @@ int block_task(tid_t id) return ret; } +/* + * we use this struct to guarantee that the id + * has its own cache line + */ +typedef struct { + uint32_t id __attribute__ ((aligned (CACHE_LINE))); + uint8_t gap[CACHE_LINE-sizeof(uint32_t)]; +} last_id_t; + /** @brief _The_ scheduler procedure * * Manages scheduling - right now this is just a round robin scheduler. @@ -797,8 +806,9 @@ void scheduler(void) { task_t* orig_task; task_t* curr_task; - unsigned int i; - unsigned int new_id; + uint32_t i; + uint32_t new_id; + static last_id_t last_id = { 0 }; #if MAX_CORES > 1 spinlock_irqsave_lock(&table_lock); @@ -816,7 +826,7 @@ void scheduler(void) curr_task->flags &= ~TASK_FPU_USED; } - for(i=1, new_id=(curr_task->id + 1) % MAX_TASKS; + for(i=1, new_id=(last_id.id + 1) % MAX_TASKS; istatus = TASK_READY; task_table[new_id].status = TASK_RUNNING; curr_task = per_core(current_task) = task_table+new_id; + last_id.id = new_id; goto get_task_out; } From 452aa3b1d193baa3c07f830041e55587f8b4b3d5 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 3 Aug 2011 19:37:05 +0200 Subject: [PATCH 217/261] cosmetic changes and add some scheduling statistics --- arch/x86/include/asm/processor.h | 4 ++-- arch/x86/include/asm/tasks.h | 5 +++++ arch/x86/kernel/apic.c | 6 +++--- include/metalsvm/tasks_types.h | 10 ++++++---- kernel/main.c | 1 + kernel/tasks.c | 27 +++++++++++++++++++++++++-- kernel/tests.c | 2 ++ 7 files changed, 44 insertions(+), 11 deletions(-) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 91f30387..da3b3556 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -42,9 +42,9 @@ extern "C" { // feature list 1 #define CPU_FEATURE_FPU (1 << 0) #define CPU_FEATURE_MMX (1 << 23) -#define CPU_FEATURE_FXSR (1 << 24) +#define CPU_FEATURE_FXSR (1 << 24) #define CPU_FEATURE_SSE (1 << 25) -#define CPU_FEATURE_SSE2 (1 << 26) +#define CPU_FEATURE_SSE2 (1 << 26) // feature list 2 #define CPU_FEATURE_AVX (1 << 28) diff --git a/arch/x86/include/asm/tasks.h b/arch/x86/include/asm/tasks.h index c12f946a..d2cf6731 100644 --- a/arch/x86/include/asm/tasks.h +++ b/arch/x86/include/asm/tasks.h @@ -36,6 +36,11 @@ extern "C" { #endif +/** + * @brief Dump some scheduling statistics + */ +int dump_scheduling_statistics(void); + /** @brief Fork a task from current task * * @param task Pointer to the task structure to fork to diff --git a/arch/x86/kernel/apic.c b/arch/x86/kernel/apic.c index 29033d0e..0651750e 100644 --- a/arch/x86/kernel/apic.c +++ b/arch/x86/kernel/apic.c @@ -301,9 +301,6 @@ void smp_start(uint32_t id) // install IDT idt_install(); - // enable additional cpu features - cpu_detection(); - /* enable paging */ write_cr3((uint32_t)get_boot_pgd()); i = read_cr0(); @@ -320,6 +317,9 @@ void smp_start(uint32_t id) */ register_task(per_core(current_task)); + // enable additional cpu features + cpu_detection(); + smp_main(); // idle loop diff --git a/include/metalsvm/tasks_types.h b/include/metalsvm/tasks_types.h index 9725454b..f63ae533 100644 --- a/include/metalsvm/tasks_types.h +++ b/include/metalsvm/tasks_types.h @@ -41,11 +41,11 @@ extern "C" { #endif #define TASK_INVALID 0 -#define TASK_READY 1 +#define TASK_READY 1 #define TASK_RUNNING 2 #define TASK_BLOCKED 3 #define TASK_FINISHED 4 -#define TASK_IDLE 5 +#define TASK_IDLE 5 #define TASK_DEFAULT_FLAGS 0 #define TASK_FPU_INIT (1 << 0) @@ -61,8 +61,10 @@ typedef struct task { tid_t id; /// Task status (INVALID, READY, RUNNING, ...) uint32_t status; + /// Number of used time slices + uint32_t time_slices; /// Usage in number of pages - atomic_int32_t user_usage; + atomic_int32_t user_usage; /// Avoids concurrent access to the page directory spinlock_t pgd_lock; /// pointer to the page directory @@ -85,7 +87,7 @@ typedef struct task { mailbox_wait_msg_t* outbox[MAX_TASKS]; /// FPU state union fpu_state fpu; -} __attribute__((packed)) task_t; +} task_t; #ifdef __cplusplus } diff --git a/kernel/main.c b/kernel/main.c index 86646610..8b54795f 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -128,6 +128,7 @@ int main(void) list_root(); test_init(); per_core(current_task)->status = TASK_IDLE; + per_core(current_task)->time_slices = 0; // reset the number of time slices reschedule(); while(1) { diff --git a/kernel/tasks.c b/kernel/tasks.c index 00e23098..95c4c1ed 100644 --- a/kernel/tasks.c +++ b/kernel/tasks.c @@ -47,8 +47,8 @@ * A task's id will be its position in this array. */ static task_t task_table[MAX_TASKS] = { \ - [0] = {0, TASK_RUNNING, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0, 0}, \ - [1 ... MAX_TASKS-1] = {0, TASK_INVALID, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0, 0}}; + [0] = {0, TASK_RUNNING, 0, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0, 0}, \ + [1 ... MAX_TASKS-1] = {0, TASK_INVALID, 0, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0, 0}}; static spinlock_irqsave_t table_lock = SPINLOCK_IRQSAVE_INIT; DEFINE_PER_CORE(task_t*, current_task, task_table+0); @@ -63,6 +63,24 @@ task_t* get_current_task(void) { return per_core(current_task); } +int dump_scheduling_statistics(void) +{ + uint32_t i; + uint32_t id = 0; + + kprintf("Scheduling statistics:\n"); + kprintf("======================\n"); + kprintf("total ticks:\t%llu\n", get_clock_tick()); + for(i=0; itime_slices++; + /* signalizes that this task could be reused */ if (curr_task->status == TASK_FINISHED) curr_task->status = TASK_INVALID; diff --git a/kernel/tests.c b/kernel/tests.c index ecef70c2..bced389b 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -121,6 +121,8 @@ static int join_test(void* arg) kprintf("Child %u finished: result = %d\n", id, result); + dump_scheduling_statistics(); + return 0; } From 40230ade507748b936be007b33eed441f9d84ae6 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 3 Aug 2011 21:38:40 +0200 Subject: [PATCH 218/261] avoid unneeded using of per_core macro --- include/metalsvm/semaphore.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/metalsvm/semaphore.h b/include/metalsvm/semaphore.h index 735c0e78..42348383 100644 --- a/include/metalsvm/semaphore.h +++ b/include/metalsvm/semaphore.h @@ -83,6 +83,8 @@ inline static int sem_destroy(sem_t* s) { * - -1 on failure */ inline static int sem_wait(sem_t* s) { + task_t* curr_task = per_core(current_task); + if (BUILTIN_EXPECT(!s, 0)) return -1; @@ -92,9 +94,9 @@ next_try: s->value--; spinlock_unlock(&s->lock); } else { - s->queue[s->pos] = per_core(current_task)->id; + s->queue[s->pos] = curr_task->id; s->pos = (s->pos + 1) % MAX_TASKS; - block_task(per_core(current_task)->id); + block_task(curr_task->id); spinlock_unlock(&s->lock); reschedule(); goto next_try; From 2e1cfd7965eeb061c08c8d99a1f50a5423b040d8 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 3 Aug 2011 21:40:07 +0200 Subject: [PATCH 219/261] fix wrong data type and wrong using of create_kernel_task --- lwip/src/arch/sys_arch.c | 2 +- lwip/src/include/arch/sys_arch.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lwip/src/arch/sys_arch.c b/lwip/src/arch/sys_arch.c index 47c6e6ec..b9b2d7db 100644 --- a/lwip/src/arch/sys_arch.c +++ b/lwip/src/arch/sys_arch.c @@ -82,7 +82,7 @@ sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, tid_t tmp; kprintf("Create LWIP task %s\n", name); - create_kernel_task(&tmp,thread,arg); + create_kernel_task(&tmp, thread, arg); return tmp; } diff --git a/lwip/src/include/arch/sys_arch.h b/lwip/src/include/arch/sys_arch.h index eab88cb5..6857d983 100644 --- a/lwip/src/include/arch/sys_arch.h +++ b/lwip/src/include/arch/sys_arch.h @@ -21,7 +21,7 @@ typedef struct int valid; } sys_mbox_t; -typedef tid_t* sys_thread_t; +typedef tid_t sys_thread_t; #if SYS_LIGHTWEIGHT_PROT #if MAX_CORES > 1 From 22441375bb2253b0f1f82f6ef5e4d6fb4cade0dd Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 3 Aug 2011 21:41:06 +0200 Subject: [PATCH 220/261] add blocking timers only the idle tasks use the polling mode --- arch/x86/kernel/timer.c | 56 ++++++++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/arch/x86/kernel/timer.c b/arch/x86/kernel/timer.c index 251f71f8..66c4ac82 100644 --- a/arch/x86/kernel/timer.c +++ b/arch/x86/kernel/timer.c @@ -23,17 +23,26 @@ #include #include #include +#include #include #include #include #include #include +typedef struct { + uint8_t active; + uint64_t timeout; +} timer_t; + +static timer_t timers[MAX_TASKS] = {[0 ... MAX_TASKS-1] = {0, 0}}; +static spinlock_irqsave_t timers_lock = SPINLOCK_IRQSAVE_INIT; + /* * This will keep track of how many ticks the system * has been running for */ -static volatile uint64_t timer_ticks __attribute__ ((aligned (CACHE_LINE))) = 0; +static volatile uint64_t timer_ticks = 0; uint64_t get_clock_tick(void) { @@ -60,13 +69,24 @@ int sys_times(struct tms* buffer, clock_t* clock) */ static void timer_handler(struct state *s) { + uint32_t i; + /* Increment our 'tick counter' */ #if MAX_CORES > 1 if (smp_id() == 0) - timer_ticks++; -#else - timer_ticks++; #endif + { + timer_ticks++; + + spinlock_irqsave_lock(&timers_lock); + for(i=1; i= timers[i].timeout)) { + timers[i].active = 0; + wakeup_task(i); + } + } + spinlock_irqsave_unlock(&timers_lock); + } /* * Every TIMER_FREQ clocks (approximately 1 second), we will @@ -84,15 +104,33 @@ static void timer_handler(struct state *s) void timer_wait(unsigned int ticks) { uint64_t eticks = timer_ticks + ticks; + task_t* curr_task = per_core(current_task); - while (timer_ticks < eticks) { + // Task 0 is always an idle task + // Perhaps, the status is not set correctly... + if ((curr_task->status == TASK_IDLE) || (curr_task->id == 0)) + { + while (timer_ticks < eticks) { + check_workqueues(); + + // recheck break condition + if (timer_ticks >= eticks) + break; + + HALT; + } + } else if (timer_ticks < eticks) { check_workqueues(); - // recheck break condition - if (timer_ticks >= eticks) - break; + spinlock_irqsave_lock(&timers_lock); + if (timer_ticks < eticks) { + timers[curr_task->id].active = 1; + timers[curr_task->id].timeout = eticks; + block_task(curr_task->id); + spinlock_irqsave_unlock(&timers_lock); - reschedule(); + reschedule(); + } else spinlock_irqsave_unlock(&timers_lock); } } From 7f4d3b3f9d5c4ddd7f93827aab3228e681d4621b Mon Sep 17 00:00:00 2001 From: "U-MobileHooK\\Benedikt" Date: Thu, 4 Aug 2011 14:22:44 +0200 Subject: [PATCH 221/261] test out new buffer implementation --- drivers/net/mmnif.c | 1073 +++++++++++++++---------------------------- 1 file changed, 383 insertions(+), 690 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 494f83d6..6ef8c66a 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -12,6 +12,10 @@ #include "mmnif.h" /* definitions */ #ifdef WIN32 +#define kmalloc malloc +#define kfree(x,y) free(x) +#define RCCE_shfree(x) VirtualFree(x,NULL,NULL); + #include "mailbox.h" /* mailbox_ptr_t */ #else #include /* mailbox_ptr_t */ @@ -65,19 +69,27 @@ extern HANDLE hProc; #endif -#define MMNIF_TX_QUEUELEN 4 -#define MMNIF_RX_QUEUELEN 8 - -#define MMNIF_RX_BUFFERLEN 1792 #define MMNIF_TX_BUFFERLEN 1792 +#define MMNIF_TX_QUEUELEN 4 -#define MMNIF_CORES 2 +#define MMNIF_RX_BUFFERLEN 8192 +#define MMNIF_MAX_DESCRIPTORS 32 + +#define MMNIF_CORES 2 #define MMNIF_WORKER_BUDGET 4 #define MMNIF_POLL_BUDGET 0x100000 #define MMNIF_WAIT_BUDGET 0x2 + +#define MMNIF_STATUS_FREE 0x00 +#define MMNIF_STATUS_PENDING 0x01 +#define MMNIF_STATUS_RDY 0x02 +#define MMNIF_STATUS_INPROC 0x03 +#define MMNIF_STATUS_PROC 0x04 + + /* decide whether it's polling mode or not */ static int no_irq = 0; @@ -107,24 +119,9 @@ static unsigned int router_ip_address = 0xC0A80001; /* 192.168.0.1 */ char* mpb_start_address = NULL; unsigned int mpb_size = NULL; - -/* Register offset for the CONFIG and LOCK registers */ -#define RCK_GLCFG0 0x10 -#define RCK_GLCFG1 0x18 -#define RCK_TILEID 0x100 - -#define RCK_TILE_SIZE 0x01000000 - -/* Start address of the local register bank */ -static int local_crb = 0xF8000000; - /* just set and reset the irq */ static int pulse_irq = 0; -/* Mask of the interrupt bits */ -#define RCK_INTR_MASK 0x00000002 -#define RCK_NMI_MASK 0x00000001 - /* * the memory mapped network device */ @@ -167,38 +164,40 @@ typedef struct mmnif_device_stats } mmnif_device_stats_t; +typedef struct rx_desc +{ + uint8_t stat; + uint16_t len; + uint32_t addr; + +} rx_desc_t; + +/* receive ring buffer structure */ typedef struct mm_rx_buffer { - /* memory rx buffer build - * - queued : how many packets are in the queue - * - pos : which is the next packet to be worked on - * - pending : how many packets are pending - * - iv_intr : inform via interrupt or not - * - lock: semaphore to lock the local variables to be multi access save - * - * Note: this section will soon be complexer. - * I won't use a single buffer the whole time. I think i will use an descripor table - * and a table which descriptor is in use and use the buffer space dynamically with - * descriptors - * Also timeouts should be checked so if one core dies the buffer space is not blocked - * all the time + /* + * */ - uint8_t queued; - uint8_t pos; - uint8_t pending; + uint16_t iv_intr; + uint16_t roffset; + uint16_t woffset; + uint32_t head; + uint32_t tail; + uint16_t tot_bytes; + uint16_t free_bytes; + uint16_t free_bytes_head; + uint16_t free_bytes_tail; + spinlock_t wlock; + spinlock_t rlock; + /* + * + */ + rx_desc_t desc_table[MMNIF_MAX_DESCRIPTORS]; + uint8_t dcount; + uint8_t dread; + uint8_t dwrite; + spinlock_t dlock; - uint8_t iv_intr; - -// sem_t lock; - spinlock_t lock; - -// uint32_t timestamp[MMNIF_RX_QUEUELEN]; -// uint32_t bitmap[MMNIF_RX_QUEUELEN]; - -// void* rx_desc[MMNIF_CORES * MMNIF_RX_QUEUELEN]; -// uint8_t rx_inuse[MMNIF_CORES * MMNIF_RX_QUEUELEN]; /* bits 1: pending 2: finished 3: free ...*/ -// uint8_t fin; -// uint8_t* data[MMNIF_RX_QUEUELEN]; } mm_rx_buffer_t; typedef struct mmnif @@ -209,7 +208,7 @@ typedef struct mmnif * - ehternet address * - local ip address */ - struct eth_addr* ethaddr; + struct eth_addr* ethaddr; uint32_t ipaddr; /* memory interaction variables: @@ -219,186 +218,36 @@ typedef struct mmnif */ uint8_t tx_queue; uint8_t* tx_buff[MMNIF_TX_QUEUELEN]; - mm_rx_buffer_t* rx_buff; + mm_rx_buffer_t* rx_buff; + + spinlock_t lock; sem_t com_poll; /* comunication mailbox */ - mailbox_ptr_t mbox; + mailbox_ptr_t mbox; }mmnif_t; #ifdef WIN32 - -__inline int RCCE_ue(void) -{ +__inline int RCCE_ue(void){ #ifndef RECV return 1; #else return 0; #endif } - #endif /* * memory maped interface helper functions */ - -/* read the queue value from the remote buffer - * and return it. - */ -__inline uint8_t mmnif_read_rx_queue(uint32_t dest_ip) -{ #ifdef WIN32 - /* Read the value of the forgein process - * form rx_buff->queued - */ - mm_rx_buffer_t hdr; - while(!ReadProcessMemory(hProc,(char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,&hdr,sizeof(hdr),NULL)); - return hdr.queued; +#define __MEMCPY(x,y,z) memcpy(x,y,z) #else - mm_rx_buffer_t hdr; - memcpy(&hdr,(char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,sizeof(hdr)); - return hdr.queued; +#define __MEMCPY(x,y,z) memcpy(x,y,z) #endif -}; - -/* read the pos value from the remote buffer - * and return it. - */ -__inline uint8_t mmnif_read_rx_pos(uint32_t dest_ip) -{ -#ifdef WIN32 - /* Read the value of the forgein process - * form rx_buff->pos - */ - mm_rx_buffer_t hdr; - while(!ReadProcessMemory(hProc,(char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,&hdr,sizeof(hdr),NULL)); - return hdr.pos; -#else - mm_rx_buffer_t hdr; - memcpy(&hdr,(char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,sizeof(hdr)); - return hdr.pos; -#endif -}; - -/* read the inv_intr from the remote buffer - * and return it. - */ -__inline uint8_t mmnif_read_rx_inv_intr(uint32_t dest_ip) -{ -#ifdef WIN32 - /* Read the value of the forgein process - * form rx_buff->inv_intr - */ - mm_rx_buffer_t hdr; - while(!ReadProcessMemory(hProc,(char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,&hdr,sizeof(hdr),NULL)); - return hdr.iv_intr; -#else - mm_rx_buffer_t hdr; - memcpy(&hdr,(char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,sizeof(hdr)); - return hdr.iv_intr; -#endif -}; - -/* read the pending value from the remote buffer - * and return it. - */ -__inline uint8_t mmnif_read_rx_pending(uint32_t dest_ip) -{ -#ifdef WIN32 - /* Read the value of the forgein process - * form rx_buff->pending - */ - mm_rx_buffer_t hdr; - while(!ReadProcessMemory(hProc,(char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,&hdr,sizeof(hdr),NULL)); - return hdr.pending; -#else - mm_rx_buffer_t hdr; - memcpy(&hdr,(char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,sizeof(hdr)); - return hdr.pending; -#endif -}; - -/* write data to the remote buffer - * - */ -__inline int mmnif_write_rx_buff(uint32_t dest_ip, uint32_t pos,void* data) -{ -#ifdef WIN32 - /* we assume this is a correct buffer - * therefore here is no further error checking - */ - uint32_t nr_of_bytes_written = 0; - uint16_t length = *((uint16_t*)data); - while(!WriteProcessMemory(hProc,(char*)mpb_start_address +(dest_ip -1 ) * mpb_size + sizeof(mm_rx_buffer_t)+ pos * MMNIF_RX_BUFFERLEN,data,length+2,&nr_of_bytes_written)); - return nr_of_bytes_written; -#else - uint16_t length = *((uint16_t*)data); - memcpy((char*)mpb_start_address +(dest_ip -1 ) * mpb_size + sizeof(mm_rx_buffer_t)+ pos * MMNIF_RX_BUFFERLEN,data,length+2); - return 1; -#endif -}; - -__inline int mmnif_write_rx_buffl(uint32_t dest_ip, uint32_t pos,void* data,uint16_t length) -{ -#ifdef WIN32 - /* we assume this is a correct buffer - * therefore here is no further error checking - */ - uint32_t nr_of_bytes_written = 0; - while(!WriteProcessMemory(hProc,(char*)mpb_start_address +(dest_ip -1 ) * mpb_size + sizeof(mm_rx_buffer_t)+ pos * MMNIF_RX_BUFFERLEN,&length,2,&nr_of_bytes_written)); - while(!WriteProcessMemory(hProc,(char*)mpb_start_address +(dest_ip -1 ) * mpb_size + sizeof(mm_rx_buffer_t)+ pos * MMNIF_RX_BUFFERLEN + 2,data,length,&nr_of_bytes_written)); - return nr_of_bytes_written+2; -#else -// uint16_t length = *((uint16_t*)data); - memcpy((char*)mpb_start_address +(dest_ip -1 ) * mpb_size + sizeof(mm_rx_buffer_t)+ pos * MMNIF_RX_BUFFERLEN,&length,2); - memcpy((char*)mpb_start_address +(dest_ip -1 ) * mpb_size + sizeof(mm_rx_buffer_t)+ pos * MMNIF_RX_BUFFERLEN + 2,data,length); - return 1; -#endif -}; - -/* write the new queue value to the remote buffer - * - */ -__inline int mmnif_write_rx_queue(uint32_t dest_ip,uint8_t queue) -{ - /* tell the remote buffer/process - * that there is another packet in the queue - */ -#ifdef WIN32 - uint32_t nr_of_bytes_written = 0; - while(!WriteProcessMemory(hProc,(char*)mpb_start_address + ( dest_ip -1 ) * mpb_size ,&queue,1,&nr_of_bytes_written)); - return nr_of_bytes_written; -#else - - memcpy((char*)mpb_start_address + ( dest_ip -1 ) * mpb_size ,&queue,1); - - return 1; -#endif -}; - -/* write the new queue value to the remote buffer - * - */ -__inline int mmnif_write_rx_pending(uint32_t dest_ip,uint8_t pending) -{ - /* tell the remote buffer/process - * that there is another packet in the queue - */ -#ifdef WIN32 - uint32_t nr_of_bytes_written = 0; - while(!WriteProcessMemory(hProc,(char*)mpb_start_address + ( dest_ip -1 ) * mpb_size + 2 ,&pending,1,&nr_of_bytes_written)); - return nr_of_bytes_written; -#else - - memcpy((char*)mpb_start_address + ( dest_ip -1 ) * mpb_size + 2 , &pending,1); - - return 1; -#endif -}; /* trigger an interrupt on the remote processor * @@ -406,40 +255,8 @@ __inline int mmnif_write_rx_pending(uint32_t dest_ip,uint8_t pending) __inline int mmnif_trigger_irq(dest_ip) { #ifdef WIN32 - return PulseEvent(remote_process_event); + return SetEvent(remote_process_event); #else -#if 0 - /* NOTE: have to check how the remote interrupt managment works - * on the SCC - */ - mmnif_t* mmnif = mmnif_dev->state; - int core = (dest_ip - 1) % 2; - int irq_address = mmnif->crb[dest_ip-1]; - unsigned int value; - - if (core == 0) irq_address += RCK_GLCFG0; - else irq_address += RCK_GLCFG1; - - /**/ - value = ReadConfigReg((void*)irq_address); - - if ((!pulse_irq) && (value & RCK_INTR_MASK)) - { - value &= (~(RCK_INTR_MASK|RCK_NMI_MASK)); - SetConfigReg((void*)irq_address,value); - } - - value |= RCK_INTR_MASK; - SetConfigReg((void*) irq_address,value); - - /**/ - if (pulse_irq) - { - value &= (~(RCK_INTR_MASK|RCK_NMI_MASK)); - SetConfigReg((void*)irq_address,value); - } -#endif - int tmp, x, y, z, addr; int ue = dest_ip -1; @@ -461,52 +278,7 @@ __inline int mmnif_trigger_irq(dest_ip) #endif }; -/* mmnif_device_schedule() : - * if there is no interupt used to indicate new packets - * this creates a polling thread which looks for data - * itself - */ -__inline int mmnif_device_schedule() -{ -#ifdef WIN32 - bthread_create(&polling_thread,NULL,mmnif_poll,NULL); - return NULL; -#else - create_kernel_task(&polling_thread,mmnif_poll,NULL); - return NULL; -#endif -} -/* mmnif_worker_schedule() : - * if there is no interupt used to indicate new packets - * this creates a polling thread which looks for data - * itself - */ -__inline int mmnif_worker_schedule() -{ -#ifdef WIN32 - bthread_create(&worker_thread,NULL,mmnif_worker,NULL); - return NULL; -#else - create_kernel_task(&worker_thread,mmnif_worker,NULL); - return NULL; -#endif -} -void* mmnif_retrigger(void* e) -{ - while(active) - { - sleep(1); - mmnif_irqhandler(); - } - return NULL; -} - -__inline int mmnif_retrigger_schedule() -{ - tid_t tmp; - create_kernel_task(&tmp,mmnif_retrigger,NULL); -} /* Allocate Shared Memory for communication this could be: * - in Message Passing Buffer * - Shared Memory Address Space (0x8000000 + ) @@ -516,67 +288,20 @@ __inline int mmnif_retrigger_schedule() __inline void* mmnif_shmalloc() { #ifdef WIN32 - mpb_size = sizeof(mm_rx_buffer_t) + MMNIF_RX_QUEUELEN* MMNIF_RX_BUFFERLEN; + mpb_size = sizeof(mm_rx_buffer_t) + MMNIF_RX_BUFFERLEN; mpb_start_address = VirtualAlloc((char*)0x41000000 /*+ (mpb_size) * (own_ip_address - router_ip_address)*/, mpb_size *MMNIF_CORES,MEM_COMMIT|MEM_RESERVE,PAGE_READWRITE); return (char*)0x41000000 + (mpb_size) * (own_ip_address - router_ip_address); #else - mpb_size = (sizeof(mm_rx_buffer_t) + MMNIF_RX_QUEUELEN* MMNIF_RX_BUFFERLEN); + mpb_size = (sizeof(mm_rx_buffer_t) + MMNIF_RX_BUFFERLEN); mpb_start_address = RCCE_shmalloc(mpb_size*MMNIF_CORES); return mpb_start_address + (mpb_size) * (own_ip_address - router_ip_address); #endif } -/* mmnif_lock_rx_hdr(): lock the header of mm_rx_buffer - * so there is no race condition on the variables - */ -__inline void mmnif_lock_rx_hdr(int dest_ip) -{ -#ifdef WIN32 -// mm_rx_buffer_t hdr; -// if(disable_locking) return; -// while(!ReadProcessMemory(hProc,(char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,&hdr,sizeof(hdr),NULL)); -// ReadProcessMemory(hProc,(char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,&hdr,sizeof(hdr),NULL); -// sem_wait(&hdr.lock); - - if (dest_ip != own_ip_address && 0xFF) - return WaitForSingleObject(remote_process_mutex,INFINITE); - else - return WaitForSingleObject(own_process_mutex,INFINITE); - -#else - if(disable_locking) return; - mm_rx_buffer_t* hdr = (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size; -// sem_wait(&hdr->lock); - spinlock_lock(&hdr->lock); -#endif -} -/* mmnif_unlock_rx_hdr(): unlock the header - * again - */ -__inline void mmnif_unlock_rx_hdr(int dest_ip) -{ -#ifdef WIN32 -// mm_rx_buffer_t hdr; -// if(disable_locking) return; -// while(!ReadProcessMemory(hProc,(char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,&hdr,sizeof(hdr),NULL)); -// ReadProcessMemory(hProc,(char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,&hdr,sizeof(hdr),NULL); -// sem_post(&hdr.lock); - if (dest_ip != own_ip_address && 0xFF) - return ReleaseMutex(remote_process_mutex); - else - return ReleaseMutex(own_process_mutex); -#else - if(disable_locking) return; - mm_rx_buffer_t* hdr = (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size; -// sem_post(&hdr->lock); - spinlock_unlock(&hdr->lock); -#endif -} - /* mmnif_timestamp(): genereate a timestamp for the * packets */ @@ -651,7 +376,6 @@ uint8_t mmnif_get_destination(struct netif* netif, struct pbuf* p) uint8_t addr[4]; uint32_t netmask = 0xFFFFFF00; - /* grab the destination ip address out of the ip header * for internal routing the last ocet is interpreted as core ID. */ @@ -672,8 +396,6 @@ uint8_t mmnif_get_destination(struct netif* netif, struct pbuf* p) if (!((netmask & *(uint32_t*)addr) == (netmask & own_ip_address) )) return 1; - - core = addr[0]; /* check if the address is legitimata else return router core again */ @@ -681,9 +403,173 @@ uint8_t mmnif_get_destination(struct netif* netif, struct pbuf* p) core = 1; return core; - } +/* + * + */ +uint32_t mmnif_rxbuff_alloc(uint8_t dest,uint16_t len) +{ + mmnif_t* mmnif = mmnif_dev->state; + mm_rx_buffer_t* rb = (mm_rx_buffer_t*)((char*)mpb_start_address + ( dest -1 ) * mpb_size); + char* memblock = (char*)rb + sizeof(mm_rx_buffer_t); + + uint32_t ret; + + spinlock_lock(&rb->dlock); + + if (rb->dcount) + { + if (rb->woffset > rb->roffset) + { + if (MMNIF_RX_BUFFERLEN - rb->woffset > len) + { + rb->desc_table[rb->dwrite].stat = MMNIF_STATUS_PENDING; + ret = memblock + rb->woffset; + rb->desc_table[rb->dwrite].addr = ret; + rb->desc_table[rb->dwrite].len = len; + rb->dcount--; + rb->dwrite = (++rb->dwrite)%MMNIF_MAX_DESCRIPTORS; + + rb->woffset = (rb->woffset + len); + spinlock_unlock(&rb->dlock); + return ret; + } + else if (rb->roffset > len) + { + rb->desc_table[rb->dwrite].stat = MMNIF_STATUS_PENDING; + ret = memblock; + rb->desc_table[rb->dwrite].addr = ret; + rb->desc_table[rb->dwrite].len = len; + rb->dcount--; + rb->dwrite = (++rb->dwrite)%MMNIF_MAX_DESCRIPTORS; + + rb->woffset = len; + spinlock_unlock(&rb->dlock); + return ret; + } + else + { + spinlock_unlock(&rb->dlock); + return NULL; + } + } + else + { + if (rb->roffset - rb->woffset > len) + { + rb->desc_table[rb->dwrite].stat = MMNIF_STATUS_PENDING; + ret = memblock + rb->woffset; + rb->desc_table[rb->dwrite].addr = ret; + rb->desc_table[rb->dwrite].len = len; + rb->dcount--; + rb->dwrite = (++rb->dwrite)%MMNIF_MAX_DESCRIPTORS; + + rb->woffset = (rb->woffset + len); + spinlock_unlock(&rb->dlock); + return ret; + } + else if (rb->woffset == rb->roffset) + { + if (MMNIF_RX_BUFFERLEN - rb->woffset < len) + { + rb->woffset = 0; + if (rb->dread == rb->dwrite) + rb->roffset = 0; + } + + rb->desc_table[rb->dwrite].stat = MMNIF_STATUS_PENDING; + ret = memblock + rb->woffset; + rb->desc_table[rb->dwrite].addr = ret; + rb->desc_table[rb->dwrite].len = len; + rb->dcount--; + rb->dwrite = (++rb->dwrite)%MMNIF_MAX_DESCRIPTORS; + + rb->woffset = (rb->woffset + len); + spinlock_unlock(&rb->dlock); + return ret; + } + else + { + spinlock_unlock(&rb->dlock); + return NULL; + } + } + } + else + { + spinlock_unlock(&rb->dlock); + return NULL; + } +} + +/* + * + */ +int mmnif_commit_packet(uint8_t dest,uint32_t addr) +{ + mmnif_t* mmnif = mmnif_dev->state; + mm_rx_buffer_t* rb = (mm_rx_buffer_t*)((char*)mpb_start_address + ( dest -1 ) * mpb_size); + uint32_t i; + + for (i = 0; i < MMNIF_MAX_DESCRIPTORS; i++) + { + if (rb->desc_table[i].addr == addr && rb->desc_table[i].stat == MMNIF_STATUS_PENDING) + { + rb->desc_table[i].stat = MMNIF_STATUS_RDY; + return 0; + } + } + return -1; +} +/* + * + */ +void mmnif_rxbuff_free() +{ + mmnif_t* mmnif = mmnif_dev->state; + mm_rx_buffer_t* b = mmnif->rx_buff; + uint32_t i,j; + uint32_t rpos; + + spinlock_lock(&b->dlock); + + rpos = b->dread; + + for (i = 0, j = rpos; i < MMNIF_MAX_DESCRIPTORS; i++) + { + j = (j+i)%MMNIF_MAX_DESCRIPTORS; + + if (b->desc_table[j].stat == MMNIF_STATUS_PROC) + { + b->dcount++; + b->dread = (b->dread +1)%MMNIF_MAX_DESCRIPTORS; + b->desc_table[j].stat = MMNIF_STATUS_FREE; + + if (b->woffset > b->roffset) + { + b->roffset += b->desc_table[j].len; + } + else + { + if ( (b->desc_table[(j+1)%MMNIF_MAX_DESCRIPTORS].stat != MMNIF_STATUS_FREE ) + && ( b->desc_table[j].addr > b->desc_table[(j+1)%MMNIF_MAX_DESCRIPTORS].addr)) + { + b->roffset = 0; + + } + else + { + b->roffset += b->desc_table[j].len; + } + } + } + else + break; + } + + spinlock_unlock(&b->dlock); +} /* * Transmid a packet (called by the lwip) */ @@ -691,41 +577,43 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) { mmnif_t* mmnif = netif->state; uint8_t slot = mmnif->tx_queue; - uint8_t queued; - uint8_t pos; - uint8_t pending; + + uint16_t queued; + uint32_t write_address; uint32_t i; struct pbuf* q; /* interator */ + uint8_t build_buff = TRUE; uint8_t dest_intr = FALSE; + uint32_t dest_ip = mmnif_get_destination(netif,p); -// mmnif_lock_rx_hdr(dest_ip); - /* take a place in the tx_queue */ -// InterlockedIncrement(&mmnif->tx_queue); +#ifdef WIN32 + ReadProcessMemory(hProc, (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size, + (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,mpb_size,NULL); + WaitForSingleObject(remote_process_mutex,INFINITE); +#endif + + spinlock_lock(&mmnif->lock); mmnif->tx_queue++; + spinlock_unlock(&mmnif->lock); + /* Perform serveral sanity checks on the packet and the buffers: * - is the queue full? * - is the output packet to big? - * - * - * HINT: MMNIF_TX_QUEUELEN should be 1 as long there is no mutex availible to ensure - * just one thread is writing to pos and queue of the mm_rx_buff */ if (mmnif->tx_queue > MMNIF_TX_QUEUELEN) { DEBUGPRINTF("mmnif_tx(): too many packets at once for tx_queue\n"); - mmnif->tx_queue--; - goto drop_packet_fast; + goto drop_packet; } if (p->tot_len > MMNIF_TX_BUFFERLEN) { - DEBUGPRINTF("mmnif_tx(): packet is longer than 1792 bytes\n"); - mmnif->tx_queue--; - goto drop_packet_fast; + DEBUGPRINTF("mmnif_tx(): packet is longer than %d bytes\n",MMNIF_TX_BUFFERLEN); + goto drop_packet; } /* check if the pbuf consists only of one element @@ -738,120 +626,80 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) if (build_buff) { - /* write packet length to start transmit buffer */ - *((unsigned short*)mmnif->tx_buff[slot]) = p->tot_len; - /* build the payload out of the p's * ensure that the packet is in one memory chunk stored in the transmid buffer */ - for (q = p, i = 2; q != 0; q = q->next) + for (q = p, i = 0; q != 0; q = q->next) { memcpy(mmnif->tx_buff[slot] + i, q->payload, q->len); i += q->len; } } - else - { - /* because there is no copy operation to the tx_slots - * we don't need a place in the queue anymore - */ -// mmnif->tx_queue--; -// InterlockedDecrement(&mmnif->tx_queue); - } - /* get the palce the router core is looking for the packet */ - /* lock the dest_ip mm_rx_buffer_hdr */ - mmnif_lock_rx_hdr(dest_ip); + /* lookup writeoffset and allocate needed space in the remote buffer */ - /* read and edit needed values */ - queued = mmnif_read_rx_queue(dest_ip); - pos = mmnif_read_rx_pos(dest_ip); + write_address = mmnif_rxbuff_alloc(dest_ip,p->tot_len); - pending = mmnif_read_rx_pending(dest_ip); - - pending++; - mmnif_write_rx_pending(dest_ip,pending); - - /* and unlock the dest_ip mm_rx_buffer_hdr */ - - mmnif_unlock_rx_hdr(dest_ip); - - /* check if there is a space in the queue without overwriting another packet */ - if ((queued + pending) > MMNIF_RX_QUEUELEN) - { - DEBUGPRINTF("mmnif_tx(): too many packet's at once for the remote queue : q:%d p:%d\n",queued , pending); - goto drop_packet; - } - - pos = (pos + queued + pending -1) % MMNIF_RX_QUEUELEN; + if (!write_address) + goto drop_packet; /* write buffer to buffer & increment the queued packet count * this can be safely done without locking because this place is * reserved for us because it has the status "pending" */ if (build_buff) - mmnif_write_rx_buff(dest_ip, pos, mmnif->tx_buff[slot]); + memcpy(write_address,mmnif->tx_buff[slot],p->tot_len); else - mmnif_write_rx_buffl(dest_ip, pos, p->payload,p->tot_len); + memcpy(write_address,p->payload,p->tot_len); - /* like above ensure we are the only ones editing the hdr */ - mmnif_lock_rx_hdr(dest_ip); - - queued = mmnif_read_rx_queue(dest_ip); - pending = mmnif_read_rx_pending(dest_ip); - queued++; - pending--; - - dest_intr = mmnif_read_rx_inv_intr(dest_ip); + if (mmnif_commit_packet(dest_ip,write_address)) + { + DEBUGPRINTF("mmnif_tx(): packet somehow lost on commit\n"); + } + #ifdef DEBUG_MMNIF_PACKET DEBUGPRINTF("\n SEND 0x%.8X with length: %d\n",(char*)mpb_start_address + (dest_ip -1)*mpb_size + pos * 1792,p->tot_len +2); hex_dump(p->tot_len, p->payload); #endif - mmnif_write_rx_queue(dest_ip, queued); - mmnif_write_rx_pending(dest_ip, pending); - - mmnif_unlock_rx_hdr(dest_ip); - - /* if driver is not in polling mode inform core that a message has arrived */ - if (dest_intr) - mmnif_trigger_irq(dest_ip); - - /* free the transmid queue*/ -// if(build_buff) + spinlock_lock(&mmnif->lock); mmnif->tx_queue--; -// InterlockedDecrement(&mmnif->tx_queue); + spinlock_unlock(&mmnif->lock); - /* gather stats: - * - firstly for lwip - * - secondly for us - */ - LINK_STATS_INC(link.xmit); mmnif->stats.tx++; mmnif->stats.tx_bytes += p->tot_len; -// mmnif_unlock_rx_hdr(dest_ip); +#ifdef WIN32 + WriteProcessMemory(hProc, (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size, + (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,mpb_size,NULL); + + SetEvent(remote_process_event); + + ReleaseMutex(remote_process_mutex); +#endif + + mmnif_trigger_irq(dest_ip); + return ERR_OK; -drop_packet: /* packet is lost. clean up and gather stats */ - - mmnif_lock_rx_hdr(dest_ip); - - pending = mmnif_read_rx_pending(dest_ip); - pending--; - mmnif_write_rx_pending(dest_ip, pending); - - mmnif_unlock_rx_hdr(dest_ip); -drop_packet_fast: +drop_packet: + spinlock_lock(&mmnif->lock); + mmnif->tx_queue--; + spinlock_unlock(&mmnif->lock); + LINK_STATS_INC(link.drop); - mmnif->stats.tx_err++; - return ERR_IF; +#ifdef WIN32 + WriteProcessMemory(hProc, (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size, + (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,mpb_size,NULL); +#endif + + return ERR_IF; } /* mmnif_link_layer(): wrapper function called by ip_output() @@ -873,17 +721,12 @@ err_t mmnif_init(struct netif* netif) { mmnif_t* mmnif; uint32_t i; - static int num = 0; - uint16_t speed = 4000; - + int num = 0; /* Alloc and clear memory for the device struct */ -#ifdef WIN32 - mmnif = malloc(sizeof(mmnif_t)); -#else mmnif = kmalloc(sizeof(mmnif_t)); -#endif + if (!mmnif) { DEBUGPRINTF("mmnif init():out of memory\n"); @@ -901,14 +744,20 @@ err_t mmnif_init(struct netif* netif) } memset(mmnif->rx_buff, 0, mpb_size); - /* init the lock for the hdr + mmnif->rx_buff->dcount = MMNIF_MAX_DESCRIPTORS; + mmnif->rx_buff->free_bytes_tail = MMNIF_RX_BUFFERLEN; + + /* init the lock's for the hdr */ -// sem_init(&mmnif->rx_buff->lock,1); - spinlock_init(&mmnif->rx_buff->lock); + + spinlock_init(&mmnif->rx_buff->wlock); + spinlock_init(&mmnif->rx_buff->rlock); + spinlock_init(&mmnif->rx_buff->dlock); + + spinlock_init(&mmnif->lock); /* init the sems for communication art */ - sem_init(&mmnif->com_poll,1); /* since there is no possibilty to create a full semaphore we just block it manually @@ -922,21 +771,11 @@ err_t mmnif_init(struct netif* netif) /* Alloc and clear internal memory for tx_buff */ -#ifdef WIN32 - mmnif->tx_buff[0] = malloc(MMNIF_TX_QUEUELEN * MMNIF_TX_BUFFERLEN); -#else mmnif->tx_buff[0] = kmalloc(MMNIF_TX_QUEUELEN * MMNIF_TX_BUFFERLEN); -#endif + if (!(mmnif->tx_buff[0])) { DEBUGPRINTF("mmnif init: out of memory tx\n"); -#ifdef WIN32 - free(mmnif->rx_buff); - free(mmnif); -#else -// kfree(mmnif->rx_buff); -// kfree(mmnif); -#endif return ERR_MEM; } mmnif->tx_queue = 0; @@ -945,24 +784,10 @@ err_t mmnif_init(struct netif* netif) for (i = 0; i < MMNIF_TX_QUEUELEN -1 ; i++) mmnif->tx_buff[i+1] = mmnif->tx_buff[i] + MMNIF_TX_BUFFERLEN; - /* initialize the mailbox system */ - mailbox_ptr_init(&mmnif->mbox); - /* pass the device state to lwip */ netif->state = mmnif; mmnif_dev = netif; - /* Generate MAC address */ - mmnif_dev->hwaddr[0] = 0x11;mmnif_dev->hwaddr[1] = 0x22;mmnif_dev->hwaddr[2] = 0x33; - mmnif_dev->hwaddr[3] = 0x44;mmnif_dev->hwaddr[4] = 0x55;mmnif_dev->hwaddr[5] = RCCE_ue()*0x11 +0x66; - - /* - * Initialize the snmp variables and counters inside the struct netif. - * The last argument should be replaced with your link speed, in units - * of bits per second. - */ - NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, speed); - /* administrative details */ netif->name[0] = 'e'; netif->name[1] = 'n'; @@ -975,12 +800,10 @@ err_t mmnif_init(struct netif* netif) /* maximum transfer unit */ netif->mtu = 1500; /* broadcast capability, keep all default flags*/ - netif->flags |= NETIF_FLAG_BROADCAST /*| NETIF_FLAG_ETHARP*/ | NETIF_FLAG_LINK_UP; + netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_LINK_UP; /* hardware address length */ netif->hwaddr_len = 6; - mmnif->ethaddr = (struct eth_addr *)netif->hwaddr; - active = TRUE; #ifdef MMNIF_DEBUG @@ -996,33 +819,68 @@ err_t mmnif_init(struct netif* netif) static void mmnif_rx(struct netif* netif) { mmnif_t* mmnif = netif->state; - uint16_t length,i; + mm_rx_buffer_t* b = mmnif->rx_buff; + + uint16_t length; struct pbuf* p = NULL; struct pbuf* q; - char* data; - uint32_t pos; - uint8_t queued; + char* packet; - /* retrieve pointer to actual data array */ - data = (char*) mmnif->rx_buff + sizeof(mm_rx_buffer_t); - /* retrice position wich is needed to be worked on */ - mmnif_lock_rx_hdr(own_ip_address && 0xFF); - pos = (mmnif->rx_buff->pos % MMNIF_RX_QUEUELEN) * MMNIF_RX_BUFFERLEN; -// mmnif_unlock_rx_hdr(own_ip_address && 0xFF); + uint16_t l1,l2,remaining; - /* The packet length is stored in the first 2 bytes but does not include - * the header. Check for reasonable sizes before processing the data to - * prevent nasty memory overflow errors. - */ - length = *((uint16_t*) (data + pos)); + uint32_t i,j; + uint8_t rdesc = 0xFF; + + err_t err = NULL; + +#ifdef WIN32 + ReadProcessMemory(hProc, (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size, + (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size,mpb_size,NULL); + + WaitForSingleObject(own_process_mutex,INFINITE); +#endif + + + spinlock_lock(&b->rlock); + + if (b->desc_table[b->dread].stat == MMNIF_STATUS_FREE) + { + spinlock_unlock(&b->rlock); +#ifdef WIN32 + WriteProcessMemory(hProc, (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size, + (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size,mpb_size,NULL); +#endif + return; + } + + + for (i = 0,j = b->dread; i < MMNIF_MAX_DESCRIPTORS; i++) + { + if (b->desc_table[(j + i)% MMNIF_MAX_DESCRIPTORS].stat == MMNIF_STATUS_RDY) + { + rdesc = (j + i)% MMNIF_MAX_DESCRIPTORS; + b->desc_table[rdesc].stat = MMNIF_STATUS_INPROC; + packet = (char*)b->desc_table[rdesc].addr; + length = b->desc_table[rdesc].len; + break; + } + } + + spinlock_unlock(&b->rlock); + + if (rdesc == 0xFF) + { +#ifdef WIN32 + WriteProcessMemory(hProc, (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size, + (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size,mpb_size,NULL); +#endif + return; + } /* If length is zero return silently */ if (length == 0) { -// mmnif->rx_buff->pos++; -// mmnif->rx_buff->queued--; DEBUGPRINTF("mmnif_rx(): empty packet error\n"); - mmnif_unlock_rx_hdr(own_ip_address & 0xFF); return; } if (length < sizeof(struct ip_hdr) ||length > netif->mtu) @@ -1035,16 +893,11 @@ static void mmnif_rx(struct netif* netif) * has to be worked on */ + #ifdef DEBUG_MMNIF_PACKET + DEBUGPRINTF("\n RECIEVED - 0x%.8X with legth: %d\n",packet,length); + hex_dump(length,packet); + #endif -#ifdef DEBUG_MMNIF_PACKET - DEBUGPRINTF("\n RECIEVED - 0x%.8X with legth: %d\n",data + pos,length+2); - hex_dump(length+2,data + pos); -#endif - - /* drop the length word of the packet data since it's no longer needed*/ - pos += 2; - - /* Build the pbuf for the packet so the lwip * and other higher layer can handle it */ @@ -1054,11 +907,11 @@ static void mmnif_rx(struct netif* netif) DEBUGPRINTF("mmnif_rx(): low on mem - packet dropped\n"); goto drop_packet; } - + /* copy packet to pbuf structure going through linked list */ for (q=p, i = 0; q!=NULL; q=q->next) { - memcpy((uint8_t*)q->payload + i,&data[pos+i],q->len); + memcpy((uint8_t*)q->payload,&packet[i],q->len); i +=q->len; } @@ -1066,24 +919,18 @@ static void mmnif_rx(struct netif* netif) * the old one for new incoming packets */ -// mmnif_lock_rx_hdr(own_ip_address & 0xFF); + mmnif->rx_buff->desc_table[rdesc].stat = MMNIF_STATUS_PROC; - mmnif->rx_buff->pos++; - mmnif->rx_buff->queued--; - if (mmnif->rx_buff->queued > MMNIF_RX_QUEUELEN) + mmnif_rxbuff_free(); + + + /* full packet send to tcpip_thread to process */ + if ((err = mmnif_dev->input(p, mmnif_dev)) != ERR_OK) { - DEBUGPRINTF("mmnif_rx(): integer underflow on mmnif->rx_buff->queued\n"); - mmnif->rx_buff->queued = 0; + DEBUGPRINTF("mmnif_rx: IP input error\n"); + pbuf_free(p); } - -// mmnif_unlock_rx_hdr(own_ip_address & 0xFF); - - /* using the mailbox to hand the buffer to the incoming packet thread - * so the "interrupt" itself is not taking to long - */ - mailbox_ptr_post(&mmnif->mbox, (void*)p); - /* gather some stats and leave the rx handler */ LINK_STATS_INC(link.xmit); mmnif->stats.rx++; @@ -1095,179 +942,32 @@ static void mmnif_rx(struct netif* netif) else mmnif->stats.rx_poll++; - mmnif_unlock_rx_hdr(own_ip_address & 0xFF); +#ifdef WIN32 + WriteProcessMemory(hProc, (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size, + (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size,mpb_size,NULL); + + ReleaseMutex(own_process_mutex); +#endif + return; drop_packet: - /* packet is lost so gather stats and leave the rx handler*/ - // mmnif_lock_rx_hdr(own_ip_address & 0xFF); - mmnif->rx_buff->pos++; - mmnif->rx_buff->queued--; + spinlock_lock(&mmnif->rx_buff->rlock); + /*error handling*/ + spinlock_unlock(&mmnif->rx_buff->rlock); - mmnif_unlock_rx_hdr(own_ip_address & 0xFF); - - LINK_STATS_INC(link.drop); + LINK_STATS_INC(link.drop); mmnif->stats.rx_err++; + +#ifdef WIN32 + WriteProcessMemory(hProc, (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size, + (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size,mpb_size,NULL); +#endif return; } -/* - * The wait implementation which is processing all incoming packets - */ -static int mmnif_wait(struct netif* netif, uint32_t poll, int budget) -{ - mmnif_t* mmnif = netif->state; - struct eth_hdr * ethhdr; - struct pbuf* p = NULL; - int err = ERR_OK; - unsigned int npackets = 0; - unsigned int quota = 0; - if (budget > mmnif->rx_buff->queued) - { - quota = mmnif->rx_buff->queued; - } - else - { - quota = budget; - - mmnif->stats.bdg_overflow++; - if (mmnif->stats.bdg_overflow >= MMNIF_WAIT_BUDGET) - { - /* enable polling and disable interrupts - * (only if polling isn't enabled anyways) - */ - if (mmnif->rx_buff->iv_intr == TRUE) - { -// mmnif_lock_rx_hdr(own_ip_address && 0xff); - mmnif->rx_buff->iv_intr = FALSE; -// mmnif_unlock_rx_hdr(own_ip_address && 0xff); -#ifdef DEBUG_MMNIF - DEBUGPRINTF("mmnif_wait(): heuristical polling enables\n"); -#endif - sem_post(&mmnif->com_poll); - } - - mmnif->stats.bdg_overflow = 0; - } - - } - - /* process up to quota packets from the receive queue */ - while (npackets <= quota) - { - /* fetch new data from mmnif_rx() if there is any */ - if (poll) - { - /* if there is no data return immeadieatly */ - if (mailbox_ptr_tryfetch(&(mmnif->mbox), (void**) &p)) - { - DEBUGPRINTF("mmnif_wait(): fetched empty mailbox\n"); - return err; - } - } - else - { - mailbox_ptr_fetch(&(mmnif->mbox), (void**) &p); - } - - /* if there is data, pass it up to the lwip - * so he can handle it properly - */ - - /* full packet send to tcpip_thread to process */ - if ((err = mmnif_dev->input(p, mmnif_dev)) != ERR_OK) - { - DEBUGPRINTF("mmnif_poll: IP input error\n"); - pbuf_free(p); - } - - npackets++; - } - - /* Note : i will add an return error wich indicates that - * there is no budget left but messages in the queue - */ - return err; - -} - -/* - * worker thread - */ -int mmnif_worker(void* e) -{ -#ifdef DEBUG_MMNIF - DEBUGPRINTF("Waiting for work to do!!!\n"); -#endif - while (active) - mmnif_wait(mmnif_dev,0,MMNIF_WORKER_BUDGET); - - return NULL; -} - -/* - * the poll function wich is used if no interrupt wake up our mmnif_rx functions - */ -int mmnif_poll(void* e) -{ - mmnif_t* mmnif; - unsigned int diff = mmnif_timestamp(); - - if (!mmnif_dev) - { - DEBUGPRINTF("mmnif_poll(): the driver is not initialized yet\n"); - return -1; - } - - mmnif = (mmnif_t*) mmnif_dev->state; - -#ifdef DEBUG_MMNIF - DEBUGPRINTF("Polling for work to do!!!! ONBBBB 0x%.8X BBBB\n\n",mmnif->rx_buff); -#endif - - if (!no_irq) - { - sem_wait(&mmnif->com_poll); - } - - /*run while driver is up*/ - while (active) - { - while (!mmnif->rx_buff->queued) - { - mmnif->stats.pll_empty++; - if (mmnif->stats.pll_empty >= MMNIF_POLL_BUDGET) - { - /* enable interrupts and suspend polling - * - */ -// mmnif_lock_rx_hdr(own_ip_address && 0xff); - mmnif->rx_buff->iv_intr = TRUE; -// mmnif_unlock_rx_hdr(own_ip_address && 0xff); -#ifdef DEBUG_MMNIF - DEBUGPRINTF("mmnif_poll(): heuristical interrupts enabled\n"); -#endif - sem_wait(&mmnif->com_poll); - } - /* uncomment this to test only polling - */ - // mmnif->stats.pll_empty = 0; - } - mmnif->stats.pll_empty=0; - mmnif_rx(mmnif_dev); - - if (instant_process) - mmnif_wait(mmnif_dev,1,MMNIF_WORKER_BUDGET); - } - - return NULL; -} - -/* mmnif_irqhandler(): handles incoming interrupts - * its just a local wrapper for mmnif_rx() - */ void mmnif_irqhandler() { mmnif_t* mmnif; @@ -1280,12 +980,12 @@ void mmnif_irqhandler() mmnif = (mmnif_t*) mmnif_dev->state; - while (mmnif->rx_buff->queued) + while (mmnif->rx_buff->dcount < MMNIF_MAX_DESCRIPTORS) { mmnif_rx(mmnif_dev); - if (instant_process) - mmnif_wait(mmnif_dev,1,MMNIF_WORKER_BUDGET); +// if (instant_process) +// mmnif_wait(mmnif_dev,1,MMNIF_WORKER_BUDGET); } } @@ -1307,11 +1007,8 @@ int mmnif_open() own_ip_address+= RCCE_ue() +1; -#ifdef WIN32 - mmnif_dev = malloc(sizeof(struct netif)); -#else mmnif_dev = kmalloc(sizeof(struct netif)); -#endif + /* register our Memory Mapped Virtual IP interface in the lwip stack * and tell him how to use the interface: * - mmnif_dev : the device data storage @@ -1347,16 +1044,16 @@ int mmnif_open() /* If interrupts are not used we immediately add the polling function * to the queue which would otherwise be done through the IRQ handler. */ - mmnif_device_schedule(); +// mmnif_device_schedule(); /* Start the device worker thread wich actually processes the incoming * packet's this is not done in the "interrupt handler" to shorten them up */ - if (!instant_process) - mmnif_worker_schedule(); +// if (!instant_process) +// mmnif_worker_schedule(); - mmnif_retrigger_schedule(); + // mmnif_retrigger_schedule(); #ifdef DEBUG_MMNIF DEBUGPRINTF("mmnif_dev is open\n"); @@ -1385,14 +1082,10 @@ int mmnif_close() */ active = FALSE; -#ifdef WIN32 - free(mmnif->tx_buff); - free(mmnif_dev); - VirtualFree(mpb_start_address,NULL,NULL); -#else + kfree(mmnif->tx_buff[0],MMNIF_TX_QUEUELEN * MMNIF_TX_BUFFERLEN); kfree(mmnif_dev,sizeof(mmnif_t)); RCCE_shfree(mpb_start_address); -#endif + return NULL; } From 6457e1efac257a075bf6247a8a43514763fb0347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 4 Aug 2011 14:28:30 +0200 Subject: [PATCH 222/261] ... --- kernel/tests.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 5d33dd1b..7e204b7c 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -157,7 +157,7 @@ void srv_on_conn(ServerEventArgs* e) char buff[256]; kprintf("someone finally connected\n"); -// shelldebugprint("someone finally connected\n"); + SHELLDEBUGPRINTF("someone finally connected\n"); tmp1 = get_clock_tick(); for (i = 0; i < 1024*4; i++) @@ -166,11 +166,11 @@ void srv_on_conn(ServerEventArgs* e) err = srv_sendBuffer(&srv,e->ClientID,buff,sizeof(buff)); if ( err < 0) -// SHELLDEBUGPRINTF("err: %d", err); + SHELLDEBUGPRINTF("err: %d", err); kprintf("err: %d", err); if (!(i%10)) -// SHELLDEBUGPRINTF("\r-%d-",i); + SHELLDEBUGPRINTF("\r-%d-",i); kprintf("\r-%d-",i); // Sleep(10); @@ -330,14 +330,14 @@ void* client_task(void* e) while (err) { err = cli_ConnectTo(&cli,"192.168.0.1",5555,0); - // SHELLDEBUGPRINTF("retry connect err = %d socket: %d\n",err,cli.sSocket); + SHELLDEBUGPRINTF("retry connect err = %d socket: %d\n",err,cli.sSocket); kprintf("Client is ready...\n"); } -// SHELLDEBUGPRINTF("connected\n"); + SHELLDEBUGPRINTF("connected\n"); kprintf("Client is ready...\n"); sleep(1); err = cli_sendBuffer(&cli,"Hallo Welt",sizeof("Hallo Welt")); -// SHELLDEBUGPRINTF("send message err = %d\n",err); + SHELLDEBUGPRINTF("send message err = %d\n",err); kprintf("Client is ready...\n"); while(1) sleep(2); @@ -424,10 +424,10 @@ int test_init(void) #if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK) -// shell_init(RCCE_ue()); + shell_init(RCCE_ue()); - // sleep(10); - // SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",RCCE_ue()); + sleep(10); + SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",RCCE_ue()); if (!RCCE_ue()) create_kernel_task(NULL,server_task,NULL); From 03912a8fa7053934258de2416b93fbfbbff9da8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 4 Aug 2011 14:30:05 +0200 Subject: [PATCH 223/261] ... --- kernel/tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 7e204b7c..0bdd5dee 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -367,7 +367,7 @@ void* client_task(void* e) /* fill in the socket structure with host information */ memset(&pin, 0, sizeof(pin)); pin.sin_family = AF_INET; - pin.sin_addr.s_addr = inet_addr("192.168.0.1"); + pin.sin_addr.s_addr = inet_addr("192.168.0.2"); pin.sin_port = htons(5001); /* grab an Internet domain socket */ @@ -429,7 +429,7 @@ int test_init(void) sleep(10); SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",RCCE_ue()); - if (!RCCE_ue()) + if (RCCE_ue()) create_kernel_task(NULL,server_task,NULL); else create_kernel_task(NULL,client_task,NULL); From 7f46c0a3c40a2569950f825b24c62e7e307c2b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 4 Aug 2011 14:36:45 +0200 Subject: [PATCH 224/261] ... --- kernel/tests.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index 0bdd5dee..5bf71903 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -322,16 +322,19 @@ void* client_task(void* e) cli_init(&cli); cli._OnRead = cli_on_read; cli._OnDisconnect = cli_on_disc; - sleep(5); + sleep(4); // SHELLDEBUGPRINTF("Client is ready...\n"); SHELLDEBUGPRINTF("Client is ready...\n"); + kprintf("Client is ready...\n"); while (err) { - err = cli_ConnectTo(&cli,"192.168.0.1",5555,0); + sleep(1); + err = cli_ConnectTo(&cli,"192.168.0.2",5555,0); SHELLDEBUGPRINTF("retry connect err = %d socket: %d\n",err,cli.sSocket); - kprintf("Client is ready...\n"); + + } SHELLDEBUGPRINTF("connected\n"); kprintf("Client is ready...\n"); From 02b2f137951b570b827698656d8ab18bccaa4527 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 4 Aug 2011 14:39:50 +0200 Subject: [PATCH 225/261] ... --- kernel/tests.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 5bf71903..dbf09400 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -166,12 +166,16 @@ void srv_on_conn(ServerEventArgs* e) err = srv_sendBuffer(&srv,e->ClientID,buff,sizeof(buff)); if ( err < 0) + { SHELLDEBUGPRINTF("err: %d", err); - kprintf("err: %d", err); + kprintf("err: %d", err); + } if (!(i%10)) + { SHELLDEBUGPRINTF("\r-%d-",i); kprintf("\r-%d-",i); + } // Sleep(10); } From 2f7aac6868e9a6602f679a5b7733f4d37cbaf7ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 4 Aug 2011 14:45:55 +0200 Subject: [PATCH 226/261] ... --- kernel/tests.c | 204 +++++-------------------------------------------- 1 file changed, 17 insertions(+), 187 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index dbf09400..8015d999 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -131,6 +131,10 @@ static int join_test(void* arg) } #if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK) + + +#define SHELLDEBUGPRINTF(x,...) kprintf(x,##__VA_ARGS__); + static int srv_cnt = 0; static Server srv; void srv_on_read(ServerEventArgs* e) @@ -156,40 +160,32 @@ void srv_on_conn(ServerEventArgs* e) int tmp1,tmp2; char buff[256]; - kprintf("someone finally connected\n"); SHELLDEBUGPRINTF("someone finally connected\n"); tmp1 = get_clock_tick(); for (i = 0; i < 1024*4; i++) { -// sleep(1); - err = srv_sendBuffer(&srv,e->ClientID,buff,sizeof(buff)); if ( err < 0) { SHELLDEBUGPRINTF("err: %d", err); - kprintf("err: %d", err); } if (!(i%10)) { SHELLDEBUGPRINTF("\r-%d-",i); - kprintf("\r-%d-",i); } - // Sleep(10); } tmp2 = get_clock_tick(); - kprintf("send with %f kb/s", ((float)i*sizeof(buff))/(tmp2-tmp1)); +// SHELLDEBUGPRINTF("send with %f kb/s",((float)i*sizeof(buff))/(tmp2-tmp1)); + SHELLDEBUGPRINTF("send %d kb in %d ticks",i*sizeof(buff),(tmp2-tmp1)); } -//#define SHELLDEBUGPRINTF(x,...) kprintf(x,##__VA_ARGS__); - void* server_task(void* e) { - kprintf("created server\n"); - + SHELLDEBUGPRINTF("created server\n"); server_init(&srv,5555,2); @@ -197,104 +193,10 @@ void* server_task(void* e) srv._OnDisconnect = srv_on_disc; srv._OnConnect = srv_on_conn; - -// shelldebugprint("Server is ready...\n"); - while(1) sleep(2); return NULL; - -#if 0 - int sockfd, newsockfd, portno, clilen; - char buffer[512]; - struct sockaddr_in serv_addr, cli_addr; - int n; - uint64_t tmp1,tmp2; - int err; -t - /* First call to socket() function */ - sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); - if (sockfd < 0) - { - SHELLDEBUGPRINTF("ERROR opening socket"); - return; - } - /* Initialize socket structure */ - memset((char *) &serv_addr,0, sizeof(serv_addr)); - portno = 5001; - serv_addr.sin_family = AF_INET; - serv_addr.sin_addr.s_addr = INADDR_ANY; - serv_addr.sin_port = htons(portno); - - SHELLDEBUGPRINTF("binding"); - /* Now bind the host address using bind() call.*/ - if (bind(sockfd, (struct sockaddr *) &serv_addr, - sizeof(serv_addr)) < 0) - { - SHELLDEBUGPRINTF("ERROR on binding"); - return; - } - - /* Now start listening for the clients, here process will - * go in sleep mode and will wait for the incoming connection - */ - SHELLDEBUGPRINTF("listening"); - listen(sockfd,5); - clilen = sizeof(cli_addr); - - /* Accept actual connection from the client */ - SHELLDEBUGPRINTF("accepting"); - newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr, - &clilen); - if (newsockfd < 0) - { - kprintf("ERROR on accept"); - return; - } - /* If connection is established then start communicating */ - memset(buffer,0,256); - SHELLDEBUGPRINTF("recieving"); - n = recv( newsockfd,buffer,255,0 ); - if (n < 0) - { - SHELLDEBUGPRINTF("ERROR reading from socket"); - return; - } - SHELLDEBUGPRINTF("Here is the message: %s\n",buffer); - - /* Write a response to the client */ - kprintf("writing"); - n = send(newsockfd,"I got your message",18,0); - if (n < 0) - { - SHELLDEBUGPRINTF("ERROR writing to socket"); - return; - } - - tmp1 = get_clock_tick(); - - for (n = 0; n < 1024*256 ; n++) - { - if (!(n%100)) - SHELLDEBUGPRINTF("%d-",n); - err = send(newsockfd,buffer,sizeof(buffer),0); - if (err < 0) - { - SHELLDEBUGPRINTF("error on sending: %d",err); - break; - } - // if (!(n%100)) - // sleep(1); - // udelay(100); - } - - tmp2 = get_clock_tick(); - - SHELLDEBUGPRINTF("Send 1024*256 Bytes in : %d clock ticks",tmp2-tmp1); - -#endif - return 0; } static int cli_cnt = 0; @@ -326,97 +228,25 @@ void* client_task(void* e) cli_init(&cli); cli._OnRead = cli_on_read; cli._OnDisconnect = cli_on_disc; - sleep(4); + sleep(2); - // SHELLDEBUGPRINTF("Client is ready...\n"); SHELLDEBUGPRINTF("Client is ready...\n"); - kprintf("Client is ready...\n"); - while (err) { sleep(1); err = cli_ConnectTo(&cli,"192.168.0.2",5555,0); SHELLDEBUGPRINTF("retry connect err = %d socket: %d\n",err,cli.sSocket); - - } SHELLDEBUGPRINTF("connected\n"); - kprintf("Client is ready...\n"); + sleep(1); err = cli_sendBuffer(&cli,"Hallo Welt",sizeof("Hallo Welt")); SHELLDEBUGPRINTF("send message err = %d\n",err); - kprintf("Client is ready...\n"); + + while(1) - sleep(2); + sleep(2); - -#if 1 - while(1) - { - cli_sendBuffer(&cli,netbuffer,sizeof(netbuffer)); - sleep(1); - } -#endif - return NULL; - -#if 0 - char dir[2048]; - int sd; - struct sockaddr_in sin; - struct sockaddr_in pin; - struct hostent *hp; - int n; - - int on = 1; - - sleep(1); - - /* fill in the socket structure with host information */ - memset(&pin, 0, sizeof(pin)); - pin.sin_family = AF_INET; - pin.sin_addr.s_addr = inet_addr("192.168.0.2"); - pin.sin_port = htons(5001); - - /* grab an Internet domain socket */ - if ((sd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) { - kprintf("socketfail"); - return; - } - - // setsockopt( sd, IPPROTO_TCP, TCP_NODELAY, (char *) &on, sizeof( on)); - - kprintf("connecting with socket nr : %d",sd); - /* connect to PORT on HOST */ - - if (connect(sd,(struct sockaddr *) &pin, sizeof(pin)) == -1) { - kprintf("connectfail"); - return; - } - kprintf("sending"); - /* send a message to the server PORT on machine HOST */ - if (send(sd, "HELLO THERE", strlen("HELLO THERE"), 0) == -1) { - kprintf("sendfail"); - return; - } - kprintf("recieving"); - /* wait for a message to come back from the server */ - if (recv(sd, dir, 256, 0) == -1) { - kprintf("recvfail"); - return; - } - - /* spew-out the results and bail out of here! */ - kprintf("%s\n", dir); - - while(1) - { - recv(sd,dir,sizeof(dir),0); - // udelay(100); - } - -// close(sd); - -#endif return NULL; } #endif @@ -431,12 +261,12 @@ int test_init(void) #if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK) - shell_init(RCCE_ue()); +// shell_init(RCCE_ue()); +// +// sleep(10); +// SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",RCCE_ue()); - sleep(10); - SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",RCCE_ue()); - - if (RCCE_ue()) + if (!RCCE_ue()) create_kernel_task(NULL,server_task,NULL); else create_kernel_task(NULL,client_task,NULL); From 70953872fa70914f548d6050e9d61e0314edf2f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 4 Aug 2011 14:46:38 +0200 Subject: [PATCH 227/261] ... --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index 8015d999..3e831230 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -234,7 +234,7 @@ void* client_task(void* e) while (err) { sleep(1); - err = cli_ConnectTo(&cli,"192.168.0.2",5555,0); + err = cli_ConnectTo(&cli,"192.168.0.1",5555,0); SHELLDEBUGPRINTF("retry connect err = %d socket: %d\n",err,cli.sSocket); } SHELLDEBUGPRINTF("connected\n"); From 695ca0da4fdcd1b3ba9b96efc2d7c4cfa395e5a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 4 Aug 2011 14:53:16 +0200 Subject: [PATCH 228/261] ... --- drivers/net/mmnif.c | 13 +++++++++++-- kernel/tests.c | 11 +++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 6ef8c66a..8c45fad4 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -7,8 +7,11 @@ * * Carl-Benedikt Krüger 2011 * + * + * EXPERIMENTAL VERSION */ + #include "mmnif.h" /* definitions */ #ifdef WIN32 @@ -69,13 +72,19 @@ extern HANDLE hProc; #endif +/* define constants + * regarding the driver & its configuration + */ + +/* + */ #define MMNIF_TX_BUFFERLEN 1792 #define MMNIF_TX_QUEUELEN 4 #define MMNIF_RX_BUFFERLEN 8192 -#define MMNIF_MAX_DESCRIPTORS 32 +#define MMNIF_MAX_DESCRIPTORS 32 -#define MMNIF_CORES 2 +#define MMNIF_CORES 2 #define MMNIF_WORKER_BUDGET 4 diff --git a/kernel/tests.c b/kernel/tests.c index 3e831230..27f4aafd 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -251,6 +251,15 @@ return NULL; } #endif +void* alive(void*e) +{ + while (1) + { + kprintf("IM ALIVE"); + sleep(2); + } +} + int test_init(void) { // char* argv[] = {"/bin/tests", NULL}; @@ -266,6 +275,8 @@ int test_init(void) // sleep(10); // SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",RCCE_ue()); + create_kernel_task(NULL,alive,NULL); + if (!RCCE_ue()) create_kernel_task(NULL,server_task,NULL); else From a5b402b1f5d4303107d2fd548646809276abd465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 4 Aug 2011 15:02:23 +0200 Subject: [PATCH 229/261] ... --- drivers/net/mmnif.c | 66 +++++++++++++++++++++------------------------ kernel/tests.c | 4 +-- 2 files changed, 32 insertions(+), 38 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 8c45fad4..bb723a35 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -76,8 +76,6 @@ extern HANDLE hProc; * regarding the driver & its configuration */ -/* - */ #define MMNIF_TX_BUFFERLEN 1792 #define MMNIF_TX_QUEUELEN 4 @@ -128,9 +126,6 @@ static unsigned int router_ip_address = 0xC0A80001; /* 192.168.0.1 */ char* mpb_start_address = NULL; unsigned int mpb_size = NULL; -/* just set and reset the irq */ -static int pulse_irq = 0; - /* * the memory mapped network device */ @@ -184,19 +179,18 @@ typedef struct rx_desc /* receive ring buffer structure */ typedef struct mm_rx_buffer { - /* - * + /* iv_intr: inform via interrupt + * states whether the interface wants to recieve an interrupt for + * incoming packet + */ + uint16_t iv_intr; + /* memory "pseudo-ring/heap" + * packets are always in one single chunk of memory + * head : head of allocated memory region + * tail : tail of allocated memory region */ - uint16_t iv_intr; - uint16_t roffset; - uint16_t woffset; - uint32_t head; - uint32_t tail; - uint16_t tot_bytes; - uint16_t free_bytes; - uint16_t free_bytes_head; - uint16_t free_bytes_tail; - spinlock_t wlock; + uint16_t head; + uint16_t tail; spinlock_t rlock; /* * @@ -429,22 +423,22 @@ uint32_t mmnif_rxbuff_alloc(uint8_t dest,uint16_t len) if (rb->dcount) { - if (rb->woffset > rb->roffset) + if (rb->tail > rb->head) { - if (MMNIF_RX_BUFFERLEN - rb->woffset > len) + if (MMNIF_RX_BUFFERLEN - rb->tail > len) { rb->desc_table[rb->dwrite].stat = MMNIF_STATUS_PENDING; - ret = memblock + rb->woffset; + ret = memblock + rb->tail; rb->desc_table[rb->dwrite].addr = ret; rb->desc_table[rb->dwrite].len = len; rb->dcount--; rb->dwrite = (++rb->dwrite)%MMNIF_MAX_DESCRIPTORS; - rb->woffset = (rb->woffset + len); + rb->tail = (rb->tail + len); spinlock_unlock(&rb->dlock); return ret; } - else if (rb->roffset > len) + else if (rb->head > len) { rb->desc_table[rb->dwrite].stat = MMNIF_STATUS_PENDING; ret = memblock; @@ -453,7 +447,7 @@ uint32_t mmnif_rxbuff_alloc(uint8_t dest,uint16_t len) rb->dcount--; rb->dwrite = (++rb->dwrite)%MMNIF_MAX_DESCRIPTORS; - rb->woffset = len; + rb->tail = len; spinlock_unlock(&rb->dlock); return ret; } @@ -465,36 +459,36 @@ uint32_t mmnif_rxbuff_alloc(uint8_t dest,uint16_t len) } else { - if (rb->roffset - rb->woffset > len) + if (rb->head - rb->tail > len) { rb->desc_table[rb->dwrite].stat = MMNIF_STATUS_PENDING; - ret = memblock + rb->woffset; + ret = memblock + rb->tail; rb->desc_table[rb->dwrite].addr = ret; rb->desc_table[rb->dwrite].len = len; rb->dcount--; rb->dwrite = (++rb->dwrite)%MMNIF_MAX_DESCRIPTORS; - rb->woffset = (rb->woffset + len); + rb->tail = (rb->tail + len); spinlock_unlock(&rb->dlock); return ret; } - else if (rb->woffset == rb->roffset) + else if (rb->tail == rb->head) { - if (MMNIF_RX_BUFFERLEN - rb->woffset < len) + if (MMNIF_RX_BUFFERLEN - rb->tail < len) { - rb->woffset = 0; + rb->tail = 0; if (rb->dread == rb->dwrite) - rb->roffset = 0; + rb->head = 0; } rb->desc_table[rb->dwrite].stat = MMNIF_STATUS_PENDING; - ret = memblock + rb->woffset; + ret = memblock + rb->tail; rb->desc_table[rb->dwrite].addr = ret; rb->desc_table[rb->dwrite].len = len; rb->dcount--; rb->dwrite = (++rb->dwrite)%MMNIF_MAX_DESCRIPTORS; - rb->woffset = (rb->woffset + len); + rb->tail = (rb->tail + len); spinlock_unlock(&rb->dlock); return ret; } @@ -555,21 +549,21 @@ void mmnif_rxbuff_free() b->dread = (b->dread +1)%MMNIF_MAX_DESCRIPTORS; b->desc_table[j].stat = MMNIF_STATUS_FREE; - if (b->woffset > b->roffset) + if (b->tail > b->head) { - b->roffset += b->desc_table[j].len; + b->head += b->desc_table[j].len; } else { if ( (b->desc_table[(j+1)%MMNIF_MAX_DESCRIPTORS].stat != MMNIF_STATUS_FREE ) && ( b->desc_table[j].addr > b->desc_table[(j+1)%MMNIF_MAX_DESCRIPTORS].addr)) { - b->roffset = 0; + b->head = 0; } else { - b->roffset += b->desc_table[j].len; + b->head += b->desc_table[j].len; } } } diff --git a/kernel/tests.c b/kernel/tests.c index 27f4aafd..09555c4d 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -158,7 +158,7 @@ void srv_on_conn(ServerEventArgs* e) { int i = 0, err = 0; int tmp1,tmp2; - char buff[256]; + char buff[1024]; SHELLDEBUGPRINTF("someone finally connected\n"); @@ -180,7 +180,7 @@ void srv_on_conn(ServerEventArgs* e) tmp2 = get_clock_tick(); // SHELLDEBUGPRINTF("send with %f kb/s",((float)i*sizeof(buff))/(tmp2-tmp1)); - SHELLDEBUGPRINTF("send %d kb in %d ticks",i*sizeof(buff),(tmp2-tmp1)); + SHELLDEBUGPRINTF("send %d bytes in %d ticks",i*sizeof(buff),(tmp2-tmp1)); } void* server_task(void* e) From 8082128fc1d37ea84df0f7207d32c276c575a6c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 4 Aug 2011 15:03:21 +0200 Subject: [PATCH 230/261] ... --- drivers/net/mmnif.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index bb723a35..60446879 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -748,12 +748,10 @@ err_t mmnif_init(struct netif* netif) memset(mmnif->rx_buff, 0, mpb_size); mmnif->rx_buff->dcount = MMNIF_MAX_DESCRIPTORS; - mmnif->rx_buff->free_bytes_tail = MMNIF_RX_BUFFERLEN; /* init the lock's for the hdr */ - spinlock_init(&mmnif->rx_buff->wlock); spinlock_init(&mmnif->rx_buff->rlock); spinlock_init(&mmnif->rx_buff->dlock); From 070fffd9c0d5ee139ad9dc5e874eac21126a0239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 4 Aug 2011 15:20:18 +0200 Subject: [PATCH 231/261] ... --- drivers/net/mmnif.c | 100 ++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 64 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 60446879..91468abf 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -18,7 +18,7 @@ #define kmalloc malloc #define kfree(x,y) free(x) #define RCCE_shfree(x) VirtualFree(x,NULL,NULL); - +#define RCCE_shmalloc(x) VirtualAlloc((char*)0x41000000,x,MEM_COMMIT|MEM_RESERVE,PAGE_READWRITE); #include "mailbox.h" /* mailbox_ptr_t */ #else #include /* mailbox_ptr_t */ @@ -168,6 +168,7 @@ typedef struct mmnif_device_stats } mmnif_device_stats_t; +/* receive descror structure */ typedef struct rx_desc { uint8_t stat; @@ -192,44 +193,48 @@ typedef struct mm_rx_buffer uint16_t head; uint16_t tail; spinlock_t rlock; - /* - * + /* descritpor queue + * desc_table : descriptor table + * dcount : descriptor's free in queue + * dread : next descriptor to read + * dwrite : next descriptor to write + * dlock : lock to protect these members */ rx_desc_t desc_table[MMNIF_MAX_DESCRIPTORS]; uint8_t dcount; uint8_t dread; uint8_t dwrite; spinlock_t dlock; - } mm_rx_buffer_t; typedef struct mmnif { - struct mmnif_device_stats stats; + struct mmnif_device_stats stats; /* Interface constants: * - ehternet address - * - local ip address + * - local ip address */ - struct eth_addr* ethaddr; - uint32_t ipaddr; + struct eth_addr* ethaddr; + uint32_t ipaddr; /* memory interaction variables: * - transmit queue * - pointer to transmit buffer * - pointer to recive buffer */ - uint8_t tx_queue; - uint8_t* tx_buff[MMNIF_TX_QUEUELEN]; - mm_rx_buffer_t* rx_buff; + uint8_t tx_queue; + uint8_t* tx_buff[MMNIF_TX_QUEUELEN]; + mm_rx_buffer_t* rx_buff; - spinlock_t lock; + /* lock to protect members + */ + spinlock_t lock; - sem_t com_poll; + /* + */ + sem_t com_poll; - /* comunication mailbox - */ - mailbox_ptr_t mbox; }mmnif_t; @@ -253,7 +258,7 @@ __inline int RCCE_ue(void){ #endif /* trigger an interrupt on the remote processor - * + * so he knows there is a packet to read */ __inline int mmnif_trigger_irq(dest_ip) { @@ -279,45 +284,8 @@ __inline int mmnif_trigger_irq(dest_ip) return 0; #endif -}; - - -/* Allocate Shared Memory for communication this could be: - * - in Message Passing Buffer - * - Shared Memory Address Space (0x8000000 + ) - * - * Note: under windows this is kernel space so we take arbitrary 0x41000000 here - */ -__inline void* mmnif_shmalloc() -{ -#ifdef WIN32 - mpb_size = sizeof(mm_rx_buffer_t) + MMNIF_RX_BUFFERLEN; - mpb_start_address = VirtualAlloc((char*)0x41000000 /*+ - (mpb_size) * (own_ip_address - router_ip_address)*/, - mpb_size *MMNIF_CORES,MEM_COMMIT|MEM_RESERVE,PAGE_READWRITE); - - return (char*)0x41000000 + (mpb_size) * (own_ip_address - router_ip_address); -#else - mpb_size = (sizeof(mm_rx_buffer_t) + MMNIF_RX_BUFFERLEN); - - mpb_start_address = RCCE_shmalloc(mpb_size*MMNIF_CORES); - return mpb_start_address + (mpb_size) * (own_ip_address - router_ip_address); -#endif } -/* mmnif_timestamp(): genereate a timestamp for the - * packets - */ -__inline int mmnif_timestamp() -{ -#ifdef WIN32 - return GetTickCount(); -#else - return get_clock_tick(); -#endif -} - - /* mmnif_get_device_stats(): Returns a copy of the * current device */ @@ -333,7 +301,6 @@ mmnif_device_stats_t mmnif_get_device_stats() return stats; } - /* mmnif_print_stats(): Print the devices stats of the * current device */ @@ -408,14 +375,15 @@ uint8_t mmnif_get_destination(struct netif* netif, struct pbuf* p) return core; } -/* - * +/* mmnif_rxbuff_alloc(): + * this function allocates a continues chunk of memory + * right inside of the buffer which is used for communication + * with the remote end */ uint32_t mmnif_rxbuff_alloc(uint8_t dest,uint16_t len) { - mmnif_t* mmnif = mmnif_dev->state; mm_rx_buffer_t* rb = (mm_rx_buffer_t*)((char*)mpb_start_address + ( dest -1 ) * mpb_size); - char* memblock = (char*)rb + sizeof(mm_rx_buffer_t); + char* memblock = (char*)rb + sizeof(mm_rx_buffer_t); uint32_t ret; @@ -506,12 +474,12 @@ uint32_t mmnif_rxbuff_alloc(uint8_t dest,uint16_t len) } } -/* - * +/* mmnif_commit_packet: this function set the state of the (in advance) + * allocated packet to RDY so the recieve queue knows that it can be + * processed further */ int mmnif_commit_packet(uint8_t dest,uint32_t addr) { - mmnif_t* mmnif = mmnif_dev->state; mm_rx_buffer_t* rb = (mm_rx_buffer_t*)((char*)mpb_start_address + ( dest -1 ) * mpb_size); uint32_t i; @@ -739,8 +707,12 @@ err_t mmnif_init(struct netif* netif) /* Alloc and clear shared memory for rx_buff */ - mmnif->rx_buff = mmnif_shmalloc(); - if (!(mmnif->rx_buff)) + + mpb_size = (sizeof(mm_rx_buffer_t) + MMNIF_RX_BUFFERLEN); + mpb_start_address = RCCE_shmalloc(mpb_size*MMNIF_CORES); + + mmnif->rx_buff = mpb_start_address + (mpb_size) * (own_ip_address - router_ip_address); + if (!(mpb_start_address)) { DEBUGPRINTF("mmnif init(): allocating shared memory failed\n"); return ERR_MEM; From 88dddd08a729787e21af229a938d51a62502d82f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 4 Aug 2011 15:42:56 +0200 Subject: [PATCH 232/261] major changes --- drivers/net/mmnif.c | 168 +++++++++++++++++++++++--------------------- 1 file changed, 86 insertions(+), 82 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 91468abf..b76a3192 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -14,48 +14,35 @@ #include "mmnif.h" /* definitions */ -#ifdef WIN32 -#define kmalloc malloc -#define kfree(x,y) free(x) -#define RCCE_shfree(x) VirtualFree(x,NULL,NULL); -#define RCCE_shmalloc(x) VirtualAlloc((char*)0x41000000,x,MEM_COMMIT|MEM_RESERVE,PAGE_READWRITE); -#include "mailbox.h" /* mailbox_ptr_t */ -#else -#include /* mailbox_ptr_t */ -#endif - #include /* lwip netif */ #include /* inteface stats */ #include /* ethernet arp packets */ #include /* struct iphdr*/ #include /* tcpip_input()*/ -#define DEBUG_MMNIF -//#define DEBUG_MMNIF_PACKET - -#ifdef DEBUG_MMNIF -#include "util.h" /* hex dump */ -#endif - #ifdef WIN32 + +#define kmalloc malloc +#define kfree(x,y) free(x) +#define RCCE_shfree(x) VirtualFree(x,NULL,NULL); +#define RCCE_shmalloc(x) VirtualAlloc((char*)0x41000000,x,MEM_COMMIT|MEM_RESERVE,PAGE_READWRITE); +#include "mailbox.h" /* mailbox_ptr_t */ #define WIN32_LEAN_AND_MEAN #include #include - typedef bthread_sem_t sem_t; typedef bthread_t tid_t; - /* "interrupt" of the other virutal network card*/ extern HANDLE remote_process_event; extern HANDLE remote_process_mutex; extern HANDLE own_process_mutex; /* HANDLE to the other Process (for WPM and RPM)*/ extern HANDLE hProc; - - #define DEBUGPRINTF(x,...) printf(x,__VA_ARGS__) + #else -#define DEBUGPRINTF(x,...) kprintf(x,##__VA_ARGS__) + +#include /* mailbox_ptr_t */ #include #include @@ -69,6 +56,25 @@ extern HANDLE hProc; #include +#define DEBUGPRINTF(x,...) kprintf(x,##__VA_ARGS__) + +#endif + + + +#define DEBUG_MMNIF +//#define DEBUG_MMNIF_PACKET + +#ifdef DEBUG_MMNIF +#include "util.h" /* hex dump */ +#endif + +#ifdef WIN32 + +#else + + + #endif @@ -493,8 +499,9 @@ int mmnif_commit_packet(uint8_t dest,uint32_t addr) } return -1; } -/* - * + +/* mmnif_rxbuff_free() : the opposite to mmnif_rxbuff_alloc() a from the receiver + * already processed chunk of memory is freed so that it can be allocated again */ void mmnif_rxbuff_free() { @@ -546,22 +553,20 @@ void mmnif_rxbuff_free() */ err_t mmnif_tx(struct netif* netif, struct pbuf* p) { - mmnif_t* mmnif = netif->state; - uint8_t slot = mmnif->tx_queue; + mmnif_t* mmnif = netif->state; + uint8_t slot = mmnif->tx_queue; - uint16_t queued; - uint32_t write_address; - uint32_t i; + uint32_t write_address; + uint32_t i; struct pbuf* q; /* interator */ - uint8_t build_buff = TRUE; - uint8_t dest_intr = FALSE; - - uint32_t dest_ip = mmnif_get_destination(netif,p); + uint8_t build_buff = TRUE; + uint32_t dest_ip = mmnif_get_destination(netif,p); + + mm_rx_buffer_t* rb = (mm_rx_buffer_t*)((char*)mpb_start_address + ( dest -1 ) * mpb_size); #ifdef WIN32 - ReadProcessMemory(hProc, (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size, - (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,mpb_size,NULL); + ReadProcessMemory(hProc, (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size, (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,mpb_size,NULL); WaitForSingleObject(remote_process_mutex,INFINITE); #endif @@ -577,14 +582,14 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) if (mmnif->tx_queue > MMNIF_TX_QUEUELEN) { - DEBUGPRINTF("mmnif_tx(): too many packets at once for tx_queue\n"); - goto drop_packet; + DEBUGPRINTF("mmnif_tx(): too many packets at once for tx_queue\n"); + goto drop_packet; } if (p->tot_len > MMNIF_TX_BUFFERLEN) { - DEBUGPRINTF("mmnif_tx(): packet is longer than %d bytes\n",MMNIF_TX_BUFFERLEN); - goto drop_packet; + DEBUGPRINTF("mmnif_tx(): packet is longer than %d bytes\n",MMNIF_TX_BUFFERLEN); + goto drop_packet; } /* check if the pbuf consists only of one element @@ -594,7 +599,6 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) if (!p->next) build_buff = FALSE; - if (build_buff) { /* build the payload out of the p's @@ -607,7 +611,7 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) } } - /* lookup writeoffset and allocate needed space in the remote buffer */ + /* allocate memory for the packet in the remote buffer */ write_address = mmnif_rxbuff_alloc(dest_ip,p->tot_len); @@ -626,7 +630,7 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) if (mmnif_commit_packet(dest_ip,write_address)) { - DEBUGPRINTF("mmnif_tx(): packet somehow lost on commit\n"); + DEBUGPRINTF("mmnif_tx(): packet somehow lost during commit\n"); } #ifdef DEBUG_MMNIF_PACKET @@ -634,30 +638,31 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) hex_dump(p->tot_len, p->payload); #endif + /* release the tx_queue because it's finished */ spinlock_lock(&mmnif->lock); mmnif->tx_queue--; spinlock_unlock(&mmnif->lock); + /* just gather some stats */ LINK_STATS_INC(link.xmit); mmnif->stats.tx++; mmnif->stats.tx_bytes += p->tot_len; #ifdef WIN32 - WriteProcessMemory(hProc, (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size, - (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,mpb_size,NULL); - + WriteProcessMemory(hProc, (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size, (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,mpb_size,NULL); SetEvent(remote_process_event); - ReleaseMutex(remote_process_mutex); #endif - mmnif_trigger_irq(dest_ip); + if (rb->iv_intr) + mmnif_trigger_irq(dest_ip); return ERR_OK; drop_packet: - + /* drop packet for one or another reason + */ spinlock_lock(&mmnif->lock); mmnif->tx_queue--; spinlock_unlock(&mmnif->lock); @@ -666,11 +671,10 @@ drop_packet: mmnif->stats.tx_err++; #ifdef WIN32 - WriteProcessMemory(hProc, (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size, - (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,mpb_size,NULL); + WriteProcessMemory(hProc, (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,(char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,mpb_size,NULL); #endif - return ERR_IF; + return ERR_IF; } /* mmnif_link_layer(): wrapper function called by ip_output() @@ -707,7 +711,6 @@ err_t mmnif_init(struct netif* netif) /* Alloc and clear shared memory for rx_buff */ - mpb_size = (sizeof(mm_rx_buffer_t) + MMNIF_RX_BUFFERLEN); mpb_start_address = RCCE_shmalloc(mpb_size*MMNIF_CORES); @@ -719,6 +722,8 @@ err_t mmnif_init(struct netif* netif) } memset(mmnif->rx_buff, 0, mpb_size); + /* set initial values + */ mmnif->rx_buff->dcount = MMNIF_MAX_DESCRIPTORS; /* init the lock's for the hdr @@ -791,42 +796,39 @@ err_t mmnif_init(struct netif* netif) */ static void mmnif_rx(struct netif* netif) { - mmnif_t* mmnif = netif->state; + mmnif_t* mmnif = netif->state; mm_rx_buffer_t* b = mmnif->rx_buff; - uint16_t length; + uint16_t length; struct pbuf* p = NULL; struct pbuf* q; - char* packet; + char* packet; - uint16_t l1,l2,remaining; + uint32_t i,j; + uint8_t rdesc = 0xFF; - uint32_t i,j; - uint8_t rdesc = 0xFF; - - err_t err = NULL; + err_t err = NULL; #ifdef WIN32 - ReadProcessMemory(hProc, (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size, - (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size,mpb_size,NULL); - + ReadProcessMemory(hProc, (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size, (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size,mpb_size,NULL); WaitForSingleObject(own_process_mutex,INFINITE); #endif - spinlock_lock(&b->rlock); + /* check if this call to mmnif_rx makes any sense + */ if (b->desc_table[b->dread].stat == MMNIF_STATUS_FREE) { spinlock_unlock(&b->rlock); #ifdef WIN32 - WriteProcessMemory(hProc, (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size, - (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size,mpb_size,NULL); + WriteProcessMemory(hProc, (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size, (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size,mpb_size,NULL); #endif return; } - + /* search the packet whose transmission is finished + */ for (i = 0,j = b->dread; i < MMNIF_MAX_DESCRIPTORS; i++) { if (b->desc_table[(j + i)% MMNIF_MAX_DESCRIPTORS].stat == MMNIF_STATUS_RDY) @@ -841,16 +843,18 @@ static void mmnif_rx(struct netif* netif) spinlock_unlock(&b->rlock); + /* if there is no packet finished we encountered a random error + */ if (rdesc == 0xFF) { #ifdef WIN32 - WriteProcessMemory(hProc, (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size, - (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size,mpb_size,NULL); + WriteProcessMemory(hProc, (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size, (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size,mpb_size,NULL); #endif return; } - /* If length is zero return silently */ + /* If length is zero return silently + */ if (length == 0) { DEBUGPRINTF("mmnif_rx(): empty packet error\n"); @@ -888,15 +892,17 @@ static void mmnif_rx(struct netif* netif) i +=q->len; } + /* indicate that the copy process is done and the packet can be freed + * note that we did not lock here because we are the only one editing this value + */ + mmnif->rx_buff->desc_table[rdesc].stat = MMNIF_STATUS_PROC; + /* everything is copied to a new buffer so it's save to release * the old one for new incoming packets */ - mmnif->rx_buff->desc_table[rdesc].stat = MMNIF_STATUS_PROC; - mmnif_rxbuff_free(); - /* full packet send to tcpip_thread to process */ if ((err = mmnif_dev->input(p, mmnif_dev)) != ERR_OK) { @@ -916,9 +922,7 @@ static void mmnif_rx(struct netif* netif) mmnif->stats.rx_poll++; #ifdef WIN32 - WriteProcessMemory(hProc, (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size, - (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size,mpb_size,NULL); - + WriteProcessMemory(hProc, (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size, (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size,mpb_size,NULL); ReleaseMutex(own_process_mutex); #endif @@ -930,12 +934,11 @@ drop_packet: /*error handling*/ spinlock_unlock(&mmnif->rx_buff->rlock); - LINK_STATS_INC(link.drop); + LINK_STATS_INC(link.drop); mmnif->stats.rx_err++; #ifdef WIN32 - WriteProcessMemory(hProc, (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size, - (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size,mpb_size,NULL); + WriteProcessMemory(hProc, (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size, (char*)mpb_start_address + ( !((own_ip_address && 0xFF)-1) ) * mpb_size,mpb_size,NULL); #endif return; } @@ -944,6 +947,7 @@ drop_packet: void mmnif_irqhandler() { mmnif_t* mmnif; + /* return if mmnif_dev is not yet initialized*/ if (!mmnif_dev) { @@ -993,7 +997,7 @@ int mmnif_open() * Note: Ethernet Input will be removed because its NOT needed and will * be replaced with ip_input */ - if (!netif_add(mmnif_dev, &ipaddr, &netmask, &gw, NULL,(netif_init_fn)mmnif_init, tcpip_input/*ethernet_input*/)) + if (!netif_add(mmnif_dev, &ipaddr, &netmask, &gw, NULL,(netif_init_fn)mmnif_init, tcpip_input)) { DEBUGPRINTF("mmnif_open() : unable to add network interface\n"); return -1; @@ -1015,8 +1019,8 @@ int mmnif_open() active = TRUE; /* If interrupts are not used we immediately add the polling function - * to the queue which would otherwise be done through the IRQ handler. - */ + * to the queue which would otherwise be done through the IRQ handler. + */ // mmnif_device_schedule(); /* Start the device worker thread wich actually processes the incoming From da213b14af2cc19243253a69a4536d77a19cb9f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 4 Aug 2011 15:43:40 +0200 Subject: [PATCH 233/261] major changes --- drivers/net/mmnif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index b76a3192..de3d32a7 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -563,7 +563,7 @@ err_t mmnif_tx(struct netif* netif, struct pbuf* p) uint8_t build_buff = TRUE; uint32_t dest_ip = mmnif_get_destination(netif,p); - mm_rx_buffer_t* rb = (mm_rx_buffer_t*)((char*)mpb_start_address + ( dest -1 ) * mpb_size); + mm_rx_buffer_t* rb = (mm_rx_buffer_t*)((char*)mpb_start_address + ( dest_ip -1 ) * mpb_size); #ifdef WIN32 ReadProcessMemory(hProc, (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size, (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size,mpb_size,NULL); From e37c0c4ca722972aafccfc0e83643b2ad3fd4e2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 4 Aug 2011 15:55:12 +0200 Subject: [PATCH 234/261] major changes --- drivers/net/mmnif.c | 77 +++++++++++++++++++++++++++++++++++++++++++-- kernel/tests.c | 2 +- 2 files changed, 75 insertions(+), 4 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index de3d32a7..2884699e 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -263,6 +263,22 @@ __inline int RCCE_ue(void){ #define __MEMCPY(x,y,z) memcpy(x,y,z) #endif +/* mmnif_device_schedule() : + * if there is no interupt used to indicate new packets + * this creates a polling thread which looks for data + * itself + */ +__inline int mmnif_device_schedule() +{ +#ifdef WIN32 + bthread_create(&polling_thread,NULL,mmnif_poll,NULL); + return NULL; +#else + create_kernel_task(&polling_thread,mmnif_poll,NULL); + return NULL; +#endif +} + /* trigger an interrupt on the remote processor * so he knows there is a packet to read */ @@ -942,8 +958,9 @@ drop_packet: #endif return; } - - +/* mmnif_irqhandler(): + * handles the incomint interrupts + */ void mmnif_irqhandler() { mmnif_t* mmnif; @@ -965,7 +982,61 @@ void mmnif_irqhandler() // mmnif_wait(mmnif_dev,1,MMNIF_WORKER_BUDGET); } } +/* + * the poll function wich is used if no interrupt wake up our mmnif_rx functions + */ +int mmnif_poll(void* e) +{ + mmnif_t* mmnif; + unsigned int diff = mmnif_timestamp(); + if (!mmnif_dev) + { + DEBUGPRINTF("mmnif_poll(): the driver is not initialized yet\n"); + return -1; + } + + mmnif = (mmnif_t*) mmnif_dev->state; + +#ifdef DEBUG_MMNIF + DEBUGPRINTF("mmnif_poll(): polling thread launched",mmnif->rx_buff); +#endif + + if (!no_irq) + { + sem_wait(&mmnif->com_poll); + } + + /*run while driver is up*/ + while (active) + { + while (!mmnif->rx_buff->dcount == MMNIF_MAX_DESCRIPTORS) + { + mmnif->stats.pll_empty++; + if (mmnif->stats.pll_empty >= MMNIF_POLL_BUDGET) + { + /* enable interrupts and suspend polling + * + */ + mmnif->rx_buff->iv_intr = TRUE; + mmnif->stats.pll_empty = 0; +#ifdef DEBUG_MMNIF + DEBUGPRINTF("mmnif_poll(): heuristical interrupts enabled\n"); +#endif + sem_wait(&mmnif->com_poll); + } + /* uncomment this to test only polling + */ + // mmnif->stats.pll_empty = 0; + } + + mmnif->stats.pll_empty=0; + mmnif_rx(mmnif_dev); + + } + + return NULL; +} /* * Open the interface should be called by kernel to use this network interface */ @@ -1021,7 +1092,7 @@ int mmnif_open() /* If interrupts are not used we immediately add the polling function * to the queue which would otherwise be done through the IRQ handler. */ -// mmnif_device_schedule(); + mmnif_device_schedule(); /* Start the device worker thread wich actually processes the incoming * packet's this is not done in the "interrupt handler" to shorten them up diff --git a/kernel/tests.c b/kernel/tests.c index 09555c4d..ecb708ee 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -158,7 +158,7 @@ void srv_on_conn(ServerEventArgs* e) { int i = 0, err = 0; int tmp1,tmp2; - char buff[1024]; + char buff[2047]; SHELLDEBUGPRINTF("someone finally connected\n"); From 50fd4073845f71372481e75ce80c2cbf02eb466c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 4 Aug 2011 15:56:11 +0200 Subject: [PATCH 235/261] benchmark --- drivers/net/mmnif.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 2884699e..e5a2bf2d 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -988,7 +988,6 @@ void mmnif_irqhandler() int mmnif_poll(void* e) { mmnif_t* mmnif; - unsigned int diff = mmnif_timestamp(); if (!mmnif_dev) { From 2d088421fffc469a5b4ac185ac4a6e509a3ad621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 4 Aug 2011 15:59:16 +0200 Subject: [PATCH 236/261] benchmark --- kernel/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/tests.c b/kernel/tests.c index ecb708ee..0723ac56 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -158,7 +158,7 @@ void srv_on_conn(ServerEventArgs* e) { int i = 0, err = 0; int tmp1,tmp2; - char buff[2047]; + char buff[1220]; SHELLDEBUGPRINTF("someone finally connected\n"); From 210ebfb68f29e08336d224d6985103554dbbba9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 4 Aug 2011 16:00:22 +0200 Subject: [PATCH 237/261] benchmark --- drivers/net/mmnif.c | 1 - kernel/tests.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index e5a2bf2d..ea55b00b 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -703,7 +703,6 @@ static void mmnif_link_layer(struct netif *netif, struct pbuf *q, ip_addr_t *ipa netif->linkoutput(netif,q); } - /* * Init the device (called from lwip) * It's invoked in netif_add diff --git a/kernel/tests.c b/kernel/tests.c index 0723ac56..09555c4d 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -158,7 +158,7 @@ void srv_on_conn(ServerEventArgs* e) { int i = 0, err = 0; int tmp1,tmp2; - char buff[1220]; + char buff[1024]; SHELLDEBUGPRINTF("someone finally connected\n"); From 82eb79df71515be72cc02b1b847d73e1cf8ded8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Benedikt=20Kr=C3=BCger?= Date: Thu, 4 Aug 2011 16:21:01 +0200 Subject: [PATCH 238/261] cosmetics --- drivers/net/mmnif.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index ea55b00b..63102836 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -67,15 +67,6 @@ extern HANDLE hProc; #ifdef DEBUG_MMNIF #include "util.h" /* hex dump */ -#endif - -#ifdef WIN32 - -#else - - - - #endif /* define constants @@ -88,16 +79,12 @@ extern HANDLE hProc; #define MMNIF_RX_BUFFERLEN 8192 #define MMNIF_MAX_DESCRIPTORS 32 -#define MMNIF_CORES 2 - -#define MMNIF_WORKER_BUDGET 4 +#define MMNIF_CORES 48 #define MMNIF_POLL_BUDGET 0x100000 -#define MMNIF_WAIT_BUDGET 0x2 - #define MMNIF_STATUS_FREE 0x00 -#define MMNIF_STATUS_PENDING 0x01 +#define MMNIF_STATUS_PENDING 0x01 #define MMNIF_STATUS_RDY 0x02 #define MMNIF_STATUS_INPROC 0x03 #define MMNIF_STATUS_PROC 0x04 From 387ef0ea9b92303073fd18f5a4a2ca9bc45ff1b6 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 4 Aug 2011 16:48:04 +0200 Subject: [PATCH 239/261] cosmetic changes --- arch/x86/kernel/apic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/apic.c b/arch/x86/kernel/apic.c index 0651750e..379a181b 100644 --- a/arch/x86/kernel/apic.c +++ b/arch/x86/kernel/apic.c @@ -338,7 +338,7 @@ static apic_mp_t* search_apic(size_t base, size_t limit) { if (tmp->signature == MP_FLT_SIGNATURE) { if (!((tmp->version > 4) || tmp->features[0])) return tmp; - } + } } return NULL; From 87cd484bb92e8f0ac49e08b5d8e71b62fdbe9a11 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sat, 6 Aug 2011 15:46:10 +0200 Subject: [PATCH 240/261] add additional debug information --- drivers/net/rtl8139.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/rtl8139.c b/drivers/net/rtl8139.c index 1afc6a10..c7978fdf 100644 --- a/drivers/net/rtl8139.c +++ b/drivers/net/rtl8139.c @@ -113,7 +113,8 @@ static err_t rtl8139if_output(struct netif* netif, struct pbuf* p) static void rtl8139if_input(struct netif* netif, struct pbuf* p) { struct eth_hdr *ethhdr; - + err_t err; + /* points to packet payload, which starts with an Ethernet header */ ethhdr = p->payload; @@ -127,8 +128,9 @@ static void rtl8139if_input(struct netif* netif, struct pbuf* p) case ETHTYPE_PPPOE: #endif /* PPPOE_SUPPORT */ /* full packet send to tcpip_thread to process */ - if (mynetif->input(p, mynetif) != ERR_OK) { - LWIP_DEBUGF(NETIF_DEBUG, ("rtl8139if_input: IP input error\n")); + err = mynetif->input(p, mynetif); + if (err != ERR_OK) { + LWIP_DEBUGF(NETIF_DEBUG, ("rtl8139if_input: IP input error %d\n", (int32_t) err)); pbuf_free(p); } break; From e4a170938e3789b571c8701e86f0f840584f05c7 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sat, 6 Aug 2011 15:52:47 +0200 Subject: [PATCH 241/261] create a special init task (initd), which spawns all other tasks --- kernel/init.c | 43 +++++++++++++++++++++++++++++++++++++++++++ kernel/main.c | 42 ++---------------------------------------- 2 files changed, 45 insertions(+), 40 deletions(-) diff --git a/kernel/init.c b/kernel/init.c index b63c5c43..39274ebb 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -25,6 +25,7 @@ #include #include #include +#include #ifdef CONFIG_LWIP #include #include @@ -47,6 +48,7 @@ void echo_init(void); void ping_init(void); +int test_init(void); /* * Note that linker symbols are not variables, they have no memory allocated for @@ -178,4 +180,45 @@ int network_shutdown(void) return 0; } +static void list_fs(vfs_node_t* node, uint32_t depth) +{ + int j, i = 0; + dirent_t* dirent = NULL; + + while ((dirent = readdir_fs(node, i)) != 0) { + for(j=0; jname); + + if (strcmp(dirent->name, ".") && strcmp(dirent->name, "..")) { + vfs_node_t *new_node = finddir_fs(node, dirent->name); + if (new_node) { + if (new_node->type == FS_FILE) { + char buff[16] = {[0 ... 15] = 0x00}; + + read_fs(new_node, (uint8_t*)buff, 8, 0); + for(j=0; j #include #include -#include #include #include +#include #include #include #include @@ -34,8 +34,6 @@ #include #endif -extern int test_init(void); - /* * Note that linker symbols are not variables, they have no memory allocated for * maintaining a value, rather their address is their value. @@ -45,39 +43,6 @@ extern const void kernel_end; extern char __BUILD_DATE; extern char __BUILD_TIME; -static void list_fs(vfs_node_t* node, uint32_t depth) -{ - int j, i = 0; - dirent_t* dirent = NULL; - - while ((dirent = readdir_fs(node, i)) != 0) { - for(j=0; jname); - - if (strcmp(dirent->name, ".") && strcmp(dirent->name, "..")) { - vfs_node_t *new_node = finddir_fs(node, dirent->name); - if (new_node) { - if (new_node->type == FS_FILE) { - char buff[16] = {[0 ... 15] = 0x00}; - - read_fs(new_node, (uint8_t*)buff, 8, 0); - for(j=0; j 1 // idle loop of the application processors int smp_main(void) @@ -117,7 +82,6 @@ int main(void) kprintf("Kernel starts at %p and ends at %p\n", &kernel_start, &kernel_end); system_calibration(); - network_init(); kprintf("Processor frequency: %u MHz\n", get_cpu_frequency()); kprintf("Total memory: %u MBytes\n", atomic_int32_read(&total_pages)/((1024*1024)/PAGE_SIZE)); @@ -125,9 +89,7 @@ int main(void) kprintf("Current available memory: %u MBytes\n", atomic_int32_read(&total_available_pages)/((1024*1024)/PAGE_SIZE)); sleep(5); - list_root(); - test_init(); - per_core(current_task)->status = TASK_IDLE; + create_kernel_task(NULL, initd, NULL); per_core(current_task)->time_slices = 0; // reset the number of time slices reschedule(); From 54dfd7ba49304c05c9a154af1e1fed47b029c194 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sat, 6 Aug 2011 15:54:00 +0200 Subject: [PATCH 242/261] add example macro to check if the tcpip thread is alive --- lwip/src/include/lwipopts.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index 4be7eb4c..1d3e7b9d 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -118,4 +118,5 @@ #define TIMERS_DEBUG LWIP_DBG_OFF #define SOCKETS_DEBUG LWIP_DBG_OFF +//#define LWIP_TCPIP_THREAD_ALIVE() kputs("TCPIP thread is alive!\n") #endif From a179ded21bf7c1a0c313b27fa334c7ccc1083199 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sat, 6 Aug 2011 15:55:34 +0200 Subject: [PATCH 243/261] redesign of the timers, support of timeouts in mailboxes and semaphores --- arch/x86/kernel/gdt.c | 7 +- arch/x86/kernel/timer.c | 59 +++++------- include/metalsvm/init.h | 3 + include/metalsvm/mailbox.h | 39 +++++--- include/metalsvm/semaphore.h | 139 +++++++++++++++++++---------- include/metalsvm/semaphore_types.h | 4 +- include/metalsvm/tasks.h | 7 -- include/metalsvm/tasks_types.h | 8 +- include/metalsvm/time.h | 8 +- kernel/tasks.c | 137 +++++++++++++++------------- kernel/tests.c | 6 +- lwip/src/arch/sys_arch.c | 105 +++++++++++----------- 12 files changed, 287 insertions(+), 235 deletions(-) diff --git a/arch/x86/kernel/gdt.c b/arch/x86/kernel/gdt.c index 9441410a..f6667c60 100644 --- a/arch/x86/kernel/gdt.c +++ b/arch/x86/kernel/gdt.c @@ -116,9 +116,8 @@ int arch_fork(task_t* task) asm volatile ("pop %0" : "=r"(task_state_segments[id].ecx)); asm volatile ("pop %0" : "=r"(task_state_segments[id].eax)); - // store current EFLAGS and set IF flag - // => the parent task will enable the interrupt handling - asm volatile ("pushf; pop %%eax; or $2,%%ah" : "=a"(task_state_segments[id].eflags)); + // store the current EFLAGS + asm volatile ("pushf; pop %%eax" : "=a"(task_state_segments[id].eflags)); // This will be the entry point for the new task. asm volatile ("call read_eip" : "=a"(task_state_segments[id].eip)); @@ -146,7 +145,7 @@ int create_default_frame(task_t* task, internal_entry_point_t ep, void* arg) task_state_segments[id].fs = ds; task_state_segments[id].gs = ds; task_state_segments[id].es = ds; - task_state_segments[id].eflags = 0x1202; + task_state_segments[id].eflags = 0x1002; // 0x1202; task_state_segments[id].cr3 = (uint32_t) (virt_to_phys((size_t)task->pgd)); task_state_segments[id].eip = (uint32_t) ep; task_state_segments[id].esp = (uint32_t) kstacks[id] + KERNEL_STACK_SIZE - sizeof(size_t); diff --git a/arch/x86/kernel/timer.c b/arch/x86/kernel/timer.c index 66c4ac82..8a806eb6 100644 --- a/arch/x86/kernel/timer.c +++ b/arch/x86/kernel/timer.c @@ -30,14 +30,6 @@ #include #include -typedef struct { - uint8_t active; - uint64_t timeout; -} timer_t; - -static timer_t timers[MAX_TASKS] = {[0 ... MAX_TASKS-1] = {0, 0}}; -static spinlock_irqsave_t timers_lock = SPINLOCK_IRQSAVE_INIT; - /* * This will keep track of how many ticks the system * has been running for @@ -78,38 +70,27 @@ static void timer_handler(struct state *s) { timer_ticks++; - spinlock_irqsave_lock(&timers_lock); - for(i=1; i= timers[i].timeout)) { - timers[i].active = 0; - wakeup_task(i); - } - } - spinlock_irqsave_unlock(&timers_lock); + /* + * Every TIMER_FREQ clocks (approximately 1 second), we will + * display a message on the screen + */ + /*if (timer_ticks % TIMER_FREQ == 0) { + vga_puts("One second has passed\n"); + }*/ } - - /* - * Every TIMER_FREQ clocks (approximately 1 second), we will - * display a message on the screen - */ - /*if (timer_ticks % TIMER_FREQ == 0) { - vga_puts("One second has passed\n"); - }*/ } -/* - * This will continuously loop until the given time has - * been reached - */ -void timer_wait(unsigned int ticks) +int timer_wait(unsigned int ticks) { uint64_t eticks = timer_ticks + ticks; task_t* curr_task = per_core(current_task); - // Task 0 is always an idle task - // Perhaps, the status is not set correctly... - if ((curr_task->status == TASK_IDLE) || (curr_task->id == 0)) + if (curr_task->status == TASK_IDLE) { + /* + * This will continuously loop until the given time has + * been reached + */ while (timer_ticks < eticks) { check_workqueues(); @@ -122,16 +103,18 @@ void timer_wait(unsigned int ticks) } else if (timer_ticks < eticks) { check_workqueues(); - spinlock_irqsave_lock(&timers_lock); if (timer_ticks < eticks) { - timers[curr_task->id].active = 1; - timers[curr_task->id].timeout = eticks; - block_task(curr_task->id); - spinlock_irqsave_unlock(&timers_lock); + uint32_t flags = irq_nested_disable(); + curr_task->timeout = eticks; + curr_task->flags |= TASK_TIMER_USED; + curr_task->status = TASK_BLOCKED; + irq_nested_enable(flags); reschedule(); - } else spinlock_irqsave_unlock(&timers_lock); + } } + + return 0; } #define LATCH(f) ((CLOCK_TICK_RATE + f/2) / f) diff --git a/include/metalsvm/init.h b/include/metalsvm/init.h index fddf3409..02f97091 100644 --- a/include/metalsvm/init.h +++ b/include/metalsvm/init.h @@ -42,6 +42,9 @@ int network_init(void); /** @brief Shutdown the networking subsystem. */ int network_shutdown(void); +/** @brief Entry point of the init task */ +int initd(void* arg); + #ifdef __cplusplus } #endif diff --git a/include/metalsvm/mailbox.h b/include/metalsvm/mailbox.h index 3ffb1d87..8d86492c 100644 --- a/include/metalsvm/mailbox.h +++ b/include/metalsvm/mailbox.h @@ -24,6 +24,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { @@ -32,7 +33,7 @@ extern "C" { #define MAILBOX(name, type) \ inline static int mailbox_##name##_init(mailbox_##name##_t* m) { \ if (BUILTIN_EXPECT(!m, 0)) \ - return -1; \ + return -EINVAL; \ \ memset(m->buffer, 0x00, sizeof(type)*MAILBOX_SIZE); \ m->wpos = m->rpos = 0; \ @@ -46,7 +47,7 @@ extern "C" { \ inline static int mailbox_##name##_destroy(mailbox_##name##_t* m) { \ if (BUILTIN_EXPECT(!m, 0)) \ - return -1; \ + return -EINVAL; \ \ sem_destroy(&m->mails); \ sem_destroy(&m->boxes); \ @@ -58,9 +59,9 @@ extern "C" { \ inline static int mailbox_##name##_post(mailbox_##name##_t* m, type mail) { \ if (BUILTIN_EXPECT(!m, 0)) \ - return -1; \ + return -EINVAL; \ \ - sem_wait(&m->boxes); \ + sem_wait(&m->boxes, 0); \ spinlock_lock(&m->wlock); \ m->buffer[m->wpos] = mail; \ m->wpos = (m->wpos+1) % MAILBOX_SIZE; \ @@ -70,11 +71,29 @@ extern "C" { return 0; \ } \ \ - inline static int mailbox_##name##_fetch(mailbox_##name##_t* m, type* mail) { \ - if (BUILTIN_EXPECT(!m || !mail, 0)) \ - return -1; \ + inline static int mailbox_##name##_trypost(mailbox_##name##_t* m, type mail) { \ + if (BUILTIN_EXPECT(!m, 0)) \ + return -EINVAL; \ \ - sem_wait(&m->mails); \ + if (sem_trywait(&m->boxes)) \ + return -EBUSY; \ + spinlock_lock(&m->wlock); \ + m->buffer[m->wpos] = mail; \ + m->wpos = (m->wpos+1) % MAILBOX_SIZE; \ + spinlock_unlock(&m->wlock); \ + sem_post(&m->mails); \ + \ + return 0; \ + } \ + \ + inline static int mailbox_##name##_fetch(mailbox_##name##_t* m, type* mail, uint32_t ms) { \ + int err; \ + \ + if (BUILTIN_EXPECT(!m || !mail, 0)) \ + return -EINVAL; \ + \ + err = sem_wait(&m->mails, ms); \ + if (err) return err; \ spinlock_lock(&m->rlock); \ *mail = m->buffer[m->rpos]; \ m->rpos = (m->rpos+1) % MAILBOX_SIZE; \ @@ -86,10 +105,10 @@ extern "C" { \ inline static int mailbox_##name##_tryfetch(mailbox_##name##_t* m, type* mail) { \ if (BUILTIN_EXPECT(!m || !mail, 0)) \ - return -1; \ + return -EINVAL; \ \ if (sem_trywait(&m->mails) != 0) \ - return -1; \ + return -EINVAL; \ spinlock_lock(&m->rlock); \ *mail = m->buffer[m->rpos]; \ m->rpos = (m->rpos+1) % MAILBOX_SIZE; \ diff --git a/include/metalsvm/semaphore.h b/include/metalsvm/semaphore.h index 42348383..19ad8e38 100644 --- a/include/metalsvm/semaphore.h +++ b/include/metalsvm/semaphore.h @@ -29,6 +29,8 @@ #include #include #include +#include +#include #ifdef __cplusplus extern "C" { @@ -43,19 +45,19 @@ extern "C" { * * @return * - 0 on success - * - -1 on failure + * - -EINVAL on invalid argument */ inline static int sem_init(sem_t* s, unsigned int v) { unsigned int i; if (BUILTIN_EXPECT(!s, 0)) - return -1; + return -EINVAL; s->value = v; s->pos = 0; for(i=0; iqueue[i] = MAX_TASKS; - spinlock_init(&s->lock); + spinlock_irqsave_init(&s->lock); return 0; } @@ -63,44 +65,13 @@ inline static int sem_init(sem_t* s, unsigned int v) { /** @brief Destroy semaphore * @return * - 0 on success - * - -1 on failure + * - -EINVAL on invalid argument */ inline static int sem_destroy(sem_t* s) { if (BUILTIN_EXPECT(!s, 0)) - return -1; + return -EINVAL; - spinlock_destroy(&s->lock); - - return 0; -} - -/** @brief Blocking wait for semaphore - * - * This will put your task to sleep - * - * @return - * - 0 on success - * - -1 on failure - */ -inline static int sem_wait(sem_t* s) { - task_t* curr_task = per_core(current_task); - - if (BUILTIN_EXPECT(!s, 0)) - return -1; - -next_try: - spinlock_lock(&s->lock); - if (s->value > 0) { - s->value--; - spinlock_unlock(&s->lock); - } else { - s->queue[s->pos] = curr_task->id; - s->pos = (s->pos + 1) % MAX_TASKS; - block_task(curr_task->id); - spinlock_unlock(&s->lock); - reschedule(); - goto next_try; - } + spinlock_irqsave_destroy(&s->lock); return 0; } @@ -111,37 +82,111 @@ next_try: * * @return * - 0 on success (You got the semaphore) - * - -1 on failure (You still have to wait) + * - -EINVAL on invalid argument + * - -ECANCELED on failure (You still have to wait) */ inline static int sem_trywait(sem_t* s) { - int ret = -1; + int ret = -ECANCELED; if (BUILTIN_EXPECT(!s, 0)) - return -1; + return -EINVAL; - spinlock_lock(&s->lock); + spinlock_irqsave_lock(&s->lock); if (s->value > 0) { s->value--; ret = 0; } - spinlock_unlock(&s->lock); + spinlock_irqsave_unlock(&s->lock); return ret; } +/** @brief Blocking wait for semaphore + * + * @param ms Timeout in milliseconds + * @return + * - 0 on success + * - -EINVAL on invalid argument + * - -ETIME on timer expired + */ +inline static int sem_wait(sem_t* s, uint32_t ms) { + task_t* curr_task = per_core(current_task); + + if (BUILTIN_EXPECT(!s, 0)) + return -EINVAL; + + if (!ms) { +next_try1: + spinlock_irqsave_lock(&s->lock); + if (s->value > 0) { + s->value--; + spinlock_irqsave_unlock(&s->lock); + } else { + s->queue[s->pos] = curr_task->id; + s->pos = (s->pos + 1) % MAX_TASKS; + curr_task->status = TASK_BLOCKED; + spinlock_irqsave_unlock(&s->lock); + reschedule(); + NOP2; + goto next_try1; + } + + return 0; + } else { + uint32_t ticks = (ms * TIMER_FREQ) / 1000; + uint32_t remain = (ms * TIMER_FREQ) % 1000; + + if (ticks) { + uint64_t deadline = get_clock_tick() + ticks; + +next_try2: + spinlock_irqsave_lock(&s->lock); + if (s->value > 0) { + s->value--; + spinlock_irqsave_unlock(&s->lock); + return 0; + } else { + if (get_clock_tick() >= deadline) { + spinlock_irqsave_unlock(&s->lock); + goto timeout; + } + s->queue[s->pos] = curr_task->id; + s->pos = (s->pos + 1) % MAX_TASKS; + curr_task->timeout = deadline; + curr_task->flags |= TASK_TIMER_USED; + curr_task->status = TASK_BLOCKED; + spinlock_irqsave_unlock(&s->lock); + reschedule(); + goto next_try2; + } + } + +timeout: + while (remain) { + udelay(1000); + remain--; + + if (!sem_trywait(s)) + return 0; + } + + return -ETIME; + } +} + /** @brief Give back resource * @return * - 0 on success - * - -1 on failure + * - -EINVAL on invalid argument */ inline static int sem_post(sem_t* s) { if (BUILTIN_EXPECT(!s, 0)) - return -1; + return -EINVAL; - spinlock_lock(&s->lock); + spinlock_irqsave_lock(&s->lock); if (s->value > 0) { s->value++; - spinlock_unlock(&s->lock); + spinlock_irqsave_unlock(&s->lock); } else { unsigned int k, i; @@ -155,7 +200,7 @@ inline static int sem_post(sem_t* s) { } i = (i + 1) % MAX_TASKS; } - spinlock_unlock(&s->lock); + spinlock_irqsave_unlock(&s->lock); } return 0; diff --git a/include/metalsvm/semaphore_types.h b/include/metalsvm/semaphore_types.h index a80dbc5e..5812d51a 100644 --- a/include/metalsvm/semaphore_types.h +++ b/include/metalsvm/semaphore_types.h @@ -41,11 +41,11 @@ typedef struct { /// Position in queue unsigned int pos; /// Access lock - spinlock_t lock; + spinlock_irqsave_t lock; } sem_t; /// Macro for initialization of semaphore -#define SEM_INIT(v) {v, {[0 ... MAX_TASKS-1] = MAX_TASKS}, 0, SPINLOCK_INIT} +#define SEM_INIT(v) {v, {[0 ... MAX_TASKS-1] = MAX_TASKS}, 0, SPINLOCK_IRQSAVE_INIT} #ifdef __cplusplus } diff --git a/include/metalsvm/tasks.h b/include/metalsvm/tasks.h index c4e68991..0b0bcdac 100644 --- a/include/metalsvm/tasks.h +++ b/include/metalsvm/tasks.h @@ -100,13 +100,6 @@ void scheduler(void); */ int wakeup_task(tid_t); -/** @brief Change a task's status to TASK_BLOCKED - * @return - * - 0 on success - * - -EINVAL (-22) on failure - */ -int block_task(tid_t); - /** @brief Abort current task */ void NORETURN abort(void); diff --git a/include/metalsvm/tasks_types.h b/include/metalsvm/tasks_types.h index f63ae533..f972feba 100644 --- a/include/metalsvm/tasks_types.h +++ b/include/metalsvm/tasks_types.h @@ -50,6 +50,8 @@ extern "C" { #define TASK_DEFAULT_FLAGS 0 #define TASK_FPU_INIT (1 << 0) #define TASK_FPU_USED (1 << 1) +#define TASK_TIMER_USED (1 << 2) +#define TASK_SWITCH_IN_PROGRESS (1 << 3) typedef int (*entry_point_t)(void*); typedef int (STDCALL *internal_entry_point_t)(void*); @@ -61,8 +63,12 @@ typedef struct task { tid_t id; /// Task status (INVALID, READY, RUNNING, ...) uint32_t status; + /// Additional status flags. For instance, to signalize the using of the FPU + uint32_t flags; /// Number of used time slices uint32_t time_slices; + /// timeout for a blocked task + uint64_t timeout; /// Usage in number of pages atomic_int32_t user_usage; /// Avoids concurrent access to the page directory @@ -73,8 +79,6 @@ typedef struct task { spinlock_t vma_lock; /// List of VMAs vma_t* vma_list; - /// Additional status flags. For instance, to signalize the using of the FPU - uint32_t flags; /// starting time/tick of the task uint64_t start_tick; /// Start address of the heap diff --git a/include/metalsvm/time.h b/include/metalsvm/time.h index aa47e47a..c20d059c 100644 --- a/include/metalsvm/time.h +++ b/include/metalsvm/time.h @@ -56,13 +56,13 @@ int sys_times(struct tms*, clock_t* clock); */ int timer_init(void); -/** @brief Blocking wait function - * - * This function does no busy-wait. +/** @brief Initialized a timer * * @param ticks Amount of ticks to wait + * @return + * - 0 on success */ -void timer_wait(unsigned int ticks); +int timer_wait(unsigned int ticks); /** @brief Returns the current number of ticks. * @return Current number of ticks diff --git a/kernel/tasks.c b/kernel/tasks.c index 95c4c1ed..5813e50a 100644 --- a/kernel/tasks.c +++ b/kernel/tasks.c @@ -47,8 +47,8 @@ * A task's id will be its position in this array. */ static task_t task_table[MAX_TASKS] = { \ - [0] = {0, TASK_RUNNING, 0, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0, 0}, \ - [1 ... MAX_TASKS-1] = {0, TASK_INVALID, 0, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0, 0}}; + [0] = {0, TASK_IDLE, 0, 0, 0, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0}, \ + [1 ... MAX_TASKS-1] = {0, TASK_INVALID, 0, 0, 0, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0}}; static spinlock_irqsave_t table_lock = SPINLOCK_IRQSAVE_INIT; DEFINE_PER_CORE(task_t*, current_task, task_table+0); @@ -82,15 +82,17 @@ int dump_scheduling_statistics(void) } int multitasking_init(void) { - if (BUILTIN_EXPECT(task_table[0].status == TASK_RUNNING, 1)) { - mailbox_wait_msg_init(&task_table[0].inbox); - memset(task_table[0].outbox, 0x00, sizeof(mailbox_wait_msg_t*)*MAX_TASKS); - task_table[0].pgd = get_boot_pgd(); - task_table[0].flags = TASK_DEFAULT_FLAGS; - return 0; + if (BUILTIN_EXPECT(task_table[0].status != TASK_IDLE, 0)) { + kputs("Task 0 is not an idle task\n"); + return -ENOMEM; } - return -ENOMEM; + mailbox_wait_msg_init(&task_table[0].inbox); + memset(task_table[0].outbox, 0x00, sizeof(mailbox_wait_msg_t*)*MAX_TASKS); + task_table[0].pgd = get_boot_pgd(); + task_table[0].flags = TASK_DEFAULT_FLAGS; + + return 0; } size_t get_idle_task(uint32_t id) @@ -100,13 +102,13 @@ size_t get_idle_task(uint32_t id) return -EINVAL; task_table[id].id = id; - task_table[id].time_slices = 0; task_table[id].status = TASK_IDLE; + task_table[id].flags = TASK_DEFAULT_FLAGS; + task_table[id].time_slices = 0; atomic_int32_set(&task_table[id].user_usage, 0); mailbox_wait_msg_init(&task_table[id].inbox); memset(task_table[id].outbox, 0x00, sizeof(mailbox_wait_msg_t*)*MAX_TASKS); task_table[id].pgd = get_boot_pgd(); - task_table[id].flags = TASK_DEFAULT_FLAGS; current_task[id].var = task_table+id; return get_stack(id); @@ -192,17 +194,6 @@ void NORETURN abort(void) { do_exit(-1); } -/* - * @brief: if the task gets the first time slice, - * the table_lock is hold and have to be released. - */ -inline static void start_first_time_slice(void) -{ -#if MAX_CORES > 1 - spinlock_irqsave_unlock(&table_lock); -#endif -} - /** @brief Create a task with a specific entry point * * @param id Pointer to a tid_t struct were the id shall be set @@ -236,6 +227,8 @@ static int create_task(tid_t* id, internal_entry_point_t ep, void* arg) } task_table[i].id = i; + task_table[i].status = TASK_READY; + task_table[i].flags = TASK_DEFAULT_FLAGS; task_table[i].time_slices = 0; spinlock_init(&task_table[i].vma_lock); task_table[i].vma_list = NULL; @@ -248,11 +241,9 @@ static int create_task(tid_t* id, internal_entry_point_t ep, void* arg) ret = create_default_frame(task_table+i, ep, arg); - task_table[i].flags = TASK_DEFAULT_FLAGS; task_table[i].start_heap = 0; task_table[i].end_heap = 0; task_table[i].start_tick = get_clock_tick(); - task_table[i].status = TASK_READY; break; } } @@ -312,7 +303,7 @@ int sys_fork(void) mailbox_wait_msg_init(&task_table[i].inbox); memset(task_table[i].outbox, 0x00, sizeof(mailbox_wait_msg_t*)*MAX_TASKS); task_table[i].outbox[parent_task->id] = &parent_task->inbox; - task_table[i].flags = parent_task->flags; + task_table[i].flags = parent_task->flags & ~TASK_SWITCH_IN_PROGRESS; memcpy(&(task_table[i].fpu), &(parent_task->fpu), sizeof(union fpu_state)); task_table[i].start_tick = get_clock_tick(); task_table[i].start_heap = 0; @@ -325,7 +316,13 @@ int sys_fork(void) // Leave the function without releasing the locks // because the locks are already released // by the parent task! - start_first_time_slice(); +#if MAX_CORES > 1 + task_t* old = per_core(old_task); + + if (old) + old->flags &= ~TASK_SWITCH_IN_PROGRESS; +#endif + irq_enable(); return 0; } @@ -359,8 +356,13 @@ static int STDCALL kernel_entry(void* args) { int ret; kernel_args_t* kernel_args = (kernel_args_t*) args; +#if MAX_CORES > 1 + task_t* old = per_core(old_task); - start_first_time_slice(); + if (old) + old->flags &= ~TASK_SWITCH_IN_PROGRESS; +#endif + irq_enable(); if (BUILTIN_EXPECT(!kernel_args, 0)) return -EINVAL; @@ -600,8 +602,13 @@ invalid: static int STDCALL user_entry(void* arg) { int ret; +#if MAX_CORES > 1 + task_t* old = per_core(old_task); - start_first_time_slice(); + if (old) + old->flags &= ~TASK_SWITCH_IN_PROGRESS; +#endif + irq_enable(); if (BUILTIN_EXPECT(!arg, 0)) return -EINVAL; @@ -754,7 +761,7 @@ tid_t wait(int32_t* result) if (BUILTIN_EXPECT(curr_task->status == TASK_IDLE, 0)) return -EINVAL; - mailbox_wait_msg_fetch(&curr_task->inbox, &tmp); + mailbox_wait_msg_fetch(&curr_task->inbox, &tmp, 0); if (result) *result = tmp.result; @@ -772,12 +779,9 @@ int wakeup_task(tid_t id) { int ret = -EINVAL; - /* avoid nested locking */ spinlock_irqsave_lock(&table_lock); - if (task_table[id].status != TASK_BLOCKED) { - kprintf("Task %d is not blocked!\n", id); - } else { + if (task_table[id].status == TASK_BLOCKED) { task_table[id].status = TASK_READY; ret = 0; } @@ -787,28 +791,6 @@ int wakeup_task(tid_t id) return ret; } -/** @brief Block a running or ready task. - * @param id The task's tid_t structure - * @return - * - 0 on success - * - -EINVAL (-22) on failure - */ -int block_task(tid_t id) -{ - int ret = -EINVAL; - - spinlock_irqsave_lock(&table_lock); - - if ((task_table[id].status == TASK_RUNNING) || (task_table[id].status == TASK_READY)) { - task_table[id].status = TASK_BLOCKED; - ret = 0; - } else kprintf("Unable to block task %d!\n", id); - - spinlock_irqsave_unlock(&table_lock); - - return ret; -} - /* * we use this struct to guarantee that the id * has its own cache line @@ -828,12 +810,13 @@ void scheduler(void) task_t* curr_task; uint32_t i; uint32_t new_id; + uint64_t current_tick; static last_id_t last_id = { 0 }; #if MAX_CORES > 1 spinlock_irqsave_lock(&table_lock); #endif - + current_tick = get_clock_tick(); orig_task = curr_task = per_core(current_task); /* increase the number of used time slices */ @@ -849,12 +832,29 @@ void scheduler(void) curr_task->flags &= ~TASK_FPU_USED; } - for(i=1, new_id=(last_id.id + 1) % MAX_TASKS; + for(i=0, new_id=(last_id.id + 1) % MAX_TASKS; istatus == TASK_RUNNING) + if (task_table[new_id].flags & TASK_TIMER_USED) { + if (task_table[new_id].status != TASK_BLOCKED) + task_table[new_id].flags &= ~TASK_TIMER_USED; + if ((task_table[new_id].status == TASK_BLOCKED) && (current_tick >= task_table[new_id].timeout)) { + task_table[new_id].flags &= ~TASK_TIMER_USED; + task_table[new_id].status = TASK_READY; + } + } + + if ((task_table[new_id].status == TASK_READY) && !(task_table[new_id].flags & TASK_SWITCH_IN_PROGRESS)) { + if (curr_task->status == TASK_RUNNING) { curr_task->status = TASK_READY; +#if MAX_CORES > 1 + curr_task->flags |= TASK_SWITCH_IN_PROGRESS; + per_core(old_task) = curr_task; +#endif + } +#if MAX_CORES > 1 + else per_core(old_task) = NULL; +#endif task_table[new_id].status = TASK_RUNNING; curr_task = per_core(current_task) = task_table+new_id; last_id.id = new_id; @@ -863,6 +863,10 @@ void scheduler(void) } } +#if MAX_CORES > 1 + per_core(old_task) = NULL; +#endif + if ((curr_task->status == TASK_RUNNING) || (curr_task->status == TASK_IDLE)) goto get_task_out; @@ -874,14 +878,19 @@ void scheduler(void) curr_task = per_core(current_task) = task_table+CORE_ID; get_task_out: - //kprintf("schedule %d on core %d\n", per_core(current_task)->id, smp_id()); - - if (curr_task != orig_task) - switch_task(new_id); - #if MAX_CORES > 1 spinlock_irqsave_unlock(&table_lock); #endif + + if (curr_task != orig_task) { + //kprintf("schedule from %d to %d on core %d\n", orig_task->id, curr_task->id, smp_id()); + switch_task(new_id); +#if MAX_CORES > 1 + orig_task= per_core(old_task); + if (orig_task) + orig_task->flags &= ~TASK_SWITCH_IN_PROGRESS; +#endif + } } void reschedule(void) diff --git a/kernel/tests.c b/kernel/tests.c index bced389b..989dfe51 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -44,14 +44,14 @@ static int consumer(void* arg) int i, m = 0; for(i=0; i<5; i++) { - sem_wait(&consuming); + sem_wait(&consuming, 0); kprintf("Consumer got %d\n", val); val = 0; sem_post(&producing); } for(i=0; i<5; i++) { - mailbox_int32_fetch(&mbox, &m); + mailbox_int32_fetch(&mbox, &m, 0); kprintf("Got mail %d\n", m); } @@ -64,7 +64,7 @@ static int producer(void* arg) int mail[5] = {1, 2, 3, 4, 5}; for(i=0; i<5; i++) { - sem_wait(&producing); + sem_wait(&producing, 0); kprintf("Produce value: current val %d\n", val); val = 42; sem_post(&consuming); diff --git a/lwip/src/arch/sys_arch.c b/lwip/src/arch/sys_arch.c index b9b2d7db..b46f0fd7 100644 --- a/lwip/src/arch/sys_arch.c +++ b/lwip/src/arch/sys_arch.c @@ -32,18 +32,22 @@ #define FALSE 0 #endif +#if SYS_LIGHTWEIGHT_PROT +#if MAX_CORES > 1 +static spinlock_irqsave_t lwprot_lock; +#endif +#endif + /** Returns the current time in milliseconds, * may be the same as sys_jiffies or at least based on it. */ -u32_t -sys_now(void) +u32_t sys_now(void) { - return (get_clock_tick() / TIMER_FREQ) * 1000; + return (get_clock_tick() / TIMER_FREQ) * 1000; } -u32_t -sys_jiffies(void) +u32_t sys_jiffies(void) { - return (get_clock_tick() / TIMER_FREQ) * 1000; + return (get_clock_tick() / TIMER_FREQ) * 1000; } #if !NO_SYS @@ -51,9 +55,13 @@ sys_jiffies(void) /* sys_init(): init needed system resources * Note: At the moment there are none */ -void -sys_init(void) +void sys_init(void) { +#if SYS_LIGHTWEIGHT_PROT +#if MAX_CORES > 1 + spinlock_irqsave_init(&lwprot_lock); +#endif +#endif } /** @@ -61,28 +69,24 @@ sys_init(void) * * @param ms number of milliseconds to sleep */ -void -sys_msleep(u32_t ms) +void sys_msleep(u32_t ms) { - if (ms > 0) { - sys_sem_t delaysem; - err_t err = sys_sem_new(&delaysem, 0); - if (err == ERR_OK) { - sys_arch_sem_wait(&delaysem, ms); - sys_sem_free(&delaysem); - } - } + if (ms * TIMER_FREQ / 1000 > 0) + timer_wait(ms * TIMER_FREQ / 1000); + else if (ms > 0) + udelay(ms * 1000); } /* sys_thread_new(): Spawns a new thread with given attributes as supported * Note: In MetalSVM this is realized as kernel tasks */ -sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio) +sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, + int stacksize, int prio) { - tid_t tmp; + sys_thread_t tmp; - kprintf("Create LWIP task %s\n", name); create_kernel_task(&tmp, thread, arg); + kprintf("Created LWIP task %s with id %u\n", name, tmp); return tmp; } @@ -108,10 +112,10 @@ int sys_sem_valid(sys_sem_t* sem) /* sys_sem_new(): creates a new semaphre with given count. * This semaphore becomes valid */ -err_t sys_sem_new(sys_sem_t* sem,u8_t count) +err_t sys_sem_new(sys_sem_t* sem, u8_t count) { sem->valid = TRUE; - return sem_init(&sem->sem,count); + return sem_init(&sem->sem, count); } /* sys_sem_set_invalid(): this semapohore becomes invalid @@ -137,16 +141,11 @@ void sys_sem_signal(sys_sem_t* sem) u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout) { int err; - if (!timeout) - return sem_wait(&sem->sem); - while (timeout) - { - err = sem_trywait(&sem->sem); - if (err != -1) - return err; - udelay(1000); - timeout--; - } + + err = sem_wait(&sem->sem, timeout); + if (!err) + return 0; + return SYS_ARCH_TIMEOUT; } @@ -164,16 +163,11 @@ int sys_mbox_valid(sys_mbox_t * mbox) */ u32_t sys_arch_mbox_fetch(sys_mbox_t * mbox, void **msg, u32_t timeout) { - if (!timeout) - return mailbox_ptr_fetch(&mbox->mailbox,msg); + int err; - while(timeout) - { - if (!mailbox_ptr_tryfetch(&mbox->mailbox,msg)) - return 0; - udelay(1000); - timeout--; - } + err = mailbox_ptr_fetch(&mbox->mailbox, msg, timeout); + if (!err) + return 0; return SYS_ARCH_TIMEOUT; } @@ -192,13 +186,13 @@ void sys_mbox_free(sys_mbox_t* mbox) */ u32_t sys_arch_mbox_tryfetch(sys_mbox_t* mbox, void** msg) { - return mailbox_ptr_tryfetch(&mbox->mailbox,msg); + mailbox_ptr_tryfetch(&mbox->mailbox, msg); } /* sys_mbox_new(): create a new mailbox with a minimum size of "size" * */ -err_t sys_mbox_new(sys_mbox_t* mbox,int size) +err_t sys_mbox_new(sys_mbox_t* mbox, int size) { mbox->valid = TRUE; return mailbox_ptr_init(&mbox->mailbox); @@ -218,15 +212,19 @@ void sys_mbox_set_invalid(sys_mbox_t* mbox) */ err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg) { - return mailbox_ptr_post(&mbox->mailbox,msg); + int err; + + err = mailbox_ptr_trypost(&mbox->mailbox, msg); + + return err; } /* sys_mbox_post(): post new data to the mailbox * */ -void sys_mbox_post(sys_mbox_t* mbox,void* msg) +void sys_mbox_post(sys_mbox_t* mbox, void* msg) { - mailbox_ptr_post(&mbox->mailbox,msg); + mailbox_ptr_post(&mbox->mailbox, msg); } /* sys_mutex_lock(): lock the given mutex @@ -235,7 +233,7 @@ void sys_mbox_post(sys_mbox_t* mbox,void* msg) */ void sys_mutex_lock(sys_mutex_t* mutex) { - sem_wait(mutex); + sem_wait(mutex, 0); } /* sys_mutex_unlock(): unlock the given mutex @@ -251,23 +249,22 @@ void sys_mutex_unlock(sys_mutex_t* mutex) */ err_t sys_mutex_new(sys_mutex_t * mutex) { - sem_init(mutex,1); + sem_init(mutex, 1); return 0; } #if SYS_LIGHTWEIGHT_PROT #if MAX_CORES > 1 -static spinlock_irqsave_t lwprot_lock = SPINLOCK_IRQSAVE_INIT; - sys_prot_t sys_arch_protect(void) { - spinlock_irqsave_lock(&lwprot_lock); - return 0; + spinlock_irqsave_lock(&lwprot_lock); + return 0; } void sys_arch_unprotect(sys_prot_t pval) { - spinlock_irqsave_unlock(&lwprot_lock); + LWIP_UNUSED_ARG(pval); + spinlock_irqsave_unlock(&lwprot_lock); } #endif #endif From 6d08dbcf72e2ae3493df41963bd7c684fda10208 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sat, 6 Aug 2011 07:24:21 -0700 Subject: [PATCH 244/261] minor changes to support the new semaphore interface --- drivers/net/mmnif.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index d2dbdece..18c126d2 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -540,7 +540,7 @@ __inline void mmnif_lock_rx_hdr(int dest_ip) #else if(disable_locking) return; mm_rx_buffer_t* hdr = (char*)mpb_start_address + ( dest_ip -1 ) * mpb_size; - sem_wait(&hdr->lock); + sem_wait(&hdr->lock, 0); #endif } /* mmnif_unlock_rx_hdr(): unlock the header @@ -879,7 +879,7 @@ err_t mmnif_init(struct netif* netif) */ sem_init(&mmnif->com_poll,1); - sem_wait(&mmnif->com_poll); + sem_wait(&mmnif->com_poll,0); /* inform via interrupt should be the dafault */ @@ -1113,7 +1113,7 @@ static int mmnif_wait(struct netif* netif, uint32_t poll, int budget) } else { - mailbox_ptr_fetch(&(mmnif->mbox), (void**) &p); + mailbox_ptr_fetch(&(mmnif->mbox), (void**) &p,0); } /* if there is data, pass it up to the lwip @@ -1174,7 +1174,7 @@ int mmnif_poll(void* e) if (!no_irq) { - sem_wait(&mmnif->com_poll); + sem_wait(&mmnif->com_poll,0); } /*run while driver is up*/ @@ -1196,7 +1196,7 @@ int mmnif_poll(void* e) #ifdef DEBUG_MMNIF DEBUGPRINTF("mmnif_poll(): heuristical interrupts enabled\n"); #endif - sem_wait(&mmnif->com_poll); + sem_wait(&mmnif->com_poll,0); mmnif->stats.pll_empty = 1; } } From 40d3763d4cec1ba8addc0cae586ebe37ecd37cdc Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sat, 6 Aug 2011 07:27:14 -0700 Subject: [PATCH 245/261] remove typo --- drivers/net/rckemac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/rckemac.c b/drivers/net/rckemac.c index cd3409e9..1c8ae09d 100644 --- a/drivers/net/rckemac.c +++ b/drivers/net/rckemac.c @@ -276,7 +276,7 @@ static void rckemacif_input(struct netif* netif, struct pbuf* p) #endif /* PPPOE_SUPPORT */ /* full packet send to tcpip_thread to process */ if (mynetif->input(p, mynetif) != ERR_OK) { - LWIP_DEBUGF(NETIF_DEBUG, ("rtl8139if_input: IP input error\n")); + LWIP_DEBUGF(NETIF_DEBUG, ("rckemacif_input: IP input error\n")); pbuf_free(p); } break; From 6c13cc7584d8081c13e9f9bc37011872af312da2 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sat, 6 Aug 2011 08:52:07 -0700 Subject: [PATCH 246/261] enable mmnif and some cosmetic changes --- drivers/net/mmnif.c | 12 ++++++------ kernel/init.c | 4 ++-- kernel/tests.c | 29 ++++++++--------------------- 3 files changed, 16 insertions(+), 29 deletions(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 5dd5d1c0..514400f8 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -298,7 +298,7 @@ __inline int mmnif_trigger_irq(dest_ip) /* mmnif_get_device_stats(): Returns a copy of the * current device */ -mmnif_device_stats_t mmnif_get_device_stats() +mmnif_device_stats_t mmnif_get_device_stats(void) { mmnif_device_stats_t stats = {0}; @@ -313,7 +313,7 @@ mmnif_device_stats_t mmnif_get_device_stats() /* mmnif_print_stats(): Print the devices stats of the * current device */ -void mmnif_print_stats() +void mmnif_print_stats(void) { mmnif_t* mmnif; @@ -506,7 +506,7 @@ int mmnif_commit_packet(uint8_t dest,uint32_t addr) /* mmnif_rxbuff_free() : the opposite to mmnif_rxbuff_alloc() a from the receiver * already processed chunk of memory is freed so that it can be allocated again */ -void mmnif_rxbuff_free() +void mmnif_rxbuff_free(void) { mmnif_t* mmnif = mmnif_dev->state; mm_rx_buffer_t* b = mmnif->rx_buff; @@ -947,7 +947,7 @@ drop_packet: /* mmnif_irqhandler(): * handles the incomint interrupts */ -void mmnif_irqhandler() +void mmnif_irqhandler(void) { mmnif_t* mmnif; @@ -1025,7 +1025,7 @@ int mmnif_poll(void* e) /* * Open the interface should be called by kernel to use this network interface */ -int mmnif_open() +int mmnif_open(void) { struct ip_addr ipaddr; struct ip_addr netmask; @@ -1100,7 +1100,7 @@ int mmnif_open() * close the interface should be called by kernel to close this interface and release resources * Note: it's temporarly empty. Support will be added. */ -int mmnif_close() +int mmnif_close(void) { mmnif_t* mmnif; diff --git a/kernel/init.c b/kernel/init.c index 6ada0799..444739f4 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -152,7 +152,7 @@ int network_init(void) } } #else - //mmnif_open(); + mmnif_open(); #endif // start echo and ping server @@ -167,7 +167,7 @@ int network_shutdown(void) { #ifdef CONFIG_LWIP #ifdef CONFIG_ROCKCREEK - //mmnif_close(); + mmnif_close(); #elif defined(CONFIG_PCI) dhcp_release(default_netif); dhcp_stop(default_netif); diff --git a/kernel/tests.c b/kernel/tests.c index 0bd523d0..24073e4e 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -132,7 +132,6 @@ static int join_test(void* arg) #if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK) - #define SHELLDEBUGPRINTF(x,...) kprintf(x,##__VA_ARGS__); static int srv_cnt = 0; @@ -247,19 +246,10 @@ void* client_task(void* e) while(1) sleep(2); -return NULL; + return NULL; } #endif -void* alive(void*e) -{ - while (1) - { - kprintf("IM ALIVE"); - sleep(2); - } -} - int test_init(void) { char* argv[] = {"/bin/tests", NULL}; @@ -275,22 +265,19 @@ int test_init(void) // sleep(10); // SHELLDEBUGPRINTF("hello World! I AM CORE NO. %d =) \n",RCCE_ue()); - create_kernel_task(NULL,alive,NULL); - - if (!RCCE_ue()) - create_kernel_task(NULL,server_task,NULL); - else - create_kernel_task(NULL,client_task,NULL); - +// if (!RCCE_ue()) +// create_kernel_task(NULL,server_task,NULL); +// else +// create_kernel_task(NULL,client_task,NULL); #endif -// create_kernel_task(NULL, foo, "Hello from foo1"); -// create_kernel_task(NULL, join_test, NULL); + create_kernel_task(NULL, foo, "Hello from foo1"); + create_kernel_task(NULL, join_test, NULL); //create_kernel_task(NULL, producer, NULL); //create_kernel_task(NULL, consumer, NULL); //create_kernel_task(NULL, mail_ping, NULL); //create_user_task(NULL, "/bin/hello", argv); -// create_user_task(NULL, "/bin/tests", argv); + create_user_task(NULL, "/bin/tests", argv); //create_user_task(NULL, "/bin/jacobi", argv); //create_user_task(NULL, "/bin/jacobi", argv); From 173c5d54b688d9cc24ac7c447a1ef43796b02f52 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sat, 6 Aug 2011 08:57:53 -0700 Subject: [PATCH 247/261] set rckemacif as default interface --- drivers/net/mmnif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 514400f8..52a5e9c5 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -1060,7 +1060,7 @@ int mmnif_open(void) } /* set our network interface to the default interface for lwip*/ - netif_set_default(mmnif_dev); + //netif_set_default(mmnif_dev); /* tell lwip all initialization is done and we want to set it ab*/ netif_set_up(mmnif_dev); From 399876928f658945c077d3964a43cf99be6e8b5c Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sat, 6 Aug 2011 18:09:25 +0200 Subject: [PATCH 248/261] build mmnif only on RockCreek --- drivers/net/mmnif.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 52a5e9c5..6d805772 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -19,6 +19,7 @@ #include /* ethernet arp packets */ #include /* struct iphdr*/ #include /* tcpip_input()*/ +#if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK) #ifdef WIN32 @@ -1122,3 +1123,5 @@ int mmnif_close(void) return NULL; } + +#endif From c3fbc90b9e40b6d18afb3974c8908903624a551d Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 8 Aug 2011 23:32:34 +0200 Subject: [PATCH 249/261] switch (partly) from a Apache License to a BSD License --- arch/x86/include/asm/syscall.h | 40 ++++++++++++++------ include/metalsvm/syscall.h | 48 ++++++++++++++++++------ newlib/src/libgloss/metalsvm/_exit.c | 40 ++++++++++++++------ newlib/src/libgloss/metalsvm/chown.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/close.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/crt0.asm | 49 ++++++++++++++++--------- newlib/src/libgloss/metalsvm/environ.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/errno.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/execve.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/fork.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/fstat.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/getpid.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/gettod.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/init.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/isatty.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/kill.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/link.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/lseek.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/open.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/read.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/readlink.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/sbrk.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/stat.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/symlink.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/syscall.h | 48 ++++++++++++++++++------ newlib/src/libgloss/metalsvm/times.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/unlink.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/wait.c | 38 +++++++++++++------ newlib/src/libgloss/metalsvm/write.c | 38 +++++++++++++------ 29 files changed, 808 insertions(+), 329 deletions(-) diff --git a/arch/x86/include/asm/syscall.h b/arch/x86/include/asm/syscall.h index 13285ed2..17aa1abf 100644 --- a/arch/x86/include/asm/syscall.h +++ b/arch/x86/include/asm/syscall.h @@ -1,20 +1,36 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * This file is part of MetalSVM. + * This file is part of MetalSVM. */ /** diff --git a/include/metalsvm/syscall.h b/include/metalsvm/syscall.h index b47fc284..70c6ff4c 100644 --- a/include/metalsvm/syscall.h +++ b/include/metalsvm/syscall.h @@ -1,20 +1,36 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * This file is part of MetalSVM. + * This file is part of MetalSVM. */ /** @@ -50,6 +66,14 @@ extern "C" { #define __NR_wait 13 #define __NR_execve 14 #define __NR_times 15 +#define __NR_accept 16 +#define __NR_bind 17 +#define __NR_closesocket 18 +#define __NR_connect 19 +#define __NR_listen 20 +#define __NR_recv 21 +#define __NR_send 22 +#define __NR_socket 23 #ifdef __cplusplus } diff --git a/newlib/src/libgloss/metalsvm/_exit.c b/newlib/src/libgloss/metalsvm/_exit.c index 78499875..ab8fb363 100644 --- a/newlib/src/libgloss/metalsvm/_exit.c +++ b/newlib/src/libgloss/metalsvm/_exit.c @@ -1,20 +1,36 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * This file is part of MetalSVM. + * This file is part of MetalSVM. */ #include "config.h" diff --git a/newlib/src/libgloss/metalsvm/chown.c b/newlib/src/libgloss/metalsvm/chown.c index 323538d4..028e904a 100644 --- a/newlib/src/libgloss/metalsvm/chown.c +++ b/newlib/src/libgloss/metalsvm/chown.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/close.c b/newlib/src/libgloss/metalsvm/close.c index 5bcf18e6..e5e64d22 100644 --- a/newlib/src/libgloss/metalsvm/close.c +++ b/newlib/src/libgloss/metalsvm/close.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/crt0.asm b/newlib/src/libgloss/metalsvm/crt0.asm index a1130587..5cca9cee 100644 --- a/newlib/src/libgloss/metalsvm/crt0.asm +++ b/newlib/src/libgloss/metalsvm/crt0.asm @@ -1,20 +1,35 @@ -; -; Copyright 2010 Stefan Lankes, Chair for Operating Systems, -; RWTH Aachen University -; -; Licensed under the Apache License, Version 2.0 (the "License"); -; you may not use this file except in compliance with the License. -; You may obtain a copy of the License at -; -; http://www.apache.org/licenses/LICENSE-2.0 -; -; Unless required by applicable law or agreed to in writing, software -; distributed under the License is distributed on an "AS IS" BASIS, -; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -; See the License for the specific language governing permissions and -; limitations under the License. -; -; This file is part of MetalSVM. + ; Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + ; RWTH Aachen University + ; + ; All rights reserved. + ; + ; Redistribution and use in source and binary forms, with or without + ; modification, are permitted provided that the following conditions are met: + ; 1. Redistributions of source code must retain the above copyright + ; notice, this list of conditions and the following disclaimer. + ; 2. Redistributions in binary form must reproduce the above copyright + ; notice, this list of conditions and the following disclaimer in the + ; documentation and/or other materials provided with the distribution. + ; 3. All advertising materials mentioning features or use of this software + ; must display the following acknowledgement: + ; This product includes software developed by the Chair for Operating Systems, + ; RWTH Aachen University. + ; 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + ; nor the names of its contributors may be used to endorse or promote products + ; derived from this software without specific prior written permission. + ; + ; THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + ; DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ; + ; This file is part of MetalSVM. [BITS 32] SECTION .text diff --git a/newlib/src/libgloss/metalsvm/environ.c b/newlib/src/libgloss/metalsvm/environ.c index 2274cfb9..6bf7f583 100644 --- a/newlib/src/libgloss/metalsvm/environ.c +++ b/newlib/src/libgloss/metalsvm/environ.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/errno.c b/newlib/src/libgloss/metalsvm/errno.c index c6289903..c61abbb3 100644 --- a/newlib/src/libgloss/metalsvm/errno.c +++ b/newlib/src/libgloss/metalsvm/errno.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/execve.c b/newlib/src/libgloss/metalsvm/execve.c index 285b8248..45fa7614 100644 --- a/newlib/src/libgloss/metalsvm/execve.c +++ b/newlib/src/libgloss/metalsvm/execve.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/fork.c b/newlib/src/libgloss/metalsvm/fork.c index 91864ee9..606c388c 100644 --- a/newlib/src/libgloss/metalsvm/fork.c +++ b/newlib/src/libgloss/metalsvm/fork.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/fstat.c b/newlib/src/libgloss/metalsvm/fstat.c index 51e1dbf5..54fbc09a 100644 --- a/newlib/src/libgloss/metalsvm/fstat.c +++ b/newlib/src/libgloss/metalsvm/fstat.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/getpid.c b/newlib/src/libgloss/metalsvm/getpid.c index 9c386e00..ca3f23f0 100644 --- a/newlib/src/libgloss/metalsvm/getpid.c +++ b/newlib/src/libgloss/metalsvm/getpid.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/gettod.c b/newlib/src/libgloss/metalsvm/gettod.c index 6fdea902..0d2a9307 100644 --- a/newlib/src/libgloss/metalsvm/gettod.c +++ b/newlib/src/libgloss/metalsvm/gettod.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/init.c b/newlib/src/libgloss/metalsvm/init.c index 74b2a283..be79d519 100644 --- a/newlib/src/libgloss/metalsvm/init.c +++ b/newlib/src/libgloss/metalsvm/init.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/isatty.c b/newlib/src/libgloss/metalsvm/isatty.c index 714b40f1..38952ee1 100644 --- a/newlib/src/libgloss/metalsvm/isatty.c +++ b/newlib/src/libgloss/metalsvm/isatty.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/kill.c b/newlib/src/libgloss/metalsvm/kill.c index 07315752..a883f9cc 100644 --- a/newlib/src/libgloss/metalsvm/kill.c +++ b/newlib/src/libgloss/metalsvm/kill.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/link.c b/newlib/src/libgloss/metalsvm/link.c index 2e030e5a..d2e0d793 100644 --- a/newlib/src/libgloss/metalsvm/link.c +++ b/newlib/src/libgloss/metalsvm/link.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/lseek.c b/newlib/src/libgloss/metalsvm/lseek.c index 82328753..f263ad72 100644 --- a/newlib/src/libgloss/metalsvm/lseek.c +++ b/newlib/src/libgloss/metalsvm/lseek.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/open.c b/newlib/src/libgloss/metalsvm/open.c index c7f40c14..918d2dc9 100644 --- a/newlib/src/libgloss/metalsvm/open.c +++ b/newlib/src/libgloss/metalsvm/open.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/read.c b/newlib/src/libgloss/metalsvm/read.c index a240d838..057f725c 100644 --- a/newlib/src/libgloss/metalsvm/read.c +++ b/newlib/src/libgloss/metalsvm/read.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/readlink.c b/newlib/src/libgloss/metalsvm/readlink.c index db23173e..004872f4 100644 --- a/newlib/src/libgloss/metalsvm/readlink.c +++ b/newlib/src/libgloss/metalsvm/readlink.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/sbrk.c b/newlib/src/libgloss/metalsvm/sbrk.c index 78002469..25948a43 100644 --- a/newlib/src/libgloss/metalsvm/sbrk.c +++ b/newlib/src/libgloss/metalsvm/sbrk.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/stat.c b/newlib/src/libgloss/metalsvm/stat.c index 4d008a9f..4ab81546 100644 --- a/newlib/src/libgloss/metalsvm/stat.c +++ b/newlib/src/libgloss/metalsvm/stat.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/symlink.c b/newlib/src/libgloss/metalsvm/symlink.c index a4ddef46..c2ccc403 100644 --- a/newlib/src/libgloss/metalsvm/symlink.c +++ b/newlib/src/libgloss/metalsvm/symlink.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/syscall.h b/newlib/src/libgloss/metalsvm/syscall.h index 6d137508..5bd58118 100644 --- a/newlib/src/libgloss/metalsvm/syscall.h +++ b/newlib/src/libgloss/metalsvm/syscall.h @@ -1,20 +1,36 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * Standard x86 syscalls for user programs running under MetalSVM + * This file is part of MetalSVM. */ #ifndef __SYSCALL_H__ @@ -39,6 +55,14 @@ extern "C" { #define __NR_wait 13 #define __NR_execve 14 #define __NR_times 15 +#define __NR_accept 16 +#define __NR_bind 17 +#define __NR_closesocket 18 +#define __NR_connect 19 +#define __NR_listen 20 +#define __NR_recv 21 +#define __NR_send 22 +#define __NR_socket 23 #define _STR(token) #token #define _SYSCALLSTR(x) "int $" _STR(x) " " diff --git a/newlib/src/libgloss/metalsvm/times.c b/newlib/src/libgloss/metalsvm/times.c index 5c4ebcd7..9f294ef7 100644 --- a/newlib/src/libgloss/metalsvm/times.c +++ b/newlib/src/libgloss/metalsvm/times.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/unlink.c b/newlib/src/libgloss/metalsvm/unlink.c index 23f2b763..5e26561c 100644 --- a/newlib/src/libgloss/metalsvm/unlink.c +++ b/newlib/src/libgloss/metalsvm/unlink.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/wait.c b/newlib/src/libgloss/metalsvm/wait.c index 166bef02..f4392ec9 100644 --- a/newlib/src/libgloss/metalsvm/wait.c +++ b/newlib/src/libgloss/metalsvm/wait.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ diff --git a/newlib/src/libgloss/metalsvm/write.c b/newlib/src/libgloss/metalsvm/write.c index 8c0fd3c0..b1f1d17a 100644 --- a/newlib/src/libgloss/metalsvm/write.c +++ b/newlib/src/libgloss/metalsvm/write.c @@ -1,18 +1,34 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * This file is part of MetalSVM. */ From 1bb959fdee5c010574c4609bad26175b83a6bba9 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 8 Aug 2011 23:34:30 +0200 Subject: [PATCH 250/261] add Makefiles to build libsocket.a and copyright statements --- newlib/Makefile | 4 +++- newlib/net/Makefile | 30 +++++++++++++++++++++++++ newlib/net/accept.c | 32 +++++++++++++++++++++++++++ newlib/net/bind.c | 32 +++++++++++++++++++++++++++ newlib/net/closesocket.c | 32 +++++++++++++++++++++++++++ newlib/net/config.h | 26 ++++++++++++++++++++++ newlib/net/connect.c | 32 +++++++++++++++++++++++++++ newlib/net/listen.c | 32 +++++++++++++++++++++++++++ newlib/net/recv.c | 32 +++++++++++++++++++++++++++ newlib/net/send.c | 32 +++++++++++++++++++++++++++ newlib/net/socket.c | 32 +++++++++++++++++++++++++++ newlib/net/syscall.h | 48 ++++++++++++++++++++++++++++++---------- newlib/net/warning.h | 44 ++++++++++++++++++++++++++++++++++++ 13 files changed, 395 insertions(+), 13 deletions(-) create mode 100644 newlib/net/Makefile create mode 100644 newlib/net/config.h create mode 100644 newlib/net/warning.h diff --git a/newlib/Makefile b/newlib/Makefile index 07751473..9031eced 100644 --- a/newlib/Makefile +++ b/newlib/Makefile @@ -16,7 +16,9 @@ TMP = $(TOPDIR)/tmp OPT = --disable-shared --disable-multilib --enable-newlib-hw-fp default: $(ARCH) - $(MAKE) -C examples depend + $(MAKE) CFLAGS+="-nostdinc -Wall -fno-builtin -I$(NEWLIB)/include -I../../include -I../../arch/$(ARCH)/include" LDFLAGS+="-nostdlib -L$(NEWLIB)/lib" -C net depend + $(MAKE) CFLAGS+="-nostdinc -Wall -fno-builtin -I$(NEWLIB)/include -I../../include -I../../arch/$(ARCH)/include" LDFLAGS+="-nostdlib -L$(NEWLIB)/lib" -C net + $(MAKE) CFLAGS+="-nostdinc -Wall -fno-builtin -I$(NEWLIB)/include -I../../include -I../../arch/$(ARCH)/include" LDFLAGS+="-nostdlib -L$(NEWLIB)/lib" -C examples depend $(MAKE) CFLAGS+="-nostdinc -Wall -fno-builtin -I$(NEWLIB)/include -I../../include -I../../arch/$(ARCH)/include" LDFLAGS+="-nostdlib -L$(NEWLIB)/lib" -C examples $(ARCH): diff --git a/newlib/net/Makefile b/newlib/net/Makefile new file mode 100644 index 00000000..61715d0c --- /dev/null +++ b/newlib/net/Makefile @@ -0,0 +1,30 @@ +ARCH = x86 +NEWLIB = ../x86/i586-metalsvm-elf32 +MAKE = make +STRIP_DEBUG = --strip-debug +KEEP_DEBUG = --only-keep-debug +LDFLAGS = +LIBNAME = libsocket.a +ARFLAGS = ruv +OBJS = accept.o bind.o closesocket.o connect.o listen.o recv.o send.o socket.o + +# other implicit rules +%.o : %.c + $(CC_FOR_TARGET) -c $(CFLAGS) -o $@ $< + +default: all + +all: $(LIBNAME) + +$(LIBNAME): $(OBJS) + $(AR_FOR_TARGET) $(ARFLAGS) $@ $(OBJS) + cp $@ $(NEWLIB)/lib + +clean: + $(RM) $(LIBNAME) *.o *~ + +depend: + $(CC_FOR_TARGET) -MM $(CFLAGS) *.c > Makefile.dep + +-include Makefile.dep +# DO NOT DELETE diff --git a/newlib/net/accept.c b/newlib/net/accept.c index 2b092f68..e188200f 100644 --- a/newlib/net/accept.c +++ b/newlib/net/accept.c @@ -1,3 +1,35 @@ +/* + * Copyright (c) 2011, Carl-Benedikt Krueger, Chair for Operating Systems, + * RWTH Aachen University + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include "config.h" #include <_ansi.h> diff --git a/newlib/net/bind.c b/newlib/net/bind.c index 9c02b834..9adecc22 100644 --- a/newlib/net/bind.c +++ b/newlib/net/bind.c @@ -1,3 +1,35 @@ +/* + * Copyright (c) 2011, Carl-Benedikt Krueger, Chair for Operating Systems, + * RWTH Aachen University + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include "config.h" #include <_ansi.h> diff --git a/newlib/net/closesocket.c b/newlib/net/closesocket.c index e24ce3c6..0733d126 100644 --- a/newlib/net/closesocket.c +++ b/newlib/net/closesocket.c @@ -1,3 +1,35 @@ +/* + * Copyright (c) 2011, Carl-Benedikt Krueger, Chair for Operating Systems, + * RWTH Aachen University + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include "config.h" #include <_ansi.h> diff --git a/newlib/net/config.h b/newlib/net/config.h new file mode 100644 index 00000000..962b38e3 --- /dev/null +++ b/newlib/net/config.h @@ -0,0 +1,26 @@ +/* Name of package. */ +#define PACKAGE libsocket + +/* Version of package. */ +#define VERSION 0.1 + +/* Missing syscall names */ +#define MISSING_SYSCALL_NAMES 1 + +/* Using ELF format */ +#define HAVE_ELF 1 + +/* Using GNU LD */ +#define HAVE_GNU_LD 1 + +/* .previous directive allowed */ +#define HAVE_ASM_PREVIOUS_DIRECTIVE 1 + +/* .pushsection/.popsection directives allowed */ +#define HAVE_ASM_POPSECTION_DIRECTIVE 1 + +/* support for section attributes */ +#define HAVE_SECTION_ATTRIBUTES 1 + +/* symbol prefix */ +#define __SYMBOL_PREFIX "" diff --git a/newlib/net/connect.c b/newlib/net/connect.c index ba3408e8..f737d44f 100644 --- a/newlib/net/connect.c +++ b/newlib/net/connect.c @@ -1,3 +1,35 @@ +/* + * Copyright (c) 2011, Carl-Benedikt Krueger, Chair for Operating Systems, + * RWTH Aachen University + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include "config.h" #include <_ansi.h> diff --git a/newlib/net/listen.c b/newlib/net/listen.c index 7d75dfc2..699bfcd1 100644 --- a/newlib/net/listen.c +++ b/newlib/net/listen.c @@ -1,3 +1,35 @@ +/* + * Copyright (c) 2011, Carl-Benedikt Krueger, Chair for Operating Systems, + * RWTH Aachen University + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include "config.h" #include <_ansi.h> diff --git a/newlib/net/recv.c b/newlib/net/recv.c index d6159fbb..cd7a39e1 100644 --- a/newlib/net/recv.c +++ b/newlib/net/recv.c @@ -1,3 +1,35 @@ +/* + * Copyright (c) 2011, Carl-Benedikt Krueger, Chair for Operating Systems, + * RWTH Aachen University + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include "config.h" #include <_ansi.h> diff --git a/newlib/net/send.c b/newlib/net/send.c index 4da06e06..939a5262 100644 --- a/newlib/net/send.c +++ b/newlib/net/send.c @@ -1,3 +1,35 @@ +/* + * Copyright (c) 2011, Carl-Benedikt Krueger, Chair for Operating Systems, + * RWTH Aachen University + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include "config.h" #include <_ansi.h> diff --git a/newlib/net/socket.c b/newlib/net/socket.c index 8aae8f67..0e7d850b 100644 --- a/newlib/net/socket.c +++ b/newlib/net/socket.c @@ -1,3 +1,35 @@ +/* + * Copyright (c) 2011, Carl-Benedikt Krueger, Chair for Operating Systems, + * RWTH Aachen University + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include "config.h" #include <_ansi.h> diff --git a/newlib/net/syscall.h b/newlib/net/syscall.h index 6d137508..5bd58118 100644 --- a/newlib/net/syscall.h +++ b/newlib/net/syscall.h @@ -1,20 +1,36 @@ /* - * Copyright 2010 Stefan Lankes, Chair for Operating Systems, - * RWTH Aachen University + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * All rights reserved. * - * http://www.apache.org/licenses/LICENSE-2.0 + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * Standard x86 syscalls for user programs running under MetalSVM + * This file is part of MetalSVM. */ #ifndef __SYSCALL_H__ @@ -39,6 +55,14 @@ extern "C" { #define __NR_wait 13 #define __NR_execve 14 #define __NR_times 15 +#define __NR_accept 16 +#define __NR_bind 17 +#define __NR_closesocket 18 +#define __NR_connect 19 +#define __NR_listen 20 +#define __NR_recv 21 +#define __NR_send 22 +#define __NR_socket 23 #define _STR(token) #token #define _SYSCALLSTR(x) "int $" _STR(x) " " diff --git a/newlib/net/warning.h b/newlib/net/warning.h new file mode 100644 index 00000000..9232a924 --- /dev/null +++ b/newlib/net/warning.h @@ -0,0 +1,44 @@ +#ifndef __WARNING_H__ +#define __WARNING_H__ + +#ifdef HAVE_GNU_LD +# ifdef HAVE_ELF + +/* We want the .gnu.warning.SYMBOL section to be unallocated. */ +# ifdef HAVE_ASM_PREVIOUS_DIRECTIVE +# define __make_section_unallocated(section_string) \ + asm(".section " section_string "\n .previous"); +# elif defined (HAVE_ASM_POPSECTION_DIRECTIVE) +# define __make_section_unallocated(section_string) \ + asm(".pushsection " section_string "\n .popsection"); +# else +# define __make_section_unallocated(section_string) +# endif + +# ifdef HAVE_SECTION_ATTRIBUTES +# define link_warning(symbol, msg) \ + static const char __evoke_link_warning_##symbol[] \ + __attribute__ ((section (".gnu.warning." __SYMBOL_PREFIX #symbol), \ + __used__)) = msg; +# else +# define link_warning(symbol, msg) +# endif + +#else /* !ELF */ + +# define link_warning(symbol, msg) \ + asm(".stabs \"" msg "\",30,0,0,0\n" \ + ".stabs \"" __SYMBOL_PREFIX #symbol "\",1,0,0,0\n"); +# endif +#else /* !GNULD */ +/* We will never be heard; they will all die horribly. */ +# define link_warning(symbol, msg) +#endif + +/* A canned warning for sysdeps/stub functions. + The GNU linker prepends a "warning: " string. */ +#define stub_warning(name) \ + link_warning (name, \ + #name " is not implemented and will always fail") + +#endif /* __WARNING_H__ */ From 4321b18b3cf24c6a7b29e430115c32b803f4805c Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 10 Aug 2011 08:02:30 +0200 Subject: [PATCH 251/261] at netio server (see http://www.nwlab.net/art/netio/netio.html) --- kernel/Makefile | 2 +- kernel/netio.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 kernel/netio.c diff --git a/kernel/Makefile b/kernel/Makefile index a5aa5b13..9f1eb11f 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,4 +1,4 @@ -C_source := main.c tasks.c syscall.c tests.c echo.c ping.c init.c server.c client.c shell.c +C_source := main.c tasks.c syscall.c tests.c echo.c ping.c netio.c init.c server.c client.c shell.c MODULE := kernel include $(TOPDIR)/Makefile.inc diff --git a/kernel/netio.c b/kernel/netio.c new file mode 100644 index 00000000..166bbc18 --- /dev/null +++ b/kernel/netio.c @@ -0,0 +1,62 @@ +/* + * this example is derived from the netio example of the contrib-1.4.0 + * + * see http://download.savannah.gnu.org/releases/lwip/ + */ + +#include +#include + +#if defined(CONFIG_LWIP) + +#include +#include + +/* See http://www.nwlab.net/art/netio/netio.html to get the netio tool */ + +#if LWIP_TCP +static err_t netio_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) +{ + + LWIP_UNUSED_ARG(arg); + + if (err == ERR_OK && p != NULL) { + tcp_recved(pcb, p->tot_len); + pbuf_free(p); + } else { + pbuf_free(p); + } + + if (err == ERR_OK && p == NULL) { + tcp_arg(pcb, NULL); + tcp_sent(pcb, NULL); + tcp_recv(pcb, NULL); + tcp_close(pcb); + } + + return ERR_OK; +} + +static err_t netio_accept(void *arg, struct tcp_pcb *pcb, err_t err) +{ + LWIP_UNUSED_ARG(arg); + LWIP_UNUSED_ARG(err); + + tcp_arg(pcb, NULL); + tcp_sent(pcb, NULL); + tcp_recv(pcb, netio_recv); + return ERR_OK; +} + +void netio_init(void) +{ + struct tcp_pcb *pcb; + + pcb = tcp_new(); + tcp_bind(pcb, IP_ADDR_ANY, 18767); + pcb = tcp_listen(pcb); + tcp_accept(pcb, netio_accept); +} +#endif /* LWIP_TCP */ + +#endif From 8e317a5a20f7cb8b65d5dce6234874067bd8daf7 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 10 Aug 2011 08:13:07 +0200 Subject: [PATCH 252/261] add headers and helper function to build a mini socket library --- newlib/net/Makefile | 10 +- newlib/net/closesocket.c | 4 +- newlib/net/in.h | 76 +++++++++ newlib/net/inet.h | 109 +++++++++++++ newlib/net/ip_addr.c | 336 +++++++++++++++++++++++++++++++++++++++ newlib/net/socket.h | 323 +++++++++++++++++++++++++++++++++++++ 6 files changed, 853 insertions(+), 5 deletions(-) create mode 100644 newlib/net/in.h create mode 100644 newlib/net/inet.h create mode 100644 newlib/net/ip_addr.c create mode 100644 newlib/net/socket.h diff --git a/newlib/net/Makefile b/newlib/net/Makefile index 61715d0c..4d8e4bce 100644 --- a/newlib/net/Makefile +++ b/newlib/net/Makefile @@ -6,7 +6,8 @@ KEEP_DEBUG = --only-keep-debug LDFLAGS = LIBNAME = libsocket.a ARFLAGS = ruv -OBJS = accept.o bind.o closesocket.o connect.o listen.o recv.o send.o socket.o +CP = cp +OBJS = accept.o bind.o closesocket.o connect.o listen.o recv.o send.o socket.o ip_addr.o # other implicit rules %.o : %.c @@ -16,9 +17,12 @@ default: all all: $(LIBNAME) -$(LIBNAME): $(OBJS) +$(LIBNAME): $(OBJS) socket.h $(AR_FOR_TARGET) $(ARFLAGS) $@ $(OBJS) - cp $@ $(NEWLIB)/lib + $(CP) $@ $(NEWLIB)/lib + $(CP) socket.h $(NEWLIB)/include/sys + $(CP) in.h $(NEWLIB)/include/netinet + $(CP) inet.h $(NEWLIB)/include/arpa clean: $(RM) $(LIBNAME) *.o *~ diff --git a/newlib/net/closesocket.c b/newlib/net/closesocket.c index 0733d126..edcf03b6 100644 --- a/newlib/net/closesocket.c +++ b/newlib/net/closesocket.c @@ -47,11 +47,11 @@ _DEFUN (closesocket, (s), { int ret; - ret = SYSCALL1(__NR_closesocket, s); + ret = SYSCALL1(__NR_closesocket, s); if (ret < 0) { errno = -ret; ret = -1; } - return ret; + return ret; } diff --git a/newlib/net/in.h b/newlib/net/in.h new file mode 100644 index 00000000..cd676dbe --- /dev/null +++ b/newlib/net/in.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * The kernel of MetalSVM uses LwIP as lightweight TCP/IP stack. + * This header defines only a small wrapper to use LwIP functions + * from user space. + */ + +#ifndef __NETINET_IN_H__ +#define __NETINET_IN_H__ + +#include +#include + +#ifdef __cplusplus +{ +#endif + +struct in_addr { + uint32_t s_addr; +}; + +/** 255.255.255.255 */ +#define IPADDR_NONE ((uint32_t)0xffffffffUL) +/** 127.0.0.1 */ +#define IPADDR_LOOPBACK ((uint32_t)0x7f000001UL) +/** 0.0.0.0 */ +#define IPADDR_ANY ((uint32_t)0x00000000UL) +/** 255.255.255.255 */ +#define IPADDR_BROADCAST ((uint32_t)0xffffffffUL) + +/** 255.255.255.255 */ +#define INADDR_NONE IPADDR_NONE +/** 127.0.0.1 */ +#define INADDR_LOOPBACK IPADDR_LOOPBACK +/** 0.0.0.0 */ +#define INADDR_ANY IPADDR_ANY +/** 255.255.255.255 */ +#define INADDR_BROADCAST IPADDR_BROADCAST + +#ifdef __cplusplus +} +#endif + +#endif /* __NETINET_IN_H__ */ diff --git a/newlib/net/inet.h b/newlib/net/inet.h new file mode 100644 index 00000000..39bbc745 --- /dev/null +++ b/newlib/net/inet.h @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * The kernel of MetalSVM uses LwIP as lightweight TCP/IP stack. + * This header defines only a small wrapper to use LwIP functions + * from user space. + */ + +#ifndef __ARPA_INET_H__ +#define __ARPA_INET_H__ + +#include +#include + +#ifdef __cplusplus +{ +#endif + +/* + * This is the aligned version of ip_addr_t, + * used as local variable, on the stack, etc. + */ +struct ip_addr { + uint32_t addr; +}; + +#ifndef LITTLE_ENDIAN +// Convert an uint16_t from host- to network byte order. +static inline uint16_t htons(uint16_t n) +{ + return ((n & 0xff) << 8) | ((n & 0xff00) >> 8); +} + +// Convert an uint16_t from network- to host byte order. +static inline uint16_t ntohs(uint16_t n) +{ + return htons(n); +} + +// Convert an uint32_t from host- to network byte order. +static inline uint32_t htonl(uint32_t n) +{ + return ((n & 0xff) << 24) | ((n & 0xff00) << 8) | ((n & 0xff0000UL) >> 8) | + ((n & 0xff000000UL) >> 24); +} + +// Convert an uint32_t from network- to host byte order. +static inline uint32_t ntohl(uint32_t n) +{ + return htonl(n); +} +#else +#error currently not supported!!! +#endif + + +/** ip_addr_t uses a struct for convenience only, so that the same defines can + * operate both on ip_addr_t as well as on ip_addr_p_t. */ +typedef struct ip_addr ip_addr_t; +//typedef struct ip_addr_packed ip_addr_p_t; + +uint32_t ipaddr_addr(const char *cp); +int ipaddr_aton(const char *cp, ip_addr_t *addr); +/** returns ptr to static buffer; not reentrant! */ +char *ipaddr_ntoa(const ip_addr_t *addr); +char *ipaddr_ntoa_r(const ip_addr_t *addr, char *buf, int buflen); + +/* directly map this to the lwip internal functions */ +#define inet_addr(cp) ipaddr_addr(cp) +#define inet_aton(cp, addr) ipaddr_aton(cp, (ip_addr_t*)addr) +#define inet_ntoa(addr) ipaddr_ntoa((ip_addr_t*)&(addr)) +#define inet_ntoa_r(addr, buf, buflen) ipaddr_ntoa_r((ip_addr_t*)&(addr), buf, buflen) + +#ifdef __cplusplus +} +#endif + +#endif /* __NETINET_IN_H__ */ diff --git a/newlib/net/ip_addr.c b/newlib/net/ip_addr.c new file mode 100644 index 00000000..53e19db1 --- /dev/null +++ b/newlib/net/ip_addr.c @@ -0,0 +1,336 @@ +/** + * @file + * This is the IPv4 address tools implementation. + * + */ + +/* + * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY + * OF SUCH DAMAGE. + * + * This file is part of the lwIP TCP/IP stack. + * + * Author: Adam Dunkels + * + */ + +/* + * LwIP backports of helper function for user-space applications + */ +#include "inet.h" +#include + +/* Define generic types used in lwIP */ +typedef uint8_t u8_t; +typedef int8_t s8_t; +typedef uint16_t u16_t; +typedef int16_t s16_t; +typedef uint32_t u32_t; +typedef int32_t s32_t; + +#define LWIP_ASSERT(message, assertion) do { if(!(assertion)) \ + fprintf(stderr, message); } while(0) + +/** IPv4 only: set the IP address given as an u32_t */ +#define ip4_addr_set_u32(dest_ipaddr, src_u32) ((dest_ipaddr)->addr = (src_u32)) +/** IPv4 only: get the IP address as an u32_t */ +#define ip4_addr_get_u32(src_ipaddr) ((src_ipaddr)->addr) + +#if 0 +#include "lwip/opt.h" +#include "lwip/ip_addr.h" +#include "lwip/netif.h" + +/* used by IP_ADDR_ANY and IP_ADDR_BROADCAST in ip_addr.h */ +const ip_addr_t ip_addr_any = { IPADDR_ANY }; +const ip_addr_t ip_addr_broadcast = { IPADDR_BROADCAST }; + +/** + * Determine if an address is a broadcast address on a network interface + * + * @param addr address to be checked + * @param netif the network interface against which the address is checked + * @return returns non-zero if the address is a broadcast address + */ +u8_t +ip4_addr_isbroadcast(u32_t addr, const struct netif *netif) +{ + ip_addr_t ipaddr; + ip4_addr_set_u32(&ipaddr, addr); + + /* all ones (broadcast) or all zeroes (old skool broadcast) */ + if ((~addr == IPADDR_ANY) || + (addr == IPADDR_ANY)) { + return 1; + /* no broadcast support on this network interface? */ + } else if ((netif->flags & NETIF_FLAG_BROADCAST) == 0) { + /* the given address cannot be a broadcast address + * nor can we check against any broadcast addresses */ + return 0; + /* address matches network interface address exactly? => no broadcast */ + } else if (addr == ip4_addr_get_u32(&netif->ip_addr)) { + return 0; + /* on the same (sub) network... */ + } else if (ip_addr_netcmp(&ipaddr, &(netif->ip_addr), &(netif->netmask)) + /* ...and host identifier bits are all ones? =>... */ + && ((addr & ~ip4_addr_get_u32(&netif->netmask)) == + (IPADDR_BROADCAST & ~ip4_addr_get_u32(&netif->netmask)))) { + /* => network broadcast address */ + return 1; + } else { + return 0; + } +} + +/** Checks if a netmask is valid (starting with ones, then only zeros) + * + * @param netmask the IPv4 netmask to check (in network byte order!) + * @return 1 if the netmask is valid, 0 if it is not + */ +u8_t +ip4_addr_netmask_valid(u32_t netmask) +{ + u32_t mask; + u32_t nm_hostorder = lwip_htonl(netmask); + + /* first, check for the first zero */ + for (mask = 1UL << 31 ; mask != 0; mask >>= 1) { + if ((nm_hostorder & mask) == 0) { + break; + } + } + /* then check that there is no one */ + for (; mask != 0; mask >>= 1) { + if ((nm_hostorder & mask) != 0) { + /* there is a one after the first zero -> invalid */ + return 0; + } + } + /* no one after the first zero -> valid */ + return 1; +} + +/* Here for now until needed in other places in lwIP */ +#ifndef isprint +#define in_range(c, lo, up) ((u8_t)c >= lo && (u8_t)c <= up) +#define isprint(c) in_range(c, 0x20, 0x7f) +#define isdigit(c) in_range(c, '0', '9') +#define isxdigit(c) (isdigit(c) || in_range(c, 'a', 'f') || in_range(c, 'A', 'F')) +#define islower(c) in_range(c, 'a', 'z') +#define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v') +#endif + +/** + * Ascii internet address interpretation routine. + * The value returned is in network order. + * + * @param cp IP address in ascii represenation (e.g. "127.0.0.1") + * @return ip address in network order + */ +u32_t +ipaddr_addr(const char *cp) +{ + ip_addr_t val; + + if (ipaddr_aton(cp, &val)) { + return ip4_addr_get_u32(&val); + } + return (IPADDR_NONE); +} +#endif + +/** + * Check whether "cp" is a valid ascii representation + * of an Internet address and convert to a binary address. + * Returns 1 if the address is valid, 0 if not. + * This replaces inet_addr, the return value from which + * cannot distinguish between failure and a local broadcast address. + * + * @param cp IP address in ascii represenation (e.g. "127.0.0.1") + * @param addr pointer to which to save the ip address in network order + * @return 1 if cp could be converted to addr, 0 on failure + */ +int +ipaddr_aton(const char *cp, ip_addr_t *addr) +{ + u32_t val; + u8_t base; + char c; + u32_t parts[4]; + u32_t *pp = parts; + + c = *cp; + for (;;) { + /* + * Collect number up to ``.''. + * Values are specified as for C: + * 0x=hex, 0=octal, 1-9=decimal. + */ + if (!isdigit(c)) + return (0); + val = 0; + base = 10; + if (c == '0') { + c = *++cp; + if (c == 'x' || c == 'X') { + base = 16; + c = *++cp; + } else + base = 8; + } + for (;;) { + if (isdigit(c)) { + val = (val * base) + (int)(c - '0'); + c = *++cp; + } else if (base == 16 && isxdigit(c)) { + val = (val << 4) | (int)(c + 10 - (islower(c) ? 'a' : 'A')); + c = *++cp; + } else + break; + } + if (c == '.') { + /* + * Internet format: + * a.b.c.d + * a.b.c (with c treated as 16 bits) + * a.b (with b treated as 24 bits) + */ + if (pp >= parts + 3) { + return (0); + } + *pp++ = val; + c = *++cp; + } else + break; + } + /* + * Check for trailing characters. + */ + if (c != '\0' && !isspace(c)) { + return (0); + } + /* + * Concoct the address according to + * the number of parts specified. + */ + switch (pp - parts + 1) { + + case 0: + return (0); /* initial nondigit */ + + case 1: /* a -- 32 bits */ + break; + + case 2: /* a.b -- 8.24 bits */ + if (val > 0xffffffUL) { + return (0); + } + val |= parts[0] << 24; + break; + + case 3: /* a.b.c -- 8.8.16 bits */ + if (val > 0xffff) { + return (0); + } + val |= (parts[0] << 24) | (parts[1] << 16); + break; + + case 4: /* a.b.c.d -- 8.8.8.8 bits */ + if (val > 0xff) { + return (0); + } + val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); + break; + default: + LWIP_ASSERT("unhandled", 0); + break; + } + if (addr) { + ip4_addr_set_u32(addr, htonl(val)); + } + return (1); +} + +/** + * Convert numeric IP address into decimal dotted ASCII representation. + * returns ptr to static buffer; not reentrant! + * + * @param addr ip address in network order to convert + * @return pointer to a global static (!) buffer that holds the ASCII + * represenation of addr + */ +char * +ipaddr_ntoa(const ip_addr_t *addr) +{ + static char str[16]; + return ipaddr_ntoa_r(addr, str, 16); +} + +/** + * Same as ipaddr_ntoa, but reentrant since a user-supplied buffer is used. + * + * @param addr ip address in network order to convert + * @param buf target buffer where the string is stored + * @param buflen length of buf + * @return either pointer to buf which now holds the ASCII + * representation of addr or NULL if buf was too small + */ +char *ipaddr_ntoa_r(const ip_addr_t *addr, char *buf, int buflen) +{ + u32_t s_addr; + char inv[3]; + char *rp; + u8_t *ap; + u8_t rem; + u8_t n; + u8_t i; + int len = 0; + + s_addr = ip4_addr_get_u32(addr); + + rp = buf; + ap = (u8_t *)&s_addr; + for(n = 0; n < 4; n++) { + i = 0; + do { + rem = *ap % (u8_t)10; + *ap /= (u8_t)10; + inv[i++] = '0' + rem; + } while(*ap); + while(i--) { + if (len++ >= buflen) { + return NULL; + } + *rp++ = inv[i]; + } + if (len++ >= buflen) { + return NULL; + } + *rp++ = '.'; + ap++; + } + *--rp = 0; + return buf; +} diff --git a/newlib/net/socket.h b/newlib/net/socket.h new file mode 100644 index 00000000..92d9ad0f --- /dev/null +++ b/newlib/net/socket.h @@ -0,0 +1,323 @@ +/* + * Copyright (c) 2011, Stefan Lankes, Chair for Operating Systems, + * RWTH Aachen University + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the Chair for Operating Systems, + * RWTH Aachen University. + * 4. Neither the name of the Chair for Operating Systems, RWTH Aachen University + * nor the names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY ''AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * The kernel of MetalSVM uses LwIP as lightweight TCP/IP stack. + * This header defines only a small wrapper to use LwIP functions + * from user space. + */ + +#ifndef __SOCKET_H__ +#define __SOCKET_H__ + +#include +#include +#include +#include + +#ifdef __cplusplus +{ +#endif + +struct sockaddr_in { + uint8_t sin_len; + uint8_t sin_family; + uint16_t sin_port; + struct in_addr sin_addr; + char sin_zero[8]; +}; + +struct sockaddr { + uint8_t sa_len; + uint8_t sa_family; + char sa_data[14]; +}; + +#ifndef socklen_t +# define socklen_t uint32_t +#endif + +/* Socket protocol types (TCP/UDP/RAW) */ +#define SOCK_STREAM 1 +#define SOCK_DGRAM 2 +#define SOCK_RAW 3 + +/* + * Option flags per-socket. These must match the SOF_ flags in ip.h (checked in init.c) + */ +#define SO_DEBUG 0x0001 /* Unimplemented: turn on debugging info recording */ +#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ +#define SO_REUSEADDR 0x0004 /* Allow local address reuse */ +#define SO_KEEPALIVE 0x0008 /* keep connections alive */ +#define SO_DONTROUTE 0x0010 /* Unimplemented: just use interface addresses */ +#define SO_BROADCAST 0x0020 /* permit to send and to receive broadcast messages (see IP_SOF_BROADCAST option) */ +#define SO_USELOOPBACK 0x0040 /* Unimplemented: bypass hardware when possible */ +#define SO_LINGER 0x0080 /* linger on close if data present */ +#define SO_OOBINLINE 0x0100 /* Unimplemented: leave received OOB data in line */ +#define SO_REUSEPORT 0x0200 /* Unimplemented: allow local address & port reuse */ + +#define SO_DONTLINGER ((int)(~SO_LINGER)) + +/* + * Additional options, not kept in so_options. + */ +#define SO_SNDBUF 0x1001 /* Unimplemented: send buffer size */ +#define SO_RCVBUF 0x1002 /* receive buffer size */ +#define SO_SNDLOWAT 0x1003 /* Unimplemented: send low-water mark */ +#define SO_RCVLOWAT 0x1004 /* Unimplemented: receive low-water mark */ +#define SO_SNDTIMEO 0x1005 /* Unimplemented: send timeout */ +#define SO_RCVTIMEO 0x1006 /* receive timeout */ +#define SO_ERROR 0x1007 /* get error status and clear */ +#define SO_TYPE 0x1008 /* get socket type */ +#define SO_CONTIMEO 0x1009 /* Unimplemented: connect timeout */ +#define SO_NO_CHECK 0x100a /* don't create UDP checksum */ + + +/* + * Structure used for manipulating linger option. + */ +struct linger { + int l_onoff; /* option on/off */ + int l_linger; /* linger time */ +}; + +/* + * Level number for (get/set)sockopt() to apply to socket itself. + */ +#define SOL_SOCKET 0xfff /* options for socket level */ + + +#define AF_UNSPEC 0 +#define AF_INET 2 +#define PF_INET AF_INET +#define PF_UNSPEC AF_UNSPEC + +#define IPPROTO_IP 0 +#define IPPROTO_TCP 6 +#define IPPROTO_UDP 17 +#define IPPROTO_UDPLITE 136 + +/* Flags we can use with send and recv. */ +#define MSG_PEEK 0x01 /* Peeks at an incoming message */ +#define MSG_WAITALL 0x02 /* Unimplemented: Requests that the function block until the full amount of data requested can be returned */ +#define MSG_OOB 0x04 /* Unimplemented: Requests out-of-band data. The significance and semantics of out-of-band data are protocol-specific */ +#define MSG_DONTWAIT 0x08 /* Nonblocking i/o for this operation only */ +#define MSG_MORE 0x10 /* Sender will send more */ + + +/* + * Options for level IPPROTO_IP + */ +#define IP_TOS 1 +#define IP_TTL 2 + +/* + * Options for level IPPROTO_TCP + */ +#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ +#define TCP_KEEPALIVE 0x02 /* send KEEPALIVE probes when idle for pcb->keep_idle milliseconds */ +#define TCP_KEEPIDLE 0x03 /* set pcb->keep_idle - Same as TCP_KEEPALIVE, but use seconds for get/setsockopt */ +#define TCP_KEEPINTVL 0x04 /* set pcb->keep_intvl - Use seconds for get/setsockopt */ +#define TCP_KEEPCNT 0x05 /* set pcb->keep_cnt - Use number of probes sent for get/setsockopt */ + +/* + * Options for level IPPROTO_UDPLITE + */ +#define UDPLITE_SEND_CSCOV 0x01 /* sender checksum coverage */ +#define UDPLITE_RECV_CSCOV 0x02 /* minimal receiver checksum coverage */ + + +/* + * Options and types for UDP multicast traffic handling + */ +#define IP_ADD_MEMBERSHIP 3 +#define IP_DROP_MEMBERSHIP 4 +#define IP_MULTICAST_TTL 5 +#define IP_MULTICAST_IF 6 +#define IP_MULTICAST_LOOP 7 + +typedef struct ip_mreq { + struct in_addr imr_multiaddr; /* IP multicast address of group */ + struct in_addr imr_interface; /* local IP address of interface */ +} ip_mreq; + +/* + * The Type of Service provides an indication of the abstract + * parameters of the quality of service desired. These parameters are + * to be used to guide the selection of the actual service parameters + * when transmitting a datagram through a particular network. Several + * networks offer service precedence, which somehow treats high + * precedence traffic as more important than other traffic (generally + * by accepting only traffic above a certain precedence at time of high + * load). The major choice is a three way tradeoff between low-delay, + * high-reliability, and high-throughput. + * The use of the Delay, Throughput, and Reliability indications may + * increase the cost (in some sense) of the service. In many networks + * better performance for one of these parameters is coupled with worse + * performance on another. Except for very unusual cases at most two + * of these three indications should be set. + */ +#define IPTOS_TOS_MASK 0x1E +#define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK) +#define IPTOS_LOWDELAY 0x10 +#define IPTOS_THROUGHPUT 0x08 +#define IPTOS_RELIABILITY 0x04 +#define IPTOS_LOWCOST 0x02 +#define IPTOS_MINCOST IPTOS_LOWCOST + +/* + * The Network Control precedence designation is intended to be used + * within a network only. The actual use and control of that + * designation is up to each network. The Internetwork Control + * designation is intended for use by gateway control originators only. + * If the actual use of these precedence designations is of concern to + * a particular network, it is the responsibility of that network to + * control the access to, and use of, those precedence designations. + */ +#define IPTOS_PREC_MASK 0xe0 +#define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK) +#define IPTOS_PREC_NETCONTROL 0xe0 +#define IPTOS_PREC_INTERNETCONTROL 0xc0 +#define IPTOS_PREC_CRITIC_ECP 0xa0 +#define IPTOS_PREC_FLASHOVERRIDE 0x80 +#define IPTOS_PREC_FLASH 0x60 +#define IPTOS_PREC_IMMEDIATE 0x40 +#define IPTOS_PREC_PRIORITY 0x20 +#define IPTOS_PREC_ROUTINE 0x00 + + +/* + * Commands for ioctlsocket(), taken from the BSD file fcntl.h. + * lwip_ioctl only supports FIONREAD and FIONBIO, for now + * + * Ioctl's have the command encoded in the lower word, + * and the size of any in or out parameters in the upper + * word. The high 2 bits of the upper word are used + * to encode the in/out status of the parameter; for now + * we restrict parameters to at most 128 bytes. + */ +#if !defined(FIONREAD) || !defined(FIONBIO) +#define IOCPARM_MASK 0x7fU /* parameters must be < 128 bytes */ +#define IOC_VOID 0x20000000UL /* no parameters */ +#define IOC_OUT 0x40000000UL /* copy out parameters */ +#define IOC_IN 0x80000000UL /* copy in parameters */ +#define IOC_INOUT (IOC_IN|IOC_OUT) + /* 0x20000000 distinguishes new & + old ioctl's */ +#define _IO(x,y) (IOC_VOID|((x)<<8)|(y)) + +#define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) + +#define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) +#endif /* !defined(FIONREAD) || !defined(FIONBIO) */ + +#ifndef FIONREAD +#define FIONREAD _IOR('f', 127, unsigned long) /* get # bytes to read */ +#endif +#ifndef FIONBIO +#define FIONBIO _IOW('f', 126, unsigned long) /* set/clear non-blocking i/o */ +#endif + +/* Socket I/O Controls: unimplemented */ +#ifndef SIOCSHIWAT +#define SIOCSHIWAT _IOW('s', 0, unsigned long) /* set high watermark */ +#define SIOCGHIWAT _IOR('s', 1, unsigned long) /* get high watermark */ +#define SIOCSLOWAT _IOW('s', 2, unsigned long) /* set low watermark */ +#define SIOCGLOWAT _IOR('s', 3, unsigned long) /* get low watermark */ +#define SIOCATMARK _IOR('s', 7, unsigned long) /* at oob mark? */ +#endif + +/* commands for fnctl */ +#ifndef F_GETFL +#define F_GETFL 3 +#endif +#ifndef F_SETFL +#define F_SETFL 4 +#endif + +/* File status flags and file access modes for fnctl, + these are bits in an int. */ +#ifndef O_NONBLOCK +#define O_NONBLOCK 1 /* nonblocking I/O */ +#endif +#ifndef O_NDELAY +#define O_NDELAY 1 /* same as O_NONBLOCK, for compatibility */ +#endif + +#ifndef SHUT_RD + #define SHUT_RD 0 + #define SHUT_WR 1 + #define SHUT_RDWR 2 +#endif + +/* FD_SET used for lwip_select */ +#ifndef FD_SET + #undef FD_SETSIZE + /* Make FD_SETSIZE match NUM_SOCKETS in socket.c */ + #define FD_SETSIZE MEMP_NUM_NETCONN + #define FD_SET(n, p) ((p)->fd_bits[(n)/8] |= (1 << ((n) & 7))) + #define FD_CLR(n, p) ((p)->fd_bits[(n)/8] &= ~(1 << ((n) & 7))) + #define FD_ISSET(n,p) ((p)->fd_bits[(n)/8] & (1 << ((n) & 7))) + #define FD_ZERO(p) memset((void*)(p),0,sizeof(*(p))) + + typedef struct fd_set { + unsigned char fd_bits [(FD_SETSIZE+7)/8]; + } fd_set; + +#endif /* FD_SET */ + +int accept(int s, struct sockaddr *addr, socklen_t *addrlen); +int bind(int s, const struct sockaddr *name, socklen_t namelen); +int getpeername (int s, struct sockaddr *name, socklen_t *namelen); +int getsockname (int s, struct sockaddr *name, socklen_t *namelen); +int getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen); +int setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen); +int connect(int s, const struct sockaddr *name, socklen_t namelen); +int listen(int s, int backlog); +int recv(int s, void *mem, size_t len, int flags); +int recvfrom(int s, void *mem, size_t len, int flags, + struct sockaddr *from, socklen_t *fromlen); +int send(int s, const void *dataptr, size_t size, int flags); +int sendto(int s, const void *dataptr, size_t size, int flags, + const struct sockaddr *to, socklen_t tolen); +int socket(int domain, int type, int protocol); +//int select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, +// struct timeval *timeout); +//int ioctl(int s, long cmd, void *argp); +//int fcntl(int s, int cmd, int val); + +#ifdef __cplusplus +} +#endif + +#endif /* __SOCKET_H__ */ From 5d9f36117422906dda1f75ad0b51e167b818121d Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 10 Aug 2011 08:15:53 +0200 Subject: [PATCH 253/261] add system calls to map the user-level socket library to LwIP sockets --- kernel/init.c | 2 + kernel/syscall.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++- kernel/tasks.c | 6 +- kernel/tests.c | 9 ++- 4 files changed, 156 insertions(+), 5 deletions(-) diff --git a/kernel/init.c b/kernel/init.c index 444739f4..a29807ac 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -48,6 +48,7 @@ void echo_init(void); void ping_init(void); +void netio_init(void); int test_init(void); /* @@ -158,6 +159,7 @@ int network_init(void) // start echo and ping server echo_init(); //ping_init(); + netio_init(); #endif return 0; diff --git a/kernel/syscall.c b/kernel/syscall.c index d3eba333..6eaecd28 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -24,6 +24,27 @@ #include #include #include +#include + +#if defined(CONFIG_LWIP) && LWIP_SOCKET +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * We set the a bit LWIP_FD_BIT to determine, + * if the descriptor belongs to LwIP or MetalSVM. + */ +#define LWIP_FD_BIT (1 << 28) +#endif static int sys_write(int fildes, const char *buf, size_t len) { @@ -85,15 +106,33 @@ int syscall_handler(uint32_t sys_nr, ...) const char* buf = va_arg(vl, const char*); size_t len = va_arg(vl, size_t); +#if defined(CONFIG_LWIP) && LWIP_SOCKET + if (fildes & LWIP_FD_BIT) { + ret = lwip_write(fildes & ~LWIP_FD_BIT, buf, len); + if (ret < 0) + ret = -errno; + } else ret = sys_write(fildes, buf, len); +#else ret = sys_write(fildes, buf, len); +#endif break; } case __NR_open: ret = 1; break; - case __NR_close: + case __NR_close: { +#if defined(CONFIG_LWIP) && LWIP_SOCKET + int s = va_arg(vl, int); + if (s & LWIP_FD_BIT) { + ret = lwip_close(s & ~LWIP_FD_BIT); + if (ret < 0) + ret = -errno; + } else ret = 0; +#else ret = 0; +#endif break; + } case __NR_sbrk: { int incr = va_arg(vl, int); @@ -127,6 +166,109 @@ int syscall_handler(uint32_t sys_nr, ...) ret = sys_times(buffer, clock); break; } +#if defined(CONFIG_LWIP) && LWIP_SOCKET + case __NR_read: { + int s = va_arg(vl, int); + void* mem = va_arg(vl, void*); + size_t len = va_arg(vl, size_t); + + if (!(s & LWIP_FD_BIT)) { + ret = -ENOTSOCK; + break; + } + + ret = lwip_read(s & ~LWIP_FD_BIT, mem, len); + if (ret < 0) + ret = -errno; + break; + } + case __NR_closesocket: { + int s = va_arg(vl, int); + + if (BUILTIN_EXPECT(!(s & LWIP_FD_BIT), 0)) { + ret = -ENOTSOCK; + break; + } + + ret = lwip_close(s & ~LWIP_FD_BIT); + if (ret < 0) + ret = -errno; + break; + } + case __NR_socket: { + int domain = va_arg(vl, int); + int type = va_arg(vl, int); + int protocol = va_arg(vl, int); + + ret = lwip_socket(domain, type, protocol); + if (ret >= 0) + ret |= LWIP_FD_BIT; + else + ret = -errno; + break; + } + case __NR_connect: { + int s = va_arg(vl, int); + const struct sockaddr* name = va_arg(vl, const struct sockaddr*); + socklen_t namelen = va_arg(vl, socklen_t); + + if (BUILTIN_EXPECT(!(s & LWIP_FD_BIT), 0)) { + ret = -ENOTSOCK; + break; + } + + ret = lwip_connect(s & ~LWIP_FD_BIT, name, namelen); + if (ret < 0) + ret = -errno; + break; + } + case __NR_bind: { + int s = va_arg(vl, int); + const struct sockaddr* name = va_arg(vl, const struct sockaddr*); + socklen_t namelen = va_arg(vl, socklen_t); + + if (BUILTIN_EXPECT(!(s & LWIP_FD_BIT), 0)) { + ret = -ENOTSOCK; + break; + } + + ret = lwip_bind(s & ~LWIP_FD_BIT, name, namelen); + if (ret < 0) + ret = -errno; + break; + } + case __NR_listen:{ + int s = va_arg(vl, int); + int backlog = va_arg(vl, int); + + if (BUILTIN_EXPECT(!(s & LWIP_FD_BIT), 0)) { + ret = -ENOTSOCK; + break; + } + + ret = lwip_listen(s & ~LWIP_FD_BIT, backlog); + if (ret < 0) + ret = -errno; + break; + } + case __NR_accept: { + int s = va_arg(vl, int); + struct sockaddr* addr = va_arg(vl, struct sockaddr*); + socklen_t* addrlen = va_arg(vl, socklen_t*); + + if (BUILTIN_EXPECT(!(s & LWIP_FD_BIT), 0)) { + ret = -ENOTSOCK; + break; + } + + ret = lwip_accept(s & ~LWIP_FD_BIT, addr, addrlen); + if (ret >= 0) + ret |= LWIP_FD_BIT; + else + ret = -errno; + break; + } +#endif default: kputs("invalid system call\n"); ret = -ENOSYS; diff --git a/kernel/tasks.c b/kernel/tasks.c index 5813e50a..c941e57e 100644 --- a/kernel/tasks.c +++ b/kernel/tasks.c @@ -47,8 +47,8 @@ * A task's id will be its position in this array. */ static task_t task_table[MAX_TASKS] = { \ - [0] = {0, TASK_IDLE, 0, 0, 0, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0}, \ - [1 ... MAX_TASKS-1] = {0, TASK_INVALID, 0, 0, 0, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0}}; + [0] = {0, TASK_IDLE, 0, 0, 0, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0, 0}, \ + [1 ... MAX_TASKS-1] = {0, TASK_INVALID, 0, 0, 0, ATOMIC_INIT(0), SPINLOCK_INIT, NULL, SPINLOCK_INIT, NULL, 0, 0, 0, 0}}; static spinlock_irqsave_t table_lock = SPINLOCK_IRQSAVE_INIT; DEFINE_PER_CORE(task_t*, current_task, task_table+0); @@ -243,6 +243,7 @@ static int create_task(tid_t* id, internal_entry_point_t ep, void* arg) task_table[i].start_heap = 0; task_table[i].end_heap = 0; + task_table[i].lwip_err = 0; task_table[i].start_tick = get_clock_tick(); break; } @@ -308,6 +309,7 @@ int sys_fork(void) task_table[i].start_tick = get_clock_tick(); task_table[i].start_heap = 0; task_table[i].end_heap = 0; + task_table[i].lwip_err = 0; ret = arch_fork(task_table+i); diff --git a/kernel/tests.c b/kernel/tests.c index 24073e4e..d29e2853 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -253,6 +253,8 @@ void* client_task(void* e) int test_init(void) { char* argv[] = {"/bin/tests", NULL}; + char* server_argv[] = {"/bin/server", "6789", NULL}; + char* client_argv[] = {"/bin/client", "127.0.0.1", "6789", NULL}; sem_init(&producing, 1); sem_init(&consuming, 0); @@ -272,14 +274,17 @@ int test_init(void) #endif create_kernel_task(NULL, foo, "Hello from foo1"); - create_kernel_task(NULL, join_test, NULL); + //create_kernel_task(NULL, join_test, NULL); //create_kernel_task(NULL, producer, NULL); //create_kernel_task(NULL, consumer, NULL); //create_kernel_task(NULL, mail_ping, NULL); - //create_user_task(NULL, "/bin/hello", argv); + create_user_task(NULL, "/bin/hello", argv); create_user_task(NULL, "/bin/tests", argv); //create_user_task(NULL, "/bin/jacobi", argv); //create_user_task(NULL, "/bin/jacobi", argv); + create_user_task(NULL, "/bin/server", server_argv); + //sleep(5); + //create_user_task(NULL, "/bin/client", client_argv); return 0; } From 926f90fc4fc01ce58d6dde86fa1977d0ce3f2696 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 10 Aug 2011 08:17:32 +0200 Subject: [PATCH 254/261] add LwIP errno variable in the context of the task --- include/metalsvm/tasks_types.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/metalsvm/tasks_types.h b/include/metalsvm/tasks_types.h index f972feba..3379fccb 100644 --- a/include/metalsvm/tasks_types.h +++ b/include/metalsvm/tasks_types.h @@ -85,6 +85,10 @@ typedef struct task { uint32_t start_heap; /// End address of the heap uint32_t end_heap; +#ifdef CONFIG_LWIP + /// LwIP error code + int lwip_err; +#endif /// Mail inbox mailbox_wait_msg_t inbox; /// Mail outbox array From 8d7dd29b104e0004331e71ac20ab968041fce631 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 10 Aug 2011 08:20:46 +0200 Subject: [PATCH 255/261] add helper macro to determine the LwIP error code for the current task --- lwip/src/include/arch/cc.h | 2 +- lwip/src/include/arch/sys_arch.h | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lwip/src/include/arch/cc.h b/lwip/src/include/arch/cc.h index 94fb22ee..3474f573 100644 --- a/lwip/src/include/arch/cc.h +++ b/lwip/src/include/arch/cc.h @@ -81,5 +81,5 @@ typedef size_t mem_ptr_t; #define LWIP_PLATFORM_ASSERT(x) do {kprintf("Assertion \"%s\" failed at line %d in %s\n", \ x, __LINE__, __FILE__); abort();} while(0) - + #endif /* __ARCH_CC_H__ */ diff --git a/lwip/src/include/arch/sys_arch.h b/lwip/src/include/arch/sys_arch.h index 6857d983..e71a6d36 100644 --- a/lwip/src/include/arch/sys_arch.h +++ b/lwip/src/include/arch/sys_arch.h @@ -43,4 +43,10 @@ static inline void sys_arch_unprotect(sys_prot_t pval) #endif #endif +/* define errno to determine error code */ +#ifdef CONFIG_LWIP +#define ERRNO +#define errno per_core(current_task)->lwip_err +#endif + #endif /* __ARCH_SYS_ARCH_H__ */ From 49da0d2356894e14f62ce97bacc029f07b6285d4 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 10 Aug 2011 08:22:23 +0200 Subject: [PATCH 256/261] add user-level socket example --- .gitignore | 2 ++ lwip/src/include/lwipopts.h | 4 +++ newlib/Makefile | 2 ++ newlib/examples/Makefile | 16 +++++++-- newlib/examples/client.c | 57 +++++++++++++++++++++++++++++ newlib/examples/server.c | 72 +++++++++++++++++++++++++++++++++++++ 6 files changed, 151 insertions(+), 2 deletions(-) create mode 100644 newlib/examples/client.c create mode 100644 newlib/examples/server.c diff --git a/.gitignore b/.gitignore index 2b5e79dd..56762699 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,8 @@ newlib/examples/hello newlib/examples/echo newlib/examples/tests newlib/examples/jacobi +newlib/examples/server +newlib/examples/client newlib/tmp/* newlib/x86/* metalsvm.elf diff --git a/lwip/src/include/lwipopts.h b/lwip/src/include/lwipopts.h index 1d3e7b9d..fb9ebf6e 100644 --- a/lwip/src/include/lwipopts.h +++ b/lwip/src/include/lwipopts.h @@ -117,6 +117,10 @@ #define NETIF_DEBUG LWIP_DBG_ON #define TIMERS_DEBUG LWIP_DBG_OFF #define SOCKETS_DEBUG LWIP_DBG_OFF +#define PBUF_DEBUG LWIP_DBG_OFF + +// we need this feature to avoid memcpy operation between user- and kernel space +#define LWIP_TCPIP_CORE_LOCKING 1 //#define LWIP_TCPIP_THREAD_ALIVE() kputs("TCPIP thread is alive!\n") #endif diff --git a/newlib/Makefile b/newlib/Makefile index 9031eced..be63ebef 100644 --- a/newlib/Makefile +++ b/newlib/Makefile @@ -25,6 +25,8 @@ $(ARCH): $(RM) $(TMP) $(MKDIR) $(TMP) $(CD) $(TMP); $(TOPDIR)/src/configure --target=$(TARGET) --prefix=$(TOPDIR)/$(ARCH) $(OPT) && make && make install + $(MKDIR) $(NEWLIB)/include/netinet + $(MKDIR) $(NEWLIB)/include/arpa clean: $(MAKE) -C examples clean diff --git a/newlib/examples/Makefile b/newlib/examples/Makefile index e1a373f9..4e2a747f 100644 --- a/newlib/examples/Makefile +++ b/newlib/examples/Makefile @@ -11,7 +11,7 @@ LDFLAGS = default: all -all: hello tests jacobi +all: hello tests jacobi server client jacobi: jacobi.o $(CC_FOR_TARGET) -T link.ld -o $@ $(LDFLAGS) $< -lm @@ -31,8 +31,20 @@ hello: hello.o $(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ chmod a-x $@.sym +server: server.o + $(CC_FOR_TARGET) -T link.ld -o $@ $(LDFLAGS) $< -lsocket + $(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym + $(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ + chmod a-x $@.sym + +client: client.o + $(CC_FOR_TARGET) -T link.ld -o $@ $(LDFLAGS) $< -lsocket + $(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym + $(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@ + chmod a-x $@.sym + clean: - $(RM) hello tests *.sym *.o *~ + $(RM) hello tests server client *.sym *.o *~ depend: $(CC_FOR_TARGET) -MM $(CFLAGS) *.c > Makefile.dep diff --git a/newlib/examples/client.c b/newlib/examples/client.c new file mode 100644 index 00000000..ae1f0a0a --- /dev/null +++ b/newlib/examples/client.c @@ -0,0 +1,57 @@ +/* derived form http://www.cs.put.poznan.pl/csobaniec/examples/sockets/client-tcp-simple.c */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#undef errno +extern int errno; + +#define MAX_BUF 100 + +int main(int argc, char* argv[]) +{ + int sockd; + int count; + struct sockaddr_in serv_name; + char buf[MAX_BUF]; + int status; + + if (argc < 3) + { + fprintf(stderr, "Usage: %s ip_address port_number\n", argv[0]); + exit(1); + } + /* create a socket */ + sockd = socket(AF_INET, SOCK_STREAM, 0); + if (sockd == -1) + { + perror("Socket creation"); + exit(1); + } + + /* server address */ + serv_name.sin_family = AF_INET; + inet_aton(argv[1], &serv_name.sin_addr); + serv_name.sin_port = htons(atoi(argv[2])); + + /* connect to the server */ + status = connect(sockd, (struct sockaddr*)&serv_name, sizeof(serv_name)); + if (status == -1) + { + perror("Connection error"); + exit(1); + } + + count = read(sockd, buf, MAX_BUF); + write(1, buf, count); + + close(sockd); + + return 0; +} diff --git a/newlib/examples/server.c b/newlib/examples/server.c new file mode 100644 index 00000000..35e09e43 --- /dev/null +++ b/newlib/examples/server.c @@ -0,0 +1,72 @@ +/* derived from http://www.cs.put.poznan.pl/csobaniec/examples/sockets/server-tcp-simple.c */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#undef errno +extern int errno; + +static char msg[] =" Hello from server!\n"; + +int main(int argc, char* argv[]) +{ + int sockd, sockd2; + unsigned int addrlen; + struct sockaddr_in my_name, peer_name; + int status; + + /* create a socket */ + sockd = socket(AF_INET, SOCK_STREAM, 0); + if (sockd == -1) + { + perror("Socket creation error"); + exit(1); + } + + if (argc < 2) + { + fprintf(stderr, "Usage: %s port_number\n", argv[0]); + exit(1); + } + + /* server address */ + my_name.sin_family = AF_INET; + my_name.sin_addr.s_addr = INADDR_ANY; + my_name.sin_port = htons(atoi(argv[1])); + + status = bind(sockd, (struct sockaddr*)&my_name, sizeof(my_name)); + if (status == -1) + { + perror("Binding error"); + exit(1); + } + + status = listen(sockd, 5); + if (status == -1) + { + perror("Listening error"); + exit(1); + } + + while(1) + { + /* wait for a connection */ + addrlen = sizeof(peer_name); + sockd2 = accept(sockd, (struct sockaddr*)&peer_name, &addrlen); + if (sockd2 == -1) + { + perror("Wrong connection"); + exit(1); + } + write(sockd2, msg, strlen(msg)+1); + close(sockd2); + } + + return 0; +} From d2a313774935e0d77aeb6a5cdc1b60cc9e8786ef Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 10 Aug 2011 08:47:21 +0200 Subject: [PATCH 257/261] remove typo --- kernel/tests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/tests.c b/kernel/tests.c index d29e2853..5b67a06d 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -274,11 +274,11 @@ int test_init(void) #endif create_kernel_task(NULL, foo, "Hello from foo1"); - //create_kernel_task(NULL, join_test, NULL); + create_kernel_task(NULL, join_test, NULL); //create_kernel_task(NULL, producer, NULL); //create_kernel_task(NULL, consumer, NULL); //create_kernel_task(NULL, mail_ping, NULL); - create_user_task(NULL, "/bin/hello", argv); + //create_user_task(NULL, "/bin/hello", argv); create_user_task(NULL, "/bin/tests", argv); //create_user_task(NULL, "/bin/jacobi", argv); //create_user_task(NULL, "/bin/jacobi", argv); From 20b074d81c4e23d687caf238d200a23288f5651c Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 10 Aug 2011 09:55:59 -0700 Subject: [PATCH 258/261] add additional error messages --- kernel/tasks.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/kernel/tasks.c b/kernel/tasks.c index c941e57e..2dec1348 100644 --- a/kernel/tasks.c +++ b/kernel/tasks.c @@ -419,6 +419,7 @@ static int load_task(load_args_t* largs) //elf_section_header_t sec_header; vfs_node_t* node; task_t* curr_task = per_core(current_task); + int err; if (!largs) return -EINVAL; @@ -427,7 +428,12 @@ static int load_task(load_args_t* largs) if (!node) return -EINVAL; - read_fs(node, (uint8_t*)&header, sizeof(elf_header_t), 0); + err = read_fs(node, (uint8_t*)&header, sizeof(elf_header_t), 0); + if (err < 0) { + kprintf("read_fs failed: %d\n", err); + return err; + } + if (BUILTIN_EXPECT(header.ident.magic != ELF_MAGIC, 0)) goto invalid; @@ -595,6 +601,12 @@ static int load_task(load_args_t* largs) invalid: kprintf("Invalid executable!\n"); + kprintf("magic number 0x%x\n", (uint32_t) header.ident.magic); + kprintf("header type 0x%x\n", (uint32_t) header.type); + kprintf("machine type 0x%x\n", (uint32_t) header.machine); + kprintf("elf ident class 0x%x\n", (uint32_t) header.ident._class); + kprintf("elf identdata !0x%x\n", header.ident.data); + kprintf("program entry point 0x%x\n", (size_t) header.entry); return -EINVAL; } From 023282e7760c57e42498cd56e9692f8a11fd5870 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 10 Aug 2011 01:44:34 -0700 Subject: [PATCH 259/261] prepare also the initrd for the SCC --- tools/prepare.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/prepare.sh b/tools/prepare.sh index c94b5104..961cb45e 100755 --- a/tools/prepare.sh +++ b/tools/prepare.sh @@ -9,3 +9,13 @@ if [ $SIZE -ne 0 ]; then else echo not patching $NAME fi; + +NAME=initrd.img +SIZE=`ls -ld "$NAME" | awk '{print $5 % 64}'` +if [ $SIZE -ne 0 ]; then + echo "$NAME: patching $SIZE Zero-Bytes" + dd if=/dev/zero of=zero.bin bs=1 count=$SIZE + cat zero.bin >> $NAME +else + echo not patching $NAME +fi; From 1583f886b816119ac639f15267ab0ad38947419b Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 10 Aug 2011 03:25:22 -0700 Subject: [PATCH 260/261] on the SCC, the kernel determines the virtual address for the initrd --- arch/x86/mm/page.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/arch/x86/mm/page.c b/arch/x86/mm/page.c index aa952edf..6eadd3d1 100644 --- a/arch/x86/mm/page.c +++ b/arch/x86/mm/page.c @@ -730,12 +730,6 @@ int arch_paging_init(void) // map SCC's bootinfo map_region(SCC_BOOTINFO, SCC_BOOTINFO, 1, MAP_KERNEL_SPACE); - // map the initial ramdisk - npages = bootinfo->size >> PAGE_SHIFT; - if (bootinfo->size & (PAGE_SIZE-1)) - npages++; - map_region(bootinfo->addr, bootinfo->addr, npages, MAP_KERNEL_SPACE); - // map SCC's configuration registers viraddr = map_region(CRB_X0_Y0, CRB_X0_Y0, (CRB_OWN-CRB_X0_Y0+16*1024*1024) >> PAGE_SHIFT, MAP_KERNEL_SPACE|MAP_NO_CACHE); kprintf("Map configuration registers at 0x%x\n", viraddr); @@ -756,6 +750,15 @@ int arch_paging_init(void) write_cr0(i); paging_enabled = 1; +#ifdef CONFIG_ROCKCREEK + // map the initial ramdisk + npages = bootinfo->size >> PAGE_SHIFT; + if (bootinfo->size & (PAGE_SIZE-1)) + npages++; + bootinfo->addr = map_region(0, bootinfo->addr, npages, MAP_KERNEL_SPACE); + kprintf("Map initrd at 0x%x (size %u bytes)\n", bootinfo->addr, bootinfo->size); +#endif + /* * we turned on paging * => now, we are able to register our task for Task State Switching From 86b874250ddbca879009d9a97bc4d4be9ac8872a Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 15 Aug 2011 01:08:19 -0700 Subject: [PATCH 261/261] remove compiling errors by disabling the LwIP stack --- kernel/tasks.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/tasks.c b/kernel/tasks.c index 2dec1348..413ce994 100644 --- a/kernel/tasks.c +++ b/kernel/tasks.c @@ -243,7 +243,9 @@ static int create_task(tid_t* id, internal_entry_point_t ep, void* arg) task_table[i].start_heap = 0; task_table[i].end_heap = 0; +#ifdef CONFIG_LWIP task_table[i].lwip_err = 0; +#endif task_table[i].start_tick = get_clock_tick(); break; } @@ -309,7 +311,9 @@ int sys_fork(void) task_table[i].start_tick = get_clock_tick(); task_table[i].start_heap = 0; task_table[i].end_heap = 0; +#ifdef CONFIG_LWIP task_table[i].lwip_err = 0; +#endif ret = arch_fork(task_table+i);