aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/arch/x86_64/gdt.h
diff options
context:
space:
mode:
authorEmu <89668582+EmulatedSeasons@users.noreply.github.com>2024-05-31 23:38:46 -0400
committerGitHub <noreply@github.com>2024-05-31 23:38:46 -0400
commit27a44e0d79d1c6e01cd832feb8ad958d5999b5e3 (patch)
tree3759eb02fcad7a609a064080d81b7c6f9dbec4c8 /kernel/arch/x86_64/gdt.h
parent639240bbf498195912d8ceb6cb396b89391a5b1b (diff)
parentfd5a1699592ce0afafc42ebf22401596abcdfc28 (diff)
Merge pull request #1 from EmulatedSeasons/limineswitch
Limineswitch
Diffstat (limited to 'kernel/arch/x86_64/gdt.h')
-rw-r--r--kernel/arch/x86_64/gdt.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/kernel/arch/x86_64/gdt.h b/kernel/arch/x86_64/gdt.h
new file mode 100644
index 0000000..4f68977
--- /dev/null
+++ b/kernel/arch/x86_64/gdt.h
@@ -0,0 +1,38 @@
+#ifndef GDT_H
+#define GDT_H
+
+#include <stdint.h>
+
+struct GDTR {
+ uint16_t size;
+ uint64_t offset;
+}__attribute__((packed));
+
+struct SegDesc {
+ uint16_t limit_low;
+ uint16_t base_low;
+ uint8_t base_mid;
+ uint8_t access;
+ uint8_t flag_limit_high;
+ uint8_t base_high;
+}__attribute__((packed));
+
+// tss segment descriptor is larger than the normal ones
+struct TssSegDesc {
+ uint16_t limit_low;
+ uint16_t base1; // lowest base
+ uint8_t base2;
+ uint8_t access;
+ uint8_t flag_limit_high; // both in the same 8 bits
+ uint8_t base3;
+ uint32_t base4; // highest base
+ uint32_t reserved;
+}__attribute__((packed));
+
+void gdt_entry(SegDesc* seg, uint32_t base, uint32_t limit, uint8_t access, uint8_t flags);
+void gdt_tss_entry(TssSegDesc* seg, uint64_t base, uint32_t limit, uint8_t access, uint8_t flags);
+
+extern "C" void load_gdt(GDTR*);
+extern "C" void reload_segments();
+
+#endif \ No newline at end of file