aboutsummaryrefslogtreecommitdiff
path: root/kapi
diff options
context:
space:
mode:
Diffstat (limited to 'kapi')
-rw-r--r--kapi/include/kapi/acpi.hpp44
-rw-r--r--kapi/include/kapi/memory/layout.hpp12
2 files changed, 43 insertions, 13 deletions
diff --git a/kapi/include/kapi/acpi.hpp b/kapi/include/kapi/acpi.hpp
index 1068921..d5e3c87 100644
--- a/kapi/include/kapi/acpi.hpp
+++ b/kapi/include/kapi/acpi.hpp
@@ -2,16 +2,36 @@
#define TEACHOS_KAPI_ACPI_HPP
#include "kapi/memory.hpp"
+
#include <kstd/units>
#include <array>
#include <cstddef>
#include <cstdint>
+#include <span>
#include <string_view>
namespace kapi::acpi
{
+ //! @addtogroup kapi-acpi
+ //! @{
+
+ struct [[gnu::packed]] system_description_table_header
+ {
+ std::array<char, 4> signature;
+ std::uint32_t length;
+ std::uint8_t revision;
+ std::uint8_t checksum;
+ std::array<char, 6> oem_id;
+ std::array<char, 8> oem_table_id;
+ std::uint32_t oem_revision;
+ std::uint32_t creator_id;
+ std::uint32_t create_revision;
+ };
+
+ //! @}
+
//! @addtogroup kapi-acpi-kernel-defined
//! @{
@@ -44,20 +64,18 @@ namespace kapi::acpi
[[maybe_unused]] std::array<std::byte, 3> m_reserved;
};
- //! @}
+ //! Initialize the ACPI subsystem and discover the available tables.
+ //!
+ //! @return true iff. a valid system description tabled was found, false otherwise.
+ auto init(root_system_description_pointer const & sdp) -> bool;
- struct [[gnu::packed]] system_description_table_header
- {
- std::array<char, 4> signature;
- std::uint32_t length;
- std::uint8_t revision;
- std::uint8_t checksum;
- std::array<char, 6> oem_id;
- std::array<char, 8> oem_table_id;
- std::uint32_t oem_revision;
- std::uint32_t creator_id;
- std::uint32_t create_revision;
- };
+ //! Validate and ACPI entity checksum.
+ //!
+ //! @param data The data to validate the checksum of.
+ //! @return true iff. the checksum is valid, false otherwise.
+ auto validate_checksum(std::span<std::byte const> data) -> bool;
+
+ //! @}
} // namespace kapi::acpi
diff --git a/kapi/include/kapi/memory/layout.hpp b/kapi/include/kapi/memory/layout.hpp
index 157f41e..26b48d8 100644
--- a/kapi/include/kapi/memory/layout.hpp
+++ b/kapi/include/kapi/memory/layout.hpp
@@ -37,6 +37,18 @@ namespace kapi::memory
//! The linear base address of the loaded kernel image.
constexpr auto kernel_base = linear_address{0xffff'ffff'8000'0000uz};
+ //! Convert a physical address to a linear address using the higher-half direct map.
+ constexpr auto hhdm_to_linear(physical_address address) -> linear_address
+ {
+ return linear_address{address.raw() + higher_half_direct_map_base.raw()};
+ }
+
+ //! Convert a linear address in the higher-half direct map to a physical address.
+ constexpr auto hhdm_to_physical(linear_address address) -> physical_address
+ {
+ return physical_address{address.raw() - higher_half_direct_map_base.raw()};
+ }
+
} // namespace kapi::memory
#endif \ No newline at end of file