Syncboot/kernel/interrupts.c

212 lines
5.8 KiB
C
Raw Normal View History

/************************
*** Team Kitty, 2019 ***
*** Sync ***
***********************/
/* This file contains all of the ISR and IRQ
* (Interrupt Service Request) functions.
*
* As they use the GCC interrupt attribute,
* this file must be compiled without red-
* zone protection, thus all of these
* functions are in their own file to
* accomodate this.
*
* Calling a function like so:
*
* __attribute__((interrupt)) isr1(registers_t* frame) {}
*
* allows the function to be used to serve
* interrupts - GCC compiles it under unique
* conditions, as it preserves the state of
* the processor and stack between execution,
* as well as using the IRET instruction to
* return to the middle of the previous function.
*
* There is also a version of the interrupt
* attribute which allows for error handlers,
* these having a size_t input as an error code.
*/
#include <stddef.h>
#include <stdint.h>
#include "kernel/descriptor_tables.h"
#ifdef __x86_64__
typedef unsigned long long int uword_t;
#else
typedef unsigned int uword_t;
#endif
/* The interrupt numbers, their meanings, and
* special information is laid out below:
*
* 0 - Divide by Zero
* 1 - Debug
* 2 - Non-Maskable
* 3 - Breakpoint
* 4 - Into Detected Overflow
* 5 - Out of Bounds
* 6 - Invalid Opcode
* 7 - No Coprocessor
* 8 - Double Fault * (With Error)
* 9 - Coprocessor Segment Overrun
* 10 - Bad TSS * (With Error)
* 11 - Segment Not Present * (With Error)
* 12 - Stack Fault * (With Error)
* 13 - General Protection Fault * (With Error)
* 14 - Page Fault * (With Error)
* 15 - Unknown Interrupt
* 16 - Coprocessor Fault
* 17 - Alignment Check
* 18 - Machine Check
* 19 to 31 - Reserved
*/
__attribute__((interrupt)) void isr0(struct int_frame* r) {
isr_common(r, 0);
}
__attribute__((interrupt)) void isr1(struct int_frame* r) {
isr_common(r, 1);
}
__attribute__((interrupt)) void isr2(struct int_frame* r) {
isr_common(r, 2);
}
__attribute__((interrupt)) void isr3(struct int_frame* r) {
isr_common(r, 3);
}
__attribute__((interrupt)) void isr4(struct int_frame* r) {
isr_common(r, 4);
}
__attribute__((interrupt)) void isr5(struct int_frame* r) {
isr_common(r, 5);
}
__attribute__((interrupt)) void isr6(struct int_frame* r) {
isr_common(r, 6);
}
__attribute__((interrupt)) void isr7(struct int_frame* r) {
isr_common(r, 7);
}
__attribute__((interrupt)) void isr8(struct int_frame* r, size_t error) {
isr_error_common(r, 8, error);
}
__attribute__((interrupt)) void isr9(struct int_frame* r) {
isr_common(r, 9);
}
__attribute__((interrupt)) void isr10(struct int_frame* r, size_t error) {
isr_error_common(r, 10, error);
}
__attribute__((interrupt)) void isr11(struct int_frame* r, size_t error) {
isr_error_common(r, 11, error);
}
__attribute__((interrupt)) void isr12(struct int_frame* r, size_t error) {
isr_error_common(r, 12, error);
}
__attribute__((interrupt)) void isr13(struct int_frame* r, size_t error) {
isr_error_common(r, 13, error);
}
__attribute__((interrupt)) void isr14(struct int_frame* r, size_t error) {
isr_error_common(r, 14, error);
}
__attribute__((interrupt)) void isr15(struct int_frame* r) {
isr_common(r, 15);
}
__attribute__((interrupt)) void isr16(struct int_frame* r) {
isr_common(r, 16);
}
__attribute__((interrupt)) void isr17(struct int_frame* r) {
isr_common(r, 17);
}
__attribute__((interrupt)) void isr18(struct int_frame* r) {
isr_common(r, 18);
}
__attribute__((interrupt)) void isr19(struct int_frame* r) {
isr_common(r, 19);
}
__attribute__((interrupt)) void isr20(struct int_frame* r) {
isr_common(r, 20);
}
__attribute__((interrupt)) void isr21(struct int_frame* r) {
isr_common(r, 21);
}
__attribute__((interrupt)) void isr22(struct int_frame* r) {
isr_common(r, 22);
}
__attribute__((interrupt)) void isr23(struct int_frame* r) {
isr_common(r, 23);
}
__attribute__((interrupt)) void isr24(struct int_frame* r) {
isr_common(r, 24);
}
__attribute__((interrupt)) void isr25(struct int_frame* r) {
isr_common(r, 25);
}
__attribute__((interrupt)) void isr26(struct int_frame* r) {
isr_common(r, 26);
}
__attribute__((interrupt)) void isr27(struct int_frame* r) {
isr_common(r, 27);
}
__attribute__((interrupt)) void isr28(struct int_frame* r) {
isr_common(r, 28);
}
__attribute__((interrupt)) void isr29(struct int_frame* r) {
isr_common(r, 29);
}
__attribute__((interrupt)) void isr30(struct int_frame* r) {
isr_common(r, 30);
}
__attribute__((interrupt)) void isr31(struct int_frame* r) {
isr_common(r, 31);
}
__attribute__((interrupt)) void irq0(struct int_frame* r) {
irq_common(r, 0);
}
__attribute__((interrupt)) void irq1(struct int_frame* r) {
irq_common(r, 1);
}
__attribute__((interrupt)) void irq2(struct int_frame* r) {
irq_common(r, 2);
}
__attribute__((interrupt)) void irq3(struct int_frame* r) {
irq_common(r, 3);
}
__attribute__((interrupt)) void irq4(struct int_frame* r) {
irq_common(r, 4);
}
__attribute__((interrupt)) void irq5(struct int_frame* r) {
irq_common(r, 5);
}
__attribute__((interrupt)) void irq6(struct int_frame* r) {
irq_common(r, 6);
}
__attribute__((interrupt)) void irq7(struct int_frame* r) {
irq_common(r, 7);
}
__attribute__((interrupt)) void irq8(struct int_frame* r) {
irq_common(r, 8);
}
__attribute__((interrupt)) void irq9(struct int_frame* r) {
irq_common(r, 9);
}
__attribute__((interrupt)) void irq10(struct int_frame* r) {
irq_common(r, 10);
}
__attribute__((interrupt)) void irq11(struct int_frame* r) {
irq_common(r, 11);
}
__attribute__((interrupt)) void irq12(struct int_frame* r) {
irq_common(r, 12);
}
__attribute__((interrupt)) void irq13(struct int_frame* r) {
irq_common(r, 13);
}
__attribute__((interrupt)) void irq14(struct int_frame* r) {
irq_common(r, 14);
}
__attribute__((interrupt)) void irq15(struct int_frame* r) {
irq_common(r, 15);
}