From d6d908e3386e107b41241e9eda7dc546581524df Mon Sep 17 00:00:00 2001 From: hachem Date: Sat, 12 Sep 2026 10:59:26 +0200 Subject: feat: basic keyboard driver + tester shell --- boot/port.zig | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 boot/port.zig (limited to 'boot/port.zig') diff --git a/boot/port.zig b/boot/port.zig new file mode 100644 index 0000000..05668d3 --- /dev/null +++ b/boot/port.zig @@ -0,0 +1,25 @@ +// x86 port I/O +// +// these are pretty important cause all drivers which rely +// on serial rely on these 2 instructions so + +pub inline fn outb(port: u16, val: u8) void { + asm volatile ("outb %[val], %[port]" + : + : [val] "{al}" (val), + [port] "N{dx}" (port), + ); +} + +pub inline fn inb(port: u16) u8 { + return asm volatile ("inb %[port], %[result]" + : [result] "={al}" (-> u8), + : [port] "N{dx}" (port), + ); +} + +// a throwaway write to an unused port, ~1us. some 8259s need a beat between +// back-to-back command writes on slow hardware; harmless on QEMU. +pub inline fn wait() void { + outb(0x80, 0); +} -- cgit v1.3