Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

622 lines
13 KiB

  1. /*++
  2. Copyright (c005289-1994 Microsoft Corporation
  3. Module Name:
  4. miniport.h
  5. Abstract:
  6. Type definitions for miniport drivers.
  7. Author:
  8. Mike Glass 27-April-1992
  9. Revision History:
  10. --*/
  11. #ifndef _MINIPORT_
  12. #define _MINIPORT_
  13. #include "stddef.h"
  14. //#define ASSERT( exp )
  15. #ifndef IN
  16. #define IN
  17. #endif
  18. #ifndef OUT
  19. #define OUT
  20. #endif
  21. #ifndef OPTIONAL
  22. #define OPTIONAL
  23. #endif
  24. #ifndef NOTHING
  25. #define NOTHING
  26. #endif
  27. #ifndef CRITICAL
  28. #define CRITICAL
  29. #endif
  30. #ifndef ANYSIZE_ARRAY
  31. #define ANYSIZE_ARRAY 1 // winnt
  32. #endif
  33. // begin_winnt
  34. #if defined(_M_MRX000) && !(defined(MIDL_PASS) || defined(RC_INVOKED)) && defined(ENABLE_RESTRICTED)
  35. #define RESTRICTED_POINTER __restrict
  36. #else
  37. #define RESTRICTED_POINTER
  38. #endif
  39. #if defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC)
  40. #define UNALIGNED __unaligned
  41. #else
  42. #define UNALIGNED
  43. #endif
  44. // end_winnt
  45. #ifndef CONST
  46. #define CONST const
  47. #endif
  48. // begin_winnt
  49. #if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)
  50. #define DECLSPEC_IMPORT __declspec(dllimport)
  51. #else
  52. #define DECLSPEC_IMPORT
  53. #endif
  54. // end_winnt
  55. //
  56. // Void
  57. //
  58. typedef void *PVOID; // winnt
  59. //
  60. // Basics
  61. //
  62. #ifndef VOID
  63. #define VOID void
  64. typedef char CHAR;
  65. typedef short SHORT;
  66. typedef long LONG;
  67. #endif
  68. //
  69. // UNICODE (Wide Character) types
  70. //
  71. typedef wchar_t WCHAR; // wc, 16-bit UNICODE character
  72. typedef WCHAR *PWCHAR;
  73. typedef WCHAR *LPWCH, *PWCH;
  74. typedef CONST WCHAR *LPCWCH, *PCWCH;
  75. typedef WCHAR *NWPSTR;
  76. typedef WCHAR *LPWSTR, *PWSTR;
  77. typedef CONST WCHAR *LPCWSTR, *PCWSTR;
  78. //
  79. // ANSI (Multi-byte Character) types
  80. //
  81. typedef CHAR *PCHAR;
  82. typedef CHAR *LPCH, *PCH;
  83. typedef CONST CHAR *LPCCH, *PCCH;
  84. typedef CHAR *NPSTR;
  85. typedef CHAR *LPSTR, *PSTR;
  86. typedef CONST CHAR *LPCSTR, *PCSTR;
  87. //
  88. // Neutral ANSI/UNICODE types and macros
  89. //
  90. #ifdef UNICODE
  91. #ifndef _TCHAR_DEFINED
  92. typedef WCHAR TCHAR, *PTCHAR;
  93. typedef WCHAR TUCHAR, *PTUCHAR;
  94. #define _TCHAR_DEFINED
  95. #endif /* !_TCHAR_DEFINED */
  96. typedef LPWSTR LPTCH, PTCH;
  97. typedef LPWSTR PTSTR, LPTSTR;
  98. typedef LPCWSTR LPCTSTR;
  99. typedef LPWSTR LP;
  100. #define __TEXT(quote) L##quote
  101. #else /* UNICODE */
  102. #ifndef _TCHAR_DEFINED
  103. typedef char TCHAR, *PTCHAR;
  104. typedef unsigned char TUCHAR, *PTUCHAR;
  105. #define _TCHAR_DEFINED
  106. #endif /* !_TCHAR_DEFINED */
  107. typedef LPSTR LPTCH, PTCH;
  108. typedef LPSTR PTSTR, LPTSTR;
  109. typedef LPCSTR LPCTSTR;
  110. #define __TEXT(quote) quote
  111. #endif /* UNICODE */
  112. #define TEXT(quote) __TEXT(quote)
  113. // end_winnt
  114. typedef double DOUBLE;
  115. //
  116. // Pointer to Basics
  117. //
  118. typedef SHORT *PSHORT; // winnt
  119. typedef LONG *PLONG; // winnt
  120. //
  121. // Unsigned Basics
  122. //
  123. // Tell windef.h that some types are already defined.
  124. #define BASETYPES
  125. typedef unsigned char UCHAR;
  126. typedef unsigned short USHORT;
  127. typedef unsigned long ULONG;
  128. //
  129. // Pointer to Unsigned Basics
  130. //
  131. typedef UCHAR *PUCHAR;
  132. typedef USHORT *PUSHORT;
  133. typedef ULONG *PULONG;
  134. //
  135. // Signed characters
  136. //
  137. typedef signed char SCHAR;
  138. typedef SCHAR *PSCHAR;
  139. #ifndef NO_STRICT
  140. #ifndef STRICT
  141. #define STRICT 1
  142. #endif
  143. #endif
  144. //
  145. // Handle to an Object
  146. //
  147. // begin_winnt
  148. #ifdef STRICT
  149. typedef void *HANDLE;
  150. #define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
  151. #else
  152. typedef PVOID HANDLE;
  153. #define DECLARE_HANDLE(name) typedef HANDLE name
  154. #endif
  155. typedef HANDLE *PHANDLE;
  156. //
  157. // Flag (bit) fields
  158. //
  159. typedef UCHAR FCHAR;
  160. typedef USHORT FSHORT;
  161. typedef ULONG FLONG;
  162. // end_winnt
  163. //
  164. // Low order two bits of a handle are ignored by the system and available
  165. // for use by application code as tag bits. The remaining bits are opaque
  166. // and used to store a serial number and table index.
  167. //
  168. #define OBJ_HANDLE_TAGBITS 0x00000003L
  169. //
  170. // Cardinal Data Types [0 - 2**N-2)
  171. //
  172. typedef char CCHAR; // winnt
  173. typedef short CSHORT;
  174. typedef ULONG CLONG;
  175. typedef CCHAR *PCCHAR;
  176. typedef CSHORT *PCSHORT;
  177. typedef CLONG *PCLONG;
  178. //
  179. // __int64 is only supported by 2.0 and later midl.
  180. // __midl is set by the 2.0 midl and not by 1.0 midl.
  181. //
  182. #if (!defined(MIDL_PASS) || defined(__midl)) && (!defined(_M_IX86) || (defined(_INTEGRAL_MAX_BITS) && _INTEGRAL_MAX_BITS >= 64))
  183. typedef __int64 LONGLONG;
  184. typedef unsigned __int64 ULONGLONG;
  185. #define MAXLONGLONG (0x7fffffffffffffff)
  186. #else
  187. typedef double LONGLONG;
  188. typedef double ULONGLONG;
  189. #endif
  190. typedef LONGLONG *PLONGLONG;
  191. typedef ULONGLONG *PULONGLONG;
  192. // Update Sequence Number
  193. typedef LONGLONG USN;
  194. //
  195. // Boolean
  196. //
  197. typedef UCHAR BOOLEAN; // winnt
  198. typedef BOOLEAN *PBOOLEAN; // winnt
  199. //
  200. // Constants
  201. //
  202. #define FALSE 0
  203. #define TRUE 1
  204. #ifndef NULL
  205. #ifdef __cplusplus
  206. #define NULL 0
  207. #else
  208. #define NULL ((void *)0)
  209. #endif
  210. #endif // NULL
  211. //
  212. // Calculate the byte offset of a field in a structure of type type.
  213. //
  214. #define FIELD_OFFSET(type, field) ((LONG)&(((type *)0)->field))
  215. //
  216. // Calculate the address of the base of the structure given its type, and an
  217. // address of a field within the structure.
  218. //
  219. #define CONTAINING_RECORD(address, type, field) ((type *)( \
  220. (PCHAR)(address) - \
  221. (PCHAR)(&((type *)0)->field)))
  222. //
  223. // Interrupt Request Level (IRQL)
  224. //
  225. typedef UCHAR KIRQL;
  226. typedef KIRQL *PKIRQL;
  227. //
  228. // Macros used to eliminate compiler warning generated when formal
  229. // parameters or local variables are not declared.
  230. //
  231. // Use DBG_UNREFERENCED_PARAMETER() when a parameter is not yet
  232. // referenced but will be once the module is completely developed.
  233. //
  234. // Use DBG_UNREFERENCED_LOCAL_VARIABLE() when a local variable is not yet
  235. // referenced but will be once the module is completely developed.
  236. //
  237. // Use UNREFERENCED_PARAMETER() if a parameter will never be referenced.
  238. //
  239. // DBG_UNREFERENCED_PARAMETER and DBG_UNREFERENCED_LOCAL_VARIABLE will
  240. // eventually be made into a null macro to help determine whether there
  241. // is unfinished work.
  242. //
  243. #if ! (defined(lint) || defined(_lint))
  244. #define UNREFERENCED_PARAMETER(P) (P)
  245. #define DBG_UNREFERENCED_PARAMETER(P) (P)
  246. #define DBG_UNREFERENCED_LOCAL_VARIABLE(V) (V)
  247. #else // lint or _lint
  248. // Note: lint -e530 says don't complain about uninitialized variables for
  249. // this. line +e530 turns that checking back on. Error 527 has to do with
  250. // unreachable code.
  251. #define UNREFERENCED_PARAMETER(P) \
  252. /*lint -e527 -e530 */ \
  253. { \
  254. (P) = (P); \
  255. } \
  256. /*lint +e527 +e530 */
  257. #define DBG_UNREFERENCED_PARAMETER(P) \
  258. /*lint -e527 -e530 */ \
  259. { \
  260. (P) = (P); \
  261. } \
  262. /*lint +e527 +e530 */
  263. #define DBG_UNREFERENCED_LOCAL_VARIABLE(V) \
  264. /*lint -e527 -e530 */ \
  265. { \
  266. (V) = (V); \
  267. } \
  268. /*lint +e527 +e530 */
  269. #endif // lint or _lint
  270. #ifdef _X86_
  271. //
  272. // Disable these two pramas that evaluate to "sti" "cli" on x86 so that driver
  273. // writers to not leave them inadvertantly in their code.
  274. //
  275. #if !defined(MIDL_PASS)
  276. #if !defined(RC_INVOKED)
  277. #pragma warning(disable:4164) // disable C4164 warning so that apps that
  278. // build with /Od don't get weird errors !
  279. #ifdef _M_IX86
  280. #pragma function(_enable)
  281. #pragma function(_disable)
  282. #endif
  283. #pragma warning(default:4164) // reenable C4164 warning
  284. #endif
  285. #endif
  286. #endif //_X86_
  287. //
  288. // Define the I/O bus interface types.
  289. //
  290. //
  291. // Structures used by the kernel drivers to describe which ports must be
  292. // hooked out directly from the V86 emulator to the driver.
  293. //
  294. typedef enum _EMULATOR_PORT_ACCESS_TYPE {
  295. Uchar,
  296. Ushort,
  297. Ulong
  298. } EMULATOR_PORT_ACCESS_TYPE, *PEMULATOR_PORT_ACCESS_TYPE;
  299. //
  300. // Access Modes
  301. //
  302. #define EMULATOR_READ_ACCESS 0x01
  303. #define EMULATOR_WRITE_ACCESS 0x02
  304. typedef struct _EMULATOR_ACCESS_ENTRY {
  305. ULONG BasePort;
  306. ULONG NumConsecutivePorts;
  307. EMULATOR_PORT_ACCESS_TYPE AccessType;
  308. UCHAR AccessMode;
  309. UCHAR StringSupport;
  310. PVOID Routine;
  311. } EMULATOR_ACCESS_ENTRY, *PEMULATOR_ACCESS_ENTRY;
  312. #define PCI_TYPE0_ADDRESSES 6
  313. #define PCI_TYPE1_ADDRESSES 2
  314. #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET (PCI_COMMON_CONFIG, DeviceSpecific))
  315. #define PCI_MAX_DEVICES 32
  316. #define PCI_MAX_FUNCTION 8
  317. #define PCI_INVALID_VENDORID 0xFFFF
  318. //
  319. // Bit encodings for PCI_COMMON_CONFIG.HeaderType
  320. //
  321. #define PCI_MULTIFUNCTION 0x80
  322. #define PCI_DEVICE_TYPE 0x00
  323. #define PCI_BRIDGE_TYPE 0x01
  324. //
  325. // Bit encodings for PCI_COMMON_CONFIG.Command
  326. //
  327. #define PCI_ENABLE_IO_SPACE 0x0001
  328. #define PCI_ENABLE_MEMORY_SPACE 0x0002
  329. #define PCI_ENABLE_BUS_MASTER 0x0004
  330. #define PCI_ENABLE_SPECIAL_CYCLES 0x0008
  331. #define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010
  332. #define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020
  333. #define PCI_ENABLE_PARITY 0x0040 // (ro+)
  334. #define PCI_ENABLE_WAIT_CYCLE 0x0080 // (ro+)
  335. #define PCI_ENABLE_SERR 0x0100 // (ro+)
  336. #define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200 // (ro)
  337. //
  338. // Bit encodings for PCI_COMMON_CONFIG.Status
  339. //
  340. #define PCI_STATUS_FAST_BACK_TO_BACK 0x0080 // (ro)
  341. #define PCI_STATUS_DATA_PARITY_DETECTED 0x0100
  342. #define PCI_STATUS_DEVSEL 0x0600 // 2 bits wide
  343. #define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800
  344. #define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000
  345. #define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000
  346. #define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000
  347. #define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000
  348. //
  349. // Bit encodes for PCI_COMMON_CONFIG.u.type0.BaseAddresses
  350. //
  351. #define PCI_ADDRESS_IO_SPACE 0x00000001 // (ro)
  352. #define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006 // (ro)
  353. #define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008 // (ro)
  354. #define PCI_TYPE_32BIT 0
  355. #define PCI_TYPE_20BIT 2
  356. #define PCI_TYPE_64BIT 4
  357. //
  358. // Bit encodes for PCI_COMMON_CONFIG.u.type0.ROMBaseAddresses
  359. //
  360. #define PCI_ROMADDRESS_ENABLED 0x00000001
  361. //
  362. // Reference notes for PCI configuration fields:
  363. //
  364. // ro these field are read only. changes to these fields are ignored
  365. //
  366. // ro+ these field are intended to be read only and should be initialized
  367. // by the system to their proper values. However, driver may change
  368. // these settings.
  369. //
  370. // ---
  371. //
  372. // All resources comsumed by a PCI device start as unitialized
  373. // under NT. An uninitialized memory or I/O base address can be
  374. // determined by checking it's corrisponding enabled bit in the
  375. // PCI_COMMON_CONFIG.Command value. An InterruptLine is unitialized
  376. // if it contains the value of -1.
  377. //
  378. //
  379. // Graphics support routines.
  380. //
  381. typedef
  382. VOID
  383. (*PBANKED_SECTION_ROUTINE) (
  384. IN ULONG ReadBank,
  385. IN ULONG WriteBank,
  386. IN PVOID Context
  387. );
  388. //
  389. // Define the bit masks for Flags when type is CmResourceTypeInterrupt
  390. //
  391. #define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0
  392. #define CM_RESOURCE_INTERRUPT_LATCHED 1
  393. //
  394. // Define the bit masks for Flags when type is CmResourceTypeMemory
  395. //
  396. #define CM_RESOURCE_MEMORY_READ_WRITE 0x0000
  397. #define CM_RESOURCE_MEMORY_READ_ONLY 0x0001
  398. #define CM_RESOURCE_MEMORY_WRITE_ONLY 0x0002
  399. #define CM_RESOURCE_MEMORY_PREFETCHABLE 0x0004
  400. //
  401. // Define the bit masks for Flags when type is CmResourceTypePort
  402. //
  403. //#define CM_RESOURCE_PORT_MEMORY 0
  404. //#define CM_RESOURCE_PORT_IO 1
  405. #include "pshpack1.h"
  406. #include "poppack.h"
  407. //
  408. // Masks for EISA function information
  409. //
  410. #define EISA_FUNCTION_ENABLED 0x80
  411. #define EISA_FREE_FORM_DATA 0x40
  412. #define EISA_HAS_PORT_INIT_ENTRY 0x20
  413. #define EISA_HAS_PORT_RANGE 0x10
  414. #define EISA_HAS_DMA_ENTRY 0x08
  415. #define EISA_HAS_IRQ_ENTRY 0x04
  416. #define EISA_HAS_MEMORY_ENTRY 0x02
  417. #define EISA_HAS_TYPE_ENTRY 0x01
  418. #define EISA_HAS_INFORMATION EISA_HAS_PORT_RANGE + \
  419. EISA_HAS_DMA_ENTRY + \
  420. EISA_HAS_IRQ_ENTRY + \
  421. EISA_HAS_MEMORY_ENTRY + \
  422. EISA_HAS_TYPE_ENTRY
  423. //
  424. // Masks for EISA memory configuration
  425. //
  426. #define EISA_MORE_ENTRIES 0x80
  427. #define EISA_SYSTEM_MEMORY 0x00
  428. #define EISA_MEMORY_TYPE_RAM 0x01
  429. //
  430. // Returned error code for EISA bios call
  431. //
  432. #define EISA_INVALID_SLOT 0x80
  433. #define EISA_INVALID_FUNCTION 0x81
  434. #define EISA_INVALID_CONFIGURATION 0x82
  435. #define EISA_EMPTY_SLOT 0x83
  436. #define EISA_INVALID_BIOS_CALL 0x86
  437. //
  438. // Defines Resource Options
  439. //
  440. #define IO_RESOURCE_PREFERRED 0x01
  441. #define IO_RESOURCE_DEFAULT 0x02
  442. #define IO_RESOURCE_ALTERNATIVE 0x08
  443. #endif /* _MINIPORT_ */