aboutsummaryrefslogtreecommitdiff
path: root/src/debugcon.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/debugcon.zig')
-rw-r--r--src/debugcon.zig18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/debugcon.zig b/src/debugcon.zig
index e721a4d..6f8b8e7 100644
--- a/src/debugcon.zig
+++ b/src/debugcon.zig
@@ -1,11 +1,14 @@
-pub inline fn inb(port: u16) u8 {
+const fmt = @import("std").fmt;
+const Writer = @import("std").io.Writer;
+
+fn inb(port: u16) u8 {
return asm volatile ("inb %[port], %[result]"
: [result] "={al}" (-> u8),
: [port] "{dx}" (port),
);
}
-pub fn outb(port: u16, data: u8) void {
+fn outb(port: u16, data: u8) void {
asm volatile ("outb %[data], %[port]"
:
: [port] "{dx}" (port),
@@ -18,3 +21,14 @@ pub fn write(data: []const u8) void {
outb(0xe9, x);
}
}
+
+pub const writer = Writer(void, error{}, callback){ .context = {} };
+
+fn callback(_: void, string: []const u8) error{}!usize {
+ write(string);
+ return string.len;
+}
+
+pub fn printf(comptime format: []const u8, args: anytype) void {
+ fmt.format(writer, format, args) catch unreachable;
+}