summaryrefslogtreecommitdiff
path: root/src/bootstrap/entry.S
diff options
context:
space:
mode:
Diffstat (limited to 'src/bootstrap/entry.S')
-rw-r--r--src/bootstrap/entry.S27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/bootstrap/entry.S b/src/bootstrap/entry.S
new file mode 100644
index 0000000..bd1b417
--- /dev/null
+++ b/src/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 $_SYS_MEMFLAG, %rdi
+ mov $(STACK_TOP & ~0xFFF - (STACK_PAGES - 1) * 0x1000), %rsi
+ mov $(STACK_PAGES * 0x1000), %rdx
+ mov $MEMFLAG_PRESENT, %r10
+ syscall
+
+ mov $_SYS_MEMFLAG, %rdi
+ mov $_bss_start, %rsi
+ mov $_bss_end, %rdx
+ sub $_bss_start, %rdx
+ mov $MEMFLAG_PRESENT, %r10
+ mov %rsp, %r8
+ syscall
+
+ mov $(STACK_TOP & ~0xF), %rsp
+ call main // and don't you dare return