From fd3f51eecaecc12806a573c38263df1de43ee8c2 Mon Sep 17 00:00:00 2001 From: hachem Date: Fri, 25 Sep 2026 18:08:17 +0200 Subject: feat: pit timer --- boot/boot.zig | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'boot/boot.zig') diff --git a/boot/boot.zig b/boot/boot.zig index 108afc8..8f8c7fe 100644 --- a/boot/boot.zig +++ b/boot/boot.zig @@ -10,6 +10,7 @@ const vmm = @import("vmm.zig"); const user = @import("user.zig"); const elf = @import("elf.zig"); const keyboard = @import("keyboard.zig"); +const timer = @import("timer.zig"); const bridge = @import("bridge"); // We need a panic handler otherwise zig won't be happy, @@ -166,11 +167,16 @@ export fn _start() callconv(.c) noreturn { // the cli/pop/sti-hlt bullshit closes the lost-wakeup race (a key // arriving between "queue empty" and hlt would otherwise sit until // the next keypress) + var last_ticks: u64 = 0; while (true) { asm volatile ("cli"); if (keyboard.pop()) |sc| { asm volatile ("sti"); bridge.onKey(sc); + } else if (timer.now() != last_ticks) { + last_ticks = timer.now(); + asm volatile ("sti"); + bridge.onTick(last_ticks); } else { asm volatile ("sti; hlt"); } -- cgit v1.3