adds some more data types for printf, and moves gdt_init to a different file

This commit is contained in:
2025-05-30 13:32:52 -04:00
parent c115dcd4f7
commit ee2c5a72a1
4 changed files with 103 additions and 23 deletions

View File

@ -10,33 +10,13 @@
uint64_t gdt[GDT_SIZE];
void gdt_init()
{
#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
}
void kmain(void)
{
#ifdef __TESTING__ // important components should be declared first, but if we're testing we want to log all of that
terminal_initialize();
serial_initialize();
#endif
gdt_init();
gdt_init(gdt);
idt_init();
PIC_remap(0x20, 0x28);
@ -46,6 +26,6 @@ void kmain(void)
#endif
printf("Integer: %d\n", 10);
printf("Integer: %1\n", gdt[1]);
printf("Hex Int: %x\n", 2);
}