Skip to content

Commit edd42a3

Browse files
committed
Fix routines
1 parent e9450da commit edd42a3

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

kernel/src/kernel/system/interrupts/interrupt_routines.asm

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ interruptRoutine:
3232
; The processor has pushed registers to the stack.
3333
; We'll save the registers that are typically pushed on interrupt, including
3434
; the general-purpose registers and the instruction pointer (RIP) registers.
35+
cld
3536

3637
; Store registers
3738
push rdi
@@ -51,13 +52,30 @@ interruptRoutine:
5152
push r14
5253
push r15
5354

55+
; Store segments
56+
mov rax, ds
57+
push rax
58+
mov rax, es
59+
push rax
60+
61+
; Switch to kernel segments
62+
mov ax, 0x10
63+
mov ds, ax
64+
mov es, ax
65+
5466
; Stack pointer argument
5567
mov rdi, rsp
5668
; Call handler
5769
call _interruptHandler
5870
; Set stack pointer from return value
5971
mov rsp, rax
6072

73+
; Restore segments
74+
pop rax
75+
mov ds, rax
76+
pop rax
77+
mov es, rax
78+
6179
; Restore registers
6280
pop r15
6381
pop r14
@@ -77,7 +95,7 @@ interruptRoutine:
7795
pop rdi
7896

7997
; Skip over the interrupt error code (this was pushed before the handler call)
80-
add rsp, 8
98+
add rsp, 16
8199

82100
; Now we return with IRET, the processor will pop specific registers
83101
; IRET in x86_64 pops RIP, CS, and EFLAGS from the stack

0 commit comments

Comments
 (0)