using System.Runtime.InteropServices; //DllImport /************************************************** * The ACCES32 class contains the functions found in * the ACCES32.DLL and the struct TPCI_COMMON_CONFIG * The functions are used to read and write values * to and from I/O space. There are 1, 2, and 4 byte * versions of both read and write. For more information * on the ACCES32 DLL please read the Software reference manual *******************************************************/ public class ACCES32 { [DllImport("ACCES32.DLL")] public static extern ushort InPortB(uint Port); [DllImport("ACCES32.DLL")] public static extern ushort OutPortB(uint Port, byte value); [DllImport("ACCES32.DLL")] public static extern ushort InPort(uint Port); [DllImport("ACCES32.DLL")] public static extern ushort OutPort(uint Port, ushort value); [DllImport("ACCES32.DLL")] public static extern uint InPortL(uint Port); [DllImport("ACCEs32.DLL")] public static extern ushort OutPortL(uint Port, ulong value); /********************************************************** * This structure is how we read in the PCI_COMMON_CONFIG * The unsafe keyword is required because we are using fixed * size arrays. * The first member of the struct AsBytes allows us to read * directly from the registry into the structure. * *******************************************************/ [StructLayout(LayoutKind.Explicit, Size = 0x40)] unsafe public struct TPCI_COMMON_CONFIG { [FieldOffset(0)] public fixed byte AsBytes[0x40]; [FieldOffset(0)] public ushort VendorID; [FieldOffset(0x2)] public ushort DeviceID; [FieldOffset(0x4)] public ushort Command; [FieldOffset(0x6)] public ushort Status; [FieldOffset(0x8)] public byte RevisionID; [FieldOffset(0x9)] public byte ProgIf; [FieldOffset(0xA)] public byte SubClass; [FieldOffset(0xB)] public byte BaseClass; [FieldOffset(0xC)] public byte CacheLineSize; [FieldOffset(0xD)] public byte LatencyTimer; [FieldOffset(0xE)] public byte HeaderType; [FieldOffset(0XF)] public byte BIST; [FieldOffset(0x10)] public fixed uint BaseAddresses[6]; [FieldOffset(0x28)] public fixed uint Reserved1[2]; [FieldOffset(0x30)] public uint RomBaseAddress; [FieldOffset(0x34)] public fixed uint Reserved2[2]; [FieldOffset(0x3C)] public byte InterruptLine; [FieldOffset(0x3D)] public byte InterruptPin; [FieldOffset(0x3E)] public byte MinimumGrant; [FieldOffset(0x3F)] public byte MaximumLatency; } }