268 lines
7.3 KiB
Zig
268 lines
7.3 KiB
Zig
const root = @import("root");
|
|
|
|
const Interrupt = root.arch.interrupt.Interrupt;
|
|
const StackFrame = root.arch.interrupt.InterruptStackFrame;
|
|
|
|
const print = root.debug.print;
|
|
const abort = root.debug.abort;
|
|
|
|
pub const DivisionError = Interrupt(struct {
|
|
pub const Vector = 0x00;
|
|
pub const HasErrorCode = false;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: division error\n", .{});
|
|
print("Stack frame: {}\n", .{stack});
|
|
abort();
|
|
}
|
|
});
|
|
|
|
pub const Debug = Interrupt(struct {
|
|
pub const Vector = 0x01;
|
|
pub const HasErrorCode = false;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: debug\n", .{});
|
|
print("Stack frame: {}\n", .{stack});
|
|
}
|
|
});
|
|
|
|
pub const NonMaskable = Interrupt(struct {
|
|
pub const Vector = 0x02;
|
|
pub const HasErrorCode = false;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: non-maskable\n", .{});
|
|
print("Stack frame: {}", .{stack});
|
|
abort();
|
|
}
|
|
});
|
|
|
|
pub const Breakpoint = Interrupt(struct {
|
|
pub const Vector = 0x03;
|
|
pub const HasErrorCode = false;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: breakpoint\n", .{});
|
|
print("Stack frame: {}\n", .{stack});
|
|
}
|
|
});
|
|
|
|
pub const Overflow = Interrupt(struct {
|
|
pub const Vector = 0x04;
|
|
pub const HasErrorCode = false;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: overflow\n", .{});
|
|
print("Stack frame: {}\n", .{stack});
|
|
abort();
|
|
}
|
|
});
|
|
|
|
pub const BoundRangeExceeded = Interrupt(struct {
|
|
pub const Vector = 0x05;
|
|
pub const HasErrorCode = false;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: bound range exceeded\n", .{});
|
|
print("Stack frame: {}\n", .{stack});
|
|
abort();
|
|
}
|
|
});
|
|
|
|
pub const InvalidOpcode = Interrupt(struct {
|
|
pub const Vector = 0x06;
|
|
pub const HasErrorCode = false;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: invalid opcode\n", .{});
|
|
print("Stack frame: {}\n", .{stack});
|
|
abort();
|
|
}
|
|
});
|
|
|
|
pub const DeviceNotAvailable = Interrupt(struct {
|
|
pub const Vector = 0x07;
|
|
pub const HasErrorCode = false;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: device not availble\n", .{});
|
|
print("Stack frame: {}\n", .{stack});
|
|
abort();
|
|
}
|
|
});
|
|
|
|
pub const DoubleFault = Interrupt(struct {
|
|
pub const Vector = 0x08;
|
|
pub const HasErrorCode = true;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: double fault\n", .{});
|
|
print("Stack frame: {}\n", .{stack});
|
|
abort();
|
|
}
|
|
});
|
|
|
|
pub const InvalidTss = Interrupt(struct {
|
|
pub const Vector = 0x0A;
|
|
pub const HasErrorCode = true;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: invalid TSS\n", .{});
|
|
print("Error code: {}\n", .{stack.error_code});
|
|
print("Stack frame: {}\n", .{stack});
|
|
abort();
|
|
}
|
|
});
|
|
|
|
pub const SegmentNotPresent = Interrupt(struct {
|
|
pub const Vector = 0x0B;
|
|
pub const HasErrorCode = true;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: segment not present\n", .{});
|
|
print("Error code: {}\n", .{stack.error_code});
|
|
print("Stack frame: {}\n", .{stack});
|
|
abort();
|
|
}
|
|
});
|
|
|
|
pub const StackSegmentFault = Interrupt(struct {
|
|
pub const Vector = 0x0C;
|
|
pub const HasErrorCode = true;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: stack segment fault\n", .{});
|
|
print("Error code: {}\n", .{stack.error_code});
|
|
print("Stack frame: {}\n", .{stack});
|
|
abort();
|
|
}
|
|
});
|
|
|
|
pub const GeneralProtectionFault = Interrupt(struct {
|
|
pub const Vector = 0x0D;
|
|
pub const HasErrorCode = true;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: general protection fault\n", .{});
|
|
print("Error code: {}\n", .{stack.error_code});
|
|
print("Stack frame: {}\n", .{stack});
|
|
abort();
|
|
}
|
|
});
|
|
|
|
pub const PageFault = Interrupt(struct {
|
|
pub const Vector = 0x0E;
|
|
pub const HasErrorCode = true;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: page fault\n", .{});
|
|
print("Error code: 0x{x}\n", .{stack.error_code});
|
|
print("Address: 0x{x}\n", .{root.arch.cr2()});
|
|
print("Stack frame: {}\n", .{stack});
|
|
abort();
|
|
}
|
|
});
|
|
|
|
pub const x87FloatingPoint = Interrupt(struct {
|
|
pub const Vector = 0x10;
|
|
pub const HasErrorCode = false;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: x86 floating point\n", .{});
|
|
print("Stack frame: {}\n", .{stack});
|
|
abort();
|
|
}
|
|
});
|
|
|
|
pub const AlignmentCheck = Interrupt(struct {
|
|
pub const Vector = 0x11;
|
|
pub const HasErrorCode = true;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: alignment check\n", .{});
|
|
print("Error code: {}\n", .{stack.error_code});
|
|
print("Stack frame: {}\n", .{stack});
|
|
abort();
|
|
}
|
|
});
|
|
|
|
pub const MachineCheck = Interrupt(struct {
|
|
pub const Vector = 0x12;
|
|
pub const HasErrorCode = false;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: machine check\n", .{});
|
|
print("Stack frame: {}\n", .{stack});
|
|
abort();
|
|
}
|
|
});
|
|
|
|
pub const SimdFloatingPoint = Interrupt(struct {
|
|
pub const Vector = 0x13;
|
|
pub const HasErrorCode = false;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: SIMD floating point\n", .{});
|
|
print("Stack frame: {}\n", .{stack});
|
|
abort();
|
|
}
|
|
});
|
|
|
|
pub const Virtualization = Interrupt(struct {
|
|
pub const Vector = 0x14;
|
|
pub const HasErrorCode = false;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: virtualization\n", .{});
|
|
print("Stack frame: {}\n", .{stack});
|
|
abort();
|
|
}
|
|
});
|
|
|
|
pub const ControlProtection = Interrupt(struct {
|
|
pub const Vector = 0x15;
|
|
pub const HasErrorCode = true;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: control protection\n", .{});
|
|
print("Stack frame: {}\n", .{stack});
|
|
abort();
|
|
}
|
|
});
|
|
|
|
pub const HypervisorInjection = Interrupt(struct {
|
|
pub const Vector = 0x1C;
|
|
pub const HasErrorCode = false;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: hypervisor injection\n", .{});
|
|
print("Stack frame: {}\n", .{stack});
|
|
abort();
|
|
}
|
|
});
|
|
|
|
pub const VmmCommunication = Interrupt(struct {
|
|
pub const Vector = 0x1D;
|
|
pub const HasErrorCode = true;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: VMM communication\n", .{});
|
|
print("Error code: {}\n", .{stack.error_code});
|
|
print("Stack frame: {}\n", .{stack});
|
|
abort();
|
|
}
|
|
});
|
|
|
|
pub const Security = Interrupt(struct {
|
|
pub const Vector = 0x1E;
|
|
pub const HasErrorCode = true;
|
|
|
|
pub fn handler(stack: *StackFrame) callconv(.C) void {
|
|
print("Exception: security\n", .{});
|
|
print("Error code: {}\n", .{stack.error_code});
|
|
print("Stack frame: {}\n", .{stack});
|
|
abort();
|
|
}
|
|
});
|