private void StartDevice(PCIDeviceDriverRegistryEntry driver, Device device, PCIDevice pciDevice)
        {
            var ioPortRegions = new List <IOPortRegion>();
            var memoryRegions = new List <AddressRegion>();

            foreach (var pciBaseAddress in pciDevice.BaseAddresses)
            {
                if (pciBaseAddress == null || pciBaseAddress.Size == 0)
                {
                    continue;
                }

                switch (pciBaseAddress.Region)
                {
                case AddressType.IO: ioPortRegions.Add(new IOPortRegion((ushort)pciBaseAddress.Address, (ushort)pciBaseAddress.Size)); break;

                case AddressType.Memory: memoryRegions.Add(new AddressRegion(pciBaseAddress.Address, pciBaseAddress.Size)); break;

                default: break;
                }
            }

            //foreach (var ioportregion in ioPortRegions)
            //{
            //	HAL.DebugWriteLine("  I/O: 0x" + ioportregion.BaseIOPort.ToString("X") + " [" + ioportregion.Size.ToString("X") + "]");
            //}
            //foreach (var memoryregion in memoryRegions)
            //{
            //	HAL.DebugWriteLine("  Memory: 0x" + memoryregion.BaseAddress.ToString("X") + " [" + memoryregion.Size.ToString("X") + "]");
            //}

            var hardwareResources = new HardwareResources(ioPortRegions, memoryRegions, pciDevice.IRQ);

            DeviceService.Initialize(driver, device, driver.AutoStart, null, hardwareResources);
        }
Exemple #2
0
        /// <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);
                    }
                }
            }
        }