From e9a3562d6a5cf88e6034570ab791e91e63ffb14a Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Fri, 25 Jun 2010 16:27:36 -0500 Subject: Add shell of VFS for registering and resolving message queue names. --- src/sys/init/init_main.C | 8 +++++ src/sys/makefile | 4 +-- src/sys/vfs/makefile | 10 +++++++ src/sys/vfs/vfs_main.C | 78 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 src/sys/vfs/makefile create mode 100644 src/sys/vfs/vfs_main.C (limited to 'src/sys') diff --git a/src/sys/init/init_main.C b/src/sys/init/init_main.C index c11b4ef97..a7bc68b55 100644 --- a/src/sys/init/init_main.C +++ b/src/sys/init/init_main.C @@ -14,13 +14,21 @@ void init_child(void* unused) task_end(); } +void vfs_main(void*); + void init_main(void* unused) { printk("Starting init!\n"); + + printk("Bringing up VFS..."); + task_create(&vfs_main, NULL); + task_yield(); // TODO... add a barrier to ensure VFS is fully up. global_mutex = mutex_create(); msg_q_t msgq = msg_q_create(); + msg_q_register(msgq, "/msg/init"); + msg_t* msg = msg_allocate(); msg->type = 1; msg->data[0] = 0xDEADBEEF12345678; msg_send(msgq, msg); diff --git a/src/sys/makefile b/src/sys/makefile index 5a553e1d2..0eb552a44 100644 --- a/src/sys/makefile +++ b/src/sys/makefile @@ -2,9 +2,7 @@ IMGDIR = ../../img OBJDIR = ../../obj include ../../config.mk -SUBDIRS = init.d -IMAGES += ${IMGDIR}/kernel.elf -IMAGES += ${IMGDIR}/kernel.bin +SUBDIRS = init.d vfs.d all: ${SUBDIRS} 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 + +#include +#include + +#include +#include // 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 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; + } + } +} -- cgit v1.2.1