示例#1
0
            public byte[] ReadBytes(AcpiObject.RegionSpace regionSpace, ulong offset, ulong length)
            {
                byte[] result = new byte[length];

                switch (regionSpace)
                {
                case AcpiObject.RegionSpace.SystemMemory:
                    IoMemory region = IoMemory.MapPhysicalMemory(offset, length, true /*readable*/, false /*writable*/);
                    for (ulong i = 0; i < length; i++)
                    {
                        result[i] = region.Read8((int)i);
                    }
                    break;

                default:
                    throw new Exception("ReadBytes() only supported for SystemMemory regions");
                }

#if DUMP_RAW_READ_WRITES
                DebugStub.Write("ACPI read: space: " + regionSpace + ", offset: " + offset + ", bytes: " + length + ", result: {");
                for (int i = 0; i < result.Length; i++)
                {
                    DebugStub.Write(result[i].ToString("X"));
                    if (i < result.Length - 1)
                    {
                        DebugStub.Write(",");
                    }
                }
                DebugStub.WriteLine("}");
#endif

                return(result);
            }
示例#2
0
            public uint Read32(AcpiObject.RegionSpace regionSpace, ulong offset)
            {
                uint result;

                switch (regionSpace)
                {
                case AcpiObject.RegionSpace.SystemMemory:
                    IoMemory region = IoMemory.MapPhysicalMemory(offset, 4, true /*readable*/, false /*writable*/);
                    result = region.Read32(0);
                    break;

                case AcpiObject.RegionSpace.SystemIO:
                    IoPort port = new IoPort((ushort)offset, 4, Access.Read);
                    result = port.Read32();
                    break;

                case AcpiObject.RegionSpace.PCI_Config:
                    pciConfigAddressPort.Write32(PciConfigEnableMask | (uint)offset);
                    result = pciConfigDataPort.Read32();
                    break;

                default:
                    throw new Exception("Unimplemented operation region type" + regionSpace);
                }
#if DUMP_RAW_READ_WRITES
                DebugStub.WriteLine("ACPI read: space: " + regionSpace + ", offset: " + offset + ", bytes: " + 4 + ", result: " + result.ToString("X"));
#endif
                return(result);
            }
示例#3
0
            public void Write32(AcpiObject.RegionSpace regionSpace, ulong offset, uint value)
            {
#if DUMP_RAW_READ_WRITES
                DebugStub.WriteLine("ACPI write: space: " + regionSpace + ", offset: " + offset + ", bytes: " + 4 + ", value: " + value.ToString("X"));
#endif
                switch (regionSpace)
                {
                case AcpiObject.RegionSpace.SystemMemory:
                    IoMemory region = IoMemory.MapPhysicalMemory(offset, 4, true /*readable*/, true /*writable*/);
                    region.Write32(0, value);
                    break;

                case AcpiObject.RegionSpace.SystemIO:
                    IoPort port = new IoPort((ushort)offset, 4, Access.ReadWrite);
                    port.Write32(value);
                    break;

                case AcpiObject.RegionSpace.PCI_Config:
                    pciConfigAddressPort.Write32(PciConfigEnableMask | (uint)offset);
                    pciConfigDataPort.Write32(value);
                    break;

                default:
                    throw new Exception("Unimplemented operation region type" + regionSpace);
                }
            }
示例#4
0
            public ushort Read16(AcpiObject.RegionSpace regionSpace, ulong offset)
            {
                ushort result;

                switch (regionSpace)
                {
                case AcpiObject.RegionSpace.SystemMemory:
                    // TODO: This is a first stab - ideally the AcpiObject.OperationRegion
                    // ought to be holding onto an IoMemoryRange and passing it in.
                    IoMemory region = IoMemory.MapPhysicalMemory(offset, 2, true /*readable*/, false /*writable*/);
                    result = region.Read16(0);
                    break;

                case AcpiObject.RegionSpace.SystemIO:
                    IoPort port = new IoPort((ushort)offset, 2, Access.Read);
                    result = port.Read16();
                    break;

                case AcpiObject.RegionSpace.PCI_Config:
                    pciConfigAddressPort.Write32(PciConfigEnableMask | (uint)offset);
                    result = pciConfigDataPort.Read16();
                    break;

                default:
                    throw new Exception("Unimplemented operation region type" + regionSpace);
                }

#if DUMP_RAW_READ_WRITES
                DebugStub.WriteLine("ACPI read: space: " + regionSpace + ", offset: " + offset + ", bytes: " + 2 + ", result: " + result.ToString("X"));
#endif
                return(result);
            }