diff options
author | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2023-12-10 16:21:05 +0100 |
---|---|---|
committer | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2023-12-10 16:21:05 +0100 |
commit | 7ecfb1b21cf00d7c622cb5be9b4e149e0971a49b (patch) | |
tree | 053a09ec799b19033a23eba8247512ea2c205d7d /stage3/isr.lua | |
parent | 0451ead172447528ece5fb0fcbb461a986962532 (diff) | |
download | cuddles-7ecfb1b21cf00d7c622cb5be9b4e149e0971a49b.tar.xz |
handle interrupts
Diffstat (limited to 'stage3/isr.lua')
-rw-r--r-- | stage3/isr.lua | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/stage3/isr.lua b/stage3/isr.lua new file mode 100644 index 0000000..6c81180 --- /dev/null +++ b/stage3/isr.lua @@ -0,0 +1,55 @@ +print("global idt_entries") +print("extern interrupt_handler") + +local has_error_code = {} +for _, x in pairs({8, 10, 11, 12, 13, 14, 17, 21, 29, 30}) do + has_error_code[x] = true +end + +for i = 0, 255 do + print("isr_" .. i .. ":") + print("cli") + + if not has_error_code[i] then + print("push 0") + end + + print("push " .. i) + print("jmp isr_common") +end + +print("idt_entries:") +for i = 0, 255 do + print("dq isr_"..i) +end + +print([[ +isr_common: + push r11 + push r10 + push r9 + push r8 + push rdi + push rsi + push rcx + push rdx + push rax + + cld + lea rdi, [rsp+8*9] + call interrupt_handler + + pop rax + pop rdx + pop rcx + pop rsi + pop rdi + pop r8 + pop r9 + pop r10 + pop r11 + + add rsp, 16 + + iretq +]]) |