summaryrefslogtreecommitdiff
path: root/syscall.c
diff options
context:
space:
mode:
authorrtm <rtm>2006-06-15 16:02:20 +0000
committerrtm <rtm>2006-06-15 16:02:20 +0000
commita4c03dea09b7b5f2463147e979d20b035b81de96 (patch)
tree3ba362f412faf45f0fb0e93b72f613ecc3956193 /syscall.c
parentcb83c71628378bc0e295dd71bf6641379fbcdf37 (diff)
downloadxv6-labs-a4c03dea09b7b5f2463147e979d20b035b81de96.tar.gz
xv6-labs-a4c03dea09b7b5f2463147e979d20b035b81de96.tar.bz2
xv6-labs-a4c03dea09b7b5f2463147e979d20b035b81de96.zip
primitive fork and exit system calls
Diffstat (limited to 'syscall.c')
-rw-r--r--syscall.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/syscall.c b/syscall.c
new file mode 100644
index 0000000..9cb20dc
--- /dev/null
+++ b/syscall.c
@@ -0,0 +1,50 @@
+#include "types.h"
+#include "param.h"
+#include "mmu.h"
+#include "proc.h"
+#include "defs.h"
+#include "x86.h"
+#include "traps.h"
+#include "syscall.h"
+
+/*
+ * User code makes a system call with INT T_SYSCALL.
+ * System call number in %eax.
+ * Arguments on the stack.
+ *
+ * Return value? Error indication? Errno?
+ */
+
+void
+sys_fork()
+{
+ newproc();
+}
+
+void
+sys_exit()
+{
+ curproc->state = UNUSED;
+ // XXX free resources. notify parent. abandon children.
+ swtch();
+}
+
+void
+syscall()
+{
+ int num = curproc->tf->tf_regs.reg_eax;
+
+ cprintf("%x sys %d\n", curproc, num);
+ switch(num){
+ case SYS_fork:
+ sys_fork();
+ break;
+ case SYS_exit:
+ sys_exit();
+ break;
+ default:
+ cprintf("unknown sys call %d\n", num);
+ // XXX fault
+ break;
+ }
+}