From a2fbc8cb2e51821331f3ba8d920dddf8ab0fb96d Mon Sep 17 00:00:00 2001 From: Mark Wenning Date: Mon, 6 Jun 2011 14:07:51 -0500 Subject: Initialization Service (Flow Control) - save off changes before switch branch - rename to get rid of '_' in filenames. - split into separate files - adding errorlogs, saved off so CC guru could work - fix problem in vfs_main where we would crash if there is no _start in launched task. - refactor - fix problems with coding guidelines - add testcases for startTask and reportError - add fixes from code review Change-Id: I2ae34cb6097c466d4f6d0e41b4b32c2eba47e9df Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/145 Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III --- src/sys/init/init_main.C | 61 +++++++++++++++--------------------------------- src/sys/vfs/vfs_main.C | 22 ++++++++++------- 2 files changed, 33 insertions(+), 50 deletions(-) (limited to 'src/sys') diff --git a/src/sys/init/init_main.C b/src/sys/init/init_main.C index dd83ea131..5a7cf16ae 100644 --- a/src/sys/init/init_main.C +++ b/src/sys/init/init_main.C @@ -7,62 +7,39 @@ #include #include #include +#include -mutex_t global_mutex = MUTEX_INITIALIZER; - -/* -void init_child(void* unused) -{ - mutex_lock(&global_mutex); - printk("Crun: %d on %d\n", task_gettid(), task_getcpuid()); - mutex_unlock(&global_mutex); - for (volatile int i = 0 ; i < 100000; i++); - task_end(); -} -*/ void vfs_main(void*); void init_main(void* unused) { - printk("Starting init!\n"); - - printk("Bringing up VFS..."); - task_create(&vfs_main, NULL); - - // TODO... add a barrier to ensure VFS is fully up. - while (NULL == _syscall0(Systemcalls::MSGQ_RESOLVE_ROOT)) - task_yield(); - + tid_t tidrc = 0; -/* - uint64_t* mmio_addr = (uint64_t*) mmio_map((void*)0x800000000, 1); - printk("MMIO Access %lx\n", *mmio_addr); + printk("Starting init!\n"); - msg_q_t msgq = msg_q_create(); - msg_q_register(msgq, "/msg/init"); + printk("Bringing up VFS..."); + task_create( &vfs_main, NULL ); - msg_t* msg = msg_allocate(); - msg->type = 1; msg->data[0] = 0xDEADBEEF12345678; - msg_send(msgq, msg); - msg = msg_wait(msgq); + // TODO... add a barrier to ensure VFS is fully up. + while (NULL == _syscall0(Systemcalls::MSGQ_RESOLVE_ROOT)) + task_yield(); - printk("Got Message: %lx\n", msg->data[0]); - while(1) + // run initialization service to start up everything else. + printk("init_main: Starting Initialization Service...\n"); + tidrc = task_exec( "libinitservice.so", NULL ); + if ( (int16_t)tidrc < 0 ) // task_exec returned a -1 { - mutex_lock(&global_mutex); - int t = task_create(&init_child, NULL); - printk("Create child %d\n", t); - for (volatile int i = 0 ; i < 1000000; i++); - mutex_unlock(&global_mutex); + printk( "ERROR: init_main: failed to launch initservice: %d\n", tidrc ); + + assert( 0 ); // stop here. } -*/ - task_exec("libexample.so", NULL); + // should never reach this point... + task_end(); + - task_exec("libcxxtest.so", NULL); - while(1) - task_yield(); + task_yield(); } diff --git a/src/sys/vfs/vfs_main.C b/src/sys/vfs/vfs_main.C index 22cd306a5..322768fc9 100644 --- a/src/sys/vfs/vfs_main.C +++ b/src/sys/vfs/vfs_main.C @@ -26,7 +26,7 @@ struct VfsEntry typedef VfsPath key_type; key_type key; msg_q_t msg_q; - + VfsEntry* next; VfsEntry* prev; }; @@ -36,10 +36,10 @@ void vfs_main(void* unused) // Create message queue, register with kernel. msg_q_t vfsMsgQ = msg_q_create(); msg_q_register(vfsMsgQ, VFS_ROOT); - + printk("done.\n"); // TODO... barrier with init. - + // Initalize modules. vfs_module_init(); @@ -73,21 +73,27 @@ void vfs_main(void* unused) msg->data[0] = (uint64_t) NULL; else msg->data[0] = (uint64_t) e->msg_q; - msg_respond(vfsMsgQ, msg); + msg_respond(vfsMsgQ, msg); } break; - + case VFS_MSG_EXEC: { - printk("VFS: Got exec request of %s\n", + printk("VFS: Got exec request of %s\n", (const char*)msg->data[0]); VfsSystemModule* module = &VFS_MODULES[0]; tid_t child = -1; while ('\0' != module->module[0]) { - if (0 == strcmp((const char*) msg->data[0], + if (0 == strcmp((const char*) msg->data[0], module->module)) { + if ( module->start == NULL) + { + // module has no _start() routine, + // return child = -1 + break; + } child = task_create(module->start, (void*) msg->data[1]); break; @@ -103,5 +109,5 @@ void vfs_main(void* unused) msg_free(msg); break; } - } + } // end while(1) } -- cgit v1.2.1