diff options
| author | Emu <89668582+EmulatedSeasons@users.noreply.github.com> | 2024-05-31 23:38:46 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-31 23:38:46 -0400 |
| commit | 27a44e0d79d1c6e01cd832feb8ad958d5999b5e3 (patch) | |
| tree | 3759eb02fcad7a609a064080d81b7c6f9dbec4c8 /kernel/arch/x86/gdt2.cpp | |
| parent | 639240bbf498195912d8ceb6cb396b89391a5b1b (diff) | |
| parent | fd5a1699592ce0afafc42ebf22401596abcdfc28 (diff) | |
Merge pull request #1 from EmulatedSeasons/limineswitch
Limineswitch
Diffstat (limited to 'kernel/arch/x86/gdt2.cpp')
| -rw-r--r-- | kernel/arch/x86/gdt2.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/kernel/arch/x86/gdt2.cpp b/kernel/arch/x86/gdt2.cpp new file mode 100644 index 0000000..0acdb0e --- /dev/null +++ b/kernel/arch/x86/gdt2.cpp @@ -0,0 +1,51 @@ +#include <stdio.h>
+#include <stdint.h>
+/*
+// structure to be encoded at encodeGdtEntry()
+struct GDT
+{
+ uint32_t base;
+ uint32_t limit;
+ uint8_t access_byte;
+ uint8_t flags;
+};
+
+GDT strnulldesc {0, 0, 0, 0};
+GDT strkernelcode {0, 0xFFFFF, 0x9A, 0xC};
+GDT strkerneldata {0, 0xFFFFF, 0x92, 0xC};
+GDT strusercode {0, 0xFFFFF, 0xFA, 0xC};
+GDT struserdata {0, 0xFFFFF, 0xF2, 0xC};
+
+uint8_t* nulldesc;
+uint8_t* kernelcode;
+uint8_t* kerneldata;
+uint8_t* usercode;
+uint8_t* userdata;
+
+
+void encodeGdtEntry(uint8_t *target, struct GDT source)
+{
+ // Check the limit to make sure that it can be encoded
+ if (source.limit > 0xFFFFF) {printf("GDT cannot encode limits larger than 0xFFFFF\n");}
+
+ // Encode the limit
+ target[0] = source.limit & 0xFF;
+ target[1] = (source.limit >> 8) & 0xFF;
+ target[6] = (source.limit >> 16) & 0x0F;
+
+ // Encode the base
+ target[2] = source.base & 0xFF;
+ target[3] = (source.base >> 8) & 0xFF;
+ target[4] = (source.base >> 16) & 0xFF;
+ target[7] = (source.base >> 24) & 0xFF;
+
+ // Encode the access byte
+ target[5] = source.access_byte;
+
+ // Encode the flags
+ target[6] |= (source.flags << 4);
+}
+
+extern "C" void setupGdt() {
+
+} */
\ No newline at end of file |
