31d2e10b69
Basically, added error handling, interrupts and basic hardware communication is now possible. Yay.
119 lines
2.4 KiB
C
Executable File
119 lines
2.4 KiB
C
Executable File
#pragma once
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
void gdt_set_gate(int, unsigned long, unsigned long, unsigned char, unsigned char);
|
|
void gdt_install();
|
|
|
|
void idt_set_gate(unsigned char, unsigned long, unsigned short, unsigned char);
|
|
void idt_install();
|
|
|
|
typedef struct registers {
|
|
uint32_t ds;
|
|
uint32_t edi, esi, ebp, esp, ebx, edx, ecx, eax;
|
|
uint32_t int_no, err_code;
|
|
uint32_t eip, cs, eflags, useresp, ss;
|
|
} registers_t;
|
|
|
|
//These are all reserved by Intel, and need to be here.
|
|
extern void isr0();
|
|
extern void isr1();
|
|
extern void isr2();
|
|
extern void isr3();
|
|
extern void isr4();
|
|
extern void isr5();
|
|
extern void isr6();
|
|
extern void isr7();
|
|
extern void isr8();
|
|
extern void isr9();
|
|
extern void isr10();
|
|
extern void isr11();
|
|
extern void isr12();
|
|
extern void isr13();
|
|
extern void isr14();
|
|
extern void isr15();
|
|
extern void isr16();
|
|
extern void isr17();
|
|
extern void isr18();
|
|
extern void isr19();
|
|
extern void isr20();
|
|
extern void isr21();
|
|
extern void isr22();
|
|
extern void isr23();
|
|
extern void isr24();
|
|
extern void isr25();
|
|
extern void isr26();
|
|
extern void isr27();
|
|
extern void isr28();
|
|
extern void isr29();
|
|
extern void isr30();
|
|
extern void isr31();
|
|
|
|
extern void irq0();
|
|
extern void irq1();
|
|
extern void irq2();
|
|
extern void irq3();
|
|
extern void irq4();
|
|
extern void irq5();
|
|
extern void irq6();
|
|
extern void irq7();
|
|
extern void irq8();
|
|
extern void irq9();
|
|
extern void irq10();
|
|
extern void irq11();
|
|
extern void irq12();
|
|
extern void irq13();
|
|
extern void irq14();
|
|
extern void irq15();
|
|
|
|
static void* irq_routines[16] = {
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0, 0
|
|
};
|
|
|
|
void irq_install_handler(int irq, void (*handler)(registers_t* r));
|
|
|
|
void irq_uninstall_handler(int);
|
|
|
|
void irq_install();
|
|
|
|
void irq_handler(registers_t*);
|
|
|
|
void timer_install();
|
|
|
|
static const char* exception_messages[] = {
|
|
"Division by Zero",
|
|
"Debug",
|
|
"Non Maskable Interrupt",
|
|
"Breakpoint",
|
|
"Into Detected Overflow",
|
|
"Out of Bounds",
|
|
"Invalid Opcode",
|
|
"No Coprocessor",
|
|
"Double Fault",
|
|
"Coprocessor Segment Overrun",
|
|
"Bad TSS",
|
|
"Segment Not Present",
|
|
"Stack Fault",
|
|
"General Protection Fault",
|
|
"Page Fault",
|
|
"Unknown Interrupt",
|
|
"Coprocessor Fault",
|
|
"Alignment Check",
|
|
"Machine Check",
|
|
"Reserved",
|
|
"Reserved",
|
|
"Reserved",
|
|
"Reserved",
|
|
"Reserved",
|
|
"Reserved",
|
|
"Reserved",
|
|
"Reserved",
|
|
"Reserved",
|
|
"Reserved",
|
|
"Reserved",
|
|
"Reserved",
|
|
"Reserved"
|
|
}; |