aboutsummaryrefslogtreecommitdiff
path: root/libs/acpi
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-11-12 10:15:32 +0100
committerFelix Morgner <felix.morgner@ost.ch>2026-11-12 14:41:29 +0100
commit83510526b66c17ed26ac86e75eb1632ed0630138 (patch)
tree37e3f9ce9cf7bec850c6307980df047c16e0cb34 /libs/acpi
parentab8de113fb03736e49d89b2cccc31f9cae355500 (diff)
downloadkernel-83510526b66c17ed26ac86e75eb1632ed0630138.tar.xz
kernel-83510526b66c17ed26ac86e75eb1632ed0630138.zip
libs/acpi: don't convert addresses to pointer
Previously, ACPI table addresses in both the RSDT and XSDT were converted to pointers. However, this is not actually correct, since within the object model of the kernel, pointers always refer to objects by their linear address, and the addresses encoded in ACPI tables are, by necessity, physical addresses. The API should therefore be honest about the fact that the addresses returned by accessors of the RSDT and XSDT are physical addresses, not pointers to live objects.
Diffstat (limited to 'libs/acpi')
-rw-r--r--libs/acpi/acpi/data/rsdt.cpp6
-rw-r--r--libs/acpi/acpi/data/rsdt.hpp6
-rw-r--r--libs/acpi/acpi/data/rsdt.tests.cpp2
-rw-r--r--libs/acpi/acpi/data/xsdt.cpp6
-rw-r--r--libs/acpi/acpi/data/xsdt.hpp6
-rw-r--r--libs/acpi/acpi/data/xsdt.tests.cpp2
6 files changed, 12 insertions, 16 deletions
diff --git a/libs/acpi/acpi/data/rsdt.cpp b/libs/acpi/acpi/data/rsdt.cpp
index a8626742..99090beb 100644
--- a/libs/acpi/acpi/data/rsdt.cpp
+++ b/libs/acpi/acpi/data/rsdt.cpp
@@ -1,7 +1,5 @@
#include <acpi/data/rsdt.hpp>
-#include <acpi/common/table_header.hpp>
-
#include <kstd/cstring.hpp>
#include <cstddef>
@@ -16,7 +14,7 @@ namespace acpi
std::uint32_t address;
};
- [[nodiscard]] auto rsdt_entry::address() const noexcept -> table_header *
+ [[nodiscard]] auto rsdt_entry::address() const noexcept -> std::uintptr_t
{
using type = decltype(rsdt_entry_data::address);
@@ -28,7 +26,7 @@ namespace acpi
kstd::libc::memcpy(&value, data.data(), size);
- return reinterpret_cast<table_header *>(static_cast<uintptr_t>(value));
+ return static_cast<std::uintptr_t>(value);
}
[[nodiscard]] auto rsdt_entry::length() const noexcept -> std::size_t
diff --git a/libs/acpi/acpi/data/rsdt.hpp b/libs/acpi/acpi/data/rsdt.hpp
index ca36b33d..843e6cf2 100644
--- a/libs/acpi/acpi/data/rsdt.hpp
+++ b/libs/acpi/acpi/data/rsdt.hpp
@@ -1,13 +1,13 @@
#ifndef ACPI_DATA_RSDT_HPP
#define ACPI_DATA_RSDT_HPP
-#include <acpi/common/table_header.hpp>
#include <acpi/common/table_signature.hpp>
#include <acpi/common/table_type.hpp>
#include <acpi/common/vla_table.hpp>
#include <array>
#include <cstddef>
+#include <cstdint>
namespace acpi
{
@@ -37,8 +37,8 @@ namespace acpi
//! Get the address of the ACPI table pointed to by this entry.
//!
- //! @return A pointer to the ACPI table header of the referenced table.
- [[nodiscard]] auto address() const noexcept -> table_header *;
+ //! @return The physical address of the ACPI table header of the referenced table.
+ [[nodiscard]] auto address() const noexcept -> std::uintptr_t;
//! Get the length of the ACPI table pointed to by this entry.
//!
diff --git a/libs/acpi/acpi/data/rsdt.tests.cpp b/libs/acpi/acpi/data/rsdt.tests.cpp
index c111f749..691fd631 100644
--- a/libs/acpi/acpi/data/rsdt.tests.cpp
+++ b/libs/acpi/acpi/data/rsdt.tests.cpp
@@ -41,7 +41,7 @@ SCENARIO("RSDT parsing", "[rsdt]")
THEN("the first entry has address 0x10")
{
- REQUIRE(rsdt->cbegin()->address() == reinterpret_cast<acpi::table_header *>(0x10));
+ REQUIRE(rsdt->cbegin()->address() == 0x10);
}
THEN("the length is sizeof(rsdt) + 8 * sizeof(rsdt_entry)")
diff --git a/libs/acpi/acpi/data/xsdt.cpp b/libs/acpi/acpi/data/xsdt.cpp
index c4b109b8..6f280889 100644
--- a/libs/acpi/acpi/data/xsdt.cpp
+++ b/libs/acpi/acpi/data/xsdt.cpp
@@ -1,7 +1,5 @@
#include <acpi/data/xsdt.hpp>
-#include <acpi/common/table_header.hpp>
-
#include <kstd/cstring.hpp>
#include <cstddef>
@@ -16,7 +14,7 @@ namespace acpi
std::uint64_t address;
};
- [[nodiscard]] auto xsdt_entry::address() const noexcept -> table_header *
+ [[nodiscard]] auto xsdt_entry::address() const noexcept -> std::uintptr_t
{
using type = decltype(xsdt_entry_data::address);
@@ -28,7 +26,7 @@ namespace acpi
kstd::libc::memcpy(&value, data.data(), size);
- return reinterpret_cast<table_header *>(static_cast<uintptr_t>(value));
+ return static_cast<std::uintptr_t>(value);
}
[[nodiscard]] auto xsdt_entry::length() const noexcept -> std::size_t
diff --git a/libs/acpi/acpi/data/xsdt.hpp b/libs/acpi/acpi/data/xsdt.hpp
index ef268d5f..f8c0a775 100644
--- a/libs/acpi/acpi/data/xsdt.hpp
+++ b/libs/acpi/acpi/data/xsdt.hpp
@@ -1,13 +1,13 @@
#ifndef ACPI_DATA_XSDT_HPP
#define ACPI_DATA_XSDT_HPP
-#include <acpi/common/table_header.hpp>
#include <acpi/common/table_signature.hpp>
#include <acpi/common/table_type.hpp>
#include <acpi/common/vla_table.hpp>
#include <array>
#include <cstddef>
+#include <cstdint>
namespace acpi
{
@@ -37,8 +37,8 @@ namespace acpi
//! Get the address of the ACPI table pointed to by this entry.
//!
- //! @return A pointer to the ACPI table header of the referenced table.
- [[nodiscard]] auto address() const noexcept -> table_header *;
+ //! @return The physical address of the ACPI table header of the referenced table.
+ [[nodiscard]] auto address() const noexcept -> std::uintptr_t;
//! Get the length of the ACPI table pointed to by this entry.
//!
diff --git a/libs/acpi/acpi/data/xsdt.tests.cpp b/libs/acpi/acpi/data/xsdt.tests.cpp
index e5eaed67..955c08df 100644
--- a/libs/acpi/acpi/data/xsdt.tests.cpp
+++ b/libs/acpi/acpi/data/xsdt.tests.cpp
@@ -41,7 +41,7 @@ SCENARIO("XSDT parsing", "[xsdt]")
THEN("the first entry has address 0x10")
{
- REQUIRE(xsdt->cbegin()->address() == reinterpret_cast<acpi::table_header *>(0x10));
+ REQUIRE(xsdt->cbegin()->address() == 0x10);
}
THEN("the length is sizeof(xsdt) + 8 * sizeof(xsdt_entry)")