core/x86_64: Add general protection fault handler
This commit is contained in:
parent
090e4148b8
commit
36b9832053
@ -74,6 +74,7 @@ export fn asmInterruptEntry() callconv(.Naked) void {
|
||||
}
|
||||
|
||||
const Exceptions = enum(u64) {
|
||||
GeneralProtectionFault = 0xd,
|
||||
PageFault = 0xe,
|
||||
};
|
||||
|
||||
@ -87,6 +88,17 @@ const PageFaultCodes = enum(u64) {
|
||||
|
||||
const SYSCALL_INTERRUPT = 66;
|
||||
|
||||
fn generalProtectionFault(frame: *InterruptStackFrame) void {
|
||||
debug.print("General protection fault!\n", .{});
|
||||
debug.print("Faulting instruction: {x}\n", .{frame.rip});
|
||||
|
||||
const code = frame.error_or_irq;
|
||||
|
||||
debug.print("Error code: {d}\n", .{code});
|
||||
|
||||
while (true) {}
|
||||
}
|
||||
|
||||
fn pageFault(frame: *InterruptStackFrame) void {
|
||||
var fault_address: u64 = undefined;
|
||||
asm volatile ("mov %%cr2, %[cr2]"
|
||||
@ -132,6 +144,9 @@ export fn interruptEntry(frame: *InterruptStackFrame) callconv(.C) void {
|
||||
@intFromEnum(Exceptions.PageFault) => {
|
||||
pageFault(frame);
|
||||
},
|
||||
@intFromEnum(Exceptions.GeneralProtectionFault) => {
|
||||
generalProtectionFault(frame);
|
||||
},
|
||||
SYSCALL_INTERRUPT => {
|
||||
var args = sys.Arguments{ .arg0 = frame.rdi, .arg1 = frame.rsi, .arg2 = frame.rdx, .arg3 = frame.r10, .arg4 = frame.r8, .arg5 = frame.r9 };
|
||||
sys.invokeSyscall(frame.rax, frame, &args, @ptrFromInt(@as(usize, @intFromPtr(&frame.rax))));
|
||||
|
Loading…
x
Reference in New Issue
Block a user