hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/boot/boot.zig
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-09-25 18:08:17 +0200
committerhachem <im@hachem.wtf>2026-09-25 18:08:17 +0200
commitfd3f51eecaecc12806a573c38263df1de43ee8c2 (patch)
tree4bd43519ce87af6b791c7f86d8a273829a56786d /boot/boot.zig
parent6593ddc56fc96df0a566cc3b1a3e9396e4f3b2c6 (diff)
feat: pit timer
Diffstat (limited to 'boot/boot.zig')
-rw-r--r--boot/boot.zig6
1 files changed, 6 insertions, 0 deletions
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");
}