aboutsummaryrefslogtreecommitdiff
path: root/kernel/kapi/devices
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-07-23 18:52:24 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-07-23 18:52:24 +0200
commitcb87b4dd8e874d5d7b219487ca38f55756c205df (patch)
tree708c018ecf05db1565433b17c69cc40dc4e96680 /kernel/kapi/devices
parent969c2018d2d3741022818e3bc326b57162748053 (diff)
downloadkernel-cb87b4dd8e874d5d7b219487ca38f55756c205df.tar.xz
kernel-cb87b4dd8e874d5d7b219487ca38f55756c205df.zip
kapi: introduce driver and bus protocol
Diffstat (limited to 'kernel/kapi/devices')
-rw-r--r--kernel/kapi/devices/driver.cpp19
-rw-r--r--kernel/kapi/devices/error.cpp48
2 files changed, 67 insertions, 0 deletions
diff --git a/kernel/kapi/devices/driver.cpp b/kernel/kapi/devices/driver.cpp
new file mode 100644
index 00000000..c6b5e056
--- /dev/null
+++ b/kernel/kapi/devices/driver.cpp
@@ -0,0 +1,19 @@
+#include <kapi/devices.hpp>
+
+#include <cstdint>
+#include <optional>
+
+namespace kapi::devices
+{
+
+ auto driver::claimed_major() const -> std::optional<std::uint8_t>
+ {
+ return std::nullopt;
+ }
+
+ auto driver::query_interface(interface) -> void *
+ {
+ return nullptr;
+ }
+
+} // namespace kapi::devices
diff --git a/kernel/kapi/devices/error.cpp b/kernel/kapi/devices/error.cpp
new file mode 100644
index 00000000..9d814fbe
--- /dev/null
+++ b/kernel/kapi/devices/error.cpp
@@ -0,0 +1,48 @@
+#include <kapi/devices/error.hpp>
+
+#include <kstd/system_error.hpp>
+
+#include <string_view>
+#include <utility>
+
+namespace kapi::devices
+{
+
+ namespace
+ {
+ struct driver_match_category_t final : kstd::error_category
+ {
+ [[nodiscard]] auto name() const noexcept -> std::string_view override
+ {
+ return "driver_match";
+ }
+
+ [[nodiscard]] auto message(int value) const noexcept -> std::string_view override
+ {
+ switch (static_cast<driver_match_errc>(value))
+ {
+ case driver_match_errc::no_match:
+ return "driver does not match this device";
+ default:
+ return "unknown driver matching error";
+ }
+ }
+
+ [[nodiscard]] auto default_error_condition(int value) const noexcept -> kstd::error_condition override
+ {
+ if (value == std::to_underlying(driver_match_errc::no_match))
+ {
+ return make_error_condition(kstd::errc::not_supported);
+ }
+ return kstd::error_category::default_error_condition(value);
+ }
+
+ } constexpr driver_match_category_instance{};
+ } // namespace
+
+ auto driver_match_category() noexcept -> kstd::error_category const &
+ {
+ return driver_match_category_instance;
+ }
+
+} // namespace kapi::devices \ No newline at end of file