diff options
Diffstat (limited to 'kapi')
| -rw-r--r-- | kapi/kapi/boot_module/bus.hpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/kapi/kapi/boot_module/bus.hpp b/kapi/kapi/boot_module/bus.hpp new file mode 100644 index 00000000..e569b253 --- /dev/null +++ b/kapi/kapi/boot_module/bus.hpp @@ -0,0 +1,71 @@ +#ifndef TEACHOS_KAPI_BOOT_MODULE_BUS_HPP +#define TEACHOS_KAPI_BOOT_MODULE_BUS_HPP + +#include <kapi/boot_module/boot_module.hpp> +#include <kapi/boot_module/boot_module_registry.hpp> +#include <kapi/devices.hpp> + +#include <kstd/result.hpp> + +#include <cstddef> +#include <string_view> +#include <utility> + +namespace kapi::boot_modules +{ + + struct boot_module_identification + { + constexpr auto static id = devices::interface{"boot_module_identification"}; + + virtual ~boot_module_identification() = default; + + [[nodiscard]] auto virtual command_line() const -> std::string_view = 0; + + [[nodiscard]] auto virtual module() const -> boot_module const & = 0; + }; + + struct boot_module_driver_identification + { + constexpr auto static id = devices::interface{"boot_module_driver_identification"}; + + virtual ~boot_module_driver_identification() = default; + + [[nodiscard]] virtual auto claimed_parameter() const -> std::pair<std::string_view, std::string_view> = 0; + }; + + struct boot_module_device final : kapi::devices::device, boot_module_identification + { + boot_module_device(std::size_t index, boot_module const & module); + + auto init() -> bool override; + + auto command_line() const -> std::string_view override; + + auto module() const -> boot_module const & override; + + protected: + auto query_interface(kapi::devices::interface interface) -> void * override; + + private: + boot_module m_module; + }; + + struct boot_module_bus final : kapi::devices::bus, kapi::devices::bus_protocol + { + explicit boot_module_bus(boot_module_registry const * registry); + + auto enumerate(kapi::devices::bus & self) -> void override; + + [[nodiscard]] auto match(kapi::devices::device const & dev, kapi::devices::driver const & drv) const + -> kstd::result<unsigned> override; + + [[nodiscard]] auto protocol() -> kapi::devices::bus_protocol * override; + + private: + boot_module_registry const * m_registry; + }; + +} // namespace kapi::boot_modules + +#endif
\ No newline at end of file |
