diff options
Diffstat (limited to 'src/kernel/HALKit/AMD64/PCI/Iterator.cc')
| -rw-r--r-- | src/kernel/HALKit/AMD64/PCI/Iterator.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/kernel/HALKit/AMD64/PCI/Iterator.cc b/src/kernel/HALKit/AMD64/PCI/Iterator.cc new file mode 100644 index 00000000..103ddb2c --- /dev/null +++ b/src/kernel/HALKit/AMD64/PCI/Iterator.cc @@ -0,0 +1,30 @@ +/* ======================================== + + Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. + +======================================== */ + +#include <KernelKit/PCI/Iterator.h> + +namespace Kernel::PCI { +Iterator::Iterator(const Types::PciDeviceKind type, UInt32 bar) { + // probe devices. + for (Int32 bus = 0; bus < NE_BUS_COUNT; ++bus) { + for (Int32 device = 0; device < NE_DEVICE_COUNT; ++device) { + for (Int32 function = 0; function < NE_FUNCTION_COUNT; ++function) { + Device dev(bus, device, function, bar); + + if (dev.Class() == type) { + fDevices[bus] = dev; + } + } + } + } +} + +Iterator::~Iterator() {} + +Ref<PCI::Device> Iterator::operator[](const Size& at) { + return fDevices[at]; +} +} // namespace Kernel::PCI |
