summaryrefslogtreecommitdiff
path: root/arch/i386/boot
diff options
context:
space:
mode:
authorDanny Holman <dholman@gymli.xyz>2021-09-28 12:25:46 -0500
committerDanny Holman <dholman@gymli.xyz>2021-09-28 12:25:46 -0500
commitc4845de1e4ba49ba066e5729814fdb5bcd7e46f8 (patch)
tree95fec0743270943ea316ebc4c2af970430c2ea33 /arch/i386/boot
parentc0019e9d0bd2059351dc7d0274ee0479a71192fc (diff)
arch: i386: add PIC register support
Add functions that let the OS read the internal state registers of the 8259 PIC. Signed-off-by: Danny Holman <dholman@gymli.xyz>
Diffstat (limited to 'arch/i386/boot')
-rw-r--r--arch/i386/boot/pic.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/arch/i386/boot/pic.c b/arch/i386/boot/pic.c
index f103b92..607023c 100644
--- a/arch/i386/boot/pic.c
+++ b/arch/i386/boot/pic.c
@@ -22,6 +22,20 @@ void pic_remap(void) {
outb(PIC2_DATA, a2);
}
+static uint16_t __pic_get_irq_reg(int ocw3) {
+ outb(PIC1_COMMAND, ocw3);
+ outb(PIC2_COMMAND, ocw3);
+ return (inb(PIC2_COMMAND) << 8) | inb(PIC1_COMMAND);
+}
+
+uint16_t pic_get_irr(void) {
+ return __pic_get_irq_reg(PIC_READ_IRR);
+}
+
+uint16_t pic_get_isr(void) {
+ return __pic_get_irq_reg(PIC_READ_ISR);
+}
+
void irq_set_mask(uint8_t irq) {
uint16_t port;
uint8_t data;