--- /dev/null
+#ifndef __CRXSTD_H
+#define __CRXSTD_H
+
+#include <corax/types.h>
+#include <corax/ipc.h>
+
+extern int cxsend(pid_t, struct cxmsg*);
+extern int cxrecv(pid_t, struct cxmsg*);
+extern int cxsendrecv(pid_t, struct cxmsg*);
+
+#endif /* __CRXSTD_H */
int arch_init(void*);
void sched_tick(void);
-pid_t fork(void);
-int cxsend(pid_t, struct cxmsg*);
-int cxrecv(pid_t, struct cxmsg*);
+extern void _stdio(void);
+extern void _net(void);
void _print_mptbl(void *tbl)
{
static void _init(void)
{
- /* FIXME: Spawn the idle process */
- while(1);
-}
-
-static void _test(void)
-{
- pid_t p;
- pid_t self;
- process_t *proc;
-
- /* have to initialize C library */
+ process_t *stdio;
+ process_t *net;
+ int err;
- p = fork();
+ /*
+ * instead of something like /sbin/init, this process will behave more like the process daemon
+ * found in the MINIX3 operating system. It will spawn the daemons necessary for basic system
+ * operation, and restart them in case they should die.
+ */
- proc = process_get_current();
- self = process_get_id(proc);
+ err = process_create(&stdio, PID_STDIO, 3, (void*)_stdio);
- dbg_printf("[%02x] fork() = %02x\n", self, p);
+ if(err < 0) {
+ dbg_printf("Failed to start stdio process [err=0x%08x]\n", err);
+ }
- for(;;) {
- if(p == 0) {
- dbg_printf("c");
- } else if(p > 0) {
- dbg_printf("p");
- } else {
- dbg_printf("e");
- }
+ err = process_create(&net, PID_NET, 3, (void*)_net);
- asm volatile("hlt");
+ if(err < 0) {
+ dbg_printf("Failed to start NET process [err=0x%08x]\n", err);
}
+ /* For now, only start them once */
+ _idle();
+
return;
}
PANIC("Could not spawn idle process\n");
}
- err = process_create(&proc, PID_INIT, 3, (void*)_init);
+ err = process_create(&proc, PID_ANY, 0, (void*)_init);
if(err < 0) {
PANIC("Could not spawn init process\n");
--- /dev/null
+#include <config.h>
+#include <crxstd.h>
+#include <corax/errno.h>
+
+void _net(void)
+{
+ struct cxmsg msg;
+ int len;
+
+ while(1) {
+ len = cxrecv(PID_ANY, &msg);
+
+ if(len > 0) {
+ /* FIXME: handle message */
+
+ msg.cm_type = (u32_t)-ENOSYS;
+ msg.cm_dst = msg.cm_src;
+ cxsend(msg.cm_dst, &msg);
+ }
+ }
+
+ return;
+}
--- /dev/null
+#include <config.h>
+#include <crxstd.h>
+#include <corax/errno.h>
+
+void _stdio(void)
+{
+ struct cxmsg msg;
+ int err;
+
+ while(1) {
+ err = cxrecv(PID_ANY, &msg);
+
+ if(err > 0) {
+ /* FIXME: Handle message */
+
+ msg.cm_dst = msg.cm_src;
+ msg.cm_type = -ENOSYS;
+ cxsend(msg.cm_dst, &msg);
+ }
+ }
+
+ return;
+}