summaryrefslogtreecommitdiff
path: root/arch/i386/include
diff options
context:
space:
mode:
authorDanny Holman <dholman@gymli.xyz>2021-09-28 09:04:01 -0500
committerDanny Holman <dholman@gymli.xyz>2021-09-28 09:04:38 -0500
commit0ad50c878838640ce53c202ab028d7b2c5810fe6 (patch)
tree77f189f1369a31b1941dfc5cacb8da71fe343aca /arch/i386/include
parent7bf2c634fdb55d67affe74a2ed0a157610308942 (diff)
arch: i386: add support for 8259 PIC
Add support for the 8259 programmable interrupt controller. Signed-off-by: Danny Holman <dholman@gymli.xyz>
Diffstat (limited to 'arch/i386/include')
-rw-r--r--arch/i386/include/kernel/pic.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/arch/i386/include/kernel/pic.h b/arch/i386/include/kernel/pic.h
new file mode 100644
index 0000000..c3ede4f
--- /dev/null
+++ b/arch/i386/include/kernel/pic.h
@@ -0,0 +1,45 @@
+#ifndef I386_PIC_H
+#define I386_PIC_H
+
+#include <stdint.h>
+
+#define PIC1 0x20
+#define PIC2 0x28
+#define PIC1_COMMAND PIC1
+#define PIC1_DATA (PIC1+1)
+#define PIC2_COMMAND PIC2
+#define PIC2_DATA (PIC2+1)
+
+#define ICW1_ICW4 0x01
+#define ICW1_SINGLE 0x02
+#define ICW1_INTERVAL4 0x04
+#define ICW1_LEVEL 0x08
+#define ICW1_INIT 0x10
+
+#define ICW4_8086 0x01
+#define ICW4_AUTO 0x02
+#define ICW4_BUF_SLAVE 0x08
+#define ICW4_BUF_MASTER 0x0C
+#define ICW4_SFNM 0x10
+
+static inline void outb(uint16_t port, uint8_t value) {
+ asm volatile("outb %0, %1" : : "a"(value), "Nd"(port));
+}
+
+static inline uint8_t inb(uint16_t port) {
+ uint8_t ret;
+ asm volatile("inb %1, %0" : "=a"(ret) : "Nd"(port));
+ return ret;
+}
+
+static inline void io_wait(void) {
+ outb(0x80, 0);
+}
+
+void pic_eoi(unsigned char irq);
+void pic_remap(void);
+
+void irq_set_mask(uint8_t irq);
+void irq_clear_mask(uint8_t irq);
+
+#endif