summaryrefslogtreecommitdiffhomepage
path: root/Kernel/HALKit/AMD64
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-05-10 07:06:43 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-05-10 07:06:43 +0200
commit84b0e780dfd9272b177c32cc3bb99f37bb88304d (patch)
tree44d596f6511eae83b8762aa42550b100d5646de6 /Kernel/HALKit/AMD64
parent915c14eb3b717bbd168d069e296a4246c6aef117 (diff)
MHR-23: Getting SMP to work...
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Kernel/HALKit/AMD64')
-rw-r--r--Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx19
-rw-r--r--Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp58
2 files changed, 35 insertions, 42 deletions
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<voidPtr>(reinterpret_cast<voidPtr>(sdt));
+ if (signature_index == 4)
+ return ErrorOr<voidPtr>(reinterpret_cast<voidPtr>(&sdt));
}
-
- offsetToAdd = sdt->Length;
}
return ErrorOr<voidPtr>{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