#include <exceptions.h> #include <interrupts.h> #include <stdio.h> #include <task.h> char *EXCEPTION_MESSAGES[] = {"DIVIDE BY ZERO", "DEBUG", "NON-MASKABLE INTERRUPT", "BREAKPOINT", "OVERFLOW", "BOUND RAGE EXCEEDED", "INVALID OPCODE", "DEVICE NOT AVAILABLE", "DOUBLE FAULT", "COPROCESSOR SEGMENT OVERRUN", "INVALID TSS", "SEGMENT NOT PRESENT", "STACK SEGMENT FAULT", "GENERAL PROTECTION FAULT", "PAGE FAULT", "RESERVED", "x87 FLOATING-POINT-EXCEPTION", "ALIGNMENT CHECK", "MACHINE CHECK", "SMID FLOATING-POINT-EXCEPTION", "VIRTUALIZATION EXCEPTION", "RESERVED", "RESERVED", "RESERVED", "RESERVED", "RESERVED", "RESERVED", "RESERVED", "RESERVED", "SECURITY EXCEPTION", "RESERVED"}; void setupExceptions() { setInterrupt(0, &isrHandler0); setInterrupt(1, &isrHandler1); setInterrupt(2, &isrHandler2); setInterrupt(3, &isrHandler3); setInterrupt(4, &isrHandler4); setInterrupt(5, &isrHandler5); setInterrupt(6, &isrHandler6); setInterrupt(7, &isrHandler7); setInterrupt(8, &isrHandler8); setInterrupt(9, &isrHandler9); setInterrupt(10, &isrHandler10); setInterrupt(11, &isrHandler11); setInterrupt(12, &isrHandler12); setInterrupt(13, &isrHandler13); setInterrupt(14, &isrHandler14); setInterrupt(15, &isrHandler15); setInterrupt(16, &isrHandler16); setInterrupt(17, &isrHandler17); setInterrupt(18, &isrHandler18); setInterrupt(19, &isrHandler19); setInterrupt(20, &isrHandler20); setInterrupt(21, &isrHandler21); setInterrupt(22, &isrHandler22); setInterrupt(23, &isrHandler23); setInterrupt(24, &isrHandler24); setInterrupt(25, &isrHandler25); setInterrupt(26, &isrHandler26); setInterrupt(27, &isrHandler27); setInterrupt(28, &isrHandler28); setInterrupt(29, &isrHandler29); setInterrupt(30, &isrHandler30); setInterrupt(31, &isrHandler31); } void handleException(regs *registers) { printf("exception %s was raised with error code 0x%x!\n", EXCEPTION_MESSAGES[registers->int_no], registers->err_code); yield(); }