summaryrefslogtreecommitdiffhomepage
path: root/Private/HALKit/AMD64/PCI/Iterator.cpp
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-26 22:26:48 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-26 22:27:09 +0100
commiteba8b7ddd0a455d9e49f32dcae712c5612c0093c (patch)
tree749a3d34546d055507a920bce4ab10e8a9945719 /Private/HALKit/AMD64/PCI/Iterator.cpp
parentdd192787a70a973f2474720aea49af3f6ddabb7a (diff)
Kernel: Major repository refactor.
Rework the repo into Private and Public modules. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/HALKit/AMD64/PCI/Iterator.cpp')
-rw-r--r--Private/HALKit/AMD64/PCI/Iterator.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/Private/HALKit/AMD64/PCI/Iterator.cpp b/Private/HALKit/AMD64/PCI/Iterator.cpp
new file mode 100644
index 00000000..6f80d496
--- /dev/null
+++ b/Private/HALKit/AMD64/PCI/Iterator.cpp
@@ -0,0 +1,39 @@
+/*
+ * ========================================================
+ *
+ * hCore
+ * Copyright 2024 Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#include <KernelKit/PCI/Iterator.hpp>
+
+#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<PCI::Device> Iterator::operator[](const Size &sz) {
+ PCI_ITERATOR_FIND_AND_UNWRAP(m_Devices[sz], sz);
+ return {};
+ }
+} // namespace hCore::PCI