summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/include/sys/task.h2
-rw-r--r--src/include/sys/vfs.h1
-rw-r--r--src/lib/syscall_task.C31
-rw-r--r--src/sys/init/init_main.C14
-rw-r--r--src/sys/vfs/vfs_main.C22
-rw-r--r--src/usr/example/example.C1
6 files changed, 70 insertions, 1 deletions
diff --git a/src/include/sys/task.h b/src/include/sys/task.h
index 520008e6d..ca1475b27 100644
--- a/src/include/sys/task.h
+++ b/src/include/sys/task.h
@@ -16,6 +16,8 @@ void task_end();
tid_t task_gettid();
cpuid_t task_getcpuid();
+tid_t task_exec(const char*, void*);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/include/sys/vfs.h b/src/include/sys/vfs.h
index e596030fe..d55a44710 100644
--- a/src/include/sys/vfs.h
+++ b/src/include/sys/vfs.h
@@ -24,6 +24,7 @@ enum VfsMessages
{
VFS_MSG_REGISTER_MSGQ,
VFS_MSG_RESOLVE_MSGQ,
+ VFS_MSG_EXEC,
};
struct VfsSystemModule
diff --git a/src/lib/syscall_task.C b/src/lib/syscall_task.C
index a6b575b5e..eedd78235 100644
--- a/src/lib/syscall_task.C
+++ b/src/lib/syscall_task.C
@@ -3,6 +3,8 @@
#include <kernel/task.H>
#include <kernel/taskmgr.H>
#include <kernel/cpu.H>
+#include <sys/vfs.h>
+#include <sys/msg.h>
using namespace Systemcalls;
@@ -40,3 +42,32 @@ cpuid_t task_getcpuid()
asm volatile("addi %0, 13, 0" : "=r"(task));
return task->cpu->cpu;
}
+
+tid_t task_exec(const char* file, void* ptr)
+{
+ // The VFS process is responsible for finding the module and creating the
+ // new process. So, we send a message over to that process.
+
+ tid_t child = -1;
+
+ // Create message, send.
+ msg_q_t vfsQ = (msg_q_t)_syscall0(MSGQ_RESOLVE_ROOT);
+ msg_t* msg = msg_allocate();
+ msg->type = VFS_MSG_EXEC;
+ msg->data[0] = (uint64_t) file;
+ msg->data[1] = (uint64_t) ptr;
+ int rc = msg_sendrecv(vfsQ, msg);
+
+ if (0 == rc)
+ {
+ // Get child ID from message data 0.
+ child = (tid_t) msg->data[0];
+ }
+ else
+ {
+ child = rc;
+ }
+
+ msg_free(msg);
+ return child;
+}
diff --git a/src/sys/init/init_main.C b/src/sys/init/init_main.C
index 72bfc64a8..ef9dfb1e7 100644
--- a/src/sys/init/init_main.C
+++ b/src/sys/init/init_main.C
@@ -1,5 +1,8 @@
#include <kernel/console.H> // TODO : Remove this.
+#include <kernel/syscalls.H>
+#include <sys/syscall.h>
+
#include <sys/task.h>
#include <sys/mutex.h>
#include <sys/msg.h>
@@ -7,6 +10,7 @@
mutex_t global_mutex;
+/*
void init_child(void* unused)
{
mutex_lock(global_mutex);
@@ -15,6 +19,7 @@ void init_child(void* unused)
for (volatile int i = 0 ; i < 100000; i++);
task_end();
}
+*/
void vfs_main(void*);
@@ -24,7 +29,12 @@ void init_main(void* unused)
printk("Bringing up VFS...");
task_create(&vfs_main, NULL);
- task_yield(); // TODO... add a barrier to ensure VFS is fully up.
+
+ // TODO... add a barrier to ensure VFS is fully up.
+ while (NULL == _syscall0(Systemcalls::MSGQ_RESOLVE_ROOT));
+ task_yield();
+
+
/*
uint64_t* mmio_addr = (uint64_t*) mmio_map((void*)0x800000000, 1);
printk("MMIO Access %llx\n", *mmio_addr);
@@ -51,6 +61,8 @@ void init_main(void* unused)
}
*/
+ task_exec("libexample.so", NULL);
+
while(1)
task_yield();
}
diff --git a/src/sys/vfs/vfs_main.C b/src/sys/vfs/vfs_main.C
index 481df1101..0b41bb631 100644
--- a/src/sys/vfs/vfs_main.C
+++ b/src/sys/vfs/vfs_main.C
@@ -2,6 +2,7 @@
#include <sys/msg.h>
#include <sys/vfs.h>
+#include <sys/task.h>
#include <util/locked/list.H>
#include <kernel/console.H> // TODO : Remove this.
@@ -92,6 +93,27 @@ void vfs_main(void* unused)
msg_respond(vfsMsgQ, msg);
}
break;
+
+ case VFS_MSG_EXEC:
+ {
+ 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))
+ {
+ child = task_create(module->start,
+ (void*) msg->data[1]);
+ break;
+ }
+ }
+ msg->data[0] = child;
+ msg_respond(vfsMsgQ, msg);
+ }
+ break;
default:
msg_free(msg);
diff --git a/src/usr/example/example.C b/src/usr/example/example.C
index 18095ac5b..2fd0ef367 100644
--- a/src/usr/example/example.C
+++ b/src/usr/example/example.C
@@ -24,5 +24,6 @@ void _init(void*)
extern "C"
void _start(void*)
{
+ printk("Executing example module.\n");
task_end();
}
OpenPOWER on IntegriCloud