diff options
| author | amlal <amlalelmahrouss@icloud.com> | 2024-06-13 22:02:27 +0200 |
|---|---|---|
| committer | amlal <amlalelmahrouss@icloud.com> | 2024-06-13 22:02:27 +0200 |
| commit | 67a14f5c12510e277911cbcf8ea5ce01f8b8fbb1 (patch) | |
| tree | ad0ef9e95ef9ce136160bfa915c042e778f34b1e /Kernel/HALKit | |
| parent | 12126f9eebfa7fc6b2cd6148f13585ff71cf5425 (diff) | |
MHR-31: Detect all types of cores except the boot one.
Signed-off-by: amlal <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Kernel/HALKit')
| -rw-r--r-- | Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp | 3 | ||||
| -rw-r--r-- | Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp | 27 | ||||
| -rw-r--r-- | Kernel/HALKit/AMD64/HalKernelMain.cxx | 7 | ||||
| -rw-r--r-- | Kernel/HALKit/AMD64/PCI/Iterator.cxx | 2 | ||||
| -rw-r--r-- | Kernel/HALKit/AXP/CoreSyscallHandlerDEC.cpp | 2 |
5 files changed, 24 insertions, 17 deletions
diff --git a/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp b/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp index 51570b86..e9c0941c 100644 --- a/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp +++ b/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp @@ -82,8 +82,7 @@ EXTERN_C NewOS::Void hal_system_call_enter(NewOS::UIntPtr rcx, NewOS::UIntPtr rd /// @brief Enter kernel call from assembly (DDK only). /// @param stack the stack pushed from assembly routine. /// @return nothing. -EXTERN_C NewOS::Void hal_kernel_call_enter(NewOS::UIntPtr rcx, NewOS::UIntPtr rdx, - NewOS::UIntPtr r8, NewOS::UIntPtr r9) +EXTERN_C NewOS::Void hal_kernel_call_enter(NewOS::UIntPtr rcx, NewOS::UIntPtr rdx, NewOS::UIntPtr r8, NewOS::UIntPtr r9) { if (rcx != 0) { diff --git a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp index c15a7b55..37a681ab 100644 --- a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp +++ b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp @@ -113,10 +113,16 @@ namespace NewOS::HAL /////////////////////////////////////////////////////////////////////////////////////// - STATIC MadtType* kApicInfoBlock = nullptr; - STATIC UIntPtr kApicMadtAddresses[255] = {0}; - STATIC SizeT kApicMadtAddressesCount = 0UL; - STATIC UIntPtr cBaseAddressAPIC = 0xFEE00000; + STATIC MadtType* kApicInfoBlock = nullptr; + + STATIC struct + { + UIntPtr fAddress{0}; + UInt32 fKind{0}; + } kApicMadtAddresses[255] = {}; + + STATIC SizeT kApicMadtAddressesCount = 0UL; + STATIC UIntPtr cBaseAddressAPIC = 0xFEE00000; /// @brief this will help us schedule our cores. STATIC Boolean* cProgramInitialized = nullptr; @@ -156,7 +162,6 @@ namespace NewOS::HAL EXTERN_C Void hal_apic_acknowledge_cont(Void) { - ProcessHelper::StartScheduling(); _hal_spin_core(); } @@ -202,21 +207,23 @@ namespace NewOS::HAL if (kApicMadt != nullptr) { - MadtType* madt = (MadtType*)kApicMadt; + MadtType* madt = reinterpret_cast<MadtType*>(kApicMadt); constexpr auto cMaxProbableCores = 4; // the amount of cores we want. constexpr auto cStartAt = 0; // start here to avoid boot core. for (SizeT coreAt = cStartAt; coreAt < cMaxProbableCores; ++coreAt) { - if (madt->MadtRecords[coreAt].Flags == kThreadLAPIC) // if local apic. + if (madt->MadtRecords[coreAt].Flags != kThreadBoot) // if local apic. { MadtType::MadtAddress& madtRecord = madt->MadtRecords[coreAt]; // then register as a core for scheduler. - kcout << "newoskrnl: register core as scheduler thread.\r"; + kcout << "newoskrnl: Register Local APIC.\r"; + + kApicMadtAddresses[kApicMadtAddressesCount].fAddress = madtRecord.Address; + kApicMadtAddresses[kApicMadtAddressesCount].fKind = madt->MadtRecords[coreAt].Flags; - kApicMadtAddresses[kApicMadtAddressesCount] = madtRecord.Address; ++kApicMadtAddressesCount; } } @@ -241,7 +248,7 @@ namespace NewOS::HAL cProgramInitialized = new Boolean(true); constexpr auto cWhereToInterrupt = 0x40; - constexpr auto cWhatCore = 1; + constexpr auto cWhatCore = 1; hal_send_start_ipi(cWhatCore, cWhereToInterrupt, cBaseAddressAPIC); } diff --git a/Kernel/HALKit/AMD64/HalKernelMain.cxx b/Kernel/HALKit/AMD64/HalKernelMain.cxx index 7064183b..9b605e1a 100644 --- a/Kernel/HALKit/AMD64/HalKernelMain.cxx +++ b/Kernel/HALKit/AMD64/HalKernelMain.cxx @@ -79,8 +79,8 @@ EXTERN_C void hal_init_platform( constexpr auto cDummyInterrupt = 0x10; // 16 kSyscalls[cDummyInterrupt].Leak().Leak()->fProc = [](NewOS::VoidPtr sf) -> void { - const char* msg = (const char*)sf; - NewOS::kcout << "newoskrnl: " << msg << "\r"; + const char* msg = (const char*)sf; + NewOS::kcout << "newoskrnl: " << msg << "\r"; }; kSyscalls[cDummyInterrupt].Leak().Leak()->fHooked = true; @@ -93,5 +93,6 @@ EXTERN_C void hal_init_platform( NewOS::HAL::hal_system_get_cores(kHandoverHeader->f_HardwareTables.f_RsdPtr); while (true) - {} + { + } } diff --git a/Kernel/HALKit/AMD64/PCI/Iterator.cxx b/Kernel/HALKit/AMD64/PCI/Iterator.cxx index 297aa89c..d3167b46 100644 --- a/Kernel/HALKit/AMD64/PCI/Iterator.cxx +++ b/Kernel/HALKit/AMD64/PCI/Iterator.cxx @@ -7,7 +7,7 @@ #include <KernelKit/PCI/Iterator.hpp> #define PCI_ITERATOR_FIND_AND_UNWRAP(DEV, SZ) \ - if (DEV.Leak().Leak()) \ + if (DEV.Leak().Leak()) \ return *DEV.Leak().Leak(); namespace NewOS::PCI diff --git a/Kernel/HALKit/AXP/CoreSyscallHandlerDEC.cpp b/Kernel/HALKit/AXP/CoreSyscallHandlerDEC.cpp index 3217a660..f308b0b5 100644 --- a/Kernel/HALKit/AXP/CoreSyscallHandlerDEC.cpp +++ b/Kernel/HALKit/AXP/CoreSyscallHandlerDEC.cpp @@ -8,7 +8,7 @@ #include <HALKit/AXP/Processor.hpp> /// @brief Internal call for syscall, to work with C++. -/// @param stack +/// @param stack /// @return nothing. EXTERN_C void rt_syscall_handle(NewOS::HAL::StackFrame* stack) { |
