From 3735a23fd673bd1fc631a1ffc5f202c098ce189c Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Tue, 4 Oct 2011 00:02:33 -0700 Subject: [PATCH 1/4] =?UTF-8?q?insert=20init=20code=20f=C3=BCr=20the=20mmn?= =?UTF-8?q?if=20device?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/init.c | 47 +++++++++++++++++++++++++++++++++++++++-------- kernel/main.c | 5 ++++- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/kernel/init.c b/kernel/init.c index 4d54b4d4..ff83c477 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -71,6 +71,9 @@ int lowlevel_init(void) #if defined(CONFIG_LWIP) && (defined(CONFIG_PCI) || defined(CONFIG_ROCKCREEK)) static struct netif default_netif; +#ifdef CONFIG_ROCKCREEK +static struct netif mmnif_netif; +#endif static int init_netifs(void) { @@ -83,8 +86,9 @@ static int init_netifs(void) // Set up the lwIP network interface memset(&default_netif, 0x00, sizeof(struct netif)); - #ifdef CONFIG_ROCKCREEK + memset(&mmnif_netif, 0x00, sizeof(struct netif)); + /* Set network address variables */ IP4_ADDR(&gw, 192,168,28,254); IP4_ADDR(&ipaddr, 192,168,28,RCCE_ue()+1); @@ -92,12 +96,38 @@ static int init_netifs(void) /* Bring up the network interface */ if ((err = netifapi_netif_add(&default_netif, &ipaddr, &netmask, &gw, NULL, rckemacif_init, tcpip_input)) != ERR_OK) { - kprintf("Unable to add network interface: err = %d\n", err); + kprintf("Unable to add the network interface: err = %d\n", err); return -ENODEV; } netifapi_netif_set_default(&default_netif); netifapi_netif_set_up(&default_netif); + + /* Bring up the intra network interface */ + struct ip_addr intra_ipaddr; + struct ip_addr intra_netmask; + struct ip_addr intra_gw; + + IP4_ADDR(&intra_gw, 0,0,0,0); + IP4_ADDR(&intra_ipaddr, 192,168,0,RCCE_ue()+1); + IP4_ADDR(&intra_netmask, 255,255,255,0); + + /* 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 + * - ipaddr : the ip address wich should be used + * - gw : the gateway wicht should be used + * - mmnif_init : the initialization which has to be done in order to use our interface + * - ethernet_input : tells him that he should get ethernet input (inclusice ARP) + */ + if ((err = netifapi_netif_add(&mmnif_netif, &intra_ipaddr, &intra_netmask, &intra_gw, NULL, mmnif_init, tcpip_input)) != ERR_OK) + { + kprintf("Unable to add the intra network interface: err = %d\n", err); + return -ENODEV; + } + + /* tell lwip all initialization is done and we want to set it ab */ + netifapi_netif_set_up(&mmnif_netif); #else /* Clear network address because we use DHCP to get an ip address */ IP4_ADDR(&gw, 0,0,0,0); @@ -106,7 +136,7 @@ static int init_netifs(void) /* Bring up the network interface */ if ((err = netifapi_netif_add(&default_netif, &ipaddr, &netmask, &gw, NULL, rtl8139if_init, tcpip_input)) != ERR_OK) { - kprintf("Unable to add network interface: err = %d\n", err); + kprintf("Unable to add the network interface: err = %d\n", err); return -ENODEV; } @@ -144,11 +174,10 @@ static void tcpip_init_done(void* arg) static int network_shutdown(void) { #if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK) + mmnif_shutdown(); netifapi_netif_set_down(&default_netif); - memset(&default_netif, 0x00, sizeof(struct netif)); #elif defined(CONFIG_LWIP) && defined(CONFIG_PCI) netifapi_dhcp_stop(&default_netif); - memset(&default_netif, 0x00, sizeof(struct netif)); #endif return 0; @@ -209,6 +238,7 @@ int initd(void* arg) { #ifdef CONFIG_LWIP sys_sem_t sem; + tid_t id; char* argv[] = {"/bin/rlogind ", NULL}; // Initialize lwIP modules @@ -230,9 +260,10 @@ int initd(void* arg) #endif // start echo, netio and rlogind - echo_init(); - netio_init(); - create_user_task(NULL, "/bin/rlogind", argv); + //echo_init(); + //create_user_task(&id, "/bin/rlogind", argv); + //kprintf("Create rlogind with id %u\n", id); + //netio_init(); #endif list_root(); diff --git a/kernel/main.c b/kernel/main.c index c458c3aa..62753e41 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -60,6 +60,8 @@ int smp_main(void) int main(void) { + tid_t id; + lowlevel_init(); pushbg(COL_BLUE); @@ -91,7 +93,8 @@ int main(void) kprintf("Current available memory: %u MBytes\n", atomic_int32_read(&total_available_pages)/((1024*1024)/PAGE_SIZE)); sleep(5); - create_kernel_task(NULL, initd, NULL, NORMAL_PRIO); + create_kernel_task(&id, initd, NULL, NORMAL_PRIO); + kprintf("Create initd with id %u\n", id); reschedule(); while(1) { From 4099bc471db50722c7831ed288e2c72f486e6ba0 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Tue, 4 Oct 2011 00:03:11 -0700 Subject: [PATCH 2/4] extend test cases --- apps/tests.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/tests.c b/apps/tests.c index c01d806b..0ef511d2 100644 --- a/apps/tests.c +++ b/apps/tests.c @@ -279,7 +279,7 @@ int test_init(void) // char* argv[] = {"/bin/mshell", NULL}; char* argv[] = {"/bin/tests", NULL}; char* server_argv[] = {"/bin/server", "6789", NULL}; -// char* client_argv[] = {"/bin/client", "127.0.0.1", "6789", NULL}; + char* client_argv[] = {"/bin/client", "192.168.0.1", "6789", NULL}; sem_init(&producing, 1); sem_init(&consuming, 0); @@ -297,9 +297,11 @@ int test_init(void) //create_user_task(NULL, "/bin/jacobi", argv); //create_user_task(NULL, "/bin/mshell", 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); + /*create_user_task(NULL, "/bin/server", server_argv); + if (RCCE_ue() != 0) { + sleep(5); + create_user_task(NULL, "/bin/client", client_argv); + }*/ return 0; } From 2b129977d0dcada69bd716fc13bbf6c7d867de2b Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Tue, 4 Oct 2011 09:14:03 +0200 Subject: [PATCH 3/4] remove compiler errors --- drivers/net/mmnif.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/mmnif.c b/drivers/net/mmnif.c index 707ffe99..540b4a07 100644 --- a/drivers/net/mmnif.c +++ b/drivers/net/mmnif.c @@ -22,6 +22,10 @@ * */ +#include + +#if defined(CONFIG_LWIP) && defined(CONFIG_ROCKCREEK) + #include "mmnif.h" /* definitions */ #include /* lwip netif */ @@ -1706,3 +1710,5 @@ err_t mmnif_shutdown(void) return err; } + +#endif From 3e0a285882ccf411cdc57f32e2ac830b1827eec5 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Tue, 4 Oct 2011 00:14:25 -0700 Subject: [PATCH 4/4] enable rlogind --- kernel/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/init.c b/kernel/init.c index ff83c477..eea20644 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -261,8 +261,8 @@ int initd(void* arg) // start echo, netio and rlogind //echo_init(); - //create_user_task(&id, "/bin/rlogind", argv); - //kprintf("Create rlogind with id %u\n", id); + create_user_task(&id, "/bin/rlogind", argv); + kprintf("Create rlogind with id %u\n", id); //netio_init(); #endif