aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorNic Gaffney <gaffney_nic@protonmail.com>2023-12-21 03:32:06 -0600
committerNic Gaffney <gaffney_nic@protonmail.com>2023-12-21 03:32:06 -0600
commit138424b31d9c2af158e8ae619248b035b5a280d9 (patch)
tree0da4f6661d68737b5957029242bea43fad77d7a8 /src/include
parent9dbc5231dd738d97eea13f8ecf9005e5b78ea0d3 (diff)
downloadgftos-138424b31d9c2af158e8ae619248b035b5a280d9.tar.gz
set up bochs for debugging and started working on interrupts.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/asm.h15
-rw-r--r--src/include/gdt.h12
-rw-r--r--src/include/idt.h17
3 files changed, 39 insertions, 5 deletions
diff --git a/src/include/asm.h b/src/include/asm.h
new file mode 100644
index 0000000..97ea45a
--- /dev/null
+++ b/src/include/asm.h
@@ -0,0 +1,15 @@
+#pragma once
+#include <stdint.h>
+
+// IO
+static inline void outb(uint16_t port, uint8_t val) {
+ asm volatile("outb %0, %1" : : "a"(val), "Nd"(port) : "memory");
+}
+
+static inline uint8_t inb(uint16_t port) {
+ uint8_t ret;
+ asm volatile("inb %1, %0" : "=a"(ret) : "Nd"(port) : "memory");
+ return ret;
+}
+
+static inline void io_wait(void) { outb(0x80, 0); }
diff --git a/src/include/gdt.h b/src/include/gdt.h
index 06a0d96..8cc2542 100644
--- a/src/include/gdt.h
+++ b/src/include/gdt.h
@@ -16,11 +16,13 @@ typedef struct GDTR {
uint32_t offset;
} __attribute__((packed)) GDTR_t;
-typedef struct GDT {
- Segment_Descriptor_t nulldesc;
- Segment_Descriptor_t codedesc;
- Segment_Descriptor_t datadesc;
-} __attribute__((packed)) GDT_t;
+// typedef struct GDT {
+// Segment_Descriptor_t nulldesc;
+// Segment_Descriptor_t codedesc;
+// Segment_Descriptor_t datadesc;
+// } __attribute__((packed)) GDT_t;
+
+typedef Segment_Descriptor_t *GDT_t;
uint16_t make_code(uint8_t priv, uint8_t dc, uint8_t rw);
uint16_t make_data(uint8_t priv, uint8_t dc, uint8_t rw);
diff --git a/src/include/idt.h b/src/include/idt.h
new file mode 100644
index 0000000..b8413b8
--- /dev/null
+++ b/src/include/idt.h
@@ -0,0 +1,17 @@
+#pragma once
+#include <stdint.h>
+
+typedef struct Gate_Descriptor {
+ uint16_t offset_low;
+ uint16_t segment_selector;
+ uint8_t reserved;
+ uint8_t attrs;
+ uint16_t offset_high;
+} __attribute__((packed)) Gate_Descriptor_t;
+
+typedef Gate_Descriptor_t *IDT_t;
+
+Gate_Descriptor_t make_gate(uint32_t offset, uint8_t segment_selector,
+ uint8_t attrs);
+
+void get_idtr();