From 7cccc1fb9951f91d91fe72114b39585e5b428384 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Tue, 30 Aug 2022 11:01:28 +0200 Subject: set up the stack in user/bootstrap instead of the kernel --- src/user/bootstrap/entry.S | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/user/bootstrap/entry.S (limited to 'src/user/bootstrap/entry.S') 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 +#include + +.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 -- cgit v1.2.3