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/pic.zig | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 boot/pic.zig (limited to 'boot/pic.zig') diff --git a/boot/pic.zig b/boot/pic.zig new file mode 100644 index 0000000..0bec4a8 --- /dev/null +++ b/boot/pic.zig @@ -0,0 +1,22 @@ +// this is just a 8259 PIC thing in zig, kinda defines only the constants the +// IDT needs cause the actual remapping and masking is done in the kernel level +// which is pretty cool.EOI has to stay here cause it runs inside the ISR tho, +// so somewhere the VM cant really do much. +// +// see: https://wiki.osdev.org/8259_PIC + +const port = @import("port.zig"); + +const MASTER_CMD: u16 = 0x20; +const SLAVE_CMD: u16 = 0xA0; +const EOI: u8 = 0x20; // end-of-interrupt command + +pub const MASTER_OFFSET: u8 = 0x20; // IRQ0..7 -> vectors 0x20..0x27 +pub const SLAVE_OFFSET: u8 = 0x28; // IRQ8..15 -> vectors 0x28..0x2F + +// tell the PIC we're done. the slave's interrupts also need the master EOI'd +// since they arrive via the cascade. +pub fn eoi(irq: u4) void { + if (irq >= 8) port.outb(SLAVE_CMD, EOI); + port.outb(MASTER_CMD, EOI); +} -- cgit v1.3