feat: add interrupts handling, PIC and PIT

This commit is contained in:
2026-10-20 15:20:26 +02:00
parent 8da0918108
commit 811ce51c2c
10 changed files with 428 additions and 12 deletions
+58 -8
View File
@@ -3,18 +3,62 @@
.section .text
.code64
.extern exception_handler
.extern interrupt_handler
common_isr_stub:
push %rax
push %rbx
push %rcx
push %rdx
push %rsi
push %rdi
push %rbp
push %r8
push %r9
push %r10
push %r11
push %r12
push %r13
push %r14
push %r15
cld
mov %rsp, %rdi
call interrupt_handler
pop %r15
pop %r14
pop %r13
pop %r12
pop %r11
pop %r10
pop %r9
pop %r8
pop %rbp
pop %rdi
pop %rsi
pop %rdx
pop %rcx
pop %rbx
pop %rax
add $16, %rsp
iretq
.macro isr_err_stub i=1
isr_stub_\i:
call exception_handler
iretq
pushq $\i
jmp common_isr_stub
.endm
.macro isr_nerr_stub i
isr_stub_\i:
call exception_handler
iretq
pushq $0
pushq $\i
jmp common_isr_stub
.endm
# From https://wiki.osdev.org/Interrupts_Tutorial
@@ -39,7 +83,7 @@ isr_err_stub 17
isr_nerr_stub 18
isr_nerr_stub 19
isr_nerr_stub 20
isr_nerr_stub 21
isr_err_stub 21
isr_nerr_stub 22
isr_nerr_stub 23
isr_nerr_stub 24
@@ -47,10 +91,16 @@ isr_nerr_stub 25
isr_nerr_stub 26
isr_nerr_stub 27
isr_nerr_stub 28
isr_nerr_stub 29
isr_err_stub 29
isr_err_stub 30
isr_nerr_stub 31
.set i, 32
.rept 256 - 32
isr_nerr_stub %i
.set i, i+1
.endr
.macro isr_label i
.quad isr_stub_\i
.endm
@@ -58,7 +108,7 @@ isr_nerr_stub 31
.global isrStubTable
isrStubTable:
.set i, 0
.rept 32
.rept 256
isr_label %i
.set i, i+1
.endr