示例#1
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);
            }