5 ;KERNEL_BASE equ 0xFFFF800000000000
6 KERNEL_BASE equ 0xFFFFFFFF80000000
10 [extern gMultibootPtr]
11 [extern gMultibootMagic]
24 mov rax, start64.himem
29 mov dr0, rax ; Set CPU0
32 mov rax, 0x1F201F201F201F20 ; Set the screen to White on blue, space (4 characters)
38 mov rsp, gInitialKernelStack
41 mov edi, [gMultibootMagic - KERNEL_BASE]
42 mov esi, [gMultibootPtr - KERNEL_BASE]
59 sub ax, 0x38 ; TSS Base
60 shr ax, 4 ; One 16-byte TSS per CPU
63 KSTACK_USERSTATE_SIZE equ (16+1+5)*8 ; GPRegs, CPU, IRET
64 [global Proc_ReturnToUser]
65 [extern Proc_GetCurThread]
67 ; RBP is the handler to use
69 call Proc_GetCurThread
71 ; EAX is the current thread
73 mov rax, [rbx+40] ; Get Kernel Stack
74 sub rax, KSTACK_USERSTATE_SIZE
77 ; NOTE: This can cause corruption if the signal happens while the user
78 ; has called a kernel operation.
79 ; Good thing this can only be called on a user fault.
82 ; Get and alter User SP
83 mov rcx, [rax+KSTACK_USERSTATE_SIZE-3*8]
84 mov rdx, [rbx+60] ; Get Signal Number
86 mov rax, User_Syscall_RetAndExit
90 ; Restore Segment Registers
97 push 0x202 ; RFLAGS (IF and Rsvd)
103 ; int CallWithArgArray(void *Ptr, int NArgs, Uint *Args)
104 ; Call a function passing the array as arguments
105 [global CallWithArgArray]
112 mov [rbp+2*8], rdi ; Save Ptr to stack
147 ; No support for more
150 mov rax, [rbp+2*8] ; Ptr
161 User_Syscall_RetAndExit:
163 jmp User_Syscall_Exit
170 [global gInitialKernelStack]
171 resd 1024*4 ; 4 Pages