all: add console and logging machinery

This commit is contained in:
Loïc Grégoire
2026-06-26 23:41:22 -04:00
parent b67391e1f2
commit 827f8b90d1
10 changed files with 344 additions and 10 deletions
+1
View File
@@ -13,6 +13,7 @@ pub fn init(boot_info: *pl.BootInfo) linksection(r.init) void {
ki.impl.early_init();
std.log.info("Welcome to the machine", .{});
pl.early_init(boot_info);
ki.log.init();
ki.cpu.init_cpu(0);
ki.turnstile.init_turnstiles();
ki.shootdown.init();
+19 -3
View File
@@ -39,6 +39,22 @@ const avg_msg_size_bits = 5;
pub var ringbuffer = ki.log_ring.RingBuffer(config.log_buffer_shift, avg_msg_size_bits).init();
// Initialize manually because we need this ASAP.
pub var event: ke.Event = .{
.hdr = .{
.lock = .init(),
.signaled = 0,
.type = .Notification,
.waitblocks = .{
.head = .{ .next = &event.hdr.waitblocks.head, .prev = &event.hdr.waitblocks.head },
},
},
};
pub fn init() void {
event.init(.Notification);
}
pub fn log(
comptime level: std.log.Level,
comptime scope: @EnumLiteral(),
@@ -63,9 +79,9 @@ pub fn log(
ringbuffer.publish(res);
// TODO: for now, we print to the platform's debug output immediately.
// In the future, we should instead set an event that would get triggered in Ex,
// which would consume the ringbuffer from multiple consoles in a separate thread.
// Signal whomever is waiting on logs to get published.
event.signal();
var writer = DebugWriter.init();
const ipl = out_lock.acquire_at(.High);
+2
View File
@@ -68,6 +68,8 @@ pub const wait = struct {
pub const log = struct {
pub const register_console = p.log.register_console;
pub const log = p.log.log;
pub const ringbuffer = &p.log.ringbuffer;
pub const event = &p.log.event;
};
pub const cpu = struct {