diff options
| author | hachem <im@hachem.wtf> | 2026-09-25 18:08:17 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-09-25 18:08:17 +0200 |
| commit | fd3f51eecaecc12806a573c38263df1de43ee8c2 (patch) | |
| tree | 4bd43519ce87af6b791c7f86d8a273829a56786d /boot/idt.zig | |
| parent | 6593ddc56fc96df0a566cc3b1a3e9396e4f3b2c6 (diff) | |
feat: pit timer
Diffstat (limited to 'boot/idt.zig')
| -rw-r--r-- | boot/idt.zig | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/boot/idt.zig b/boot/idt.zig index fda5b9d..19afa6b 100644 --- a/boot/idt.zig +++ b/boot/idt.zig @@ -8,6 +8,7 @@ const gdt = @import("gdt.zig"); const serial = @import("serial.zig"); const pic = @import("pic.zig"); const keyboard = @import("keyboard.zig"); +const timer = @import("timer.zig"); // 64bit interrupt gate const Gate = packed struct { @@ -219,6 +220,7 @@ export fn irqCommon() callconv(.naked) void { export fn irqDispatch(frame: *Frame) callconv(.c) void { switch (frame.vector) { + pic.MASTER_OFFSET + 0 => timer.onIrq(), // IRQ0: PIT pic.MASTER_OFFSET + 1 => keyboard.onIrq(), // IRQ1: keyboard else => {}, } @@ -242,8 +244,10 @@ pub fn setGate(vector: u8, handler: u64, dpl: u2) void { // fill the exception vectors and load the IDT pub fn init() void { inline for (0..32) |v| setGate(v, @intFromPtr(&stub(v)), 0); + // IRQ0 (PIT) -> vector 0x20 // IRQ1 (keyboard) -> vector 0x21 - // the PIC is remapped separately in boot. + // the PIC is remapped separately in boot + setGate(pic.MASTER_OFFSET + 0, @intFromPtr(&irqStub(pic.MASTER_OFFSET + 0)), 0); setGate(pic.MASTER_OFFSET + 1, @intFromPtr(&irqStub(pic.MASTER_OFFSET + 1)), 0); idtr = .{ .limit = @sizeOf(@TypeOf(idt)) - 1, .base = @intFromPtr(&idt) }; asm volatile ("lidt (%[idtr])" |
