Implement syscalls, hello world from userspace
This commit is contained in:
48
kernel/hal/x86_64/syscall0.S
Normal file
48
kernel/hal/x86_64/syscall0.S
Normal file
@ -0,0 +1,48 @@
|
||||
#include "regs.S"
|
||||
|
||||
.extern hal_syscalldispatch
|
||||
|
||||
.global hal_enable_syscallentry
|
||||
hal_enable_syscallentry:
|
||||
movq $0xC0000080, %rcx
|
||||
rdmsr
|
||||
or $0x1, %eax
|
||||
wrmsr
|
||||
movq $0xC0000081, %rcx
|
||||
rdmsr
|
||||
movl $0x180008, %edx
|
||||
wrmsr
|
||||
ret
|
||||
|
||||
.global hal_syscallentry
|
||||
hal_syscallentry:
|
||||
cli
|
||||
swapgs
|
||||
|
||||
movq %rsp, %gs:0x8
|
||||
movq %gs:0x0, %rsp
|
||||
|
||||
pushq $0x23
|
||||
pushq %gs:0x8
|
||||
|
||||
swapgs
|
||||
|
||||
pushq %r11
|
||||
pushq $0x1b
|
||||
pushq %rcx
|
||||
|
||||
_push_regs
|
||||
|
||||
mov %rsp, %rdi
|
||||
mov $0x0, %rbp
|
||||
|
||||
call hal_syscalldispatch
|
||||
cli
|
||||
|
||||
_pop_regs
|
||||
|
||||
popq %rcx
|
||||
add $0x8, %rsp
|
||||
popq %r11
|
||||
popq %rsp
|
||||
sysret
|
Reference in New Issue
Block a user