From cb87b4dd8e874d5d7b219487ca38f55756c205df Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 23 Jul 2026 18:52:24 +0200 Subject: kapi: introduce driver and bus protocol --- kernel/kapi/devices/error.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 kernel/kapi/devices/error.cpp (limited to 'kernel/kapi/devices/error.cpp') 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 + +#include + +#include +#include + +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(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 -- cgit v1.2.3