my exception handler sucked so i redid it

This commit is contained in:
2025-06-05 17:32:38 -04:00
parent 87e5e06142
commit 79f04df82e
4 changed files with 73 additions and 20 deletions

View File

@ -1,4 +1,5 @@
#include <stdbool.h>
#include <stdint.h>
#ifdef __TESTING__
#include <kernel/_kernel.h>
@ -18,17 +19,18 @@ static bool vectors[IDT_MAX_DESCRIPTORS];
extern struct keyboard_state keyb_state;
void exception_handler(unsigned int i)
void exception_handler(struct cpu_state __attribute__((unused)) cpu, uint32_t interrupt, struct stack_state stack)
{
if (i <= 31) { // TODO: implement proper handling for each exception, also implement the proper gates & error code checking
printf("%1 %2\n", interrupt, stack.eflags);
if (interrupt <= 31) { // TODO: implement proper handling for each exception, also implement the proper gates & error code checking
#ifdef __TESTING__
kerror("EXCEPTION");
printf("Exeption: %u\n", i);
printf("Exeption: %2\n", interrupt);
#endif
__asm__ volatile ("cli; hlt"); // hangs the computer
//__asm__ volatile ("cli; hlt"); // hangs the computer
}
if (i == PIC_KEYB) {
if (interrupt == PIC_KEYB) {
unsigned char in = inb(0x60);
do_keypress(decode_scancode(in));
PIC_sendEOI(1);