diff options
author | Marvin Borner | 2019-12-01 15:47:35 +0100 |
---|---|---|
committer | Marvin Borner | 2019-12-01 15:47:35 +0100 |
commit | e9407b091b34d93014b89660601da62f13df37aa (patch) | |
tree | d60f14946e96d7e1bd72657522682032f0a99e84 /src/userspace | |
parent | 50f949d994c33ab23d63bdb9e8a438560ab0b4c4 (diff) |
Semi-working C-based userspace syscalls
Diffstat (limited to 'src/userspace')
-rw-r--r-- | src/userspace/main.asm | 12 | ||||
-rw-r--r-- | src/userspace/main.c | 10 | ||||
-rw-r--r-- | src/userspace/start.asm | 22 |
3 files changed, 32 insertions, 12 deletions
diff --git a/src/userspace/main.asm b/src/userspace/main.asm deleted file mode 100644 index 4369f10..0000000 --- a/src/userspace/main.asm +++ /dev/null @@ -1,12 +0,0 @@ -bits 32 -mov esp, ebp - -mov eax, 1 -lea edi, [ebp+welcome] -mov esi, welcome_sz -int 0x80 - -jmp $ - -welcome db "Welcome to the userspace!", 0x0A, 0x0A -welcome_sz equ $ - welcome
\ No newline at end of file diff --git a/src/userspace/main.c b/src/userspace/main.c new file mode 100644 index 0000000..22bb42a --- /dev/null +++ b/src/userspace/main.c @@ -0,0 +1,10 @@ +#include <stddef.h> + +extern void syscall(); + +void user_main() +{ + syscall(); + + while (1) {}; +}
\ No newline at end of file diff --git a/src/userspace/start.asm b/src/userspace/start.asm new file mode 100644 index 0000000..498f5f5 --- /dev/null +++ b/src/userspace/start.asm @@ -0,0 +1,22 @@ +bits 32 +section .start_section + dd _start + +section .text + global _start + extern user_main + _start: + mov esp, ebp + call user_main + + global syscall + syscall: + mov eax, 1 + lea edi, [ebp+welcome] + mov esi, welcome_sz + int 0x80 + ret + +section .data + welcome db "Welcome to the userspace", 0x0A, 0x0A + welcome_sz equ $ - welcome
\ No newline at end of file |