Kernel: Refactor TSS loading to make it cleaner >.<
This commit is contained in:
parent
97eacc027e
commit
c1f9d3323f
@ -78,11 +78,8 @@ static void set_limit(GDTEntry* entry, uint32_t limit)
|
||||
entry->limit1_flags = (entry->limit1_flags & 0xF0) | ((limit >> 16) & 0xF);
|
||||
}
|
||||
|
||||
void GDT::load()
|
||||
static void setup_tss()
|
||||
{
|
||||
static GDTR gdtr;
|
||||
gdtr.offset = (uint64_t)&internal_gdt;
|
||||
gdtr.size = sizeof(InternalGDT);
|
||||
memset(&main_tss, 0, sizeof(TSS));
|
||||
main_tss.rsp[0] =
|
||||
(uint64_t)MemoryManager::get_pages(4) + (PAGE_SIZE * 4) - 8; // allocate 16KB for the syscall stack
|
||||
@ -90,8 +87,21 @@ void GDT::load()
|
||||
set_base(&internal_gdt.tss, (uint64_t)&main_tss & 0xffffffff);
|
||||
internal_gdt.tss2.base_high = (uint32_t)(((uint64_t)&main_tss >> 32) & 0xffffffff);
|
||||
set_limit(&internal_gdt.tss, sizeof(TSS) - 1);
|
||||
kdbgln("Loading GDT at offset %lx, size %d", gdtr.offset, gdtr.size);
|
||||
load_gdt(&gdtr);
|
||||
}
|
||||
|
||||
static void load_tss()
|
||||
{
|
||||
kdbgln("Loading TR (GDT entry 0x2b)");
|
||||
load_tr(0x2b);
|
||||
}
|
||||
|
||||
void GDT::load()
|
||||
{
|
||||
static GDTR gdtr;
|
||||
gdtr.offset = (uint64_t)&internal_gdt;
|
||||
gdtr.size = sizeof(InternalGDT);
|
||||
setup_tss();
|
||||
kdbgln("Loading GDT at offset %lx, size %d", gdtr.offset, gdtr.size);
|
||||
load_gdt(&gdtr);
|
||||
load_tss();
|
||||
}
|
Loading…
Reference in New Issue
Block a user