31 lines
581 B
C
31 lines
581 B
C
#include "print.h"
|
|
#include <stdint.h>
|
|
|
|
void exception_handler(uint64_t* stack)
|
|
{
|
|
uint64_t interrupt_num = stack[0];
|
|
uint64_t error_code = stack[1];
|
|
|
|
print("EXCEPTION: ");
|
|
if (interrupt_num == 0)
|
|
{
|
|
print("Division by zero");
|
|
}
|
|
else if (interrupt_num == 13)
|
|
{
|
|
print("General protection fault");
|
|
}
|
|
else
|
|
{
|
|
print("Unknown exception");
|
|
}
|
|
print("\nError code: ");
|
|
// You'd need to implement number printing here
|
|
print("\nSystem halted.\n");
|
|
|
|
while (1)
|
|
{
|
|
__asm__ volatile("hlt");
|
|
}
|
|
}
|