From 642b5fb0007b64c77d186fcb018d571152ee1d47 Mon Sep 17 00:00:00 2001
From: dzwdz
Date: Mon, 14 Aug 2023 18:51:07 +0200
Subject: reorganization: first steps

---
 src/bootstrap/entry.S | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 src/bootstrap/entry.S

(limited to 'src/bootstrap/entry.S')

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
-- 
cgit v1.2.3