From 38610cd06dc0b5a3a4ee46f5fe7c341191aa2bc1 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 21 Dec 2019 12:25:14 +0100 Subject: Some userspace improvements GAS is bad, NASM is awesome. --- src/kernel/boot.asm | 9 ++++++--- src/kernel/kernel.c | 6 +++--- src/kernel/syscall/actions/sys_write.c | 1 + 3 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/boot.asm b/src/kernel/boot.asm index 8241786..2180069 100644 --- a/src/kernel/boot.asm +++ b/src/kernel/boot.asm @@ -38,7 +38,10 @@ section .text global jump_userspace jump_userspace: - mov ebx, dword [esp+4] + push ebp + mov ebp, esp + mov edx, DWORD[ebp + 0xC] + mov esp, edx mov ax, 0x23 mov ds, ax @@ -56,8 +59,8 @@ section .text push eax push 0x1B - push ebx - mov ebp, ebx + push DWORD[ebp + 0x8] + iret pop ebp ret diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c index 27f5ad9..196b44e 100644 --- a/src/kernel/kernel.c +++ b/src/kernel/kernel.c @@ -18,7 +18,7 @@ #include #include -extern void jump_userspace(); +extern void jump_userspace(uintptr_t location, uintptr_t stack); void kernel_main() { @@ -66,10 +66,10 @@ void kernel_main() if (!user_e) panic("Userspace binary not found!"); ATAPI_granular_read(1 + (user_e->length / 2048), user_e->lba, (uint8_t *) (userspace + 4096)); kfree(user_e); - jump_userspace(userspace + 4096); + jump_userspace(userspace + 4096, (uintptr_t) umalloc(4096)); } else { marfs_read_whole_file(4, (uint8_t *) (userspace + 4096)); - jump_userspace(userspace + 4096); + jump_userspace(userspace + 4096, (uintptr_t) umalloc(4096)); } panic("This should NOT happen!"); diff --git a/src/kernel/syscall/actions/sys_write.c b/src/kernel/syscall/actions/sys_write.c index 6377473..d395384 100644 --- a/src/kernel/syscall/actions/sys_write.c +++ b/src/kernel/syscall/actions/sys_write.c @@ -11,6 +11,7 @@ uint32_t sys_write(char *buf) uint32_t sys_writec(char ch) { + serial_write_hex(ch); writec((char) ch); return 0; } \ No newline at end of file -- cgit v1.2.3