/* Copyright (C) 2021 Rain */ /* This file is part of XNIX. */ /* XNIX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) and later version. */ /* XNIX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ /* You should have received a copy of the GNU General Public License along with XNIX. If not, see . */ #ifndef _INT_H #define _INT_H #include #include /* kernel/trap.S */ void divide_error(void); void debug(void); void nmi(void); void int3(void); void overflow(void); void bound(void); void invalid_code(void); void device_not_avaliable(void); void double_fault(void); void fpu_segment_overrun(void); void invalid_tss(void); void segment_not_present(void); void stack_error(void); void general_protection(void); void page_fault(void); void reserved(void); void fpu_error(void); void alignment(void); void machine(void); void simd(void); void virtualization(void); void register_irq(int, void *, void *); void unregister_irq(int); void do_irq(__uint64_t *, __uint64_t); void do_timer(void); void do_keyboard(void); #define IRQ_SAVE_ALL() \ "pushq %rax;\n\t" \ "pushq %rcx;\n\t" \ "pushq %rbx;\n\t" \ "pushq %rdx;\n\t" \ "pushq %rbp;\n\t" \ "pushq %rsi;\n\t" \ "pushq %rdi;\n\t" \ "pushq %r8; \n\t" \ "pushq %r9; \n\t" \ "pushq %r10;\n\t" \ "pushq %r11;\n\t" \ "pushq %r12;\n\t" \ "pushq %r13;\n\t" \ "pushq %r14;\n\t" \ "pushq %r15;\n\t" \ "movq %ds, %rax;\n\t" \ "pushq %rax; \n\t" \ "movq %es, %rax;\n\t" \ "pushq %rax; \n\t" \ "movq %fs, %rax;\n\t" \ "pushq %rax; \n\t" \ "movq %gs, %rax;\n\t" \ "pushq %rax;" \ "movq $0x10, %rax;\n\t" \ "movq %rax, %ds;\n\t" \ "movq %rax, %es;\n\t" \ "movq %rax, %fs;\n\t" \ "movq %rax, %gs;\n\t" #define IRQ_NAMEN(nr) nr##_interrupt(void) #define IRQ_NAME(nr) IRQ_NAMEN(irq##nr) #define build_irq(nr) \ void IRQ_NAME(nr); \ __asm__ ( \ ".globl irq"#nr"_interrupt\n\t;"\ "irq"#nr"_interrupt: \n\t" \ IRQ_SAVE_ALL() \ /* arguments for do_irq */ \ "movq %rsp, %rdi\n\t" \ "movq $"#nr", %rsi\n\t" \ "leaq ret_intr(%rip), %rax\n\t" \ "pushq %rax\n\t" \ "jmp do_irq\n\t" \ ); #define MAX_IRQ_NR 24 struct irq_entry { void (*handler) (void); }; extern struct irq_entry irq_table[MAX_IRQ_NR]; #endif