diff options
author | dgilbert <dgilbert@us.ibm.com> | 2011-07-28 16:42:28 -0500 |
---|---|---|
committer | Douglas R. Gilbert <dgilbert@us.ibm.com> | 2011-08-17 14:22:39 -0500 |
commit | c56648379cde6ea3bcfac07923bb560734c6e16f (patch) | |
tree | 81ee3d5abaa130d0f1e36e038c3a344e11f55ce0 /src/sys | |
parent | 20b03fdaeb7414fdf9d43634976ca1ab5fbac7f1 (diff) | |
download | talos-hostboot-c56648379cde6ea3bcfac07923bb560734c6e16f.tar.gz talos-hostboot-c56648379cde6ea3bcfac07923bb560734c6e16f.zip |
Virtual File System module load and unload
Change-Id: Iaa6a256a8a15ac48bfba5bc1cab292c5ac246166
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/253
Tested-by: Jenkins Server
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/sys')
-rw-r--r-- | src/sys/init/init_main.C | 9 | ||||
-rw-r--r-- | src/sys/vfs/vfs_init.C | 31 | ||||
-rw-r--r-- | src/sys/vfs/vfs_main.C | 94 |
3 files changed, 95 insertions, 39 deletions
diff --git a/src/sys/init/init_main.C b/src/sys/init/init_main.C index 6292500e3..da83838e4 100644 --- a/src/sys/init/init_main.C +++ b/src/sys/init/init_main.C @@ -15,16 +15,15 @@ void vfs_main(void*); void init_main(void* unused) { tid_t tidrc = 0; + barrier_t l_barrier; + barrier_init(&l_barrier,2); 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(); + task_create( &vfs_main, &l_barrier ); + barrier_wait(&l_barrier); // run initialization service to start up everything else. printk("init_main: Starting Initialization Service...\n"); diff --git a/src/sys/vfs/vfs_init.C b/src/sys/vfs/vfs_init.C index 259252171..77ce140d7 100644 --- a/src/sys/vfs/vfs_init.C +++ b/src/sys/vfs/vfs_init.C @@ -1,9 +1,15 @@ +/** + * @file vfs_init.C + * @brief function definitions for funtions used to initialize modules + */ #include <sys/vfs.h> #include <kernel/console.H> VfsSystemModule VFS_MODULES[VFS_MODULE_MAX]; uint64_t VFS_LAST_ADDRESS; +// ---------------------------------------------------------------------------- + void vfs_module_init() { printk("Initializing modules.\n"); @@ -22,18 +28,23 @@ void vfs_module_init() printk("Modules initialized.\n"); } -void (*vfs_module_find_start(const char* modName))(void*) +// ---------------------------------------------------------------------------- + +VfsSystemModule * vfs_find_module(VfsSystemModule * i_table, + const char * i_name) { - VfsSystemModule* module = &VFS_MODULES[0]; + VfsSystemModule* module = i_table; + VfsSystemModule* ret = NULL; while ('\0' != module->module[0]) { - if (0 == strcmp(modName, module->module)) - { - return module->start; - } - - module++; + if (0 == strcmp(i_name,module->module)) + { + ret = module; + break; + } + module++; } - - return NULL; + return ret; } + + diff --git a/src/sys/vfs/vfs_main.C b/src/sys/vfs/vfs_main.C index 36d6ddcff..4308da8d4 100644 --- a/src/sys/vfs/vfs_main.C +++ b/src/sys/vfs/vfs_main.C @@ -3,6 +3,7 @@ #include <sys/msg.h> #include <sys/vfs.h> #include <sys/task.h> +#include <sys/sync.h> #include <util/locked/list.H> #include <kernel/console.H> // TODO : Remove this. @@ -11,9 +12,18 @@ const char* VFS_ROOT = "/"; const char* VFS_ROOT_BIN = "/bin/"; const char* VFS_ROOT_DATA = "/data/"; const char* VFS_ROOT_MSG = "/msg/"; +const char* VFS_MSG = "/vfs/"; void vfs_module_init(); +/** + * Call the module start routine + * @param[in] i_module VfsSystemModule data for the module + * @param[in] i_param parameter to pass to task_create() for this module + * @return tid_t of started task | -1 if i_module is NULL | -2 if there is no start() + */ +tid_t vfs_exec(VfsSystemModule * i_module, void* i_param); + struct VfsPath { char key[64]; @@ -31,14 +41,16 @@ struct VfsEntry VfsEntry* prev; }; -void vfs_main(void* unused) +void vfs_main(void* i_barrier) { + barrier_t * barrier = (barrier_t *)i_barrier; // 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. + + barrier_wait(barrier); // Initalize modules. vfs_module_init(); @@ -81,28 +93,40 @@ void vfs_main(void* unused) { 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], - module->module)) - { - if ( module->start == NULL) - { - // module has no _start() routine, - // return child = -2 - child = -2; - break; - } - child = task_create(module->start, - (void*) msg->data[1]); - break; - } - module++; - } - msg->data[0] = child; - msg_respond(vfsMsgQ, msg); + + VfsSystemModule* module = + vfs_find_module(VFS_MODULES, + (const char *) msg->data[0]); + + tid_t child = vfs_exec(module,(void*) msg->data[1]); + + // child == -1 means module not found in base image so send + // a message to VFS_MSG queue to look in the extended image + // VFS_MSG queue will handle the msg_respond() + if( child == -1 ) // forward msg to usr vfs + { + VfsEntry::key_type k; + strcpy(k.key, VFS_MSG); + VfsEntry* e = vfsContents.find(k); + if(e != NULL) + { + msg_t* emsg = msg_allocate(); + emsg->type = msg->type; + emsg->data[0] = (uint64_t) msg; + emsg->data[1] = (uint64_t) vfsMsgQ; + msg_send(e->msg_q, emsg); // send async msg + } + else // Cant find VFS_MSG queue - not started yet + { + msg->data[0] = child; + msg_respond(vfsMsgQ, msg); + } + } + else // send back child (or errno) + { + msg->data[0] = child; + msg_respond(vfsMsgQ, msg); + } } break; @@ -112,3 +136,25 @@ void vfs_main(void* unused) } } // end while(1) } + +// ---------------------------------------------------------------------------- + +tid_t vfs_exec(VfsSystemModule * i_module, void* i_param) +{ + tid_t child = -1; + if(i_module != NULL) + { + if (i_module->start == NULL) + { + child = -2; // module has no start() routine + } + else + { + child = task_create(i_module->start, i_param); + } + } + return child; +} + + + |