More tasking implementation

This commit is contained in:
Alex
2022-10-21 05:31:50 +03:00
parent 7477c55ccd
commit ebd0273a99
12 changed files with 347 additions and 84 deletions

View File

@ -52,6 +52,8 @@ extern "C" void StartCPU()
namespace SMP
{
int CPUCores = 0;
void Initialize(void *madt)
{
if (strcmp(CPU::Hypervisor(), x86_CPUID_VENDOR_VIRTUALBOX) == 0)
@ -67,6 +69,8 @@ namespace SMP
else if (Config.Cores != 0)
Cores = Config.Cores;
CPUCores = Cores;
for (uint16_t i = 0; i < Cores; i++)
{
debug("Initializing CPU %d", i);
@ -87,8 +91,8 @@ namespace SMP
POKE(volatile uint64_t, STACK) = (uint64_t)KernelAllocator.RequestPages(TO_PAGES(STACK_SIZE)) + STACK_SIZE;
POKE(volatile uint64_t, CORE) = i;
asm volatile("sgdt [0x580]\n"
"sidt [0x590]\n");
asmv("sgdt [0x580]\n"
"sidt [0x590]\n");
POKE(volatile uint64_t, START_ADDR) = (uintptr_t)&StartCPU;
@ -103,7 +107,7 @@ namespace SMP
CPUEnabled = false;
}
else
KPrint("CPU %d is the BSP", ((ACPI::MADT *)madt)->lapic[i]->APICId);
KPrint("\e058C19CPU \e8888FF%d \e058C19is the BSP", ((ACPI::MADT *)madt)->lapic[i]->APICId);
}
}
}