moel@347: //----------------------------------------------------------------------------- moel@347: // Author : hiyohiyo moel@347: // Mail : hiyohiyo@crystalmark.info moel@347: // Web : http://openlibsys.org/ moel@347: // License : The modified BSD license moel@347: // moel@347: // Copyright 2007-2008 OpenLibSys.org. All rights reserved. moel@347: //----------------------------------------------------------------------------- moel@347: moel@347: #pragma once moel@347: moel@347: //----------------------------------------------------------------------------- moel@347: // moel@347: // The Device type codes form 32768 to 65535 are for customer use. moel@347: // moel@347: //----------------------------------------------------------------------------- moel@347: moel@347: #define OLS_TYPE 40000 moel@347: moel@347: //----------------------------------------------------------------------------- moel@347: // moel@347: // Version Information moel@347: // moel@347: //----------------------------------------------------------------------------- moel@347: moel@347: #define OLS_DRIVER_ID _T("WinRing0_1_2_0") moel@347: moel@347: #define OLS_DRIVER_MAJOR_VERSION 1 moel@347: #define OLS_DRIVER_MINOR_VERSION 2 moel@347: #define OLS_DRIVER_REVISION 0 moel@347: #define OLS_DRIVER_RELESE 5 moel@347: moel@347: #define OLS_DRIVER_VERSION \ moel@347: ((OLS_DRIVER_MAJOR_VERSION << 24) | (OLS_DRIVER_MINOR_VERSION << 16) \ moel@347: | (OLS_DRIVER_REVISION << 8) | OLS_DRIVER_RELESE) moel@347: moel@347: //----------------------------------------------------------------------------- moel@347: // moel@347: // The IOCTL function codes from 0x800 to 0xFFF are for customer use. moel@347: // moel@347: //----------------------------------------------------------------------------- moel@347: #define IOCTL_OLS_GET_DRIVER_VERSION \ moel@347: CTL_CODE(OLS_TYPE, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS) moel@347: moel@347: #define IOCTL_OLS_GET_REFCOUNT \ moel@347: CTL_CODE(OLS_TYPE, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS) moel@347: moel@347: #define IOCTL_OLS_READ_MSR \ moel@347: CTL_CODE(OLS_TYPE, 0x821, METHOD_BUFFERED, FILE_ANY_ACCESS) moel@347: moel@347: #define IOCTL_OLS_WRITE_MSR \ moel@347: CTL_CODE(OLS_TYPE, 0x822, METHOD_BUFFERED, FILE_ANY_ACCESS) moel@347: moel@347: #define IOCTL_OLS_READ_PMC \ moel@347: CTL_CODE(OLS_TYPE, 0x823, METHOD_BUFFERED, FILE_ANY_ACCESS) moel@347: moel@347: #define IOCTL_OLS_HALT \ moel@347: CTL_CODE(OLS_TYPE, 0x824, METHOD_BUFFERED, FILE_ANY_ACCESS) moel@347: moel@347: #define IOCTL_OLS_READ_IO_PORT \ moel@347: CTL_CODE(OLS_TYPE, 0x831, METHOD_BUFFERED, FILE_READ_ACCESS) moel@347: moel@347: #define IOCTL_OLS_WRITE_IO_PORT \ moel@347: CTL_CODE(OLS_TYPE, 0x832, METHOD_BUFFERED, FILE_WRITE_ACCESS) moel@347: moel@347: #define IOCTL_OLS_READ_IO_PORT_BYTE \ moel@347: CTL_CODE(OLS_TYPE, 0x833, METHOD_BUFFERED, FILE_READ_ACCESS) moel@347: moel@347: #define IOCTL_OLS_READ_IO_PORT_WORD \ moel@347: CTL_CODE(OLS_TYPE, 0x834, METHOD_BUFFERED, FILE_READ_ACCESS) moel@347: moel@347: #define IOCTL_OLS_READ_IO_PORT_DWORD \ moel@347: CTL_CODE(OLS_TYPE, 0x835, METHOD_BUFFERED, FILE_READ_ACCESS) moel@347: moel@347: #define IOCTL_OLS_WRITE_IO_PORT_BYTE \ moel@347: CTL_CODE(OLS_TYPE, 0x836, METHOD_BUFFERED, FILE_WRITE_ACCESS) moel@347: moel@347: #define IOCTL_OLS_WRITE_IO_PORT_WORD \ moel@347: CTL_CODE(OLS_TYPE, 0x837, METHOD_BUFFERED, FILE_WRITE_ACCESS) moel@347: moel@347: #define IOCTL_OLS_WRITE_IO_PORT_DWORD \ moel@347: CTL_CODE(OLS_TYPE, 0x838, METHOD_BUFFERED, FILE_WRITE_ACCESS) moel@347: moel@347: #define IOCTL_OLS_READ_MEMORY \ moel@347: CTL_CODE(OLS_TYPE, 0x841, METHOD_BUFFERED, FILE_READ_ACCESS) moel@347: moel@347: #define IOCTL_OLS_WRITE_MEMORY \ moel@347: CTL_CODE(OLS_TYPE, 0x842, METHOD_BUFFERED, FILE_WRITE_ACCESS) moel@347: moel@347: #define IOCTL_OLS_READ_PCI_CONFIG \ moel@347: CTL_CODE(OLS_TYPE, 0x851, METHOD_BUFFERED, FILE_READ_ACCESS) moel@347: moel@347: #define IOCTL_OLS_WRITE_PCI_CONFIG \ moel@347: CTL_CODE(OLS_TYPE, 0x852, METHOD_BUFFERED, FILE_WRITE_ACCESS) moel@347: moel@347: //----------------------------------------------------------------------------- moel@347: // moel@347: // PCI Error Code moel@347: // moel@347: //----------------------------------------------------------------------------- moel@347: moel@347: #define OLS_ERROR_PCI_BUS_NOT_EXIST (0xE0000001L) moel@347: #define OLS_ERROR_PCI_NO_DEVICE (0xE0000002L) moel@347: #define OLS_ERROR_PCI_WRITE_CONFIG (0xE0000003L) moel@347: #define OLS_ERROR_PCI_READ_CONFIG (0xE0000004L) moel@347: moel@347: //----------------------------------------------------------------------------- moel@347: // moel@347: // Support Macros moel@347: // moel@347: //----------------------------------------------------------------------------- moel@347: moel@347: // Bus Number, Device Number and Function Number to PCI Device Address moel@347: #define PciBusDevFunc(Bus, Dev, Func) ((Bus&0xFF)<<8) | ((Dev&0x1F)<<3) | (Func&7) moel@347: // PCI Device Address to Bus Number moel@347: #define PciGetBus(address) ((address>>8) & 0xFF) moel@347: // PCI Device Address to Device Number moel@347: #define PciGetDev(address) ((address>>3) & 0x1F) moel@347: // PCI Device Address to Function Number moel@347: #define PciGetFunc(address) (address&7) moel@347: moel@347: //----------------------------------------------------------------------------- moel@347: // moel@347: // Typedef Struct moel@347: // moel@347: //----------------------------------------------------------------------------- moel@347: moel@347: #pragma pack(push,4) moel@347: moel@347: typedef struct _OLS_WRITE_MSR_INPUT { moel@347: ULONG Register; moel@347: ULARGE_INTEGER Value; moel@347: } OLS_WRITE_MSR_INPUT; moel@347: moel@347: typedef struct _OLS_WRITE_IO_PORT_INPUT { moel@347: ULONG PortNumber; moel@347: union { moel@347: ULONG LongData; moel@347: USHORT ShortData; moel@347: UCHAR CharData; moel@347: }; moel@347: } OLS_WRITE_IO_PORT_INPUT; moel@347: moel@347: typedef struct _OLS_READ_PCI_CONFIG_INPUT { moel@347: ULONG PciAddress; moel@347: ULONG PciOffset; moel@347: } OLS_READ_PCI_CONFIG_INPUT; moel@347: moel@347: typedef struct _OLS_WRITE_PCI_CONFIG_INPUT { moel@347: ULONG PciAddress; moel@347: ULONG PciOffset; moel@347: UCHAR Data[1]; moel@347: } OLS_WRITE_PCI_CONFIG_INPUT; moel@347: moel@347: typedef LARGE_INTEGER PHYSICAL_ADDRESS; moel@347: moel@347: typedef struct _OLS_READ_MEMORY_INPUT { moel@347: PHYSICAL_ADDRESS Address; moel@347: ULONG UnitSize; moel@347: ULONG Count; moel@347: } OLS_READ_MEMORY_INPUT; moel@347: moel@347: typedef struct _OLS_WRITE_MEMORY_INPUT { moel@347: PHYSICAL_ADDRESS Address; moel@347: ULONG UnitSize; moel@347: ULONG Count; moel@347: UCHAR Data[1]; moel@347: } OLS_WRITE_MEMORY_INPUT; moel@347: moel@347: #pragma pack(pop)