From c8c8d009f6a32e0f6856ab0f8167563021204de9 Mon Sep 17 00:00:00 2001 From: trimill Date: Thu, 1 Feb 2024 16:53:07 -0500 Subject: debugger --- src/arch/amd64/idt.S | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/arch/amd64/idt.S') diff --git a/src/arch/amd64/idt.S b/src/arch/amd64/idt.S index 33d488a..cd8783e 100644 --- a/src/arch/amd64/idt.S +++ b/src/arch/amd64/idt.S @@ -11,9 +11,9 @@ extern idt_pic_eoi push rbx push rcx push rdx - push rbp - push rdi push rsi + push rdi + push rbp push r8 push r9 push r10 @@ -33,9 +33,9 @@ extern idt_pic_eoi pop r10 pop r9 pop r8 - pop rsi - pop rdi pop rbp + pop rdi + pop rsi pop rdx pop rcx pop rbx @@ -51,8 +51,7 @@ isr_stub_%+%1: cld mov rdi, %1 ; exception number mov rsi, 0 ; placeholder error code - mov rdx, [rsp + 15 * 8] ; instruction pointer - mov rcx, rbp ; base pointer for stack trace + mov rdx, rsp ; top of stack call idt_exception_handler POPALL iretq @@ -64,15 +63,18 @@ isr_stub_%+%1: %macro ISRExceptionCode 1 align 8 isr_stub_%+%1: + ; retrieve the error code without corrupting registers + mov [isr_tmp], rax + pop rax + mov [isr_err_code], rax + mov rax, [isr_tmp] PUSHALL cld mov rdi, %1 ; exception number - mov rsi, [rsp + 15 * 8] ; error code - mov rdx, [rsp + 16 * 8] ; instruction pointer - mov rcx, rbp ; base pointer for stack trace + mov rsi, [isr_err_code] ; error code + mov rdx, rsp ; top of stack call idt_exception_handler POPALL - sub rsp, 8 ; discard error code iretq %endmacro @@ -188,6 +190,10 @@ PICGeneric 47 ; 15 %assign i i+1 %endrep +section .data +isr_tmp: dq 0 +isr_err_code: dq 0 + ; isr stub table section .rodata bits 64 -- cgit v1.2.3-freya