Kernel: Implement thread start trampoline for userspace

This is needed on i686 to set segment registers.
This commit is contained in:
2024-04-03 00:42:39 +03:00
parent 4d70322eab
commit fe386fa819
4 changed files with 49 additions and 12 deletions

View File

@@ -24,3 +24,29 @@ start_kernel_thread:
movq 24(%rsp), %rdi
movq 16(%rsp), %rsi
call *%rsi
.global start_userspace_thread
start_userspace_thread:
call get_start_kernel_thread_sp
movq %rax, %rsp
# STACK LAYOUT
# entry
# argc
# argv
# envp
# userspace stack
call get_userspace_thread_stack_top
popq %rdx
popq %rsi
popq %rdi
popq %rcx
pushq $(0x20 | 3)
pushq %rax
pushq $0x202
pushq $(0x18 | 3)
pushq %rcx
iretq