/// <summary> /// Starts the device. /// </summary> /// <param name="pciDevice">The pci device.</param> static public void StartDevice(IPCIDevice pciDevice) { DeviceDriver deviceDriver = deviceDriverRegistry.FindDriver(pciDevice); if (deviceDriver == null) { pciDevice.SetNoDriverFound(); return; } IHardwareDevice hardwareDevice = System.Activator.CreateInstance(deviceDriver.DriverType) as IHardwareDevice; // MR 07/21/09: Commenting out, causes mono xbuild to fail on MacOS X // PCIDeviceDriverAttribute attribute = deviceDriver.Attribute as PCIDeviceDriverAttribute; LinkedList <IIOPortRegion> ioPortRegions = new LinkedList <IIOPortRegion>(); LinkedList <IMemoryRegion> memoryRegions = new LinkedList <IMemoryRegion>(); foreach (BaseAddress pciBaseAddress in pciDevice.BaseAddresses) { switch (pciBaseAddress.Region) { case AddressType.IO: ioPortRegions.Add(new IOPortRegion((ushort)pciBaseAddress.Address, (ushort)pciBaseAddress.Size)); break; case AddressType.Memory: memoryRegions.Add(new MemoryRegion(pciBaseAddress.Address, pciBaseAddress.Size)); break; default: break; } } foreach (DeviceDriverPhysicalMemoryAttribute memoryAttribute in deviceDriver.MemoryAttributes) { if (memoryAttribute.MemorySize > 0) { IMemory memory = HAL.RequestPhysicalMemory(memoryAttribute.MemorySize, memoryAttribute.MemoryAlignment); memoryRegions.Add(new MemoryRegion(memory.Address, memory.Size)); } } HardwareResources hardwareResources = new HardwareResources(resourceManager, ioPortRegions.ToArray(), memoryRegions.ToArray(), new InterruptHandler(resourceManager.InterruptManager, pciDevice.IRQ, hardwareDevice), pciDevice as IDeviceResource); if (resourceManager.ClaimResources(hardwareResources)) { hardwareResources.EnableIRQ(); if (hardwareDevice.Start() == DeviceDriverStartStatus.Started) { pciDevice.SetDeviceOnline(); } else { hardwareResources.DisableIRQ(); resourceManager.ReleaseResources(hardwareResources); } } }
/// <summary> /// Starts the device. /// </summary> /// <param name="deviceDriver">The device driver.</param> static public void StartDevice(DeviceDriver deviceDriver) { ISADeviceDriverAttribute driverAtttribute = deviceDriver.Attribute as ISADeviceDriverAttribute; if (driverAtttribute.AutoLoad) { IHardwareDevice hardwareDevice = System.Activator.CreateInstance(deviceDriver.DriverType) as IHardwareDevice; //UNUSED: //ISADeviceDriverAttribute attribute = deviceDriver.Attribute as ISADeviceDriverAttribute; LinkedList <IIOPortRegion> ioPortRegions = new LinkedList <IIOPortRegion>(); LinkedList <IMemoryRegion> memoryRegions = new LinkedList <IMemoryRegion>(); ioPortRegions.Add(new IOPortRegion(driverAtttribute.BasePort, driverAtttribute.PortRange)); if (driverAtttribute.AltBasePort != 0x00) { ioPortRegions.Add(new IOPortRegion(driverAtttribute.AltBasePort, driverAtttribute.AltPortRange)); } if (driverAtttribute.BaseAddress != 0x00) { memoryRegions.Add(new MemoryRegion(driverAtttribute.BaseAddress, driverAtttribute.AddressRange)); } foreach (DeviceDriverPhysicalMemoryAttribute memoryAttribute in deviceDriver.MemoryAttributes) { if (memoryAttribute.MemorySize > 0) { IMemory memory = HAL.RequestPhysicalMemory(memoryAttribute.MemorySize, memoryAttribute.MemoryAlignment); memoryRegions.Add(new MemoryRegion(memory.Address, memory.Size)); } } IHardwareResources hardwareResources = new HardwareResources(resourceManager, ioPortRegions.ToArray(), memoryRegions.ToArray(), new InterruptHandler(resourceManager.InterruptManager, driverAtttribute.IRQ, hardwareDevice)); hardwareDevice.Setup(hardwareResources); if (resourceManager.ClaimResources(hardwareResources)) { hardwareResources.EnableIRQ(); if (hardwareDevice.Start() == DeviceDriverStartStatus.Started) { deviceManager.Add(hardwareDevice); } else { hardwareResources.DisableIRQ(); resourceManager.ReleaseResources(hardwareResources); } } } }
/// <summary> /// Gets the memory. /// </summary> /// <param name="address">The address.</param> /// <param name="size">The size.</param> /// <returns></returns> public Memory GetMemory(uint address, uint size) { return(HAL.RequestPhysicalMemory(address, size)); }
/// <summary> /// Gets the memory. /// </summary> /// <param name="region">The region.</param> /// <returns></returns> public Memory GetMemory(byte region) { return(HAL.RequestPhysicalMemory(memoryRegions[region].BaseAddress, memoryRegions[region].Size)); }