commit 8ce0b5c7b5c1a2b4135dc8e816512657f797fa1f
parent ed757ead9e1b9eaa01d3bd720a8ba6e075cddc3d
Author: Sylvia Ivory <git@sivory.net>
Date: Mon, 16 Mar 2026 00:07:49 -0700
Cleanup logs
Diffstat:
3 files changed, 13 insertions(+), 43 deletions(-)
diff --git a/pi/pt.zig b/pi/pt.zig
@@ -29,15 +29,11 @@ pub fn init(alloc: std.mem.Allocator, count: u16) Error![]mmu.FirstLevelDescript
}
pub fn dupe(alloc: std.mem.Allocator, pt: []mmu.FirstLevelDescriptor) Error![]mmu.FirstLevelDescriptor {
- @import("devices/mini-uart.zig").print("requesting {Bi}\n", .{pt.len * @sizeOf(mmu.FirstLevelDescriptor)});
-
const page_table = try alloc.alignedAlloc(
mmu.FirstLevelDescriptor,
std.mem.Alignment.fromByteUnits(1 << 5),
pt.len,
);
- @import("devices/mini-uart.zig").print("got pt @ 0x{X:0>8}\n", .{@intFromPtr(page_table.ptr)});
-
@memcpy(page_table, pt);
mmu.sync_pte();
diff --git a/sylveos/journal.zig b/sylveos/journal.zig
@@ -27,6 +27,7 @@ pub fn write_slice(level: LogLevel, slice: []const u8) void {
uart.write_slice(&slice_len);
uart.write_slice(slice);
+ uart.flush();
}
pub fn start_entry(level: LogLevel) void {
@@ -36,18 +37,21 @@ pub fn start_entry(level: LogLevel) void {
pub fn end_entry() void {
uart.write_byte(JOURNAL_END_SENTINEL);
+ uart.flush();
}
pub fn print(level: LogLevel, comptime fmt: []const u8, args: anytype) void {
start_entry(level);
uart.print(fmt, args);
end_entry();
+ uart.flush();
}
pub fn append(comptime fmt: []const u8, args: anytype) void {
uart.write_byte(JOURNAL_APPEND_LAST_START);
uart.print(fmt, args);
uart.write_byte(JOURNAL_APPEND_LAST_END);
+ uart.flush();
}
pub fn critical(comptime fmt: []const u8, args: anytype) void {
diff --git a/sylveos/root.zig b/sylveos/root.zig
@@ -41,8 +41,7 @@ fn panic_handler(msg: []const u8, trace_addr: ?usize) noreturn {
@branchHint(.cold);
if (uart.is_initialized()) {
- uart.print("kernel panic: {s} @ 0x{X}\n", .{ msg, trace_addr orelse 0 });
- uart.flush();
+ journal.critical("kernel panic: {s} @ 0x{X}\n", .{ msg, trace_addr orelse 0 });
}
abort();
@@ -56,13 +55,10 @@ fn abort_handler(regs: interrupts.Registers, ev: interrupts.ExceptionVector) voi
const ifsr = pi.faults.IFSR.get();
const dfsr = pi.faults.DFSR.get();
- // pi.debug.set_breakpoint(0, regs.pc, .IMVAMismatch);
-
if (ev == .PrefetchAbort and ifsr.status == .InstructionDebugEventFault) {
- uart.print("[breakpoint] PC=0x{X:0>8}\n", .{regs.pc});
+ journal.warn("[breakpoint] PC = 0x{X:0>8}\n", .{regs.pc});
} else if (ev == .PrefetchAbort) {
- uart.print("[{s}] [{s}] got fault on 0x{X:0>8} from 0x{X:0>8}\n", .{
- @tagName(ev),
+ journal.err("[prefetch abort] {s}: got fault on 0x{X:0>8} from 0x{X:0>8}\n", .{
@tagName(ifsr.status),
far,
regs.pc,
@@ -72,8 +68,7 @@ fn abort_handler(regs: interrupts.Registers, ev: interrupts.ExceptionVector) voi
} else if (ev == .DataAbort) {
const status = if (dfsr.status_kind == 0) @tagName(dfsr.status.@"0") else @tagName(dfsr.status.@"1");
- uart.print("[{s}] [{s}] got fault on 0x{X:0>8} from 0x{X:0>8} (source: {s})\n", .{
- @tagName(ev),
+ journal.err("[data abort] {s}: got fault on 0x{X:0>8} from 0x{X:0>8} (source: {s})\n", .{
status,
far,
regs.pc,
@@ -82,31 +77,11 @@ fn abort_handler(regs: interrupts.Registers, ev: interrupts.ExceptionVector) voi
interrupts.dump_registers(®s);
pi.reboot();
}
-
- if (regs.pc == 0x0006E674) {
- uart.print("0x86034: {X}\n", .{pi.mem.get_u32(@ptrFromInt(0x86034))});
- interrupts.dump_registers(®s);
- }
}
fn undef(regs: interrupts.Registers, _: interrupts.ExceptionVector) void {
- if (regs.pc == 0x629c8) {
- uart.print("\n=== DEBUGGING UDF ===\n", .{});
- uart.print("lr = 0x{X}\n", .{regs.lr});
-
- const mem_88028: *const u32 = @ptrFromInt(0x88028);
- uart.print("Memory at [0x88028] = 0x{X:0>8}\n", .{mem_88028.*});
-
- const mem_88010: *const [8]u32 = @ptrFromInt(0x88010);
- uart.print("Memory at [0x88010]:\n", .{});
- for (mem_88010.*, 0..) |val, i| {
- uart.print(" [+0x{X}] = 0x{X:0>8}\n", .{ i * 4, val });
- }
-
- // Check if 0x88028 is executable
- const translated = memory.translate(0x88028) catch 0;
- uart.print("0x88028 translates to PA: 0x{X}\n", .{translated});
- }
+ journal.err("[undef] invalid instruction @ 0x{X}\n", .{regs.pc});
+ pi.reboot();
}
// Kinda just a repeat of boot...
@@ -140,7 +115,7 @@ export fn kmain(memory_size: u32) void {
// Cheaper context switches
main() catch |e| {
- uart.print("main returned error: {t}\n", .{e});
+ journal.critical("main returned error: {t}\n", .{e});
};
pi.reboot();
@@ -163,11 +138,6 @@ fn main() !void {
const pt = memory.get_page_table();
- var empty = try loader.init(pt_alloc, heap_alloc, pt, lua_binary);
- uart.print(
- \\Stack Pointer: {X:0>8}
- \\ Entrypoint: {X:0>8}
- \\
- , .{ empty.stack_pointer, empty.entrypoint });
- try loader.execute(&empty, 0, &[_][]const u8{"lua"}, &[_][]u8{});
+ var lua = try loader.init(pt_alloc, heap_alloc, pt, lua_binary);
+ try loader.execute(&lua, 0, &[_][]const u8{"lua"}, &[_][]u8{});
}