diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-04-02 13:59:27 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-04-02 14:02:13 +0200 |
| commit | b84c4c9d8c90f3d3fd5a60de282278912fad2f04 (patch) | |
| tree | ac283ed18407a8e97bcd14b2cfca3da74f60547b /arch/x86_64/src | |
| parent | d0c532af74d8d486d734904fd330d5dae7f49754 (diff) | |
| download | teachos-b84c4c9d8c90f3d3fd5a60de282278912fad2f04.tar.xz teachos-b84c4c9d8c90f3d3fd5a60de282278912fad2f04.zip | |
x86_64/devices: implement ISA bus stub
Diffstat (limited to 'arch/x86_64/src')
| -rw-r--r-- | arch/x86_64/src/bus/isa.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/arch/x86_64/src/bus/isa.cpp b/arch/x86_64/src/bus/isa.cpp new file mode 100644 index 0000000..3fe4f6f --- /dev/null +++ b/arch/x86_64/src/bus/isa.cpp @@ -0,0 +1,56 @@ +#include "arch/bus/isa.hpp" + +#include "kapi/devices.hpp" +#include "kapi/devices/device.hpp" +#include "kapi/system.hpp" + +#include <kstd/memory> +#include <kstd/print> +#include <kstd/vector> + +#include <algorithm> +#include <utility> + +namespace arch::bus +{ + + isa::isa() + : kapi::devices::bus(kapi::devices::allocate_major_number(), 0, "isa") + {} + + auto isa::add_child(kstd::unique_ptr<device> child) -> void + { + auto observer = m_observers.emplace_back(child.get()); + m_devices.push_back(std::move(child)); + + if (m_initialized) + { + kstd::println("[bus:{}} Initializing child device '{}'", name(), observer->name()); + if (!observer->init()) + { + kapi::system::panic("[x86_64:devices] Failed to initialize child device"); + } + } + } + + auto isa::children() const -> kstd::vector<kstd::observer_ptr<device>> const & + { + return m_observers; + } + + auto isa::init() -> bool + { + if (m_initialized) + { + kapi::system::panic("[x86_64:devices] ISA bus already initialized!"); + } + + m_initialized = std::ranges::fold_left(m_devices, true, [](bool acc, auto & child) -> bool { + kstd::println("[x86_64:devices] Initializing child device '{}'", child->name()); + return acc && child->init(); + }); + + return m_initialized; + } + +} // namespace arch::bus
\ No newline at end of file |
