printing debug messages to serial only

This commit is contained in:
2026-07-05 09:48:06 +01:00
parent 6cd6669a8d
commit ae1552414d
2 changed files with 52 additions and 26 deletions
+19
View File
@@ -120,3 +120,22 @@ pub const Console = struct {
while (x < self.fb.width) : (x += 1) dst[x] = src[x];
}
};
pub const SerialConsole = struct {
/// Serial-only output: goes to the machine-readable log but *not* the framebuffer,
/// so debug and test detail stays out of the on-screen console. These are free
/// functions, not `Console` methods, because serial has no dependency on the
/// framebuffer — they work even before `con` is initialised.
pub fn debugWrite(bytes: []const u8) void {
arch.serialWrite(bytes);
}
/// Formatted serial-only output, e.g. `debugPrint("x={d}\n", .{x})`. Truncates
/// past 256 bytes, like `Console.print`.
pub fn debugPrint(comptime fmt: []const u8, args: anytype) void {
var buf: [256]u8 = undefined;
debugWrite(std.fmt.bufPrint(&buf, fmt, args) catch return);
}
};