diff options
author | Patrick Williams <iawillia@us.ibm.com> | 2010-06-25 16:27:36 -0500 |
---|---|---|
committer | Patrick Williams <iawillia@us.ibm.com> | 2010-06-25 16:27:36 -0500 |
commit | e9a3562d6a5cf88e6034570ab791e91e63ffb14a (patch) | |
tree | 8f3d0727b431f81d6f8b70195ddd8d37b6c3e8e6 /src/sys/vfs | |
parent | 8085c7634979f38c1b152d0a35b98c2447ce497a (diff) | |
download | talos-hostboot-e9a3562d6a5cf88e6034570ab791e91e63ffb14a.tar.gz talos-hostboot-e9a3562d6a5cf88e6034570ab791e91e63ffb14a.zip |
Add shell of VFS for registering and resolving message queue names.
Diffstat (limited to 'src/sys/vfs')
-rw-r--r-- | src/sys/vfs/makefile | 10 | ||||
-rw-r--r-- | src/sys/vfs/vfs_main.C | 78 |
2 files changed, 88 insertions, 0 deletions
diff --git a/src/sys/vfs/makefile b/src/sys/vfs/makefile new file mode 100644 index 000000000..94ca71bbf --- /dev/null +++ b/src/sys/vfs/makefile @@ -0,0 +1,10 @@ +OBJDIR = ../../../obj +include ../../../config.mk + +OBJS = vfs_main.o +OBJECTS = $(addprefix ${OBJDIR}/, ${OBJS}) + +all: ${OBJECTS} + +clean: + (rm -f ${OBJECTS} ) diff --git a/src/sys/vfs/vfs_main.C b/src/sys/vfs/vfs_main.C new file mode 100644 index 000000000..6ba561eb2 --- /dev/null +++ b/src/sys/vfs/vfs_main.C @@ -0,0 +1,78 @@ +#include <string.h> + +#include <sys/msg.h> +#include <sys/vfs.h> + +#include <util/locked/list.H> +#include <kernel/console.H> // TODO : Remove this. + +const char* VFS_ROOT = "/"; +const char* VFS_ROOT_BIN = "/bin/"; +const char* VFS_ROOT_DATA = "/data/"; +const char* VFS_ROOT_MSG = "/msg/"; + +struct VfsPath +{ + char key[64]; + + bool operator!=(VfsPath& r) { return 0 != strcmp(key, r.key); }; +}; + +struct VfsEntry +{ + typedef VfsPath key_type; + key_type key; + msg_q_t msg_q; + + VfsEntry* next; + VfsEntry* prev; +}; + +void vfs_main(void* unused) +{ + msg_q_t vfsMsgQ = msg_q_create(); + msg_q_register(vfsMsgQ, VFS_ROOT); + + printk("done.\n"); + // TODO... barrier with init. + + Util::Locked::List<VfsEntry, VfsEntry::key_type> vfsContents; + + while(1) + { + msg_t* msg = msg_wait(vfsMsgQ); + + switch(msg->type) + { + case VFS_MSG_REGISTER_MSGQ: + { + VfsEntry* e = new VfsEntry(); + strcpy(e->key.key, (char*) msg->extra_data); + e->msg_q = (msg_q_t) msg->data[0]; + vfsContents.insert(e); + + printk("VFS: Registering %llx as %s\n", + e->msg_q, e->key.key); + msg_respond(vfsMsgQ, msg); + } + break; + + case VFS_MSG_RESOLVE_MSGQ: + { + VfsEntry::key_type k; + strcpy(k.key, (char*) msg->extra_data); + VfsEntry* e = vfsContents.find(k); + if (NULL == e) + msg->data[0] = (uint64_t) NULL; + else + msg->data[0] = (uint64_t) e->msg_q; + msg_respond(vfsMsgQ, msg); + } + break; + + default: + msg_free(msg); + break; + } + } +} |