summaryrefslogtreecommitdiff
path: root/src/user/bootstrap/entry.S
diff options
context:
space:
mode:
authordzwdz2022-08-30 11:01:28 +0200
committerdzwdz2022-08-30 11:01:28 +0200
commit7cccc1fb9951f91d91fe72114b39585e5b428384 (patch)
treeb6d68254978c26ec341f047b3312a86935faebac /src/user/bootstrap/entry.S
parent69d7da4945448f4a6901b085e746e977359f465c (diff)
set up the stack in user/bootstrap instead of the kernel
Diffstat (limited to 'src/user/bootstrap/entry.S')
-rw-r--r--src/user/bootstrap/entry.S27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/user/bootstrap/entry.S b/src/user/bootstrap/entry.S
new file mode 100644
index 0000000..ecd60dd
--- /dev/null
+++ b/src/user/bootstrap/entry.S
@@ -0,0 +1,27 @@
+#define ASM_FILE 1
+#include <camellia/syscalls.h>
+#include <camellia/flags.h>
+
+.set STACK_TOP, 0xFFFFFFFFFFFFFFFF
+.set STACK_PAGES, 4
+
+.section .text.startup
+.global _start
+.type _start, @function
+_start:
+ mov $_SYSCALL_MEMFLAG, %rdi
+ mov $(STACK_TOP & ~0xFFF - (STACK_PAGES - 1) * 0x1000), %rsi
+ mov $(STACK_PAGES * 0x1000), %rdx
+ mov $MEMFLAG_PRESENT, %r10
+ syscall
+ mov $(STACK_TOP & ~0xF), %rsp
+
+ mov $_SYSCALL_MEMFLAG, %rdi
+ mov $_bss_start, %rsi
+ mov $_bss_end, %rdx
+ sub $_bss_start, %rdx
+ mov $MEMFLAG_PRESENT, %r10
+ mov %rsp, %r8
+ syscall
+
+ jmp main