mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:37:46 +00:00
Kernel: Use StringView for ACPI table signatures
This commit is contained in:
parent
f614f0e2cb
commit
a3ca745b5a
5 changed files with 22 additions and 21 deletions
|
@ -47,7 +47,7 @@ public:
|
||||||
set_the(*new ParserType(rsdp));
|
set_the(*new ParserType(rsdp));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual PhysicalAddress find_table(const char* sig) = 0;
|
virtual PhysicalAddress find_table(const StringView& signature) = 0;
|
||||||
|
|
||||||
virtual void try_acpi_reboot() = 0;
|
virtual void try_acpi_reboot() = 0;
|
||||||
virtual bool can_reboot() = 0;
|
virtual bool can_reboot() = 0;
|
||||||
|
|
|
@ -37,6 +37,11 @@
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
namespace ACPI {
|
namespace ACPI {
|
||||||
|
|
||||||
|
static bool match_table_signature(PhysicalAddress table_header, const StringView& signature);
|
||||||
|
static PhysicalAddress search_table_in_xsdt(PhysicalAddress xsdt, const StringView& signature);
|
||||||
|
static PhysicalAddress search_table_in_rsdt(PhysicalAddress rsdt, const StringView& signature);
|
||||||
|
static bool validate_table(const Structures::SDTHeader&, size_t length);
|
||||||
|
|
||||||
void StaticParser::locate_static_data()
|
void StaticParser::locate_static_data()
|
||||||
{
|
{
|
||||||
locate_main_system_description_table();
|
locate_main_system_description_table();
|
||||||
|
@ -45,7 +50,7 @@ void StaticParser::locate_static_data()
|
||||||
init_facs();
|
init_facs();
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicalAddress StaticParser::find_table(const char* sig)
|
PhysicalAddress StaticParser::find_table(const StringView& signature)
|
||||||
{
|
{
|
||||||
#ifdef ACPI_DEBUG
|
#ifdef ACPI_DEBUG
|
||||||
dbg() << "ACPI: Calling Find Table method!";
|
dbg() << "ACPI: Calling Find Table method!";
|
||||||
|
@ -55,7 +60,7 @@ PhysicalAddress StaticParser::find_table(const char* sig)
|
||||||
#ifdef ACPI_DEBUG
|
#ifdef ACPI_DEBUG
|
||||||
dbg() << "ACPI: Examining Table @ P " << p_sdt;
|
dbg() << "ACPI: Examining Table @ P " << p_sdt;
|
||||||
#endif
|
#endif
|
||||||
if (!strncmp(sdt->sig, sig, 4)) {
|
if (!strncmp(sdt->sig, signature.characters_without_null_termination(), 4)) {
|
||||||
#ifdef ACPI_DEBUG
|
#ifdef ACPI_DEBUG
|
||||||
dbg() << "ACPI: Found Table @ P " << p_sdt;
|
dbg() << "ACPI: Found Table @ P " << p_sdt;
|
||||||
#endif
|
#endif
|
||||||
|
@ -256,7 +261,7 @@ void StaticParser::initialize_main_system_description_table()
|
||||||
|
|
||||||
auto sdt = map_typed<Structures::SDTHeader>(m_main_system_description_table, length);
|
auto sdt = map_typed<Structures::SDTHeader>(m_main_system_description_table, length);
|
||||||
|
|
||||||
klog() << "ACPI: Main Description Table valid? " << StaticParsing::validate_table(*sdt, length);
|
klog() << "ACPI: Main Description Table valid? " << validate_table(*sdt, length);
|
||||||
|
|
||||||
if (m_xsdt_supported) {
|
if (m_xsdt_supported) {
|
||||||
auto& xsdt = (const Structures::XSDT&)*sdt;
|
auto& xsdt = (const Structures::XSDT&)*sdt;
|
||||||
|
@ -343,7 +348,7 @@ static PhysicalAddress find_rsdp_in_bios_area()
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool StaticParsing::validate_table(const Structures::SDTHeader& v_header, size_t length)
|
static bool validate_table(const Structures::SDTHeader& v_header, size_t length)
|
||||||
{
|
{
|
||||||
u8 checksum = 0;
|
u8 checksum = 0;
|
||||||
auto* sdt = (const u8*)&v_header;
|
auto* sdt = (const u8*)&v_header;
|
||||||
|
@ -364,11 +369,11 @@ PhysicalAddress StaticParsing::find_rsdp()
|
||||||
return find_rsdp_in_bios_area();
|
return find_rsdp_in_bios_area();
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicalAddress StaticParsing::search_table(PhysicalAddress rsdp_address, const char* signature)
|
PhysicalAddress StaticParsing::find_table(PhysicalAddress rsdp_address, const StringView& signature)
|
||||||
{
|
{
|
||||||
// FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
|
// FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
|
||||||
// FIXME: Don't blindly use PAGE_SIZE here, but probe the actual length.
|
// FIXME: Don't blindly use PAGE_SIZE here, but probe the actual length.
|
||||||
ASSERT(strlen(signature) == 4);
|
ASSERT(signature.length() == 4);
|
||||||
|
|
||||||
auto rsdp = map_typed<Structures::RSDPDescriptor20>(rsdp_address);
|
auto rsdp = map_typed<Structures::RSDPDescriptor20>(rsdp_address);
|
||||||
|
|
||||||
|
@ -383,11 +388,11 @@ PhysicalAddress StaticParsing::search_table(PhysicalAddress rsdp_address, const
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicalAddress StaticParsing::search_table_in_xsdt(PhysicalAddress xsdt_address, const char* signature)
|
static PhysicalAddress search_table_in_xsdt(PhysicalAddress xsdt_address, const StringView& signature)
|
||||||
{
|
{
|
||||||
// FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
|
// FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
|
||||||
// FIXME: Don't blindly use PAGE_SIZE here, but probe the actual length.
|
// FIXME: Don't blindly use PAGE_SIZE here, but probe the actual length.
|
||||||
ASSERT(strlen(signature) == 4);
|
ASSERT(signature.length() == 4);
|
||||||
|
|
||||||
auto xsdt = map_typed<Structures::XSDT>(xsdt_address);
|
auto xsdt = map_typed<Structures::XSDT>(xsdt_address);
|
||||||
|
|
||||||
|
@ -398,21 +403,21 @@ PhysicalAddress StaticParsing::search_table_in_xsdt(PhysicalAddress xsdt_address
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StaticParsing::match_table_signature(PhysicalAddress table_header, const char* signature)
|
static bool match_table_signature(PhysicalAddress table_header, const StringView& signature)
|
||||||
{
|
{
|
||||||
// FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
|
// FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
|
||||||
// FIXME: Don't blindly use PAGE_SIZE here, but probe the actual length.
|
// FIXME: Don't blindly use PAGE_SIZE here, but probe the actual length.
|
||||||
ASSERT(strlen(signature) == 4);
|
ASSERT(signature.length() == 4);
|
||||||
|
|
||||||
auto table = map_typed<Structures::RSDT>(table_header);
|
auto table = map_typed<Structures::RSDT>(table_header);
|
||||||
return !strncmp(table->h.sig, signature, 4);
|
return !strncmp(table->h.sig, signature.characters_without_null_termination(), 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicalAddress StaticParsing::search_table_in_rsdt(PhysicalAddress rsdt_address, const char* signature)
|
static PhysicalAddress search_table_in_rsdt(PhysicalAddress rsdt_address, const StringView& signature)
|
||||||
{
|
{
|
||||||
// FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
|
// FIXME: There's no validation of ACPI tables here. Use the checksum to validate the tables.
|
||||||
// FIXME: Don't blindly use PAGE_SIZE here, but probe the actual length.
|
// FIXME: Don't blindly use PAGE_SIZE here, but probe the actual length.
|
||||||
ASSERT(strlen(signature) == 4);
|
ASSERT(signature.length() == 4);
|
||||||
|
|
||||||
auto rsdt = map_typed<Structures::RSDT>(rsdt_address);
|
auto rsdt = map_typed<Structures::RSDT>(rsdt_address);
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ class StaticParser : public Parser {
|
||||||
friend class Parser;
|
friend class Parser;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual PhysicalAddress find_table(const char* sig) override;
|
virtual PhysicalAddress find_table(const StringView& signature) override;
|
||||||
virtual void try_acpi_reboot() override;
|
virtual void try_acpi_reboot() override;
|
||||||
virtual bool can_reboot() override;
|
virtual bool can_reboot() override;
|
||||||
virtual bool can_shutdown() override { return false; }
|
virtual bool can_shutdown() override { return false; }
|
||||||
|
|
|
@ -337,11 +337,7 @@ class Parser;
|
||||||
|
|
||||||
namespace StaticParsing {
|
namespace StaticParsing {
|
||||||
PhysicalAddress find_rsdp();
|
PhysicalAddress find_rsdp();
|
||||||
bool match_table_signature(PhysicalAddress table_header, const char*);
|
PhysicalAddress find_table(PhysicalAddress rsdp, const StringView& signature);
|
||||||
PhysicalAddress search_table(PhysicalAddress rsdp, const char*);
|
|
||||||
PhysicalAddress search_table_in_xsdt(PhysicalAddress xsdt, const char*);
|
|
||||||
PhysicalAddress search_table_in_rsdt(PhysicalAddress rsdt, const char*);
|
|
||||||
bool validate_table(const Structures::SDTHeader&, size_t length);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ PhysicalAddress InterruptManagement::search_for_madt()
|
||||||
auto rsdp = ACPI::StaticParsing::find_rsdp();
|
auto rsdp = ACPI::StaticParsing::find_rsdp();
|
||||||
if (rsdp.is_null())
|
if (rsdp.is_null())
|
||||||
return {};
|
return {};
|
||||||
return ACPI::StaticParsing::search_table(rsdp, "APIC");
|
return ACPI::StaticParsing::find_table(rsdp, "APIC");
|
||||||
}
|
}
|
||||||
|
|
||||||
InterruptManagement::InterruptManagement()
|
InterruptManagement::InterruptManagement()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue