diff options
| author | hachem <im@hachem.wtf> | 2026-09-12 10:59:26 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-09-12 10:59:26 +0200 |
| commit | d6d908e3386e107b41241e9eda7dc546581524df (patch) | |
| tree | 8219d02a7494152722ac7f32140d63c8a3b3daa7 /boot/port.zig | |
| parent | 4f540af34d7a88547d60bed7bd28850e6d0e18ab (diff) | |
feat: basic keyboard driver + tester shell
Diffstat (limited to 'boot/port.zig')
| -rw-r--r-- | boot/port.zig | 25 |
1 files changed, 25 insertions, 0 deletions
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); +} |
