diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-04-17 23:58:28 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-17 23:58:28 +0200 |
| commit | 6b7403efd291f80a06267817afee4c0a4c8da56c (patch) | |
| tree | 7698be2bc6e750bce31da1a328f68f5bd89cab96 /dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc | |
| parent | 8ccccad87b171890cbf5040e63b613307cdc5a30 (diff) | |
| parent | f092c767a1988b91c481022f29f167f231d635ad (diff) | |
Merge pull request #22 from amlel-el-mahrouss/dev
kernel, SMP: put back AP init code.
Diffstat (limited to 'dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc')
| -rw-r--r-- | dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc b/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc index 938907f4..94c1ae73 100644 --- a/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc +++ b/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc @@ -210,15 +210,24 @@ namespace Kernel::HAL if (kMADTBlock) { - SizeT index = 1UL; + SizeT index = 1; kSMPInterrupt = 0; kSMPCount = 0; - kout << "SMP: Registering APIC IDs...\r"; + kout << "SMP: Starting APs...\r"; kApicBaseAddress = kMADTBlock->Address; + constexpr auto kMemoryAPStart = 0x7C000; + Char* ptr_ap_code = reinterpret_cast<Char*>(kMemoryAPStart); + + mm_map_page(ptr_ap_code, ptr_ap_code, kMMFlagsWr | kMMFlagsPCD); + + SizeT hal_ap_blob_len = hal_ap_blob_end - hal_ap_blob_start; + + rt_copy_memory((Char*)hal_ap_blob_start, ptr_ap_code, hal_ap_blob_len); + while (Yes) { if (kMADTBlock->List[index].Type > 9 || @@ -232,7 +241,18 @@ namespace Kernel::HAL break; kAPICLocales[kSMPCount] = kMADTBlock->List[kSMPCount].LAPIC.ProcessorID; - (Void)(kout << "SMP: APIC ID: " << number(kAPICLocales[kSMPCount]) << kendl); + (void)(kout << "SMP: APIC ID: " << number(kAPICLocales[kSMPCount]) << kendl); + + // I'll just make the AP start from scratch here. + + hal_send_start_ipi(kApicBaseAddress, kAPICLocales[kSMPCount]); + + HardwareTimer timer(Kernel::rtl_ms(10)); + timer.Wait(); + + /// TODO: HAL helper to create an address. + + hal_send_sipi(kApicBaseAddress, kAPICLocales[kSMPCount], (UInt8)(((UIntPtr)ptr_ap_code) >> 12)); ++kSMPCount; break; @@ -244,7 +264,7 @@ namespace Kernel::HAL ++index; } - (Void)(kout << "SMP: Number of IDs: " << number(kSMPCount) << kendl); + (void)(kout << "SMP: number of APs: " << number(kSMPCount) << kendl); // Kernel is now SMP aware. // That means that the scheduler is now available (on MP Kernels) |
