From 9322f1d23f0273c64ec15fbf0b226789358f573e Mon Sep 17 00:00:00 2001 From: TalonFloof <105325988+TalonFloof@users.noreply.github.com> Date: Mon, 18 Nov 2024 22:05:35 -0600 Subject: [PATCH] fdsfsd Signed-off-by: TalonFloof <105325988+TalonFloof@users.noreply.github.com> --- Makefile | 2 +- kobold/hal/x86_64/timer.zig | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 1617599..1fe17d6 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ iso: build_pc64 rm -r --force /tmp/kobold_iso run_pc64: iso - qemu-system-x86_64 -enable-kvm -cpu host,migratable=off -m 8M -serial stdio -device pcie-pci-bridge -cdrom kobold.iso -smp 2 -no-shutdown -no-reboot + qemu-system-x86_64 -enable-kvm -cpu host,migratable=off -m 8M -serial stdio -device pcie-pci-bridge -cdrom kobold.iso -smp 2 -no-hpet -no-shutdown -no-reboot run_rv64: build_rv64 qemu-system-riscv64 -machine virt -m 128M -serial stdio -device ramfb -device virtio-keyboard-device -device virtio-mouse-device -kernel kobold/zig-out/bin/kernel diff --git a/kobold/hal/x86_64/timer.zig b/kobold/hal/x86_64/timer.zig index 9ae957b..096e58a 100644 --- a/kobold/hal/x86_64/timer.zig +++ b/kobold/hal/x86_64/timer.zig @@ -48,12 +48,12 @@ pub fn init() void { const count = 0xffffffff - apic.read(0x390); ticksPerSecond = count; } else { - std.log.info("PIT @ 100 Hz for APIC Timer Calibration", .{}); + std.log.info("PIT @ 64 Hz for APIC Timer Calibration", .{}); var speakerControlByte = io.inb(0x61); speakerControlByte &= ~@as(u8, 2); io.outb(0x61, speakerControlByte); io.outb(0x43, 0x80 | 0x00 | 0x30); - const sleepDivisor = 1193180 / (1000000 / 10000); // 10 ms + const sleepDivisor = 0x48d3; // 64 Hz io.outb(0x42, sleepDivisor & 0xFF); io.outb(0x42, sleepDivisor >> 8); const pitControlByte = io.inb(0x61); @@ -66,7 +66,7 @@ pub fn init() void { } apic.write(0x320, 0x10000); const count = 0xffffffff - apic.read(0x390); - ticksPerSecond = count * 100; + ticksPerSecond = count * 64; } std.log.info("{} APIC Ticks/s", .{ticksPerSecond}); } @@ -77,8 +77,8 @@ pub fn init() void { pub fn setDeadline(microsecs: u64) void { const t: u64 = @intFromFloat(@as(f64, @floatFromInt(ticksPerSecond)) * (@as(f64, @floatFromInt(microsecs)) / 1000000.0)); - if(t > 0xffffffff) { - apic.write(0x380,0xffffffff); + if (t > 0xffffffff) { + apic.write(0x380, 0xffffffff); } else { apic.write(0x380, t); }