summaryrefslogtreecommitdiff
path: root/Kernel/ACPI
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-04-09 18:03:57 +0200
committerAndreas Kling <kling@serenityos.org>2020-04-09 18:03:57 +0200
commita3ca745b5acc6d09acf07e21105ce0c25ec70f69 (patch)
tree27d41ce98bb0200655972f60deb5511c82607a66 /Kernel/ACPI
parentf614f0e2cb6dc9035fec2b90529500813022cf1c (diff)
downloadserenity-a3ca745b5acc6d09acf07e21105ce0c25ec70f69.zip
Kernel: Use StringView for ACPI table signatures
Diffstat (limited to 'Kernel/ACPI')
-rw-r--r--Kernel/ACPI/ACPIParser.h2
-rw-r--r--Kernel/ACPI/ACPIStaticParser.cpp31
-rw-r--r--Kernel/ACPI/ACPIStaticParser.h2
-rw-r--r--Kernel/ACPI/Definitions.h6
4 files changed, 21 insertions, 20 deletions
diff --git a/Kernel/ACPI/ACPIParser.h b/Kernel/ACPI/ACPIParser.h
index 0fb09fd337..8a69682b5c 100644
--- a/Kernel/ACPI/ACPIParser.h
+++ b/Kernel/ACPI/ACPIParser.h
@@ -47,7 +47,7 @@ public:
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 bool can_reboot() = 0;
diff --git a/Kernel/ACPI/ACPIStaticParser.cpp b/Kernel/ACPI/ACPIStaticParser.cpp
index 042dd7cc0f..292f71f17a 100644
--- a/Kernel/ACPI/ACPIStaticParser.cpp
+++ b/Kernel/ACPI/ACPIStaticParser.cpp
@@ -37,6 +37,11 @@
namespace Kernel {
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()
{
locate_main_system_description_table();
@@ -45,7 +50,7 @@ void StaticParser::locate_static_data()
init_facs();
}
-PhysicalAddress StaticParser::find_table(const char* sig)
+PhysicalAddress StaticParser::find_table(const StringView& signature)
{
#ifdef ACPI_DEBUG
dbg() << "ACPI: Calling Find Table method!";
@@ -55,7 +60,7 @@ PhysicalAddress StaticParser::find_table(const char* sig)
#ifdef ACPI_DEBUG
dbg() << "ACPI: Examining Table @ P " << p_sdt;
#endif
- if (!strncmp(sdt->sig, sig, 4)) {
+ if (!strncmp(sdt->sig, signature.characters_without_null_termination(), 4)) {
#ifdef ACPI_DEBUG
dbg() << "ACPI: Found Table @ P " << p_sdt;
#endif
@@ -256,7 +261,7 @@ void StaticParser::initialize_main_system_description_table()
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) {
auto& xsdt = (const Structures::XSDT&)*sdt;
@@ -343,7 +348,7 @@ static PhysicalAddress find_rsdp_in_bios_area()
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;
auto* sdt = (const u8*)&v_header;
@@ -364,11 +369,11 @@ PhysicalAddress StaticParsing::find_rsdp()
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: 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);
@@ -383,11 +388,11 @@ PhysicalAddress StaticParsing::search_table(PhysicalAddress rsdp_address, const
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: 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);
@@ -398,21 +403,21 @@ PhysicalAddress StaticParsing::search_table_in_xsdt(PhysicalAddress xsdt_address
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: 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);
- 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: 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);
diff --git a/Kernel/ACPI/ACPIStaticParser.h b/Kernel/ACPI/ACPIStaticParser.h
index 905995b16e..506b16de0e 100644
--- a/Kernel/ACPI/ACPIStaticParser.h
+++ b/Kernel/ACPI/ACPIStaticParser.h
@@ -36,7 +36,7 @@ class StaticParser : public Parser {
friend class Parser;
public:
- virtual PhysicalAddress find_table(const char* sig) override;
+ virtual PhysicalAddress find_table(const StringView& signature) override;
virtual void try_acpi_reboot() override;
virtual bool can_reboot() override;
virtual bool can_shutdown() override { return false; }
diff --git a/Kernel/ACPI/Definitions.h b/Kernel/ACPI/Definitions.h
index 37fa9f657d..aa4f5718c5 100644
--- a/Kernel/ACPI/Definitions.h
+++ b/Kernel/ACPI/Definitions.h
@@ -337,11 +337,7 @@ class Parser;
namespace StaticParsing {
PhysicalAddress find_rsdp();
-bool match_table_signature(PhysicalAddress table_header, const char*);
-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);
+PhysicalAddress find_table(PhysicalAddress rsdp, const StringView& signature);
};
}
}