diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-03-31 21:56:37 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-04-02 11:28:08 +0200 |
| commit | e7abfb7bf87ac605b2168891973d7e04a84d627e (patch) | |
| tree | 0cfd76ecab2d523d8e8b6565ed0efe915963111e /kapi | |
| parent | 1f010078983e6ab4e74ee3d1efcfb3284620b002 (diff) | |
| download | teachos-e7abfb7bf87ac605b2168891973d7e04a84d627e.tar.xz teachos-e7abfb7bf87ac605b2168891973d7e04a84d627e.zip | |
kapi/devices: introduce basic bus abstraction
Diffstat (limited to 'kapi')
| -rw-r--r-- | kapi/include/kapi/devices/bus.hpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/kapi/include/kapi/devices/bus.hpp b/kapi/include/kapi/devices/bus.hpp new file mode 100644 index 0000000..cf8d090 --- /dev/null +++ b/kapi/include/kapi/devices/bus.hpp @@ -0,0 +1,40 @@ +#ifndef TEACHOS_KAPI_DEVICES_BUS_HPP +#define TEACHOS_KAPI_DEVICES_BUS_HPP + +#include "kapi/devices/device.hpp" + +#include <kstd/memory> +#include <kstd/string> +#include <kstd/vector> + +#include <cstddef> + +namespace kapi::devices +{ + //! A bus device that represents a logical/physical tree of devices and busses. + struct bus : device + { + //! Construct a bus with the given major number, minor number, and name. + //! + //! @param major The major number of the bus. + //! @param minor The minor number of the bus. + //! @param name The name of the bus. + bus(std::size_t major, std::size_t minor, kstd::string const & name) + : device(major, minor, name) + {} + + //! Attach a child device to this bus. + //! + //! Whenever a device is attached to a bus, the bus takes sole ownership of the device. + //! + //! @param child The child device to attach. + virtual auto add_child(kstd::unique_ptr<device> child) -> void = 0; + + //! Get a list of all child devices attached to this bus. + //! + //! @return A reference to list of child devices of this bus. + [[nodiscard]] virtual auto children() const -> kstd::vector<device *> const & = 0; + }; +} // namespace kapi::devices + +#endif
\ No newline at end of file |
