diff options
Diffstat (limited to 'kernel/kapi')
| -rw-r--r-- | kernel/kapi/devices/driver.cpp | 19 | ||||
| -rw-r--r-- | kernel/kapi/devices/error.cpp | 48 |
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 |
