[kernel] Give threads initial arguments

This commit changes the add_user_thunk to point to a new routine,
initialize_user_cpu, which sets all the registers that were previously
unset when starting a new user thread. The values for rdi and rsi are
popped off the initial stack values that add_user_thunk sets up, so that
user thread procs can take up to two arguments.

To suppor this, j6_thread_create gained two new arguments, which are
passed on to the thread.

This also let me finally get rid of the hack of passing an argument in
rsp when starting init.
This commit is contained in:
Justin C. Miller
2023-02-08 23:10:17 -08:00
parent 1cb8f1258d
commit 4125175870
10 changed files with 81 additions and 51 deletions

View File

@@ -77,6 +77,21 @@ syscall_handler_prelude:
call syscall_invalid
.end:
global initialize_user_cpu: function hidden (initialize_user_cpu.end - initialize_user_cpu)
initialize_user_cpu:
mov rax, 0xaaaaaaaa
mov rdx, 0xdddddddd
mov r8, 0x08080808
mov r9, 0x09090909
mov r10, 0x10101010
mov r11, 0x11111111
pop rdi
pop rsi
; fall through to kernel_to_user_trampoline
.end:
global kernel_to_user_trampoline: function hidden (kernel_to_user_trampoline.end - kernel_to_user_trampoline)
kernel_to_user_trampoline:
pop r15