aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-04-06 19:04:40 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-04-06 19:04:40 +0200
commitfe26083101537df306153e7bea7c291a041897f7 (patch)
tree0f26687fb172fc1852e9c4d58c351a76e9ceb50c /libs
parent2a3575a267dede6a364386c0bd6edcff92421f0d (diff)
parentd5c2e101d62f6b4b69c45c127e7a729d246da566 (diff)
downloadteachos-fe26083101537df306153e7bea7c291a041897f7.tar.xz
teachos-fe26083101537df306153e7bea7c291a041897f7.zip
Merge branch 'fmorgner/develop-BA-FS26/apci' into develop-BA-FS26
This patchset introduces basic support for ACPI. Currently, the only user of that support is the CPU discovery subsystem. It uses the processed ACPI information to initialize CPU core devices and their associated local APICs.
Diffstat (limited to 'libs')
-rw-r--r--libs/kstd/include/kstd/flat_map18
-rw-r--r--libs/kstd/include/kstd/units7
-rw-r--r--libs/multiboot2/include/multiboot2/constants/information_id.hpp8
-rw-r--r--libs/multiboot2/include/multiboot2/information.hpp43
-rw-r--r--libs/multiboot2/include/multiboot2/information/data.hpp12
5 files changed, 81 insertions, 7 deletions
diff --git a/libs/kstd/include/kstd/flat_map b/libs/kstd/include/kstd/flat_map
index 6ffbbcf..3b13754 100644
--- a/libs/kstd/include/kstd/flat_map
+++ b/libs/kstd/include/kstd/flat_map
@@ -205,6 +205,24 @@ namespace kstd
return const_reverse_iterator{cbegin()};
}
+ //! Check whether this flat map is empty or not
+ [[nodiscard]] auto empty() const noexcept -> bool
+ {
+ return m_containers.keys.empty();
+ }
+
+ //! Get the number of elements in this flat map.
+ [[nodiscard]] auto size() const noexcept -> size_type
+ {
+ return m_containers.keys.size();
+ }
+
+ //! Get the maximum number of elements possible in this flat map
+ [[nodiscard]] auto max_size() const noexcept -> size_type
+ {
+ return std::min(m_containers.keys.max_size(), m_containers.values.max_size());
+ }
+
//! Try to insert a new key-value pair into the map.
//!
//! @param args Arguments to use for constructing the key-value pair.
diff --git a/libs/kstd/include/kstd/units b/libs/kstd/include/kstd/units
index f6dcdb1..bc7e1b9 100644
--- a/libs/kstd/include/kstd/units
+++ b/libs/kstd/include/kstd/units
@@ -14,6 +14,11 @@ namespace kstd
{
using value_type = ValueType;
+ constexpr basic_unit() noexcept
+ : value{}
+ {
+ }
+
explicit constexpr basic_unit(value_type value) noexcept
: value{value}
{}
@@ -142,4 +147,4 @@ namespace kstd
} // namespace kstd
-#endif \ No newline at end of file
+#endif
diff --git a/libs/multiboot2/include/multiboot2/constants/information_id.hpp b/libs/multiboot2/include/multiboot2/constants/information_id.hpp
index be492eb..27c5300 100644
--- a/libs/multiboot2/include/multiboot2/constants/information_id.hpp
+++ b/libs/multiboot2/include/multiboot2/constants/information_id.hpp
@@ -57,10 +57,10 @@ namespace multiboot2
smbios_tables,
//! A copy of RSDP as defined per ACPI 1.0 specification.
- acpi_old_rsdp,
+ acpi_rsdp,
- //! A copy of RSDP as defined per ACPI 2.0 or later specification.
- acpi_new_rsdp,
+ //! A copy of XSDP as defined per ACPI 2.0 or later specification.
+ acpi_xsdp,
//! The network information specified specified as per DHCP.
networking_information,
@@ -83,4 +83,4 @@ namespace multiboot2
} // namespace multiboot2
-#endif \ No newline at end of file
+#endif
diff --git a/libs/multiboot2/include/multiboot2/information.hpp b/libs/multiboot2/include/multiboot2/information.hpp
index d2fac2e..a2ded56 100644
--- a/libs/multiboot2/include/multiboot2/information.hpp
+++ b/libs/multiboot2/include/multiboot2/information.hpp
@@ -11,6 +11,7 @@
#include <elf/section_header.hpp>
#include <algorithm>
+#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <optional>
@@ -128,6 +129,26 @@ namespace multiboot2
return kstd::units::bytes{end_address - start_address};
}
};
+
+ struct acpi_rsdp : vla_tag<data::acpi_rsdp, std::byte, std::span>
+ {
+ using vla_tag::vla_tag;
+
+ [[nodiscard]] auto pointer() const noexcept -> range_type
+ {
+ return {data(), size()};
+ }
+ };
+
+ struct acpi_xsdp : vla_tag<data::acpi_xsdp, std::byte, std::span>
+ {
+ using vla_tag::vla_tag;
+
+ [[nodiscard]] auto pointer() const noexcept -> range_type
+ {
+ return {data(), size()};
+ }
+ };
struct information_view
{
@@ -245,6 +266,26 @@ namespace multiboot2
std::views::transform(transform_module);
}
+ [[nodiscard]] auto maybe_acpi_rsdp() const noexcept -> std::optional<acpi_rsdp>
+ {
+ return get<multiboot2::acpi_rsdp>();
+ }
+
+ [[nodiscard]] auto acpi_rsdp() const noexcept -> acpi_rsdp
+ {
+ return maybe_acpi_rsdp().value();
+ }
+
+ [[nodiscard]] auto maybe_acpi_xsdp() const noexcept -> std::optional<acpi_xsdp>
+ {
+ return get<multiboot2::acpi_xsdp>();
+ }
+
+ [[nodiscard]] auto acpi_xsdp() const noexcept -> acpi_xsdp
+ {
+ return maybe_acpi_xsdp().value();
+ }
+
private:
template<typename Tag>
[[nodiscard]] constexpr auto get() const noexcept -> std::optional<Tag>
@@ -264,4 +305,4 @@ namespace multiboot2
} // namespace multiboot2
-#endif \ No newline at end of file
+#endif
diff --git a/libs/multiboot2/include/multiboot2/information/data.hpp b/libs/multiboot2/include/multiboot2/information/data.hpp
index 3b07d20..315eb39 100644
--- a/libs/multiboot2/include/multiboot2/information/data.hpp
+++ b/libs/multiboot2/include/multiboot2/information/data.hpp
@@ -167,8 +167,18 @@ namespace multiboot2
std::uint32_t end_address;
};
+ //! A copy of the ACPI RSDP
+ struct acpi_rsdp : tag_data<information_id::acpi_rsdp>
+ {
+ };
+
+ //! A copy of the ACPI XSDP
+ struct acpi_xsdp : tag_data<information_id::acpi_xsdp>
+ {
+ };
+
} // namespace data
} // namespace multiboot2
-#endif \ No newline at end of file
+#endif