summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/debug.h3
-rw-r--r--include/font.h2
-rw-r--r--include/idt.h34
-rw-r--r--include/io.h9
-rw-r--r--include/irq.h58
-rw-r--r--include/keyboard.h9
-rw-r--r--include/pic.h30
7 files changed, 141 insertions, 4 deletions
diff --git a/include/debug.h b/include/debug.h
index 1c53148..ebe3a52 100644
--- a/include/debug.h
+++ b/include/debug.h
@@ -4,8 +4,5 @@
#include <stdint.h>
void bochs_breakpoint(void);
-void put_in_r8(uint64_t value);
-void put_in_r9(uint64_t value);
-void put_in_r10(uint64_t value);
#endif
diff --git a/include/font.h b/include/font.h
index c95e7bc..678a6c2 100644
--- a/include/font.h
+++ b/include/font.h
@@ -4,7 +4,7 @@
#include <stdint.h>
#define PSF_FONT_MAGIC 0x864ab572
-
+
typedef struct {
uint32_t magic; /* magic bytes to identify PSF */
uint32_t version; /* zero */
diff --git a/include/idt.h b/include/idt.h
new file mode 100644
index 0000000..9ca9c3a
--- /dev/null
+++ b/include/idt.h
@@ -0,0 +1,34 @@
+#ifndef IDT_H
+#define IDT_H
+
+#include <stdint.h>
+
+#define GDT_CODE_SEG 0x08
+
+#define INTERRUPT_GATE 0x8E
+#define TRAP_GATE 0x8F
+
+struct idt_entry {
+ uint16_t offset_1; // offset bits 0..15
+ uint16_t selector; // a code segment selector in GDT or LDT
+ uint8_t ist; // bits 0..2 holds Interrupt Stack Table offset, rest of bits zero.
+ uint8_t type_attributes; // gate type, dpl, and p fields
+ uint16_t offset_2; // offset bits 16..31
+ uint32_t offset_3; // offset bits 32..63
+ uint32_t zero; // reserved
+} __attribute__((packed));
+typedef struct idt_entry idt_entry;
+
+struct idtp {
+ uint16_t size;
+ uint64_t offset;
+} __attribute__((packed));
+typedef struct idtp idtp;
+
+void init_idt(void);
+void load_idt(idtp* pointer);
+void init_idt_table(void);
+void add_to_idt(uint16_t num, uint64_t offset, uint16_t selector, uint8_t type);
+
+
+#endif
diff --git a/include/io.h b/include/io.h
new file mode 100644
index 0000000..76c401d
--- /dev/null
+++ b/include/io.h
@@ -0,0 +1,9 @@
+#ifndef IO_H
+#define IO_H
+
+#include <stdint.h>
+
+uint8_t inb(uint32_t port);
+void outb(uint32_t port, uint8_t value);
+
+#endif
diff --git a/include/irq.h b/include/irq.h
new file mode 100644
index 0000000..f0e38d6
--- /dev/null
+++ b/include/irq.h
@@ -0,0 +1,58 @@
+#ifndef IRQ_H
+#define IRQ_H
+
+#include <stdint.h>
+
+// exceptions
+void isr0(void);
+void isr1(void);
+void isr2(void);
+void isr3(void);
+void isr4(void);
+void isr5(void);
+void isr6(void);
+void isr7(void);
+void isr8(uint64_t error);
+void isr9(void);
+void isr10(uint64_t error);
+void isr11(uint64_t error);
+void isr12(uint64_t error);
+void isr13(uint64_t error);
+void isr14(uint64_t error);
+void isr15(void);
+void isr16(void);
+void isr17(uint64_t error);
+void isr18(void);
+void isr19(void);
+void isr20(void);
+void isr21(uint64_t error);
+void isr22(void);
+void isr23(void);
+void isr24(void);
+void isr25(void);
+void isr26(void);
+void isr27(void);
+void isr28(void);
+void isr29(uint64_t error);
+void isr30(uint64_t error);
+void isr31(void);
+
+// interrupts
+void irq0(void);
+void irq1(void);
+void irq2(void);
+void irq3(void);
+void irq4(void);
+void irq5(void);
+void irq6(void);
+void irq7(void);
+void irq8(void);
+void irq9(void);
+void irq10(void);
+void irq11(void);
+void irq12(void);
+void irq13(void);
+void irq14(void);
+void irq15(void);
+
+#endif
diff --git a/include/keyboard.h b/include/keyboard.h
new file mode 100644
index 0000000..3a1b7f1
--- /dev/null
+++ b/include/keyboard.h
@@ -0,0 +1,9 @@
+#ifndef KEYBOARD_H
+#define KEYBOARD_H
+
+#define KEYBOARD_DATA_PORT 0x60
+#define KEYBOARD_STATUS_PORT 0x64
+
+void keyboard_handler(void);
+
+#endif
diff --git a/include/pic.h b/include/pic.h
new file mode 100644
index 0000000..f1f4e44
--- /dev/null
+++ b/include/pic.h
@@ -0,0 +1,30 @@
+#ifndef PIC_H
+#define PIC_H
+
+#define PIC1 0x20 /* IO base address for master PIC */
+#define PIC2 0xA0 /* IO base address for slave PIC */
+#define PIC1_COMMAND PIC1
+#define PIC1_DATA (PIC1+1)
+#define PIC2_COMMAND PIC2
+#define PIC2_DATA (PIC2+1)
+
+#define PIC_EOI 0x20 /* End-of-interrupt command code */
+
+/* reinitialize the PIC controllers, giving them specified vector offsets
+ rather than 8h and 70h, as configured by default */
+
+#define ICW1_ICW4 0x01 /* ICW4 (not) needed */
+#define ICW1_SINGLE 0x02 /* Single (cascade) mode */
+#define ICW1_INTERVAL4 0x04 /* Call address interval 4 (8) */
+#define ICW1_LEVEL 0x08 /* Level triggered (edge) mode */
+#define ICW1_INIT 0x10 /* Initialization - required! */
+
+#define ICW4_8086 0x01 /* 8086/88 (MCS-80/85) mode */
+#define ICW4_AUTO 0x02 /* Auto (normal) EOI */
+#define ICW4_BUF_SLAVE 0x08 /* Buffered mode/slave */
+#define ICW4_BUF_MASTER 0x0C /* Buffered mode/master */
+#define ICW4_SFNM 0x10 /* Special fully nested (not) */
+
+void remap_pic(void);
+
+#endif