#include #include #include #include #include "../io.h" struct interrupt_frame { uint32_t eflags; uint32_t cs; uint32_t eip; }; uint8_t test = 'a'; static void stack_trace() { 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'); } } __attribute__((interrupt)) void divide_by_zero(struct interrupt_frame* frame) { terminal_writestring("Yo dude u cant divide by zero yao\n"); while (1) { } } __attribute__((interrupt)) void general_protection_fault(struct interrupt_frame* frame) { terminal_writestring("GPF handler called\n"); while (1) { } } __attribute__((interrupt)) void double_fault(struct interrupt_frame* frame) { terminal_writestring("2 Errors in a row, u better behave naughty naughty\n"); while (1) { } } __attribute__((interrupt)) void exception(struct interrupt_frame* frame) { terminal_writestring("Some weird error code stuff\n"); while (1) { } } __attribute__((interrupt)) void print(struct interrupt_frame* frame) { char* start; asm("mov %%edx, %0" : "=r" (start)); terminal_writestring(start); } __attribute__((interrupt)) void input(struct interrupt_frame* frame) { char* buffer; asm("mov %%edx, %0" : "=r" (buffer)); /* size_t index = 0; char current_character = get_last_key_pressed(); while (current_character != '\n') { char tmp = get_last_key_pressed(); if (current_character != -1 && tmp != current_character) { buffer[index] = current_character; terminal_putchar(current_character); index++; } current_character = tmp; } buffer[index] = '\0'; */ } __attribute__((interrupt)) void keyboard_interrupt(struct interrupt_frame* frame) { uint8_t scancode = inb(0x60); handle_keyboard(scancode); outb(0x20, 0x20); } __attribute__((interrupt)) void irq(struct interrupt_frame* frame) { outb(0x20, 0x20); }