/// <summary> /// Creates the partition devices. /// </summary> public void CreatePartitionDevices() { // FIXME: Do not create multiple partition devices if this method executed more than once // Find all online disk devices foreach (var device in deviceManager.GetDevices(new IsDiskDevice(), new IsOnline())) { var diskDevice = device as IDiskDevice; var mbr = new MasterBootBlock(diskDevice); if (!mbr.Valid) { return; } for (uint i = 0; i < MasterBootBlock.MaxMBRPartitions; i++) { if (mbr.Partitions[i].PartitionType != PartitionType.Empty) { deviceManager.Add(new PartitionDevice(diskDevice, mbr.Partitions[i], false)); } } } }
/// <summary> /// Creates the partition devices. /// </summary> public void CreatePCIDevices() { // Find PCI controller devices var devices = deviceManager.GetDevices <IPCIController>(DeviceStatus.Online); if (devices.Count == 0) { return; } var pciController = devices[0].DeviceDriver as IPCIController; // 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)) { var configuration = new PCIDeviceConfiguration() { Bus = (byte)bus, Slot = (byte)slot, Function = (byte)fun }; deviceManager.Initialize(new PCIDevice(), devices[0], configuration, null, null); } } } } }
/// <summary> /// Creates the disk devices. /// </summary> public void CreateDiskDevices() { // FIXME: Do not create disk devices if this method executed more than once // Find disk controller devices var controllers = deviceManager.GetDevices <IDiskControllerDevice>(DeviceStatus.Online); // For each controller foreach (var device in controllers) { var controller = device as IDiskControllerDevice; // Create disk devices var disks = CreateDevices(controller); // Add them to the device manager foreach (var disk in disks) { deviceManager.Add(disk); } } }