adds some comments, fixes a few tiny bugs

This commit is contained in:
2025-05-31 20:50:47 -04:00
parent c50d3f14a6
commit 89c02d6a93
3 changed files with 56 additions and 8 deletions

View File

@ -6,6 +6,25 @@
#include <kernel/_kernel.h>
#endif
/**
* What is this file?
*
* Well, to properly set up a lot of the system, we need something called a GDT
* or, a Global Descriptor Table.
*
* This table, establishes a few things.
*
* Mainly it sets 4 segments,
* A kernel code segment, with RING 0 permissions
* A kernel data segment, with RING 0 permissions
* A user code segment, with RING 3 permissions
* A user data segment, with RING 3 permissions
*
* This allows for future userspace to properly segment code and data,
* anything in userspace shouldn't have access to hardware like the kernel does
* So by passing through this GDT, we can dish out authority to access certain data, functions,
* etc, by going through the CPU permission system (RING 0 - 3)
*/
uint64_t gdt[GDT_SIZE];
@ -26,12 +45,14 @@ uint64_t create_descriptor(uint32_t base, uint32_t limit, uint16_t flag)
return descriptor;
}
#ifdef __TESTING__
void dump_gdt(void)
{
for (int i = 0; i < GDT_SIZE; i++) {
printf("GDT_ENTRY %d: %4 | %2\n", i, gdt[i], gdt[i]);
}
}
#endif
void gdt_init(void)