public void Write32(int offset, uint value) { if (!PciPortHandle.Write32(handle, offset, value)) { DebugStub.Break(); } }
public void Write8(int offset, byte value) { if (!PciPortHandle.Write8(handle, offset, value)) { DebugStub.Break(); } }
private unsafe uint Read32Impl(int offset) { uint v; if (PciPortHandle.Read32Impl(handle, offset, &v)) { return(v); } else { DebugStub.Break(); return(0); } }
private unsafe byte Read8Impl(int offset) { byte v; if (PciPortHandle.Read8Impl(handle, offset, &v)) { return(v); } else { DebugStub.Break(); return(0); } }
public static unsafe IoConfig GetConfig() { // first get the device signature ArrayList idlist = new ArrayList(); char[] idbuffer = new char[0x80]; for (int i = 0;; i++) { int len = (int)DeviceService.GetPnpSignature(i, null, 0); if (len == 0) { break; } if (len > idbuffer.Length) { idbuffer = new char[len]; fixed(char *idbuffer_pinned = &idbuffer[0]) { len = (int)DeviceService.GetPnpSignature(i, idbuffer_pinned, (uint)idbuffer.Length); } if (len == 0) break; } string id = new String(idbuffer, 0, len); idlist.Add(id); Tracing.Log(Tracing.Debug, "PNP Signature: [{0}]", id); } string[] ids = (string[])idlist.ToArray(typeof(string)); #if false string id = null; char[] sigArray = new char[DeviceService.GetPnpSignature(null, 0)]; fixed(char *sigPtr = &sigArray[0]) { int len = (int)DeviceService.GetPnpSignature( sigPtr, (uint)sigArray.Length); id = String.StringCTOR(sigPtr, 0, len); } #endif // now get the fixed resources IoRange[] fixedRanges = GetFixedIoResources(); // now determine if this is a PCI bus, and if so, configure it as // such PciPortHandle pciPortHandle = new PciPortHandle(); if (DeviceService.GetPciPort(out pciPortHandle)) { PciPort port = new PciPort(pciPortHandle); return(PciConfig.Create(ids, port, fixedRanges)); } else { Tracing.Log(Tracing.Debug, "PCI Config: None."); } // it isn't a PCI device, so create a PnpConfig object // TODO: We should really copy all of the ranges, so that // we can augment even PCI devices (like VGA cards). uint rangeCount = DeviceService.GetDynamicIoRangeCount(); Tracing.Log(Tracing.Debug, "I/O Ranges: {0}", rangeCount); IoRange[] dynamicRanges = new IoRange[rangeCount]; for (uint range = 0; range < rangeCount; range++) { ushort port; ushort size; bool readable; bool writable; byte * dataAddr; uint dataSize; byte irq; byte irqSize; byte dma; byte dmaSize; if (DeviceService.GetDynamicIoPortRange(range, out port, out size, out readable, out writable)) { Tracing.Log(Tracing.Debug, "{0:d4}. I/O Port: port={1:x4}" + "[{2:x}] read={3} write={4}", range, port, size, (UIntPtr)(readable ? 1 : 0), (UIntPtr)(writable ? 1 : 0)); dynamicRanges[range] = new IoPortRange(port, size, readable, writable); } else if (DeviceService.GetDynamicIoMemoryRange(range, out dataAddr, out dataSize, out readable, out writable)) { UIntPtr addr = (UIntPtr)dataAddr; Tracing.Log(Tracing.Debug, "{0:d4}. Memory: addr={1:x8}" + "[2:x] read={3} write={4}", range, addr, dataSize, (UIntPtr)(readable ? 1 : 0), (UIntPtr)(writable ? 1 : 0)); dynamicRanges[range] = new IoMemoryRange(addr, dataSize, readable, writable); } else if (DeviceService.GetDynamicIoIrqRange(range, out irq, out irqSize)) { Tracing.Log(Tracing.Debug, "{0:d4}. Irq: irq={1:x2}" + "[{2:x}]", range, irq, irqSize); dynamicRanges[range] = new IoIrqRange(irq, irqSize); } else if (DeviceService.GetDynamicIoDmaRange(range, out dma, out dmaSize)) { Tracing.Log(Tracing.Debug, "{0:d4}. Dma: dma={1:x2}" + "[{2:x}]", range, dma, dmaSize); dynamicRanges[range] = new IoDmaRange(dma, dmaSize); } else { Tracing.Log(Tracing.Debug, "{0:d4}. Empty", range); } } return(new PnpConfig(ids, dynamicRanges, fixedRanges)); }
internal PciPort(PciPortHandle pciPortHandle) { this.handle = pciPortHandle; }