1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/External/WinRing0/OlsIoctl.h Sun May 27 16:50:01 2012 +0000
1.3 @@ -0,0 +1,170 @@
1.4 +//-----------------------------------------------------------------------------
1.5 +// Author : hiyohiyo
1.6 +// Mail : hiyohiyo@crystalmark.info
1.7 +// Web : http://openlibsys.org/
1.8 +// License : The modified BSD license
1.9 +//
1.10 +// Copyright 2007-2008 OpenLibSys.org. All rights reserved.
1.11 +//-----------------------------------------------------------------------------
1.12 +
1.13 +#pragma once
1.14 +
1.15 +//-----------------------------------------------------------------------------
1.16 +//
1.17 +// The Device type codes form 32768 to 65535 are for customer use.
1.18 +//
1.19 +//-----------------------------------------------------------------------------
1.20 +
1.21 +#define OLS_TYPE 40000
1.22 +
1.23 +//-----------------------------------------------------------------------------
1.24 +//
1.25 +// Version Information
1.26 +//
1.27 +//-----------------------------------------------------------------------------
1.28 +
1.29 +#define OLS_DRIVER_ID _T("WinRing0_1_2_0")
1.30 +
1.31 +#define OLS_DRIVER_MAJOR_VERSION 1
1.32 +#define OLS_DRIVER_MINOR_VERSION 2
1.33 +#define OLS_DRIVER_REVISION 0
1.34 +#define OLS_DRIVER_RELESE 5
1.35 +
1.36 +#define OLS_DRIVER_VERSION \
1.37 + ((OLS_DRIVER_MAJOR_VERSION << 24) | (OLS_DRIVER_MINOR_VERSION << 16) \
1.38 + | (OLS_DRIVER_REVISION << 8) | OLS_DRIVER_RELESE)
1.39 +
1.40 +//-----------------------------------------------------------------------------
1.41 +//
1.42 +// The IOCTL function codes from 0x800 to 0xFFF are for customer use.
1.43 +//
1.44 +//-----------------------------------------------------------------------------
1.45 +#define IOCTL_OLS_GET_DRIVER_VERSION \
1.46 + CTL_CODE(OLS_TYPE, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)
1.47 +
1.48 +#define IOCTL_OLS_GET_REFCOUNT \
1.49 + CTL_CODE(OLS_TYPE, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS)
1.50 +
1.51 +#define IOCTL_OLS_READ_MSR \
1.52 + CTL_CODE(OLS_TYPE, 0x821, METHOD_BUFFERED, FILE_ANY_ACCESS)
1.53 +
1.54 +#define IOCTL_OLS_WRITE_MSR \
1.55 + CTL_CODE(OLS_TYPE, 0x822, METHOD_BUFFERED, FILE_ANY_ACCESS)
1.56 +
1.57 +#define IOCTL_OLS_READ_PMC \
1.58 + CTL_CODE(OLS_TYPE, 0x823, METHOD_BUFFERED, FILE_ANY_ACCESS)
1.59 +
1.60 +#define IOCTL_OLS_HALT \
1.61 + CTL_CODE(OLS_TYPE, 0x824, METHOD_BUFFERED, FILE_ANY_ACCESS)
1.62 +
1.63 +#define IOCTL_OLS_READ_IO_PORT \
1.64 + CTL_CODE(OLS_TYPE, 0x831, METHOD_BUFFERED, FILE_READ_ACCESS)
1.65 +
1.66 +#define IOCTL_OLS_WRITE_IO_PORT \
1.67 + CTL_CODE(OLS_TYPE, 0x832, METHOD_BUFFERED, FILE_WRITE_ACCESS)
1.68 +
1.69 +#define IOCTL_OLS_READ_IO_PORT_BYTE \
1.70 + CTL_CODE(OLS_TYPE, 0x833, METHOD_BUFFERED, FILE_READ_ACCESS)
1.71 +
1.72 +#define IOCTL_OLS_READ_IO_PORT_WORD \
1.73 + CTL_CODE(OLS_TYPE, 0x834, METHOD_BUFFERED, FILE_READ_ACCESS)
1.74 +
1.75 +#define IOCTL_OLS_READ_IO_PORT_DWORD \
1.76 + CTL_CODE(OLS_TYPE, 0x835, METHOD_BUFFERED, FILE_READ_ACCESS)
1.77 +
1.78 +#define IOCTL_OLS_WRITE_IO_PORT_BYTE \
1.79 + CTL_CODE(OLS_TYPE, 0x836, METHOD_BUFFERED, FILE_WRITE_ACCESS)
1.80 +
1.81 +#define IOCTL_OLS_WRITE_IO_PORT_WORD \
1.82 + CTL_CODE(OLS_TYPE, 0x837, METHOD_BUFFERED, FILE_WRITE_ACCESS)
1.83 +
1.84 +#define IOCTL_OLS_WRITE_IO_PORT_DWORD \
1.85 + CTL_CODE(OLS_TYPE, 0x838, METHOD_BUFFERED, FILE_WRITE_ACCESS)
1.86 +
1.87 +#define IOCTL_OLS_READ_MEMORY \
1.88 + CTL_CODE(OLS_TYPE, 0x841, METHOD_BUFFERED, FILE_READ_ACCESS)
1.89 +
1.90 +#define IOCTL_OLS_WRITE_MEMORY \
1.91 + CTL_CODE(OLS_TYPE, 0x842, METHOD_BUFFERED, FILE_WRITE_ACCESS)
1.92 +
1.93 +#define IOCTL_OLS_READ_PCI_CONFIG \
1.94 + CTL_CODE(OLS_TYPE, 0x851, METHOD_BUFFERED, FILE_READ_ACCESS)
1.95 +
1.96 +#define IOCTL_OLS_WRITE_PCI_CONFIG \
1.97 + CTL_CODE(OLS_TYPE, 0x852, METHOD_BUFFERED, FILE_WRITE_ACCESS)
1.98 +
1.99 +//-----------------------------------------------------------------------------
1.100 +//
1.101 +// PCI Error Code
1.102 +//
1.103 +//-----------------------------------------------------------------------------
1.104 +
1.105 +#define OLS_ERROR_PCI_BUS_NOT_EXIST (0xE0000001L)
1.106 +#define OLS_ERROR_PCI_NO_DEVICE (0xE0000002L)
1.107 +#define OLS_ERROR_PCI_WRITE_CONFIG (0xE0000003L)
1.108 +#define OLS_ERROR_PCI_READ_CONFIG (0xE0000004L)
1.109 +
1.110 +//-----------------------------------------------------------------------------
1.111 +//
1.112 +// Support Macros
1.113 +//
1.114 +//-----------------------------------------------------------------------------
1.115 +
1.116 +// Bus Number, Device Number and Function Number to PCI Device Address
1.117 +#define PciBusDevFunc(Bus, Dev, Func) ((Bus&0xFF)<<8) | ((Dev&0x1F)<<3) | (Func&7)
1.118 +// PCI Device Address to Bus Number
1.119 +#define PciGetBus(address) ((address>>8) & 0xFF)
1.120 +// PCI Device Address to Device Number
1.121 +#define PciGetDev(address) ((address>>3) & 0x1F)
1.122 +// PCI Device Address to Function Number
1.123 +#define PciGetFunc(address) (address&7)
1.124 +
1.125 +//-----------------------------------------------------------------------------
1.126 +//
1.127 +// Typedef Struct
1.128 +//
1.129 +//-----------------------------------------------------------------------------
1.130 +
1.131 +#pragma pack(push,4)
1.132 +
1.133 +typedef struct _OLS_WRITE_MSR_INPUT {
1.134 + ULONG Register;
1.135 + ULARGE_INTEGER Value;
1.136 +} OLS_WRITE_MSR_INPUT;
1.137 +
1.138 +typedef struct _OLS_WRITE_IO_PORT_INPUT {
1.139 + ULONG PortNumber;
1.140 + union {
1.141 + ULONG LongData;
1.142 + USHORT ShortData;
1.143 + UCHAR CharData;
1.144 + };
1.145 +} OLS_WRITE_IO_PORT_INPUT;
1.146 +
1.147 +typedef struct _OLS_READ_PCI_CONFIG_INPUT {
1.148 + ULONG PciAddress;
1.149 + ULONG PciOffset;
1.150 +} OLS_READ_PCI_CONFIG_INPUT;
1.151 +
1.152 +typedef struct _OLS_WRITE_PCI_CONFIG_INPUT {
1.153 + ULONG PciAddress;
1.154 + ULONG PciOffset;
1.155 + UCHAR Data[1];
1.156 +} OLS_WRITE_PCI_CONFIG_INPUT;
1.157 +
1.158 +typedef LARGE_INTEGER PHYSICAL_ADDRESS;
1.159 +
1.160 +typedef struct _OLS_READ_MEMORY_INPUT {
1.161 + PHYSICAL_ADDRESS Address;
1.162 + ULONG UnitSize;
1.163 + ULONG Count;
1.164 +} OLS_READ_MEMORY_INPUT;
1.165 +
1.166 +typedef struct _OLS_WRITE_MEMORY_INPUT {
1.167 + PHYSICAL_ADDRESS Address;
1.168 + ULONG UnitSize;
1.169 + ULONG Count;
1.170 + UCHAR Data[1];
1.171 +} OLS_WRITE_MEMORY_INPUT;
1.172 +
1.173 +#pragma pack(pop)