2024-07-11 08:56:52 +02:00
|
|
|
#include <kernel/tty.h>
|
2024-08-22 13:41:51 +02:00
|
|
|
#include <kernel/task.h>
|
|
|
|
#include "interrupt.h"
|
2024-07-16 22:51:41 +02:00
|
|
|
#include <stddef.h>
|
2024-08-05 00:59:07 +02:00
|
|
|
#include <debugging.h>
|
2024-08-11 13:40:21 +02:00
|
|
|
#include <kernel/io/keyboard.h>
|
2024-08-09 23:16:20 +02:00
|
|
|
#include "../io.h"
|
2024-07-11 08:56:52 +02:00
|
|
|
|
2024-08-05 00:59:07 +02:00
|
|
|
uint8_t test = 'a';
|
2024-07-16 22:51:41 +02:00
|
|
|
|
2024-08-05 00:59:07 +02:00
|
|
|
static void stack_trace()
|
2024-07-16 22:51:41 +02:00
|
|
|
{
|
2024-08-05 00:59:07 +02:00
|
|
|
uint32_t* stack = 0;
|
|
|
|
asm("mov %%esp, %0" : "=r" (stack));
|
|
|
|
for (int i = 0; i < 25; i++) {
|
|
|
|
uint32_t* current_address = stack + (i * 4);
|
|
|
|
print_hex_bytes(¤t_address, 4);
|
|
|
|
terminal_writestring(": ");
|
|
|
|
print_hex_bytes(current_address, 4);
|
|
|
|
terminal_putchar('\n');
|
2024-07-16 22:51:41 +02:00
|
|
|
}
|
2024-08-05 00:59:07 +02:00
|
|
|
}
|
2024-07-16 22:51:41 +02:00
|
|
|
|
2024-08-22 13:41:51 +02:00
|
|
|
__attribute__((interrupt)) void divide_by_zero(struct interrupt_frame*)
|
2024-08-05 00:59:07 +02:00
|
|
|
{
|
|
|
|
terminal_writestring("Yo dude u cant divide by zero yao\n");
|
|
|
|
while (1) { }
|
2024-07-16 22:51:41 +02:00
|
|
|
}
|
|
|
|
|
2024-08-22 13:41:51 +02:00
|
|
|
__attribute__((interrupt)) void general_protection_fault(struct interrupt_frame*)
|
2024-07-16 22:51:41 +02:00
|
|
|
{
|
2024-08-08 21:34:30 +02:00
|
|
|
terminal_writestring("GPF handler called\n");
|
2024-08-05 00:59:07 +02:00
|
|
|
while (1) { }
|
|
|
|
}
|
2024-07-16 22:51:41 +02:00
|
|
|
|
2024-08-22 13:41:51 +02:00
|
|
|
__attribute__((interrupt)) void double_fault(struct interrupt_frame*)
|
2024-08-05 00:59:07 +02:00
|
|
|
{
|
2024-08-10 01:14:29 +02:00
|
|
|
stack_trace();
|
2024-08-08 21:34:30 +02:00
|
|
|
terminal_writestring("2 Errors in a row, u better behave naughty naughty\n");
|
|
|
|
while (1) { }
|
2024-08-05 00:59:07 +02:00
|
|
|
}
|
2024-07-16 22:51:41 +02:00
|
|
|
|
2024-08-22 13:41:51 +02:00
|
|
|
__attribute__((interrupt)) void exception(struct interrupt_frame*)
|
2024-08-05 00:59:07 +02:00
|
|
|
{
|
|
|
|
terminal_writestring("Some weird error code stuff\n");
|
|
|
|
while (1) { }
|
|
|
|
}
|
2024-07-16 22:51:41 +02:00
|
|
|
|
2024-08-22 13:41:51 +02:00
|
|
|
__attribute__((interrupt)) void keyboard_interrupt(struct interrupt_frame*)
|
2024-08-09 23:16:20 +02:00
|
|
|
{
|
|
|
|
uint8_t scancode = inb(0x60);
|
|
|
|
handle_keyboard(scancode);
|
|
|
|
outb(0x20, 0x20);
|
2024-07-11 08:56:52 +02:00
|
|
|
}
|
|
|
|
|
2024-08-22 13:41:51 +02:00
|
|
|
__attribute__((interrupt)) void irq_1(struct interrupt_frame*)
|
2024-07-11 08:56:52 +02:00
|
|
|
{
|
2024-08-08 21:34:30 +02:00
|
|
|
outb(0x20, 0x20);
|
2024-07-11 08:56:52 +02:00
|
|
|
}
|
2024-08-05 00:59:07 +02:00
|
|
|
|
2024-08-22 13:41:51 +02:00
|
|
|
__attribute__((interrupt)) void irq_2(struct interrupt_frame*)
|
|
|
|
{
|
|
|
|
outb(0xA0, 0x20);
|
|
|
|
outb(0x20, 0x20);
|
|
|
|
}
|