/// <summary> /// Creates the partition devices. /// </summary> private void CreatePCIDevices(Device device, IPCIControllerLegacy pciController) { // For each controller for (int bus = 0; bus < 255; bus++) { for (int slot = 0; slot < 16; slot++) { for (int fun = 0; fun < 7; fun++) { if (!ProbeDevice(pciController, (byte)bus, (byte)slot, (byte)fun)) { continue; } // TODO: Check for duplicate var configuration = new PCIDeviceConfiguration() { Bus = (byte)bus, Slot = (byte)slot, Function = (byte)fun }; DeviceService.Initialize(new PCIDevice(), device, true, configuration, null, null); } } } }
/// <summary> /// Probes for a PCI device. /// </summary> /// <param name="pciController">The pci controller.</param> /// <param name="bus">The bus.</param> /// <param name="slot">The slot.</param> /// <param name="fun">The fun.</param> /// <returns></returns> protected bool ProbeDevice(IPCIControllerLegacy pciController, byte bus, byte slot, byte fun) { uint value = pciController.ReadConfig32(bus, slot, fun, 0); return(value != 0xFFFFFFFF); }