feat(loader, kernel): impl part of loader and initialize kernel structure
This commit is contained in:
56
arch/x86_64/boot/idt_handlers.S
Normal file
56
arch/x86_64/boot/idt_handlers.S
Normal file
@@ -0,0 +1,56 @@
|
||||
|
||||
.macro EXCEPTION_HANDLER name function error_code=0
|
||||
.global \name
|
||||
.type \name, @function
|
||||
\name:
|
||||
if \error_code == 0
|
||||
pushq $0
|
||||
end
|
||||
|
||||
pushq %rdi
|
||||
pushq %rsi
|
||||
pushq %rdx
|
||||
pushq %rcx
|
||||
pushq %rax
|
||||
pushq %r8
|
||||
pushq %r9
|
||||
pushq %r10
|
||||
pushq %r11
|
||||
pushq %rbx
|
||||
pushq %rbp
|
||||
pushq %r12
|
||||
pushq %r13
|
||||
pushq %r14
|
||||
pushq %r15
|
||||
|
||||
movq %rsp, %rdi
|
||||
/* Error code is second parameter */
|
||||
movq 120(%rsp), %rsi
|
||||
call \function
|
||||
|
||||
/* Restore regs */
|
||||
popq %r15
|
||||
popq %r14
|
||||
popq %r13
|
||||
popq %r12
|
||||
popq %rbp
|
||||
popq %rbx
|
||||
popq %r11
|
||||
popq %r10
|
||||
popq %r9
|
||||
popq %r8
|
||||
popq %rax
|
||||
popq %rcx
|
||||
popq %rdx
|
||||
popq %rsi
|
||||
popq %rdi
|
||||
|
||||
addq $8, %rsp
|
||||
|
||||
iretq
|
||||
.endm
|
||||
.text
|
||||
.code64
|
||||
|
||||
EXCEPTION_HANDLER boot_page_fault doBootPageFault error_code=1
|
||||
EXCEPTION_HANDLER boot_nmi doBootNMI
|
||||
Reference in New Issue
Block a user