5 ;KERNEL_BASE equ 0xFFFF800000000000
6 KERNEL_BASE equ 0xFFFFFFFF80000000
10 [extern gMultibootPtr]
11 [extern gMultibootMagic]
24 mov rax, start64.himem
29 mov rax, 0x1F201F201F201F20 ; Set the screen to White on blue, space (4 characters)
35 mov rsp, gInitialKernelStack
38 mov edi, [gMultibootMagic - KERNEL_BASE]
39 mov esi, [gMultibootPtr - KERNEL_BASE]
56 sub ax, 0x38 ; TSS Base
57 shr ax, 4 ; One 16-byte TSS per CPU
60 KSTACK_USERSTATE_SIZE equ (16+1+5)*8 ; GPRegs, CPU, IRET
61 [global Proc_ReturnToUser]
62 [extern Proc_GetCurThread]
64 ; RBP is the handler to use
66 call Proc_GetCurThread
68 ; EAX is the current thread
70 mov rax, [rbx+40] ; Get Kernel Stack
71 sub rax, KSTACK_USERSTATE_SIZE
74 ; NOTE: This can cause corruption if the signal happens while the user
75 ; has called a kernel operation.
76 ; Good thing this can only be called on a user fault.
79 ; Get and alter User SP
80 mov rcx, [rax+KSTACK_USERSTATE_SIZE-3*8]
81 mov rdx, [rbx+60] ; Get Signal Number
83 mov rax, User_Syscall_RetAndExit
87 ; Restore Segment Registers
94 push 0x202 ; RFLAGS (IF and Rsvd)
100 ; int CallWithArgArray(void *Ptr, int NArgs, Uint *Args)
101 ; Call a function passing the array as arguments
102 [global CallWithArgArray]
106 mov rcx, [rbp+3*8] ; Get NArgs
110 mov rax, [rdx+rcx*8-8]
121 User_Syscall_RetAndExit:
123 jmp User_Syscall_Exit
130 [global gInitialKernelStack]
131 resd 1024*4 ; 4 Pages