External/WinRing0/OlsIoctl.h
author moel.mich
Mon, 23 Jul 2012 21:54:35 +0000
changeset 370 8e4dedc41924
permissions -rw-r--r--
Added a RAM hardware and sensor, fixed Issue 115.
moel@347
     1
//-----------------------------------------------------------------------------
moel@347
     2
//     Author : hiyohiyo
moel@347
     3
//       Mail : hiyohiyo@crystalmark.info
moel@347
     4
//        Web : http://openlibsys.org/
moel@347
     5
//    License : The modified BSD license
moel@347
     6
//
moel@347
     7
//                     Copyright 2007-2008 OpenLibSys.org. All rights reserved.
moel@347
     8
//-----------------------------------------------------------------------------
moel@347
     9
moel@347
    10
#pragma once
moel@347
    11
moel@347
    12
//-----------------------------------------------------------------------------
moel@347
    13
//
moel@347
    14
// The Device type codes form 32768 to 65535 are for customer use.
moel@347
    15
//
moel@347
    16
//-----------------------------------------------------------------------------
moel@347
    17
moel@347
    18
#define OLS_TYPE 40000
moel@347
    19
moel@347
    20
//-----------------------------------------------------------------------------
moel@347
    21
//
moel@347
    22
// Version Information
moel@347
    23
//
moel@347
    24
//-----------------------------------------------------------------------------
moel@347
    25
moel@347
    26
#define OLS_DRIVER_ID							_T("WinRing0_1_2_0")
moel@347
    27
moel@347
    28
#define OLS_DRIVER_MAJOR_VERSION				1
moel@347
    29
#define OLS_DRIVER_MINOR_VERSION				2
moel@347
    30
#define OLS_DRIVER_REVISION						0
moel@347
    31
#define OLS_DRIVER_RELESE						5
moel@347
    32
moel@347
    33
#define OLS_DRIVER_VERSION \
moel@347
    34
	((OLS_DRIVER_MAJOR_VERSION << 24) | (OLS_DRIVER_MINOR_VERSION << 16) \
moel@347
    35
	| (OLS_DRIVER_REVISION << 8) | OLS_DRIVER_RELESE) 
moel@347
    36
moel@347
    37
//-----------------------------------------------------------------------------
moel@347
    38
//
moel@347
    39
// The IOCTL function codes from 0x800 to 0xFFF are for customer use.
moel@347
    40
//
moel@347
    41
//-----------------------------------------------------------------------------
moel@347
    42
#define IOCTL_OLS_GET_DRIVER_VERSION \
moel@347
    43
	CTL_CODE(OLS_TYPE, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS)
moel@347
    44
moel@347
    45
#define IOCTL_OLS_GET_REFCOUNT \
moel@347
    46
	CTL_CODE(OLS_TYPE, 0x801, METHOD_BUFFERED, FILE_ANY_ACCESS)
moel@347
    47
moel@347
    48
#define IOCTL_OLS_READ_MSR \
moel@347
    49
	CTL_CODE(OLS_TYPE, 0x821, METHOD_BUFFERED, FILE_ANY_ACCESS)
moel@347
    50
moel@347
    51
#define IOCTL_OLS_WRITE_MSR \
moel@347
    52
	CTL_CODE(OLS_TYPE, 0x822, METHOD_BUFFERED, FILE_ANY_ACCESS)
moel@347
    53
moel@347
    54
#define IOCTL_OLS_READ_PMC \
moel@347
    55
	CTL_CODE(OLS_TYPE, 0x823, METHOD_BUFFERED, FILE_ANY_ACCESS)
moel@347
    56
moel@347
    57
#define IOCTL_OLS_HALT \
moel@347
    58
	CTL_CODE(OLS_TYPE, 0x824, METHOD_BUFFERED, FILE_ANY_ACCESS)
moel@347
    59
moel@347
    60
#define IOCTL_OLS_READ_IO_PORT \
moel@347
    61
	CTL_CODE(OLS_TYPE, 0x831, METHOD_BUFFERED, FILE_READ_ACCESS)
moel@347
    62
moel@347
    63
#define IOCTL_OLS_WRITE_IO_PORT \
moel@347
    64
	CTL_CODE(OLS_TYPE, 0x832, METHOD_BUFFERED, FILE_WRITE_ACCESS)
moel@347
    65
moel@347
    66
#define IOCTL_OLS_READ_IO_PORT_BYTE \
moel@347
    67
	CTL_CODE(OLS_TYPE, 0x833, METHOD_BUFFERED, FILE_READ_ACCESS)
moel@347
    68
moel@347
    69
#define IOCTL_OLS_READ_IO_PORT_WORD \
moel@347
    70
	CTL_CODE(OLS_TYPE, 0x834, METHOD_BUFFERED, FILE_READ_ACCESS)
moel@347
    71
moel@347
    72
#define IOCTL_OLS_READ_IO_PORT_DWORD \
moel@347
    73
	CTL_CODE(OLS_TYPE, 0x835, METHOD_BUFFERED, FILE_READ_ACCESS)
moel@347
    74
moel@347
    75
#define IOCTL_OLS_WRITE_IO_PORT_BYTE \
moel@347
    76
	CTL_CODE(OLS_TYPE, 0x836, METHOD_BUFFERED, FILE_WRITE_ACCESS)
moel@347
    77
moel@347
    78
#define IOCTL_OLS_WRITE_IO_PORT_WORD \
moel@347
    79
	CTL_CODE(OLS_TYPE, 0x837, METHOD_BUFFERED, FILE_WRITE_ACCESS)
moel@347
    80
moel@347
    81
#define IOCTL_OLS_WRITE_IO_PORT_DWORD \
moel@347
    82
	CTL_CODE(OLS_TYPE, 0x838, METHOD_BUFFERED, FILE_WRITE_ACCESS)
moel@347
    83
moel@347
    84
#define IOCTL_OLS_READ_MEMORY \
moel@347
    85
	CTL_CODE(OLS_TYPE, 0x841, METHOD_BUFFERED, FILE_READ_ACCESS)
moel@347
    86
moel@347
    87
#define IOCTL_OLS_WRITE_MEMORY \
moel@347
    88
	CTL_CODE(OLS_TYPE, 0x842, METHOD_BUFFERED, FILE_WRITE_ACCESS)
moel@347
    89
moel@347
    90
#define IOCTL_OLS_READ_PCI_CONFIG \
moel@347
    91
	CTL_CODE(OLS_TYPE, 0x851, METHOD_BUFFERED, FILE_READ_ACCESS)
moel@347
    92
moel@347
    93
#define IOCTL_OLS_WRITE_PCI_CONFIG \
moel@347
    94
	CTL_CODE(OLS_TYPE, 0x852, METHOD_BUFFERED, FILE_WRITE_ACCESS)
moel@347
    95
moel@347
    96
//-----------------------------------------------------------------------------
moel@347
    97
//
moel@347
    98
// PCI Error Code
moel@347
    99
//
moel@347
   100
//-----------------------------------------------------------------------------
moel@347
   101
moel@347
   102
#define OLS_ERROR_PCI_BUS_NOT_EXIST		(0xE0000001L)
moel@347
   103
#define OLS_ERROR_PCI_NO_DEVICE			(0xE0000002L)
moel@347
   104
#define OLS_ERROR_PCI_WRITE_CONFIG		(0xE0000003L)
moel@347
   105
#define OLS_ERROR_PCI_READ_CONFIG		(0xE0000004L)
moel@347
   106
moel@347
   107
//-----------------------------------------------------------------------------
moel@347
   108
//
moel@347
   109
// Support Macros
moel@347
   110
//
moel@347
   111
//-----------------------------------------------------------------------------
moel@347
   112
moel@347
   113
// Bus Number, Device Number and Function Number to PCI Device Address
moel@347
   114
#define PciBusDevFunc(Bus, Dev, Func)	((Bus&0xFF)<<8) | ((Dev&0x1F)<<3) | (Func&7)
moel@347
   115
// PCI Device Address to Bus Number
moel@347
   116
#define PciGetBus(address)				((address>>8) & 0xFF)
moel@347
   117
// PCI Device Address to Device Number
moel@347
   118
#define PciGetDev(address)				((address>>3) & 0x1F)
moel@347
   119
// PCI Device Address to Function Number
moel@347
   120
#define PciGetFunc(address)				(address&7)
moel@347
   121
moel@347
   122
//-----------------------------------------------------------------------------
moel@347
   123
//
moel@347
   124
// Typedef Struct
moel@347
   125
//
moel@347
   126
//-----------------------------------------------------------------------------
moel@347
   127
moel@347
   128
#pragma pack(push,4)
moel@347
   129
moel@347
   130
typedef struct  _OLS_WRITE_MSR_INPUT {
moel@347
   131
	ULONG		Register;
moel@347
   132
	ULARGE_INTEGER	Value;
moel@347
   133
}   OLS_WRITE_MSR_INPUT;
moel@347
   134
moel@347
   135
typedef struct  _OLS_WRITE_IO_PORT_INPUT {
moel@347
   136
	ULONG	PortNumber; 
moel@347
   137
	union {
moel@347
   138
		ULONG   LongData;
moel@347
   139
		USHORT  ShortData;
moel@347
   140
		UCHAR   CharData;
moel@347
   141
	};
moel@347
   142
}   OLS_WRITE_IO_PORT_INPUT;
moel@347
   143
moel@347
   144
typedef struct  _OLS_READ_PCI_CONFIG_INPUT {
moel@347
   145
	ULONG PciAddress;
moel@347
   146
	ULONG PciOffset;
moel@347
   147
}   OLS_READ_PCI_CONFIG_INPUT;
moel@347
   148
moel@347
   149
typedef struct  _OLS_WRITE_PCI_CONFIG_INPUT {
moel@347
   150
	ULONG PciAddress;
moel@347
   151
	ULONG PciOffset;
moel@347
   152
	UCHAR Data[1];
moel@347
   153
}   OLS_WRITE_PCI_CONFIG_INPUT;
moel@347
   154
moel@347
   155
typedef LARGE_INTEGER PHYSICAL_ADDRESS;
moel@347
   156
moel@347
   157
typedef struct  _OLS_READ_MEMORY_INPUT {
moel@347
   158
	PHYSICAL_ADDRESS Address;
moel@347
   159
	ULONG UnitSize;
moel@347
   160
	ULONG Count;
moel@347
   161
}   OLS_READ_MEMORY_INPUT;
moel@347
   162
moel@347
   163
typedef struct  _OLS_WRITE_MEMORY_INPUT {
moel@347
   164
	PHYSICAL_ADDRESS Address;	 
moel@347
   165
	ULONG UnitSize;
moel@347
   166
	ULONG Count;
moel@347
   167
	UCHAR Data[1];
moel@347
   168
}   OLS_WRITE_MEMORY_INPUT;
moel@347
   169
moel@347
   170
#pragma pack(pop)