summaryrefslogtreecommitdiffstats
path: root/src/sys/vfs/vfs_main.C
diff options
context:
space:
mode:
authordgilbert <dgilbert@us.ibm.com>2011-07-28 16:42:28 -0500
committerDouglas R. Gilbert <dgilbert@us.ibm.com>2011-08-17 14:22:39 -0500
commitc56648379cde6ea3bcfac07923bb560734c6e16f (patch)
tree81ee3d5abaa130d0f1e36e038c3a344e11f55ce0 /src/sys/vfs/vfs_main.C
parent20b03fdaeb7414fdf9d43634976ca1ab5fbac7f1 (diff)
downloadtalos-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/vfs/vfs_main.C')
-rw-r--r--src/sys/vfs/vfs_main.C94
1 files changed, 70 insertions, 24 deletions
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;
+}
+
+
+
OpenPOWER on IntegriCloud