aboutsummaryrefslogtreecommitdiff
path: root/kapi
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-08-01 00:33:56 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-08-01 00:33:56 +0200
commit5ce5c28e0f0f034cb7c704f08e59089ef303ff7e (patch)
tree6340aef7cee1948d3b6321e83f8c5976ef192180 /kapi
parent2c9b29799dbf6a706d235d79a3257fc9a42d12d3 (diff)
downloadkernel-5ce5c28e0f0f034cb7c704f08e59089ef303ff7e.tar.xz
kernel-5ce5c28e0f0f034cb7c704f08e59089ef303ff7e.zip
kapi: add automatic driver registrationHEADdevelop
Diffstat (limited to 'kapi')
-rw-r--r--kapi/kapi/devices/driver_registry.hpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/kapi/kapi/devices/driver_registry.hpp b/kapi/kapi/devices/driver_registry.hpp
index 8af76b01..196b14c1 100644
--- a/kapi/kapi/devices/driver_registry.hpp
+++ b/kapi/kapi/devices/driver_registry.hpp
@@ -8,9 +8,45 @@
#include <kstd/memory.hpp>
#include <kstd/vector.hpp>
+#include <string_view>
+
namespace kapi::devices
{
+ //! @addtogroup kapi-devices
+ //! @{
+
+ struct driver_descriptor
+ {
+ virtual ~driver_descriptor() = default;
+
+ //! Get the name of the driver
+ [[nodiscard]] virtual auto name() const noexcept -> std::string_view = 0;
+
+ //! Create a new instance of the driver represented by this descriptor.
+ [[nodiscard]] virtual auto make_instance() const -> kstd::shared_ptr<driver> = 0;
+ };
+
+ template<typename Type>
+ struct kernel_driver
+ {
+ constexpr auto static instance = Type{};
+ [[using gnu: section("kernel_drivers"), used, visibility("hidden")]] constexpr auto static pointer{
+ kstd::make_observer<kapi::devices::driver_descriptor const>(&instance),
+ };
+ };
+
+ template<typename Type>
+ struct platform_driver
+ {
+ constexpr auto static instance = Type{};
+ [[using gnu: section("platform_drivers"), used, visibility("hidden")]] constexpr auto static pointer{
+ kstd::make_observer<kapi::devices::driver_descriptor const>(&instance),
+ };
+ };
+
+ //! @}
+
//! @addtogroup kapi-devices-kernel-defined
//! @{