summaryrefslogtreecommitdiff
path: root/kernel/gdt.h
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/gdt.h')
-rw-r--r--kernel/gdt.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/kernel/gdt.h b/kernel/gdt.h
new file mode 100644
index 0000000..e2c5b46
--- /dev/null
+++ b/kernel/gdt.h
@@ -0,0 +1,28 @@
+#ifndef GDT_H
+#define GDT_H
+
+#include "types.h"
+
+typedef struct {
+ uint16_t limit_low;
+ uint16_t base_low;
+ uint8_t base_mid;
+ uint16_t flags;
+ uint8_t base_high;
+} __attribute__((packed)) gdt_entry;
+
+typedef struct {
+ uint16_t limit;
+ gdt_entry* base;
+} __attribute__((packed)) gdt_ptr;
+
+#define gdt_entry_init(b, l, f) { \
+ .base_low = (b & 0xffff), \
+ .base_mid = (b >> 16 & 0xff), \
+ .base_high = (b >> 24 & 0xff), \
+ .limit_low = (l & 0xffff), \
+ .flags = (f | (l >> 8 & 0x0f00))}
+
+void gdt_init();
+
+#endif