aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kernel/src/acpi/manager.cpp2
-rw-r--r--libs/acpi/acpi/acpi.hpp1
-rw-r--r--libs/acpi/acpi/common/basic_table.hpp25
-rw-r--r--libs/acpi/acpi/common/vla_table.hpp4
-rw-r--r--libs/acpi/acpi/data/madt.test.cpp2
-rw-r--r--libs/acpi/acpi/data/rsdt.cpp1
-rw-r--r--libs/acpi/acpi/data/rsdt.hpp1
-rw-r--r--libs/acpi/acpi/data/rsdt.test.cpp2
8 files changed, 10 insertions, 28 deletions
diff --git a/kernel/src/acpi/manager.cpp b/kernel/src/acpi/manager.cpp
index 41469c2..2f2a1bd 100644
--- a/kernel/src/acpi/manager.cpp
+++ b/kernel/src/acpi/manager.cpp
@@ -43,7 +43,7 @@ namespace kernel::acpi
}
auto physical_root_table_address = kapi::memory::physical_address{m_sdp->table_address()};
auto linear_root_table_address = kapi::memory::hhdm_to_linear(physical_root_table_address);
- m_rsdt = static_cast<::acpi::table_header const *>(linear_root_table_address);
+ m_rsdt = static_cast<::acpi::rsdt const *>(linear_root_table_address);
}
}
diff --git a/libs/acpi/acpi/acpi.hpp b/libs/acpi/acpi/acpi.hpp
index 4cfcede..385ddc9 100644
--- a/libs/acpi/acpi/acpi.hpp
+++ b/libs/acpi/acpi/acpi.hpp
@@ -5,6 +5,7 @@
#include <acpi/common/table_signature.hpp> // IWYU pragma: export
#include <acpi/common/table_type.hpp> // IWYU pragma: export
#include <acpi/data/madt.hpp> // IWYU pragma: export
+#include <acpi/data/rsdt.hpp> // IWYU pragma: export
#include <acpi/pointers.hpp> // IWYU pragma: export
#endif
diff --git a/libs/acpi/acpi/common/basic_table.hpp b/libs/acpi/acpi/common/basic_table.hpp
index b0ead96..33f23d5 100644
--- a/libs/acpi/acpi/common/basic_table.hpp
+++ b/libs/acpi/acpi/common/basic_table.hpp
@@ -7,46 +7,27 @@
#include <cstddef>
#include <span>
-#include <string_view>
namespace acpi
{
template<typename TableType>
- struct basic_table
+ struct basic_table : table_header
{
[[nodiscard]] auto validate_checksum() const noexcept -> bool
{
- return acpi::validate_checksum({reinterpret_cast<std::byte const *>(this), m_header.length().value});
+ return acpi::validate_checksum(as_span());
}
[[nodiscard]] auto as_span() const noexcept -> std::span<std::byte const>
{
- return {reinterpret_cast<std::byte const *>(this), m_header.length().value};
- }
-
- [[nodiscard]] auto header() const noexcept -> table_header const &
- {
- return m_header;
- }
-
- [[nodiscard]] auto length() const noexcept -> std::size_t
- {
- return m_header.length().value;
- }
-
- [[nodiscard]] auto signature() const noexcept -> std::string_view
- {
- return m_header.signature();
+ return {reinterpret_cast<std::byte const *>(this), length().value};
}
[[nodiscard]] auto validate() const noexcept -> bool
{
return signature() == table_signature_v<TableType> && validate_checksum();
}
-
- private:
- table_header m_header;
};
} // namespace acpi
diff --git a/libs/acpi/acpi/common/vla_table.hpp b/libs/acpi/acpi/common/vla_table.hpp
index 450209c..a65a28e 100644
--- a/libs/acpi/acpi/common/vla_table.hpp
+++ b/libs/acpi/acpi/common/vla_table.hpp
@@ -77,7 +77,7 @@ namespace acpi
auto base = std::bit_cast<std::byte *>(this);
base += sizeof(TableType);
auto limit = std::bit_cast<std::byte *>(this);
- limit += this->length();
+ limit += this->length().value;
return iterator{std::bit_cast<entry_type *>(base), std::bit_cast<entry_type *>(limit)};
}
@@ -91,7 +91,7 @@ namespace acpi
auto base = std::bit_cast<std::byte *>(this);
base += sizeof(TableType);
auto limit = std::bit_cast<std::byte *>(this);
- limit += this->length();
+ limit += this->length().value;
return const_iterator{std::bit_cast<entry_type const *>(base), std::bit_cast<entry_type const *>(limit)};
}
diff --git a/libs/acpi/acpi/data/madt.test.cpp b/libs/acpi/acpi/data/madt.test.cpp
index 2b74d4c..6795499 100644
--- a/libs/acpi/acpi/data/madt.test.cpp
+++ b/libs/acpi/acpi/data/madt.test.cpp
@@ -38,7 +38,7 @@ SCENARIO("MADT parsing", "[madt]")
THEN("the length is sizeof(madt) + sizeof(processor_local_apic)")
{
- REQUIRE(madt->length() == sizeof(acpi::madt) + sizeof(acpi::processor_local_apic_entry));
+ REQUIRE(madt->length().value == sizeof(acpi::madt) + sizeof(acpi::processor_local_apic_entry));
}
THEN("the first entry has type processor_local_apic")
diff --git a/libs/acpi/acpi/data/rsdt.cpp b/libs/acpi/acpi/data/rsdt.cpp
index 8e20b6c..fe108c7 100644
--- a/libs/acpi/acpi/data/rsdt.cpp
+++ b/libs/acpi/acpi/data/rsdt.cpp
@@ -5,6 +5,7 @@
#include <cstddef>
#include <cstdint>
+#include <span>
namespace acpi
{
diff --git a/libs/acpi/acpi/data/rsdt.hpp b/libs/acpi/acpi/data/rsdt.hpp
index b43f066..88c5fd1 100644
--- a/libs/acpi/acpi/data/rsdt.hpp
+++ b/libs/acpi/acpi/data/rsdt.hpp
@@ -1,7 +1,6 @@
#ifndef ACPI_DATA_RSDT_HPP
#define ACPI_DATA_RSDT_HPP
-#include <acpi/acpi.hpp>
#include <acpi/common/table_signature.hpp>
#include <acpi/common/table_type.hpp>
#include <acpi/common/vla_table.hpp>
diff --git a/libs/acpi/acpi/data/rsdt.test.cpp b/libs/acpi/acpi/data/rsdt.test.cpp
index e1bd1df..937dce0 100644
--- a/libs/acpi/acpi/data/rsdt.test.cpp
+++ b/libs/acpi/acpi/data/rsdt.test.cpp
@@ -39,7 +39,7 @@ SCENARIO("RSDT parsing", "[rsdt]")
THEN("the length is sizeof(rsdt) + 8 * sizeof(rsdt_entry)")
{
- REQUIRE(rsdt->length() == sizeof(acpi::rsdt) + 8 * sizeof(acpi::rsdt_entry));
+ REQUIRE(rsdt->length().value == sizeof(acpi::rsdt) + 8 * sizeof(acpi::rsdt_entry));
}
}
}