52 lines
1.2 KiB
C
52 lines
1.2 KiB
C
#include <stdio.h>
|
|
#include <stdint.h>
|
|
|
|
#include <kernel/_kernel.h>
|
|
#include <kernel/tty.h>
|
|
#include <kernel/serial.h>
|
|
#include <kernel/x86/gdt.h>
|
|
#include <kernel/x86/idt.h>
|
|
#include <kernel/x86/pic.h>
|
|
|
|
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();
|
|
idt_init();
|
|
PIC_remap(0x20, 0x28);
|
|
|
|
#ifndef __TESTING__
|
|
terminal_initialize();
|
|
serial_initialize();
|
|
#endif
|
|
|
|
|
|
printf("Integer: %d\n", 10);
|
|
printf("Hex Int: %x\n", 2);
|
|
}
|