summaryrefslogtreecommitdiff
path: root/user/initcode.S
diff options
context:
space:
mode:
Diffstat (limited to 'user/initcode.S')
-rw-r--r--user/initcode.S28
1 files changed, 28 insertions, 0 deletions
diff --git a/user/initcode.S b/user/initcode.S
new file mode 100644
index 0000000..ca76972
--- /dev/null
+++ b/user/initcode.S
@@ -0,0 +1,28 @@
+# Initial process execs /init.
+# This code runs in user space.
+
+#include "syscall.h"
+
+# exec(init, argv)
+.globl start
+start:
+ la a0, init
+ la a1, argv
+ li a7, SYS_exec
+ ecall
+
+# for(;;) exit();
+exit:
+ li a7, SYS_exit
+ ecall
+ jal exit
+
+# char init[] = "/init\0";
+init:
+ .string "/init\0"
+
+# char *argv[] = { init, 0 };
+.p2align 2
+argv:
+ .long init
+ .long 0