x86_64: make interrupt entry code smaller

This commit is contained in:
Matheus
2024-06-12 18:28:08 -03:00
parent 797f2c118a
commit 3e82c6a8f0
+11 -8
View File
@@ -1,21 +1,26 @@
section .text section .text
%assign i 0 %assign i 0
%rep 256 %rep 256
isr_%+ i: isr_%+ i:
; push an error code if the cpu did not ; push an error code if the cpu did not
%if i <> 8 && i <> 10 && i <> 11 && i <> 12 && i <> 13 && i <> 14 %if i <> 8 && i <> 10 && i <> 11 && i <> 12 && i <> 13 && i <> 14
push qword 0 push qword 0
%endif %endif
; check if swapgs is needed push rbp ; this push is here to free a register
mov rbp, i
jmp isr_common
%assign i i + 1
%endrep
cmp qword [rsp+16], 0x23 isr_common:
; check if swapgs is needed
cmp qword [rsp+24], 0x23
jne .notneeded1 jne .notneeded1
swapgs swapgs
.notneeded1: .notneeded1:
; push context ; push context
push rbp
push rsi push rsi
push rdi push rdi
push r15 push r15
@@ -47,8 +52,8 @@ isr_%+ i:
mov es, rdi mov es, rdi
; save ctx pointer and interrupt vector number ; save ctx pointer and interrupt vector number
mov rdi, i mov rdi, rbp ; vec
mov rsi, rsp mov rsi, rsp ; ctx
cld cld
extern interrupt_isr extern interrupt_isr
@@ -84,8 +89,6 @@ isr_%+ i:
swapgs swapgs
.notneeded2: .notneeded2:
o64 iret o64 iret
%assign i i + 1
%endrep
section .rodata section .rodata
global isr_table global isr_table