Add the IDT table

This commit is contained in:
ktkk 2026-05-12 14:43:14 +00:00
parent 2e9292be6e
commit 7dfdbe10ec
2 changed files with 163 additions and 0 deletions

View file

@ -1,7 +1,11 @@
const lazy = @import("utils/Lazy.zig").lazy;
const Console = @import("Console.zig");
const MultibootInfo = @import("multiboot.zig").Info;
const InterruptDescriptorTable = @import("idt.zig").InterruptDescriptorTable;
const InterruptStackFrame = @import("idt.zig").InterruptStackFrame;
const MultibootHeader = packed struct {
magic: i32,
flags: i32,
@ -37,6 +41,8 @@ export fn _start() callconv(.naked) noreturn {
var console = lazy(Console, .init);
var idt: InterruptDescriptorTable = .empty;
fn kmain(magic: u32, info: *const MultibootInfo) callconv(.c) void {
std.debug.assert(magic == MAGIC);
@ -49,9 +55,24 @@ fn kmain(magic: u32, info: *const MultibootInfo) callconv(.c) void {
std.log.info("Booted with cmdline \"{s}\"", .{info.cmdline});
}
idt.setEntry(.breakpoint, breakpointHandler);
idt.load();
//asm volatile (
// \\ int3
// :
// :
//);
hang();
}
fn breakpointHandler(stack_frame: *InterruptStackFrame) callconv(.{ .x86_interrupt = .{} }) void {
_ = stack_frame;
std.log.err("breakpoint\n", .{});
}
fn hang() noreturn {
while (true) asm volatile ("hlt");
}