diff options
| author | Amlal <amlalelmahrouss@icloud.com> | 2024-06-06 10:27:55 +0000 |
|---|---|---|
| committer | Amlal <amlalelmahrouss@icloud.com> | 2024-06-06 10:27:55 +0000 |
| commit | 4e75e05a20ddd0dbca982e8f3bc2ea8043ed3a3f (patch) | |
| tree | 95409c0e32b644578b94a5c230417da684d79dc9 /Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx | |
| parent | f5081a8f9a8537ad5be5d639955cd1d0e68a9e1d (diff) | |
| parent | 9994b8f3f88131f41be1061fb0947177e66dc7b0 (diff) | |
Merged in MHR-23 (pull request #14)
Draft: MHR-23
Diffstat (limited to 'Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx')
| -rw-r--r-- | Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx index ff5372f4..14241f60 100644 --- a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx +++ b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx @@ -7,6 +7,8 @@ #include <Builtins/ACPI/ACPIFactoryInterface.hxx> #include <HALKit/AMD64/Processor.hpp> #include <NewKit/String.hpp> +#include <ArchKit/ArchKit.hpp> +#include <KernelKit/KernelHeap.hpp> namespace NewOS { @@ -61,44 +63,53 @@ namespace NewOS MUST_PASS(fRsdp); if (!signature) - return ErrorOr<voidPtr>{-2}; + return ErrorOr<voidPtr>{-1}; if (*signature == 0) - return ErrorOr<voidPtr>{-3}; + return ErrorOr<voidPtr>{-1}; RSDP* rsdPtr = reinterpret_cast<RSDP*>(this->fRsdp); if (rsdPtr->Revision <= 1) - { - return ErrorOr<voidPtr>{-4}; - } + return ErrorOr<voidPtr>{-1}; + + RSDT* xsdt = (RSDT*)(rsdPtr->RsdtAddress); - SDT* xsdt = (SDT*)(rsdPtr->XsdtAddress >> (rsdPtr->XsdtAddress & 0xFFF)); + Int64 num = (xsdt->Length - sizeof(SDT)) / sizeof(UInt32); - SizeT num = -(xsdt->Length - sizeof(SDT)) / 8; + if (num < 1) + { + /// stop here, we should have entries... + ke_stop(RUNTIME_CHECK_ACPI); + return ErrorOr<voidPtr>{-1}; + } this->fEntries = num; - kcout << "ACPI: Number of entries: " << number(num) << endl; + kcout << "ACPI: Number of entries: " << number(this->fEntries) << endl; + kcout << "ACPI: Revision: " << number(xsdt->Revision) << endl; + kcout << "ACPI: Signature: " << xsdt->Signature << endl; kcout << "ACPI: Address of XSDT: " << hex_number((UIntPtr)xsdt) << endl; - constexpr short ACPI_SIGNATURE_LENGTH = 4; + const short cAcpiSignatureLength = 4; for (Size index = 0; index < this->fEntries; ++index) { - SDT& sdt = xsdt[index]; + SDT& sdt = *(SDT*)xsdt->AddressArr[index]; + + kcout << "ACPI: Revision: " << number(sdt.CreatorID) << endl; - for (short signature_index = 0; signature_index < ACPI_SIGNATURE_LENGTH; ++signature_index) + for (short signature_index = 0; signature_index < cAcpiSignatureLength; ++signature_index) { if (sdt.Signature[signature_index] != signature[signature_index]) break; - if (signature_index == 4) + if (signature_index == (cAcpiSignatureLength - 1)) return ErrorOr<voidPtr>(reinterpret_cast<voidPtr>(&sdt)); } } - return ErrorOr<voidPtr>{nullptr}; + return ErrorOr<voidPtr>{-1}; } /*** |
