interrupt: nmi work

This commit is contained in:
Matheus
2025-12-05 18:09:36 -03:00
parent 47f5a2fcfb
commit d10295dcdf
4 changed files with 115 additions and 4 deletions
+75
View File
@@ -57,6 +57,9 @@ isr_common:
mov rdi, rbp ; vec
mov rsi, rsp ; ctx
; set this as the end of the stack frame
xor rbp, rbp
cld
extern interrupt_isr
call interrupt_isr
@@ -93,6 +96,78 @@ isr_common:
.notneeded2:
o64 iret
global asm_nmi_handler
asm_nmi_handler:
sub rsp, 8 ; error code, unused for nmi
push rbp
sub rsp, 8 ; vec number, unused for nmi
push rsi
push rdi
push r15
push r14
push r13
push r12
push r11
push r10
push r9
push r8
push rdx
push rcx
push rbx
push rax
mov rax, ds
push rax
mov rax, es
push rax
mov rax, fs
push rax
mov rax, gs
push rax
mov rdi,cr2
push rdi
; set up kernel segments
mov rdi, 0x10
mov ds, rdi
mov es, rdi
; save ctx pointer
mov rdi, rsp
; set this as the end of the stack frame
xor rbp, rbp
cld
extern arch_nmi_isr
call arch_nmi_isr
cli
; pop context
add rsp, 24 ; cr2 gs and fs are not popped.
pop rax
mov es,rax
pop rax
mov ds,rax
pop rax
pop rbx
pop rcx
pop rdx
pop r8
pop r9
pop r10
pop r11
pop r12
pop r13
pop r14
pop r15
pop rdi
pop rsi
add rsp, 8 ; vector num, unused for nmi
pop rbp
add rsp, 8 ; error code, unused for nmi
o64 iret
section .rodata
global isr_table
isr_table: