adds some more data types for printf, and moves gdt_init to a different file
This commit is contained in:
@ -1,5 +1,9 @@
|
||||
#include <kernel/x86/gdt.h>
|
||||
|
||||
#ifdef __TESTING__
|
||||
#include <kernel/_kernel.h>
|
||||
#endif
|
||||
|
||||
uint64_t create_descriptor(uint32_t base, uint32_t limit, uint16_t flag)
|
||||
{
|
||||
uint64_t descriptor;
|
||||
@ -16,3 +20,21 @@ uint64_t create_descriptor(uint32_t base, uint32_t limit, uint16_t flag)
|
||||
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
void gdt_init(uint64_t* gdt)
|
||||
{
|
||||
#ifdef __TESTING__
|
||||
kinfo("Initializing the GDT");
|
||||
#endif
|
||||
gdt[0] = create_descriptor(0, 0, 0); // null
|
||||
gdt[1] = create_descriptor(0, 0x000FFFFF, (GDT_CODE_PL0)); // kernel code
|
||||
gdt[2] = create_descriptor(0, 0x000FFFFF, (GDT_DATA_PL0)); // kernel data
|
||||
gdt[3] = create_descriptor(0, 0x000FFFFF, (GDT_CODE_PL3)); // user code
|
||||
gdt[4] = create_descriptor(0, 0x000FFFFF, (GDT_DATA_PL3)); // user data
|
||||
|
||||
setGdt((sizeof(uint64_t) * GDT_SIZE) - 1, &(gdt[0])); // limit, base
|
||||
reloadSegments();
|
||||
#ifdef __TESTING__
|
||||
kinfo("Initialized the GDT");
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user