Kernel: Fix AML package parsing

This commit is contained in:
Bananymous 2024-04-07 20:32:22 +03:00
parent e01c049401
commit 22bc4b4271
2 changed files with 6 additions and 2 deletions

View File

@ -58,9 +58,10 @@ namespace Kernel::ACPI::AML
}; };
struct DataRefObject; struct DataRefObject;
struct Uninitialized {};
// PackageElement := DataRefObject | NameString // PackageElement := DataRefObject | NameString
using PackageElement = BAN::Variant<BAN::UniqPtr<DataRefObject>, NameString>; using PackageElement = BAN::Variant<BAN::UniqPtr<DataRefObject>, NameString, Uninitialized>;
// DefPackage := PackageOp PkgLength NumElements PackageElementList // DefPackage := PackageOp PkgLength NumElements PackageElementList
struct Package struct Package

View File

@ -198,7 +198,7 @@ namespace Kernel::ACPI
AML_DEBUG_PRINT("Count: {}", count); \ AML_DEBUG_PRINT("Count: {}", count); \
\ \
BAN::Vector<PackageElement> elements; \ BAN::Vector<PackageElement> elements; \
for (uint8_t i = 0; i < count; i++) \ for (uint8_t i = 0; package_span.size() > 0 && i < count; i++) \
{ \ { \
if (DataRefObject::can_parse(package_span)) \ if (DataRefObject::can_parse(package_span)) \
{ \ { \
@ -221,6 +221,9 @@ namespace Kernel::ACPI
} \ } \
} \ } \
\ \
while (elements.size() < count) \
MUST(elements.push_back(PackageElement { Uninitialized {} })); \
\
return NAME { .elements = BAN::move(elements) }; \ return NAME { .elements = BAN::move(elements) }; \
} }