major restructuring, prepare for smp
This commit is contained in:
1 parent
b3569a2b90
commit
6bff37746d
229 files changed
+1617
-1489
No files matched your search
+13
-11
@@ -10,7 +10,8 @@
|
||||
// 0x30 TSS high
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <ke_idt.h>
|
||||
#include <kernel/ke_idt.h>
|
||||
#include <kernel/ke_cpu.h>
|
||||
|
||||
// External assembly procedures
|
||||
extern void KeFlushGdt(void* pGdtr, uint16_t codeSel, uint16_t dataSel, uint16_t tssSel);
|
||||
@@ -77,10 +78,7 @@ extern void KeFaultRSV31(void);
|
||||
// GDT
|
||||
// ---------------------------------------------------------------------------
|
||||
#define GDT_ENTRIES 8
|
||||
#define KERNEL_IST_STACK_SIZE 0x4000
|
||||
|
||||
static uint64_t gGdt[GDT_ENTRIES];
|
||||
static uint8_t gKernelStack[KERNEL_IST_STACK_SIZE];
|
||||
|
||||
#pragma pack(push, 1)
|
||||
typedef struct { uint16_t Limit; uint64_t Base; } GDTR;
|
||||
@@ -112,12 +110,14 @@ static void KiGdtSetTss(int idx, uintptr_t base, uint32_t limit) {
|
||||
gGdt[idx+1] = (base >> 32);
|
||||
}
|
||||
|
||||
TSS64 gTssStruct;
|
||||
TSS64* gTss = &gTssStruct;
|
||||
TSS64* gTss = (TSS64*)0;
|
||||
|
||||
void KeInitializeGdt(void) {
|
||||
KCPU* cpu = KeGetCurrentCpu();
|
||||
TSS64* tss = &cpu->Tss;
|
||||
gTss = tss;
|
||||
|
||||
memset(gGdt, 0, sizeof(gGdt));
|
||||
memset(&gTssStruct, 0, sizeof(gTssStruct));
|
||||
|
||||
// 0x00: Null
|
||||
KiGdtSetEntry(0, 0, 0, 0, 0);
|
||||
@@ -130,11 +130,13 @@ void KeInitializeGdt(void) {
|
||||
// 0x20: Ring-3 Data
|
||||
KiGdtSetEntry(4, 0, 0xFFFFF, 0xF2, 0xC);
|
||||
|
||||
// 0x28: TSS (Occupies two slots: 0x28 and 0x30)
|
||||
gTssStruct.IoMapBase = sizeof(TSS64);
|
||||
gTssStruct.RSP0 = (uint64_t)(gKernelStack + KERNEL_IST_STACK_SIZE); // top of stack
|
||||
// 0x28: TSS (Occupies two slots: 0x28 and 0x30).
|
||||
// The TSS storage is per-CPU; phase 1 initializes CPU0 only.
|
||||
tss->IoMapBase = sizeof(TSS64);
|
||||
if (!tss->RSP0)
|
||||
tss->RSP0 = cpu->KernelStackTop;
|
||||
|
||||
KiGdtSetTss(5, (uintptr_t)&gTssStruct, sizeof(TSS64) - 1);
|
||||
KiGdtSetTss(5, (uintptr_t)tss, sizeof(TSS64) - 1);
|
||||
|
||||
GDTR gdtr = { sizeof(gGdt) - 1, (uint64_t)gGdt };
|
||||
|
||||
|
||||
Reference in new issue
Block a user