diff options
| author | Marin Ivanov <[email protected]> | 2024-05-01 09:51:27 +0300 |
|---|---|---|
| committer | Marin Ivanov <[email protected]> | 2024-05-01 09:51:27 +0300 |
| commit | 26e457315d5e35677dfdd2d413fbf48ed1c869ee (patch) | |
| tree | 8711c99710804502225a5e179d9a21564a63cb5e /src/debugcon.zig | |
| parent | 9ed08e3d2a061fd1bfdefb603dd772eb324caf09 (diff) | |
wip: move inb/outb/write to debugcon.zig
Diffstat (limited to 'src/debugcon.zig')
| -rw-r--r-- | src/debugcon.zig | 25 |
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]); + } +} |
