2021-05-12 22:03:00 +00:00
|
|
|
#include "gdtc.h"
|
2021-11-02 20:03:11 +00:00
|
|
|
#include "../tty/kterm.h"
|
2021-05-12 22:03:00 +00:00
|
|
|
|
|
|
|
gdtEntry_t gdt[3];
|
|
|
|
|
|
|
|
|
|
|
|
void gdtSetGate(int num, uint64_t base, uint64_t limit, uint8_t access,
|
|
|
|
uint8_t gran){
|
|
|
|
gdt[num].lBase = (base & 0xFFFF);
|
|
|
|
gdt[num].mBase = (base >> 16) & 0xFF;
|
|
|
|
gdt[num].hBase = (base >> 24) & 0xFF;
|
|
|
|
|
|
|
|
gdt[num].lLimit = (limit & 0xFFFF);
|
|
|
|
gdt[num].granularity = ((limit >> 16) & 0x0F);
|
|
|
|
|
|
|
|
gdt[num].granularity |= (gran & 0xF0);
|
|
|
|
gdt[num].access = access;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setupGdt(){
|
2021-11-02 20:03:11 +00:00
|
|
|
|
|
|
|
printf("setupGdt is called!");
|
2021-05-12 22:03:00 +00:00
|
|
|
gdtPointer.limit = (sizeof(gdtEntry_t) * 3) - 1;
|
2021-11-02 20:03:11 +00:00
|
|
|
gdtPointer.base = &gdt;
|
2021-05-12 22:03:00 +00:00
|
|
|
|
|
|
|
gdtSetGate(0, 0, 0, 0, 0);
|
|
|
|
gdtSetGate(1, 0, 0xFFFFFFFF, 0x9A, 0xCF);
|
|
|
|
gdtSetGate(2, 0, 0xFFFFFFFF, 0x92, 0xCF);
|
|
|
|
|
|
|
|
loadGdt();
|
|
|
|
}
|