summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/HALKit/AMD64/PCI/Iterator.cc
blob: 09cfb2d2aa02c2dcf411332f6c353cddd60c6fb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* -------------------------------------------

	Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved.

------------------------------------------- */

#include <KernelKit/PCI/Iterator.h>

namespace Kernel::PCI
{
	Iterator::Iterator(const Types::PciDeviceKind& type)
	{
		// probe devices.
		for (int bus = 0; bus < NE_BUS_COUNT; ++bus)
		{
			for (int device = 0; device < NE_DEVICE_COUNT; ++device)
			{
				for (int function = 0; function < NE_FUNCTION_COUNT; ++function)
				{
					Device dev(bus, device, function, 0x00);

					if (dev.Class() == type)
					{
						fDevices[bus] = dev;
					}
				}
			}
		}
	}

	Iterator::~Iterator()
	{
	}

	Ref<PCI::Device> Iterator::operator[](const Size& at)
	{
		return fDevices[at];
	}
} // namespace Kernel::PCI