4 %include "arch/x86_64/include/common.inc.asm"
6 ;KERNEL_BASE equ 0xFFFF800000000000
7 KERNEL_BASE equ 0xFFFFFFFF80000000
11 [extern gMultibootPtr]
12 [extern gMultibootMagic]
25 mov rax, start64.himem
30 mov dr0, rax ; Set CPU0
33 mov rax, 0x1F201F201F201F20 ; Set the screen to White on blue, space (4 characters)
39 mov rsp, 0xFFFFA00000000000 + INITIAL_KSTACK_SIZE*0x1000
42 mov edi, [gMultibootMagic - KERNEL_BASE]
43 mov esi, [gMultibootPtr - KERNEL_BASE]
56 KSTACK_USERSTATE_SIZE equ (5+2+16+2)*8 ; IRET, ErrorNum, ErrorCode, GPRs, FS&GS
57 [global Proc_ReturnToUser]
64 ; NOTE: This can cause corruption if the signal happens while the user
65 ; has called a kernel operation.
66 ; Good thing this can only be called on a user fault.
70 ; Get and alter User SP
71 mov rcx, [rsi-0x20] ; Get user SP
76 ; Drop down to user mode
79 mov rcx, rdi ; SYSRET IP
81 mov rdi, rdx ; Argument for handler
82 mov r11, 0x202 ; RFlags
86 ; int CallWithArgArray(void *Ptr, int NArgs, Uint *Args)
87 ; Call a function passing the array as arguments
88 [global CallWithArgArray]
95 mov [rbp+2*8], rdi ; Save Ptr to stack
130 ; No support for more
133 mov rax, [rbp+2*8] ; Ptr