aboutsummaryrefslogtreecommitdiff
path: root/src/debugcon.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/debugcon.zig')
-rw-r--r--src/debugcon.zig25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/debugcon.zig b/src/debugcon.zig
new file mode 100644
index 0000000..2049d22
--- /dev/null
+++ b/src/debugcon.zig
@@ -0,0 +1,25 @@
+pub inline fn inb(port: u16) u8 {
+ return asm volatile ("inb %[port], %[result]"
+ : [result] "={al}" (-> u8),
+ : [port] "{dx}" (port),
+ : "dx", "al"
+ );
+}
+
+pub inline fn outb(port: u16, data: u8) void {
+ asm volatile ("outb %[data], %[port]"
+ :
+ : [port] "{dx}" (port),
+ [data] "{al}" (data),
+ : "dx", "al"
+ );
+}
+
+pub fn write(data: []const u8) void {
+ const len: u8 = @intCast(data.len & 0xFF);
+ outb(0xe9, 0x30 + len);
+ for (0..len) |i| {
+ outb(0xe9, 0x30);
+ outb(0xe9, data[i]);
+ }
+}