From 84b0e780dfd9272b177c32cc3bb99f37bb88304d Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 10 May 2024 07:06:43 +0200 Subject: MHR-23: Getting SMP to work... Signed-off-by: Amlal El Mahrouss --- Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx | 19 +++---- .../HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp | 58 ++++++++++------------ Kernel/HALKit/AXP/README.TXT | 2 +- 3 files changed, 36 insertions(+), 43 deletions(-) (limited to 'Kernel/HALKit') diff --git a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx index f4c9226e..db82616e 100644 --- a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx +++ b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx @@ -75,7 +75,7 @@ namespace NewOS SDT* xsdt = (SDT*)(rsdPtr->XsdtAddress >> (rsdPtr->XsdtAddress & 0xFFF)); - SizeT num = (xsdt->Length + sizeof(SDT)) / 8; + SizeT num = -(xsdt->Length - sizeof(SDT)) / 8; this->fEntries = num; @@ -83,22 +83,19 @@ namespace NewOS kcout << "ACPI: Address of XSDT: " << hex_number((UIntPtr)xsdt) << endl; constexpr short ACPI_SIGNATURE_LENGTH = 4; - SizeT offsetToAdd = 0UL; - - for (Size index = 0; index < num; ++index) + + for (Size index = 0; index < this->fEntries; ++index) { - SDT* sdt = &(xsdt[index]) + offsetToAdd; + SDT &sdt = xsdt[index]; - for (int signature_index = 0; signature_index < 4; signature_index++) + for (short signature_index = 0; signature_index < ACPI_SIGNATURE_LENGTH; ++signature_index) { - if (sdt->Signature[signature_index] != signature[signature_index]) + if (sdt.Signature[signature_index] != signature[signature_index]) break; - if (signature_index == 3) - return ErrorOr(reinterpret_cast(sdt)); + if (signature_index == 4) + return ErrorOr(reinterpret_cast(&sdt)); } - - offsetToAdd = sdt->Length; } return ErrorOr{nullptr}; diff --git a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp index ec6d47da..470a3286 100644 --- a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp +++ b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp @@ -46,54 +46,54 @@ namespace NewOS::HAL STATIC voidPtr kApicMadt = nullptr; STATIC const char* kApicSignature = "APIC"; - /// @brief Multiple APIC descriptor table. + /// @brief Multiple APIC Descriptor Table. struct MadtType final : public SDT { struct MadtAddress final { - UInt32 fAddress; - UInt32 fFlags; // 1 = Dual Legacy PICs installed - - Char fType; - Char fRecLen; // record length - } fMadt[]; + Char RecordType; + Char RecordLen; // record length + + UInt32 Address; + UInt32 Flags; // 1 = Dual Legacy PICs installed + } MadtRecords[]; }; struct MadtProcessorLocalApic final { - Char fProcessorId; - Char fApicId; - UInt32 fFlags; + Char AcpiProcessorId; + Char Reserved; + UInt32 Flags; }; struct MadtIOApic final { - Char fApicId; - Char fReserved; - UInt32 fAddress; - UInt32 fSystemInterruptBase; + Char ApicId; + Char Reserved; + UInt32 Address; + UInt32 SystemInterruptBase; }; struct MadtInterruptSource final { - Char fBusSource; - Char fIrqSource; - UInt32 fGSI; - UInt16 fFlags; + Char BusSource; + Char IrqSource; + UInt32 GSI; + UInt16 Flags; }; struct MadtInterruptNmi final { - Char fNmiSource; - Char fReserved; - UInt16 fFlags; - UInt32 fGSI; + Char NmiSource; + Char Reserved; + UInt16 Flags; + UInt32 GSI; }; struct MadtLocalApicAddressOverride final { - UInt16 fResvered; - UIntPtr fAddress; + UInt16 Resvered; + UIntPtr Address; }; /////////////////////////////////////////////////////////////////////////////////////// @@ -109,17 +109,13 @@ namespace NewOS::HAL if (kApicMadt) { - kcout << "New OS: Successfuly fetched the cores!\r"; + kcout << "New OS: APIC is present...\r"; kApicInfoBlock = (MadtType*)kApicMadt; - - kcout << "New OS: Revision: "; - kcout.HexNumber(kApicInfoBlock->Revision).EndLine(); - - ke_stop(RUNTIME_CHECK_BOOTSTRAP); } else { - ke_stop(RUNTIME_CHECK_BOOTSTRAP); + kcout << "New OS: APIC is not present! it is a vital component.\r"; + ke_stop(RUNTIME_CHECK_FAILED); } } } // namespace NewOS::HAL diff --git a/Kernel/HALKit/AXP/README.TXT b/Kernel/HALKit/AXP/README.TXT index 03c2b816..d4ef257d 100644 --- a/Kernel/HALKit/AXP/README.TXT +++ b/Kernel/HALKit/AXP/README.TXT @@ -1 +1 @@ -A Toy HAL to test the Kernel portability. +An toy HAL to test the kernel portability. -- cgit v1.2.3