From 6a30f42d5dcd0f944262147b2806db6c14fe7ffc Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 15 May 2025 13:56:17 +0200 Subject: feat(kernel): Finalizing the first version of the user scheduler. other: - Removed DmaPool into its own Kit. - ApplicationProcessor unit has been cleaned up. - Rename functions of MemoryMgr. - Use KIB instead of MIBs of stack. - Cleanup parts of the scheduler, and hw scheduler. - Use UD handler for INT 6. Signed-off-by: Amlal El Mahrouss --- dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc | 39 ++++++++++------------ 1 file changed, 17 insertions(+), 22 deletions(-) (limited to 'dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc') diff --git a/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc b/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc index dd9a36ed..84c52768 100644 --- a/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc +++ b/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc @@ -152,10 +152,13 @@ EXTERN_C BOOL mp_register_process(HAL::StackFramePtr stack_frame, ProcessID pid) kHWThread[process_index].mCoreID = kAPICLocales[0]; - hal_send_sipi(kApicBaseAddress, kHWThread[process_index].mCoreID, - (UInt8) (((UIntPtr) stack_frame->BP) >> 12)); + if (mp_is_smp()) { + /// TODO: - return YES; + return YES; + } + + return NO; } /***********************************************************************************/ @@ -195,44 +198,36 @@ Void mp_init_cores(VoidPtr vendor_ptr) noexcept { kSMPAware = NO; if (kMADTBlock) { - SizeT index = 1; + SizeT index = 0; kSMPInterrupt = 0; kSMPCount = 0; - kout << "SMP: Starting APs...\r"; - kApicBaseAddress = kMADTBlock->Address; + constexpr const auto kSMPCountMax = kMaxAPInsideSched; + while (Yes) { /// @note Anything bigger than x2APIC type doesn't exist. - if (kMADTBlock->List[index].Type > 9 || kSMPCount > kSchedProcessLimitPerTeam) break; + if (kSMPCount > kSMPCountMax) break; - switch (kMADTBlock->List[index].Type) { - case 0x00: { - if (kMADTBlock->List[kSMPCount].Apic.LAPIC.ProcessorID < 1) break; + if (kMADTBlock->List[index].Type > 9) { + ++index; + continue; + } - kAPICLocales[kSMPCount] = kMADTBlock->List[kSMPCount].Apic.LAPIC.ProcessorID; - (Void)(kout << "SMP: APIC ID: " << number(kAPICLocales[kSMPCount]) << kendl); + kAPICLocales[kSMPCount] = kMADTBlock->List[kSMPCount].Apic.LAPIC.ProcessorID; + (Void)(kout << "SMP: APIC ID: " << number(kAPICLocales[kSMPCount]) << kendl); - ++kSMPCount; - break; - } - default: - break; - } + ++kSMPCount; ++index; } - (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) kSMPAware = true; - - /// TODO: Notify Boot AP that it must start. } } } // namespace Kernel::HAL -- cgit v1.2.3