...
This commit is contained in:
30
src/exceptions.c
Normal file
30
src/exceptions.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user