Closer to all-cores bootstrap

This commit is contained in:
Curle 2022-07-09 00:20:00 +01:00
parent d681320463
commit ded76cd0af
6 changed files with 22 additions and 7 deletions

View File

@ -77,4 +77,4 @@ class Core {
void Bootstrap();
void SetupData(size_t ID);
} __attribute__((packed));
};

View File

@ -142,6 +142,8 @@ extern "C" {
#define KERNEL_HEAP_REGION 0xFFFFE00080000000ull // Kernel Object Space (kmalloc will allocate into this region)
#define KERNEL_HEAP_END 0xFFFFE000C0000000ull // End of Kernel Object Space
#define APIC_REGION 0x00000000FEE00000ull // Physical location of the APIC MMIO region.
#define DIRECT_REGION 0xFFFF800000000000ull
#define LOWER_REGION 0x0000000100000000ull // Lower Memory cutoff - 4GB

View File

@ -62,6 +62,7 @@ void APIC::Init() {
SerialPrintf("[ ACPI] Enabling APICs...\r\n");
Address = (void*) ACPI::MADT::instance->LocalAPICBase;
SerialPrintf("[ MADT] The APIC of this core is at 0x%p\r\n", (size_t) Address);
// TODO: Check whether the identity mapping covers this address

View File

@ -88,10 +88,14 @@ extern "C" [[noreturn]] int Main(void) {
SetForegroundColor(0x00FFFFFF);
Device::APIC::driver = new Device::APIC();
ACPI::RSDP::instance->Init(0);
ACPI::MADT::instance->Init();
Device::APIC::driver->Init();
Core::Init();
CharPrinterCallbackID = SetupKBCallback(&PrintPressedChar);
InternalBufferID = SetupKBCallback(&TrackInternalBuffer);

View File

@ -7,9 +7,6 @@
*** Chroma ***
***********************/
extern size_t startCore;
extern size_t endCore;
int Cores = 0;
volatile bool Ready = false;
@ -37,7 +34,7 @@ Core::Core(size_t APIC, size_t ID) {
GetCore(ID)->LocalAPIC = APIC;
Bootstrap();
SetupData(ID);
//SetupData(ID);
Device::APIC::driver->InitializeCore(APIC, reinterpret_cast<size_t>(initcpu));
@ -52,7 +49,7 @@ void Core::Init() {
using namespace ACPI;
Ready = false;
SerialPrintf("[CORE] Enabling Multiprocessing\n");
SerialPrintf("[ CORE] Enabling Multiprocessing\r\n");
memset(Tasks, 0, Constants::Core::MAX_CORES * sizeof(TSS64));
for (size_t i = 0; i < Constants::Core::MAX_CORES; i++)

View File

@ -68,6 +68,9 @@ void InitPaging() {
}
}
SerialPrintf("[ Mem] Identity mapping core system hardware.\r\n");
MapVirtualPageNoDirect(&KernelAddressSpace, APIC_REGION, APIC_REGION, DEFAULT_PAGE_FLAGS);
SerialPrintf("[ Mem] Mapping 0x%x bytes of bootloader structure, starting at 0x%p\r\n", bootldr.size,
BootldrAddress);
for (size_t i = BootldrAddress; i < (BootldrAddress + bootldr.size); i += PAGE_SIZE)
@ -352,4 +355,12 @@ size_t* CreateNewPageTable(address_space_t* AddressSpace) {
#ifdef __cplusplus
}
#endif
#endif
void *operator new(size_t size) {
return kmalloc(size);
}
void *operator new[](size_t size) {
return kmalloc(size);
}