From 65a97e32ef586e073988186f1f4932c0193b3409 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 16 May 2025 16:51:06 +0200 Subject: feat(kernel): Better UPS and interrupt system too. Signed-off-by: Amlal El Mahrouss --- dev/kernel/HALKit/AMD64/HalInterruptAPI.asm | 89 +++++++++++------------------ 1 file changed, 34 insertions(+), 55 deletions(-) (limited to 'dev/kernel/HALKit/AMD64/HalInterruptAPI.asm') diff --git a/dev/kernel/HALKit/AMD64/HalInterruptAPI.asm b/dev/kernel/HALKit/AMD64/HalInterruptAPI.asm index fdd62e57..667d3c5b 100644 --- a/dev/kernel/HALKit/AMD64/HalInterruptAPI.asm +++ b/dev/kernel/HALKit/AMD64/HalInterruptAPI.asm @@ -20,6 +20,8 @@ __NE_INT_%1: std + add rsp, 8 + o64 iret %endmacro @@ -30,6 +32,8 @@ __NE_INT_%1: std + add rsp, 8 + o64 iret %endmacro @@ -45,29 +49,24 @@ extern ke_io_write extern idt_handle_ud extern idt_handle_generic extern idt_handle_breakpoint +extern idt_handle_math section .text __NE_INT_0: cld - - mov al, 0x20 - out 0x20, al - push rcx call idt_handle_generic pop rcx std + add rsp, 8 + o64 iret __NE_INT_1: cld - - mov al, 0x20 - out 0x20, al - push rcx call idt_handle_generic pop rcx @@ -78,100 +77,87 @@ __NE_INT_1: __NE_INT_2: cld - - mov al, 0x20 - out 0x20, al - push rcx call idt_handle_generic pop rcx std + add rsp, 8 + o64 iret ;; @brief Triggers a breakpoint and freeze the process. RIP is also fetched. __NE_INT_3: cld - - mov al, 0x20 - out 0x20, al - push rcx call idt_handle_breakpoint pop rcx std + add rsp, 8 + o64 iret __NE_INT_4: cld - mov al, 0x20 - out 0x20, al - - push rcx call idt_handle_generic pop rcx std + add rsp, 8 + o64 iret __NE_INT_5: cld - - mov al, 0x20 - out 0x20, al - std + add rsp, 8 + o64 iret ;; Invalid opcode interrupt __NE_INT_6: cld - - mov al, 0x20 - out 0x20, al - push rcx call idt_handle_ud pop rcx std + add rsp, 8 + o64 iret __NE_INT_7: cld - - mov al, 0x20 - out 0x20, al - push rcx call idt_handle_generic pop rcx std + add rsp, 8 + o64 iret ;; Invalid opcode interrupt __NE_INT_8: cld - mov al, 0x20 - out 0x20, al - push rcx - call idt_handle_generic + call idt_handle_math pop rcx std + add rsp, 8 + o64 iret IntNormal 9 @@ -183,29 +169,26 @@ IntExp 12 __NE_INT_13: cld - mov al, 0x20 - out 0x20, al - push rcx call idt_handle_gpf pop rcx std + add rsp, 8 + o64 iret __NE_INT_14: cld - - mov al, 0x20 - out 0x20, al - push rcx call idt_handle_pf pop rcx std + add rsp, 8 + o64 iret IntNormal 15 @@ -232,11 +215,17 @@ IntNormal 31 [extern kApicBaseAddress] __NE_INT_32: + cld + push rax mov rcx, rsp call idt_handle_scheduler pop rax + std + + add rsp, 8 + o64 iret IntNormal 33 @@ -253,10 +242,6 @@ IntNormal 39 __NE_INT_40: cld - mov al, 0x20 - out 0xA0, al - out 0x20, al - push rax mov rcx, rsp call rtl_rtl8139_interrupt_handler @@ -264,6 +249,8 @@ __NE_INT_40: std + add rsp, 8 + o64 iret IntNormal 41 @@ -283,10 +270,6 @@ IntNormal 49 __NE_INT_50: cld - mov al, 0x20 - out 0xA0, al - out 0x20, al - push rax mov rax, hal_system_call_enter @@ -303,10 +286,6 @@ __NE_INT_50: __NE_INT_51: cld - mov al, 0x20 - out 0xA0, al - out 0x20, al - push rax mov rax, hal_kernel_call_enter -- cgit v1.2.3