23 mov al, [gs:104] ; End of TSS
26 KSTACK_USERSTATE_SIZE equ (16+1+5)*8 ; GPRegs, CPU, IRET
27 [global Proc_ReturnToUser]
28 [extern Proc_GetCurThread]
30 ; RBP is the handler to use
32 call Proc_GetCurThread
34 ; EAX is the current thread
36 mov rax, [rbx+40] ; Get Kernel Stack
37 sub rax, KSTACK_USERSTATE_SIZE
40 ; NOTE: This can cause corruption if the signal happens while the user
41 ; has called a kernel operation.
42 ; Good thing this can only be called on a user fault.
45 ; Get and alter User SP
46 mov rcx, [rax+KSTACK_USERSTATE_SIZE-3*8]
47 mov rdx, [rbx+60] ; Get Signal Number
49 mov rax, User_Syscall_RetAndExit
53 ; Restore Segment Registers
60 push 0x202 ; RFLAGS (IF and Rsvd)
66 ; int CallWithArgArray(void *Ptr, int NArgs, Uint *Args)
67 ; Call a function passing the array as arguments
68 [global CallWithArgArray]
72 mov rcx, [rbp+3*8] ; Get NArgs
76 mov rax, [rdx+rcx*8-8]
87 User_Syscall_RetAndExit:
96 [global gInitialKernelStack]