summaryrefslogtreecommitdiff
path: root/src/kernel/arch/amd64/interrupts/isr_stub.s
diff options
context:
space:
mode:
authordzwdz2024-08-02 15:44:24 +0200
committerdzwdz2024-08-02 15:44:24 +0200
commit974c2581c9524aa7546f5863ecc26065e328cd54 (patch)
tree3cec6690bb1642d380cdee8749742ada926ce4d4 /src/kernel/arch/amd64/interrupts/isr_stub.s
parente818cab3f1fc4a3d4d0b8e2c9424fb2e7b1dff70 (diff)
kernel/interrupts: use UserRegs in the isr handler
Diffstat (limited to 'src/kernel/arch/amd64/interrupts/isr_stub.s')
-rw-r--r--src/kernel/arch/amd64/interrupts/isr_stub.s36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/kernel/arch/amd64/interrupts/isr_stub.s b/src/kernel/arch/amd64/interrupts/isr_stub.s
index 3134808..5604f19 100644
--- a/src/kernel/arch/amd64/interrupts/isr_stub.s
+++ b/src/kernel/arch/amd64/interrupts/isr_stub.s
@@ -22,18 +22,27 @@ _isr_stubs:
.endr
_isr_stage2:
- /* pushal order, without %esp. 15 in total */
+ /* UserRegs */
+ /* I'm skipping fields that are in the IRET stack frame
+ * on the assumption it's easier to deal with them from C. */
+ push $0 /* flags */
+ push $0 /* ip */
+
push %rax
push %rcx
push %rdx
push %rbx
+
+ push $0 /* rsp */
push %rbp
push %rsi
push %rdi
+
push %r8
push %r9
push %r10
push %r11
+
push %r12
push %r13
push %r14
@@ -45,15 +54,15 @@ _isr_stage2:
// basically if you're context switching, FXSAVE
/* first argument: vector nr. computed from the return address at offset
- * 15*8 = 120 */
- mov 120(%rsp), %rdi
+ * 18*8 = 144 */
+ mov 144(%rsp), %rdi
sub $_isr_stubs, %rdi
shr $3, %rdi
- /* second argument: IRET stack frame */
- lea 136(%rsp), %rsi
+ /* second argument: stack frame */
+ mov %rsp, %rsi
- // load kernel paging
+ /* load kernel paging */
mov %cr3, %rbx
push %rbx
mov $pml4_identity, %rbx
@@ -64,27 +73,36 @@ _isr_stage2:
call isr_stage3
mov %rbp, %rsp
- pop %rax // restore old cr3
+ pop %rax /* restore old cr3 */
mov %rax, %cr3
- // restore registers
+ /* restore registers */
pop %r15
pop %r14
pop %r13
pop %r12
+
pop %r11
pop %r10
pop %r9
pop %r8
+
pop %rdi
pop %rsi
pop %rbp
+ pop %rbx /* skip rsp */
+
pop %rbx
pop %rdx
pop %rcx
pop %rax
- add $16, %rsp /* skip return address from call and the error code */
+ /* skips:
+ * UserRegs.ip
+ * UserRegs.flags
+ * return address from the CALL in the stub
+ * error code */
+ add $32, %rsp
iretq
.align 8