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