Skip to content

Commit

Permalink
just some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
TalonFloof authored Nov 18, 2024
1 parent 655e3e6 commit 73a32d6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
9 changes: 6 additions & 3 deletions kobold/hal/x86_64/timer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ pub fn init() void {
apic.write(0x320, 0x10000);
const count = 0xffffffff - apic.read(0x390);
ticksPerSecond = count;
std.log.info("{} APIC Ticks/s", .{count});
} else {
std.log.info("PIT @ 100 Hz for APIC Timer Calibration", .{});
var speakerControlByte = io.inb(0x61);
Expand All @@ -68,8 +67,8 @@ pub fn init() void {
apic.write(0x320, 0x10000);
const count = 0xffffffff - apic.read(0x390);
ticksPerSecond = count * 100;
std.log.info("{} APIC Ticks/s", .{count * 100});
}
std.log.info("{} APIC Ticks/s", .{ticksPerSecond});
}
apic.write(0x3e0, 0xb);
apic.write(0x320, 0x20);
Expand All @@ -78,7 +77,11 @@ pub fn init() void {

pub fn setDeadline(microsecs: u64) void {
const t: u64 = @intFromFloat(@as(f64, @floatFromInt(ticksPerSecond)) * (@as(f64, @floatFromInt(microsecs)) / 1000000.0));
apic.write(0x380, t);
if(t > 0xffffffff) {
apic.write(0x380,0xffffffff);
} else {
apic.write(0x380, t);
}
}

pub fn getRemainingUs() u64 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const std = @import("std");
const thread = @import("thread.zig");

pub const Semaphore = struct {
pub const EventQueue = struct {
semID: i64 = 0, // 0 id semaphores are special anonymous semaphores used in internal kernel structures like ports
teamID: i64,
name: [32]u8 = [_]u8{0} ** 32,
Expand Down
2 changes: 1 addition & 1 deletion kobold/kernel/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn panic(msg: []const u8, stacktrace: ?*std.builtin.StackTrace, retAddr: ?us

pub export fn KoboldInit() void {
_ = hal.AlignDown(u32, 0, 4096); // Prevents release builds from failing
std.log.info("Schedling Started", .{});
std.log.info("Scheduling Started", .{});
while (true) {
hal.arch.waitForInt();
}
Expand Down
2 changes: 1 addition & 1 deletion kobold/kernel/thread.zig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub const Thread = struct {
semaphoreNode: ThreadList.Node,
team: *team.Team,
name: [32]u8 = [_]u8{0} ** 32,
state: ThreadState = .Embryo,
state: ThreadState = .Runnable,
shouldKill: bool = false,
priority: usize = 16,
kstack: []u8,
Expand Down
3 changes: 2 additions & 1 deletion kobold/perLib/spinlock.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ pub const Spinlock = enum(u8) {
}
std.atomic.spinLoopHint();
}
@panic("Deadlock detected");
std.log.err("Deadlock @ 0x{x}", .{@intFromPtr(spinlock)});
@panic("Deadlock");
}

pub inline fn release(spinlock: *volatile Spinlock) void {
Expand Down

0 comments on commit 73a32d6

Please sign in to comment.