Files
banan-os/kernel/include/kernel/ACPI/AML/Scope.h
Bananymous 3a6cdfff45 Kernel: Fix ACPI namespace initialization
Now _REG, _STA, _INI are called in the order my laptop expects them to
be called. This was kinda weird because what uACPI was doing did not
work.

\_SB_.PCI0.LPC0.EC0_.BAT0._STA required \_SB_.PCI0.LPC0.EC0_._REG to be
called
\_SB_.PCI0.LPC0.EC0_._REG required \_SB_.PCI0._STA to be called

Now I call all the _REG methods of a device after calling _STA/_INI and
after performing the whole _STA/_INI sequence i call rest of missing
_REG functions
2024-12-18 18:30:45 +02:00

75 lines
1.4 KiB
C++

#pragma once
#include <BAN/Hash.h>
#include <BAN/NoCopyMove.h>
#include <BAN/Vector.h>
namespace Kernel::ACPI::AML
{
struct Scope
{
BAN_NON_COPYABLE(Scope);
public:
Scope() = default;
Scope(Scope&& other) { *this = BAN::move(other); }
Scope& operator=(Scope&& other) { parts = BAN::move(other.parts); return *this; }
BAN::Vector<uint32_t> parts;
BAN::ErrorOr<Scope> copy() const
{
Scope result;
TRY(result.parts.reserve(parts.size()));
for (uint32_t part : parts)
TRY(result.parts.push_back(part));
return result;
}
bool operator==(const Scope& other) const
{
if (parts.size() != other.parts.size())
return false;
for (size_t i = 0; i < parts.size(); i++)
if (parts[i] != other.parts[i])
return false;
return true;
}
};
}
namespace BAN
{
template<>
struct hash<Kernel::ACPI::AML::Scope>
{
hash_t operator()(const Kernel::ACPI::AML::Scope& scope) const
{
hash_t hash { 0 };
for (uint32_t part : scope.parts)
hash ^= u32_hash(part);
return hash;
}
};
}
namespace BAN::Formatter
{
template<typename F>
void print_argument(F putc, const Kernel::ACPI::AML::Scope& scope, const ValueFormat&)
{
putc('\\');
for (size_t i = 0; i < scope.parts.size(); i++) {
if (i != 0)
putc('.');
const char* name_seg = reinterpret_cast<const char*>(&scope.parts[i]);
putc(name_seg[0]); putc(name_seg[1]); putc(name_seg[2]); putc(name_seg[3]);
}
}
}