Microkernel thing OS experiment (Zig ⚡)
1pub const apic = @import("apic.zig"); 2pub const pic = @import("pic.zig"); 3pub const pit = @import("pit.zig"); 4pub const idt = @import("idt.zig"); 5const std = @import("std"); 6const arch = @import("../root.zig"); 7 8pub inline fn enable() void { 9 asm volatile ("sti"); 10} 11pub inline fn disable() void { 12 asm volatile ("cli"); 13} 14 15pub fn unhandled_interrupt(stack_frame: *idt.InterruptFrame(u64)) callconv(.{ .x86_64_sysv = .{} }) void { 16 std.log.err("Unhandled interrupt (0x{x})!!! rip = 0x{x}", .{ stack_frame.int_num.interrupt, stack_frame.rip }); 17 arch.instructions.die(); 18} 19 20pub fn breakpoint(stack_frame: *idt.InterruptFrame(u64)) callconv(.{ .x86_64_sysv = .{} }) void { 21 std.log.warn("Breakpoint @ 0x{x}, returning execution...", .{stack_frame.rip}); 22} 23 24pub fn double_fault(stack_frame: *idt.InterruptFrame(u64)) callconv(.{ .x86_64_sysv = .{} }) void { 25 std.log.err("Double fault @ 0x{x}, dying!!!", .{stack_frame.rip}); 26 arch.instructions.die(); 27} 28 29pub fn general_protection_fault(stack_frame: *idt.InterruptFrame(idt.SelectorErrorCode)) callconv(.{ .x86_64_sysv = .{} }) void { 30 std.log.warn("General Protection Fault @ 0x{x} (Error Code {}), returning execution...", .{ stack_frame.rip, stack_frame.error_code }); 31 arch.instructions.die(); 32}