From 8251da342161767fe203627223ccd4a7026701c6 Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Fri, 4 Sep 2026 11:31:40 -0400 Subject: initial commit. working on tasking --- arch/x86_64/hal/idt_entries.s | 127 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 arch/x86_64/hal/idt_entries.s (limited to 'arch/x86_64/hal/idt_entries.s') diff --git a/arch/x86_64/hal/idt_entries.s b/arch/x86_64/hal/idt_entries.s new file mode 100644 index 0000000..204fa93 --- /dev/null +++ b/arch/x86_64/hal/idt_entries.s @@ -0,0 +1,127 @@ +.section .text +.macro push_state + pushq %rax + pushq %rbx + pushq %rcx + pushq %rdx + pushq %rsi + pushq %rdi + pushq %rbp + pushq %r8 + pushq %r9 + pushq %r10 + pushq %r11 + pushq %r12 + pushq %r13 + pushq %r14 + pushq %r15 +.endm + +.macro pop_state + popq %r15 + popq %r14 + popq %r13 + popq %r12 + popq %r11 + popq %r10 + popq %r9 + popq %r8 + popq %rbp + popq %rdi + popq %rsi + popq %rdx + popq %rcx + popq %rbx + popq %rax +.endm + +.macro swapgs_if_necessary + cmpq $0x08, 0x8(%rsp) + je 1f + swapgs +1: +.endm + +.extern __int_handles +.type __isr_header @function +__isr_header: + push_state + cld + + movq %rsp, %rdi + +isr_break: + movq 0x78(%rdi), %rax + movq __int_handles(,%rax,8), %rbx + call %rbx + + pop_state + addq $16, %rsp + swapgs_if_necessary + iretq +.size __isr_header, . - __isr_header + +.macro defn_isr_err num:req +.type __isr\num @function +__isr\num: + swapgs_if_necessary + pushq $\num + jmp __isr_header +.size __isr\num, . - __isr\num +.endm + +.macro defn_isr num:req +.type __isr\num @function +__isr\num: + swapgs_if_necessary + pushq $0 + pushq $\num + jmp __isr_header +.size __isr\num, . - __isr\num +.endm + +.macro decl_isr num:req +.quad __isr\num +.endm + +defn_isr 0 +defn_isr 1 +defn_isr 2 +defn_isr 3 +defn_isr 4 +defn_isr 5 +defn_isr 6 +defn_isr 7 +defn_isr_err 8 +defn_isr 9 +defn_isr_err 10 +defn_isr_err 11 +defn_isr_err 12 +defn_isr_err 13 +defn_isr_err 14 +defn_isr 15 +defn_isr 16 +defn_isr_err 17 +defn_isr 18 +defn_isr 19 +defn_isr 20 +defn_isr_err 21 + +.altmacro +.set i, 22 +.rept 48-22 + defn_isr %i + .set i, i+1 +.endr + +.section .data + +.global __isrs +.type __isrs @object +__isrs: + .set i, 0 + .rept 48 + decl_isr %i + .set i, i+1 + .endr +.size __isrs, . - __isrs -- cgit v1.2.3