From d1ff7bcc91886626dc9060ec5fb67ee102ab7c1d Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Mon, 11 Mar 2024 21:30:31 -0400 Subject: usermode capable kernel with logging syscall --- arch/x86_64/int.S | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 arch/x86_64/int.S (limited to 'arch/x86_64/int.S') diff --git a/arch/x86_64/int.S b/arch/x86_64/int.S new file mode 100644 index 0000000..96c62d9 --- /dev/null +++ b/arch/x86_64/int.S @@ -0,0 +1,131 @@ +.section .text +.global x86_64_lidt +.type x86_64_lidt @function +x86_64_lidt: + lidt (%rdi) + retq + +.macro irq_preserve + 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 irq_restore + 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 + +.global irq_stub +.type irq_stub @function +irq_stub: + irq_preserve + + movq %rsp, %rdi + cld + + .extern irq_handle + call irq_handle + movq %rax, %rsp + + irq_restore + addq $128, %rsp + iretq + +.extern __isr_err +.extern __isr_num + +.macro isr_error num:req +.type __isr\num @function +isr\num: + subq $128, %rsp + pushq %rbx + movq 8(%rsp), %rbx + movq %rbx, __isr_err + popq %rbx + addq $8, %rsp + movq $\num, __isr_num + jmp irq_stub +.endm + +.macro isr_noerr num:req +.type __isr\num @function +isr\num: + movq $\num, __isr_num + jmp irq_stub +.endm + +isr_noerr 0 +isr_noerr 1 +isr_noerr 2 +isr_noerr 3 +isr_noerr 4 +isr_noerr 5 +isr_noerr 6 +isr_noerr 7 +isr_error 8 +isr_noerr 9 +isr_error 10 +isr_error 11 +isr_error 12 +isr_error 13 +isr_error 14 +isr_noerr 15 +isr_noerr 16 +isr_error 17 +isr_noerr 18 +isr_noerr 19 +isr_noerr 20 +isr_error 21 + +.section .data +.global __isr_stubs +.type __isr_stubs @object +__isr_stubs: + .quad isr0 + .quad isr1 + .quad isr2 + .quad isr3 + .quad isr4 + .quad isr5 + .quad isr6 + .quad isr7 + .quad isr8 + .quad isr9 + .quad isr10 + .quad isr11 + .quad isr12 + .quad isr13 + .quad isr14 + .quad isr15 + .quad isr16 + .quad isr17 + .quad isr18 + .quad isr19 + .quad isr20 + .quad isr21 -- cgit v1.2.1