From 5339d016c07bf717ee388f4feb73544087324af0 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 6 Jan 2024 09:14:11 +0100 Subject: git: port from mercurial repo. Signed-off-by: Amlal El Mahrouss --- HALKit/AMD64/PCI/Iterator.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 HALKit/AMD64/PCI/Iterator.cpp (limited to 'HALKit/AMD64/PCI/Iterator.cpp') diff --git a/HALKit/AMD64/PCI/Iterator.cpp b/HALKit/AMD64/PCI/Iterator.cpp new file mode 100644 index 00000000..a5649e52 --- /dev/null +++ b/HALKit/AMD64/PCI/Iterator.cpp @@ -0,0 +1,39 @@ +/* + * ======================================================== + * + * hCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include + +#define PCI_ITERATOR_FIND_AND_UNWRAP(DEV, SZ) \ + if (DEV.Leak()) \ + return DEV.Leak(); + +namespace hCore::PCI { + Iterator::Iterator(const Types::PciDeviceKind &type) { + // probe devices. + for (int bus = 0; bus < ME_BUS_COUNT; ++bus) { + for (int device = 0; device < ME_DEVICE_COUNT; ++device) { + for (int function = 0; function < ME_FUNCTION_COUNT; ++function) { + Device dev(bus, device, function, 0); + + if (dev.Class() == (UChar) type) { + m_Devices[bus].Leak().Leak() = dev; + } + } + } + } + } + + Iterator::~Iterator() { + } + + Ref Iterator::operator[](const Size &sz) { + PCI_ITERATOR_FIND_AND_UNWRAP(m_Devices[sz], sz); + return {}; + } +} // namespace hCore::PCI -- cgit v1.2.3