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.

1930 lines
48 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. miniport.h
  5. Abstract:
  6. Type definitions for miniport drivers.
  7. Revision History:
  8. --*/
  9. #ifndef _MINIPORT_
  10. #define _MINIPORT_
  11. #include "stddef.h"
  12. #define ASSERT( exp )
  13. #ifndef FAR
  14. #define FAR
  15. #endif
  16. #ifndef IN
  17. #define IN
  18. #endif
  19. #ifndef OUT
  20. #define OUT
  21. #endif
  22. #ifndef OPTIONAL
  23. #define OPTIONAL
  24. #endif
  25. #ifndef NOTHING
  26. #define NOTHING
  27. #endif
  28. #ifndef CRITICAL
  29. #define CRITICAL
  30. #endif
  31. #ifndef ANYSIZE_ARRAY
  32. #define ANYSIZE_ARRAY 1 // winnt
  33. #endif
  34. // begin_winnt
  35. #if defined(_M_MRX000) && !(defined(MIDL_PASS) || defined(RC_INVOKED)) && defined(ENABLE_RESTRICTED)
  36. #define RESTRICTED_POINTER __restrict
  37. #else
  38. #define RESTRICTED_POINTER
  39. #endif
  40. #if defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64) || defined(_M_AMD64)
  41. #define UNALIGNED __unaligned
  42. #if defined(_WIN64)
  43. #define UNALIGNED64 __unaligned
  44. #else
  45. #define UNALIGNED64
  46. #endif
  47. #else
  48. #define UNALIGNED
  49. #define UNALIGNED64
  50. #endif
  51. #if defined(_WIN64) || defined(_M_ALPHA)
  52. #define MAX_NATURAL_ALIGNMENT sizeof(ULONGLONG)
  53. #define MEMORY_ALLOCATION_ALIGNMENT 16
  54. #else
  55. #define MAX_NATURAL_ALIGNMENT sizeof(ULONG)
  56. #define MEMORY_ALLOCATION_ALIGNMENT 8
  57. #endif
  58. //
  59. // TYPE_ALIGNMENT will return the alignment requirements of a given type for
  60. // the current platform.
  61. //
  62. #ifdef __cplusplus
  63. #if _MSC_VER >= 1300
  64. #define TYPE_ALIGNMENT( t ) __alignof(t)
  65. #endif
  66. #else
  67. #define TYPE_ALIGNMENT( t ) \
  68. FIELD_OFFSET( struct { char x; t test; }, test )
  69. #endif
  70. #if defined(_WIN64)
  71. #define PROBE_ALIGNMENT( _s ) (TYPE_ALIGNMENT( _s ) > TYPE_ALIGNMENT( ULONG ) ? \
  72. TYPE_ALIGNMENT( _s ) : TYPE_ALIGNMENT( ULONG ))
  73. #define PROBE_ALIGNMENT32( _s ) TYPE_ALIGNMENT( ULONG )
  74. #else
  75. #define PROBE_ALIGNMENT( _s ) TYPE_ALIGNMENT( ULONG )
  76. #endif
  77. //
  78. // C_ASSERT() can be used to perform many compile-time assertions:
  79. // type sizes, field offsets, etc.
  80. //
  81. // An assertion failure results in error C2118: negative subscript.
  82. //
  83. #define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
  84. #if !defined(_MAC) && (defined(_M_MRX000) || defined(_M_AMD64) || defined(_M_IA64)) && (_MSC_VER >= 1100) && !(defined(MIDL_PASS) || defined(RC_INVOKED))
  85. #define POINTER_64 __ptr64
  86. typedef unsigned __int64 POINTER_64_INT;
  87. #if defined(_WIN64)
  88. #define POINTER_32 __ptr32
  89. #else
  90. #define POINTER_32
  91. #endif
  92. #else
  93. #if defined(_MAC) && defined(_MAC_INT_64)
  94. #define POINTER_64 __ptr64
  95. typedef unsigned __int64 POINTER_64_INT;
  96. #else
  97. #define POINTER_64
  98. typedef unsigned long POINTER_64_INT;
  99. #endif
  100. #define POINTER_32
  101. #endif
  102. #if defined(_IA64_) || defined(_AMD64_)
  103. #define FIRMWARE_PTR
  104. #else
  105. #define FIRMWARE_PTR POINTER_32
  106. #endif
  107. #include <basetsd.h>
  108. // end_winnt
  109. #ifndef CONST
  110. #define CONST const
  111. #endif
  112. // begin_winnt
  113. #if (defined(_M_IX86) || defined(_M_IA64) || defined(_M_AMD64)) && !defined(MIDL_PASS)
  114. #define DECLSPEC_IMPORT __declspec(dllimport)
  115. #else
  116. #define DECLSPEC_IMPORT
  117. #endif
  118. #ifndef DECLSPEC_NORETURN
  119. #if (_MSC_VER >= 1200) && !defined(MIDL_PASS)
  120. #define DECLSPEC_NORETURN __declspec(noreturn)
  121. #else
  122. #define DECLSPEC_NORETURN
  123. #endif
  124. #endif
  125. #ifndef DECLSPEC_ALIGN
  126. #if (_MSC_VER >= 1300) && !defined(MIDL_PASS)
  127. #define DECLSPEC_ALIGN(x) __declspec(align(x))
  128. #else
  129. #define DECLSPEC_ALIGN(x)
  130. #endif
  131. #endif
  132. #ifndef DECLSPEC_CACHEALIGN
  133. #define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN(128)
  134. #endif
  135. #ifndef DECLSPEC_UUID
  136. #if (_MSC_VER >= 1100) && defined (__cplusplus)
  137. #define DECLSPEC_UUID(x) __declspec(uuid(x))
  138. #else
  139. #define DECLSPEC_UUID(x)
  140. #endif
  141. #endif
  142. #ifndef DECLSPEC_NOVTABLE
  143. #if (_MSC_VER >= 1100) && defined(__cplusplus)
  144. #define DECLSPEC_NOVTABLE __declspec(novtable)
  145. #else
  146. #define DECLSPEC_NOVTABLE
  147. #endif
  148. #endif
  149. #ifndef DECLSPEC_SELECTANY
  150. #if (_MSC_VER >= 1100)
  151. #define DECLSPEC_SELECTANY __declspec(selectany)
  152. #else
  153. #define DECLSPEC_SELECTANY
  154. #endif
  155. #endif
  156. #ifndef NOP_FUNCTION
  157. #if (_MSC_VER >= 1210)
  158. #define NOP_FUNCTION __noop
  159. #else
  160. #define NOP_FUNCTION (void)0
  161. #endif
  162. #endif
  163. #ifndef DECLSPEC_ADDRSAFE
  164. #if (_MSC_VER >= 1200) && (defined(_M_ALPHA) || defined(_M_AXP64))
  165. #define DECLSPEC_ADDRSAFE __declspec(address_safe)
  166. #else
  167. #define DECLSPEC_ADDRSAFE
  168. #endif
  169. #endif
  170. #ifndef FORCEINLINE
  171. #if (_MSC_VER >= 1200)
  172. #define FORCEINLINE __forceinline
  173. #else
  174. #define FORCEINLINE __inline
  175. #endif
  176. #endif
  177. #ifndef DECLSPEC_DEPRECATED
  178. #if (_MSC_VER >= 1300) && !defined(MIDL_PASS)
  179. #define DECLSPEC_DEPRECATED __declspec(deprecated)
  180. #define DEPRECATE_SUPPORTED
  181. #else
  182. #define DECLSPEC_DEPRECATED
  183. #undef DEPRECATE_SUPPORTED
  184. #endif
  185. #endif
  186. // end_winnt
  187. #ifdef DEPRECATE_DDK_FUNCTIONS
  188. #ifdef _NTDDK_
  189. #define DECLSPEC_DEPRECATED_DDK DECLSPEC_DEPRECATED
  190. #ifdef DEPRECATE_SUPPORTED
  191. #define PRAGMA_DEPRECATED_DDK 1
  192. #endif
  193. #else
  194. #define DECLSPEC_DEPRECATED_DDK
  195. #define PRAGMA_DEPRECATED_DDK 1
  196. #endif
  197. #else
  198. #define DECLSPEC_DEPRECATED_DDK
  199. #define PRAGMA_DEPRECATED_DDK 0
  200. #endif
  201. //
  202. // Void
  203. //
  204. // begin_winnt
  205. typedef void *PVOID;
  206. typedef void * POINTER_64 PVOID64;
  207. // end_winnt
  208. #if defined(_M_IX86)
  209. #define FASTCALL _fastcall
  210. #else
  211. #define FASTCALL
  212. #endif
  213. //
  214. // Basics
  215. //
  216. #ifndef VOID
  217. #define VOID void
  218. typedef char CHAR;
  219. typedef short SHORT;
  220. typedef long LONG;
  221. #endif
  222. //
  223. // UNICODE (Wide Character) types
  224. //
  225. #ifndef _MAC
  226. typedef wchar_t WCHAR; // wc, 16-bit UNICODE character
  227. #else
  228. // some Macintosh compilers don't define wchar_t in a convenient location, or define it as a char
  229. typedef unsigned short WCHAR; // wc, 16-bit UNICODE character
  230. #endif
  231. typedef WCHAR *PWCHAR;
  232. typedef WCHAR *LPWCH, *PWCH;
  233. typedef CONST WCHAR *LPCWCH, *PCWCH;
  234. typedef WCHAR *NWPSTR;
  235. typedef WCHAR *LPWSTR, *PWSTR;
  236. typedef WCHAR UNALIGNED *LPUWSTR, *PUWSTR;
  237. typedef CONST WCHAR *LPCWSTR, *PCWSTR;
  238. typedef CONST WCHAR UNALIGNED *LPCUWSTR, *PCUWSTR;
  239. //
  240. // ANSI (Multi-byte Character) types
  241. //
  242. typedef CHAR *PCHAR;
  243. typedef CHAR *LPCH, *PCH;
  244. typedef CONST CHAR *LPCCH, *PCCH;
  245. typedef CHAR *NPSTR;
  246. typedef CHAR *LPSTR, *PSTR;
  247. typedef CONST CHAR *LPCSTR, *PCSTR;
  248. //
  249. // Neutral ANSI/UNICODE types and macros
  250. //
  251. #ifdef UNICODE // r_winnt
  252. #ifndef _TCHAR_DEFINED
  253. typedef WCHAR TCHAR, *PTCHAR;
  254. typedef WCHAR TUCHAR, *PTUCHAR;
  255. #define _TCHAR_DEFINED
  256. #endif /* !_TCHAR_DEFINED */
  257. typedef LPWSTR LPTCH, PTCH;
  258. typedef LPWSTR PTSTR, LPTSTR;
  259. typedef LPCWSTR PCTSTR, LPCTSTR;
  260. typedef LPUWSTR PUTSTR, LPUTSTR;
  261. typedef LPCUWSTR PCUTSTR, LPCUTSTR;
  262. typedef LPWSTR LP;
  263. #define __TEXT(quote) L##quote // r_winnt
  264. #else /* UNICODE */ // r_winnt
  265. #ifndef _TCHAR_DEFINED
  266. typedef char TCHAR, *PTCHAR;
  267. typedef unsigned char TUCHAR, *PTUCHAR;
  268. #define _TCHAR_DEFINED
  269. #endif /* !_TCHAR_DEFINED */
  270. typedef LPSTR LPTCH, PTCH;
  271. typedef LPSTR PTSTR, LPTSTR, PUTSTR, LPUTSTR;
  272. typedef LPCSTR PCTSTR, LPCTSTR, PCUTSTR, LPCUTSTR;
  273. #define __TEXT(quote) quote // r_winnt
  274. #endif /* UNICODE */ // r_winnt
  275. #define TEXT(quote) __TEXT(quote) // r_winnt
  276. // end_winnt
  277. typedef double DOUBLE;
  278. typedef struct _QUAD { // QUAD is for those times we want
  279. double DoNotUseThisField; // an 8 byte aligned 8 byte long structure
  280. } QUAD; // which is NOT really a floating point
  281. // number. Use DOUBLE if you want an FP
  282. // number.
  283. //
  284. // Pointer to Basics
  285. //
  286. typedef SHORT *PSHORT; // winnt
  287. typedef LONG *PLONG; // winnt
  288. typedef QUAD *PQUAD;
  289. //
  290. // Unsigned Basics
  291. //
  292. // Tell windef.h that some types are already defined.
  293. #define BASETYPES
  294. typedef unsigned char UCHAR;
  295. typedef unsigned short USHORT;
  296. typedef unsigned long ULONG;
  297. typedef QUAD UQUAD;
  298. //
  299. // Pointer to Unsigned Basics
  300. //
  301. typedef UCHAR *PUCHAR;
  302. typedef USHORT *PUSHORT;
  303. typedef ULONG *PULONG;
  304. typedef UQUAD *PUQUAD;
  305. //
  306. // Signed characters
  307. //
  308. typedef signed char SCHAR;
  309. typedef SCHAR *PSCHAR;
  310. #ifndef NO_STRICT
  311. #ifndef STRICT
  312. #define STRICT 1
  313. #endif
  314. #endif
  315. //
  316. // Handle to an Object
  317. //
  318. // begin_winnt
  319. #ifdef STRICT
  320. typedef void *HANDLE;
  321. #define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
  322. #else
  323. typedef PVOID HANDLE;
  324. #define DECLARE_HANDLE(name) typedef HANDLE name
  325. #endif
  326. typedef HANDLE *PHANDLE;
  327. //
  328. // Flag (bit) fields
  329. //
  330. typedef UCHAR FCHAR;
  331. typedef USHORT FSHORT;
  332. typedef ULONG FLONG;
  333. // Component Object Model defines, and macros
  334. #ifndef _HRESULT_DEFINED
  335. #define _HRESULT_DEFINED
  336. typedef LONG HRESULT;
  337. #endif // !_HRESULT_DEFINED
  338. #ifdef __cplusplus
  339. #define EXTERN_C extern "C"
  340. #else
  341. #define EXTERN_C extern
  342. #endif
  343. #if defined(_WIN32) || defined(_MPPC_)
  344. // Win32 doesn't support __export
  345. #ifdef _68K_
  346. #define STDMETHODCALLTYPE __cdecl
  347. #else
  348. #define STDMETHODCALLTYPE __stdcall
  349. #endif
  350. #define STDMETHODVCALLTYPE __cdecl
  351. #define STDAPICALLTYPE __stdcall
  352. #define STDAPIVCALLTYPE __cdecl
  353. #else
  354. #define STDMETHODCALLTYPE __export __stdcall
  355. #define STDMETHODVCALLTYPE __export __cdecl
  356. #define STDAPICALLTYPE __export __stdcall
  357. #define STDAPIVCALLTYPE __export __cdecl
  358. #endif
  359. #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
  360. #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
  361. #define STDMETHODIMP HRESULT STDMETHODCALLTYPE
  362. #define STDMETHODIMP_(type) type STDMETHODCALLTYPE
  363. // The 'V' versions allow Variable Argument lists.
  364. #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE
  365. #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE
  366. #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE
  367. #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE
  368. // end_winnt
  369. //
  370. // Low order two bits of a handle are ignored by the system and available
  371. // for use by application code as tag bits. The remaining bits are opaque
  372. // and used to store a serial number and table index.
  373. //
  374. #define OBJ_HANDLE_TAGBITS 0x00000003L
  375. //
  376. // Cardinal Data Types [0 - 2**N-2)
  377. //
  378. typedef char CCHAR; // winnt
  379. typedef short CSHORT;
  380. typedef ULONG CLONG;
  381. typedef CCHAR *PCCHAR;
  382. typedef CSHORT *PCSHORT;
  383. typedef CLONG *PCLONG;
  384. //
  385. // __int64 is only supported by 2.0 and later midl.
  386. // __midl is set by the 2.0 midl and not by 1.0 midl.
  387. //
  388. #define _ULONGLONG_
  389. #if (!defined (_MAC) && (!defined(MIDL_PASS) || defined(__midl)) && (!defined(_M_IX86) || (defined(_INTEGRAL_MAX_BITS) && _INTEGRAL_MAX_BITS >= 64)))
  390. typedef __int64 LONGLONG;
  391. typedef unsigned __int64 ULONGLONG;
  392. #define MAXLONGLONG (0x7fffffffffffffff)
  393. #else
  394. #if defined(_MAC) && defined(_MAC_INT_64)
  395. typedef __int64 LONGLONG;
  396. typedef unsigned __int64 ULONGLONG;
  397. #define MAXLONGLONG (0x7fffffffffffffff)
  398. #else
  399. typedef double LONGLONG;
  400. typedef double ULONGLONG;
  401. #endif //_MAC and int64
  402. #endif
  403. typedef LONGLONG *PLONGLONG;
  404. typedef ULONGLONG *PULONGLONG;
  405. // Update Sequence Number
  406. typedef LONGLONG USN;
  407. #if defined(MIDL_PASS)
  408. typedef struct _LARGE_INTEGER {
  409. #else // MIDL_PASS
  410. typedef union _LARGE_INTEGER {
  411. struct {
  412. ULONG LowPart;
  413. LONG HighPart;
  414. };
  415. struct {
  416. ULONG LowPart;
  417. LONG HighPart;
  418. } u;
  419. #endif //MIDL_PASS
  420. LONGLONG QuadPart;
  421. } LARGE_INTEGER;
  422. typedef LARGE_INTEGER *PLARGE_INTEGER;
  423. #if defined(MIDL_PASS)
  424. typedef struct _ULARGE_INTEGER {
  425. #else // MIDL_PASS
  426. typedef union _ULARGE_INTEGER {
  427. struct {
  428. ULONG LowPart;
  429. ULONG HighPart;
  430. };
  431. struct {
  432. ULONG LowPart;
  433. ULONG HighPart;
  434. } u;
  435. #endif //MIDL_PASS
  436. ULONGLONG QuadPart;
  437. } ULARGE_INTEGER;
  438. typedef ULARGE_INTEGER *PULARGE_INTEGER;
  439. //
  440. // Physical address.
  441. //
  442. typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS;
  443. //
  444. // Boolean
  445. //
  446. typedef UCHAR BOOLEAN; // winnt
  447. typedef BOOLEAN *PBOOLEAN; // winnt
  448. //
  449. // Constants
  450. //
  451. #define FALSE 0
  452. #define TRUE 1
  453. #ifndef NULL
  454. #ifdef __cplusplus
  455. #define NULL 0
  456. #define NULL64 0
  457. #else
  458. #define NULL ((void *)0)
  459. #define NULL64 ((void * POINTER_64)0)
  460. #endif
  461. #endif // NULL
  462. //
  463. // Calculate the byte offset of a field in a structure of type type.
  464. //
  465. #define FIELD_OFFSET(type, field) ((LONG)(LONG_PTR)&(((type *)0)->field))
  466. #if(_WIN32_WINNT > 0x0500)
  467. //
  468. // Calculate the size of a field in a structure of type type, without
  469. // knowing or stating the type of the field.
  470. //
  471. #define RTL_FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
  472. //
  473. // Calculate the size of a structure of type type up through and
  474. // including a field.
  475. //
  476. #define RTL_SIZEOF_THROUGH_FIELD(type, field) \
  477. (FIELD_OFFSET(type, field) + RTL_FIELD_SIZE(type, field))
  478. //
  479. // RTL_CONTAINS_FIELD usage:
  480. //
  481. // if (RTL_CONTAINS_FIELD(pBlock, pBlock->cbSize, dwMumble)) { // safe to use pBlock->dwMumble
  482. //
  483. #define RTL_CONTAINS_FIELD(Struct, Size, Field) \
  484. ( (((PCHAR)(&(Struct)->Field)) + sizeof((Struct)->Field)) <= (((PCHAR)(Struct))+(Size)) )
  485. //
  486. // Return the number of elements in a statically sized array.
  487. // ULONG Buffer[100];
  488. // RTL_NUMBER_OF(Buffer) == 100
  489. // This is also popularly known as: NUMBER_OF, ARRSIZE, _countof, NELEM, etc.
  490. //
  491. #define RTL_NUMBER_OF(A) (sizeof(A)/sizeof((A)[0]))
  492. //
  493. // An expression that yields the type of a field in a struct.
  494. //
  495. #define RTL_FIELD_TYPE(type, field) (((type*)0)->field)
  496. // RTL_ to avoid collisions in the global namespace.
  497. //
  498. // Given typedef struct _FOO { BYTE Bar[123]; } FOO;
  499. // RTL_NUMBER_OF_FIELD(FOO, Bar) == 123
  500. //
  501. #define RTL_NUMBER_OF_FIELD(type, field) (RTL_NUMBER_OF(RTL_FIELD_TYPE(type, field)))
  502. //
  503. // eg:
  504. // typedef struct FOO {
  505. // ULONG Integer;
  506. // PVOID Pointer;
  507. // } FOO;
  508. //
  509. // RTL_PADDING_BETWEEN_FIELDS(FOO, Integer, Pointer) == 0 for Win32, 4 for Win64
  510. //
  511. #define RTL_PADDING_BETWEEN_FIELDS(T, F1, F2) \
  512. ((FIELD_OFFSET(T, F2) > FIELD_OFFSET(T, F1)) \
  513. ? (FIELD_OFFSET(T, F2) - FIELD_OFFSET(T, F1) - RTL_FIELD_SIZE(T, F1)) \
  514. : (FIELD_OFFSET(T, F1) - FIELD_OFFSET(T, F2) - RTL_FIELD_SIZE(T, F2)))
  515. // RTL_ to avoid collisions in the global namespace.
  516. #if defined(__cplusplus)
  517. #define RTL_CONST_CAST(type) const_cast<type>
  518. #else
  519. #define RTL_CONST_CAST(type) (type)
  520. #endif
  521. // end_winnt
  522. //
  523. // This works "generically" for Unicode and Ansi/Oem strings.
  524. // Usage:
  525. // const static UNICODE_STRING FooU = RTL_CONSTANT_STRING(L"Foo");
  526. // const static STRING Foo = RTL_CONSTANT_STRING( "Foo");
  527. // instead of the slower:
  528. // UNICODE_STRING FooU;
  529. // STRING Foo;
  530. // RtlInitUnicodeString(&FooU, L"Foo");
  531. // RtlInitString(&Foo , "Foo");
  532. //
  533. #define RTL_CONSTANT_STRING(s) { sizeof( s ) - sizeof( (s)[0] ), sizeof( s ), s }
  534. // begin_winnt
  535. // like sizeof
  536. // usually this would be * CHAR_BIT, but we don't necessarily have #include <limits.h>
  537. #define RTL_BITS_OF(sizeOfArg) (sizeof(sizeOfArg) * 8)
  538. #define RTL_BITS_OF_FIELD(type, field) (RTL_BITS_OF(RTL_FIELD_TYPE(type, field)))
  539. #endif /* _WIN32_WINNT > 0x0500 */
  540. //
  541. // Calculate the address of the base of the structure given its type, and an
  542. // address of a field within the structure.
  543. //
  544. #define CONTAINING_RECORD(address, type, field) ((type *)( \
  545. (PCHAR)(address) - \
  546. (ULONG_PTR)(&((type *)0)->field)))
  547. //
  548. // Interrupt Request Level (IRQL)
  549. //
  550. typedef UCHAR KIRQL;
  551. typedef KIRQL *PKIRQL;
  552. //
  553. // Macros used to eliminate compiler warning generated when formal
  554. // parameters or local variables are not declared.
  555. //
  556. // Use DBG_UNREFERENCED_PARAMETER() when a parameter is not yet
  557. // referenced but will be once the module is completely developed.
  558. //
  559. // Use DBG_UNREFERENCED_LOCAL_VARIABLE() when a local variable is not yet
  560. // referenced but will be once the module is completely developed.
  561. //
  562. // Use UNREFERENCED_PARAMETER() if a parameter will never be referenced.
  563. //
  564. // DBG_UNREFERENCED_PARAMETER and DBG_UNREFERENCED_LOCAL_VARIABLE will
  565. // eventually be made into a null macro to help determine whether there
  566. // is unfinished work.
  567. //
  568. #if ! defined(lint)
  569. #define UNREFERENCED_PARAMETER(P) (P)
  570. #define DBG_UNREFERENCED_PARAMETER(P) (P)
  571. #define DBG_UNREFERENCED_LOCAL_VARIABLE(V) (V)
  572. #else // lint
  573. // Note: lint -e530 says don't complain about uninitialized variables for
  574. // this varible. Error 527 has to do with unreachable code.
  575. // -restore restores checking to the -save state
  576. #define UNREFERENCED_PARAMETER(P) \
  577. /*lint -save -e527 -e530 */ \
  578. { \
  579. (P) = (P); \
  580. } \
  581. /*lint -restore */
  582. #define DBG_UNREFERENCED_PARAMETER(P) \
  583. /*lint -save -e527 -e530 */ \
  584. { \
  585. (P) = (P); \
  586. } \
  587. /*lint -restore */
  588. #define DBG_UNREFERENCED_LOCAL_VARIABLE(V) \
  589. /*lint -save -e527 -e530 */ \
  590. { \
  591. (V) = (V); \
  592. } \
  593. /*lint -restore */
  594. #endif // lint
  595. //
  596. // Macro used to eliminate compiler warning 4715 within a switch statement
  597. // when all possible cases have already been accounted for.
  598. //
  599. // switch (a & 3) {
  600. // case 0: return 1;
  601. // case 1: return Foo();
  602. // case 2: return Bar();
  603. // case 3: return 1;
  604. // DEFAULT_UNREACHABLE;
  605. //
  606. #if (_MSC_VER > 1200)
  607. #define DEFAULT_UNREACHABLE default: __assume(0)
  608. #else
  609. //
  610. // Older compilers do not support __assume(), and there is no other free
  611. // method of eliminating the warning.
  612. //
  613. #define DEFAULT_UNREACHABLE
  614. #endif
  615. // end_winnt
  616. //
  617. // Define standard min and max macros
  618. //
  619. #ifndef NOMINMAX
  620. #ifndef min
  621. #define min(a,b) (((a) < (b)) ? (a) : (b))
  622. #endif
  623. #ifndef max
  624. #define max(a,b) (((a) > (b)) ? (a) : (b))
  625. #endif
  626. #endif // NOMINMAX
  627. #ifdef _X86_
  628. //
  629. // Disable these two pragmas that evaluate to "sti" "cli" on x86 so that driver
  630. // writers to not leave them inadvertantly in their code.
  631. //
  632. #if !defined(MIDL_PASS)
  633. #if !defined(RC_INVOKED)
  634. #if _MSC_VER >= 1200
  635. #pragma warning(push)
  636. #endif
  637. #pragma warning(disable:4164) // disable C4164 warning so that apps that
  638. // build with /Od don't get weird errors !
  639. #ifdef _M_IX86
  640. #pragma function(_enable)
  641. #pragma function(_disable)
  642. #endif
  643. #if _MSC_VER >= 1200
  644. #pragma warning(pop)
  645. #else
  646. #pragma warning(default:4164) // reenable C4164 warning
  647. #endif
  648. #endif
  649. #endif
  650. #endif //_X86_
  651. //
  652. // Define the I/O bus interface types.
  653. //
  654. typedef enum _INTERFACE_TYPE {
  655. InterfaceTypeUndefined = -1,
  656. Internal,
  657. Isa,
  658. Eisa,
  659. MicroChannel,
  660. TurboChannel,
  661. PCIBus,
  662. VMEBus,
  663. NuBus,
  664. PCMCIABus,
  665. CBus,
  666. MPIBus,
  667. MPSABus,
  668. ProcessorInternal,
  669. InternalPowerBus,
  670. PNPISABus,
  671. PNPBus,
  672. MaximumInterfaceType
  673. }INTERFACE_TYPE, *PINTERFACE_TYPE;
  674. //
  675. // Define the DMA transfer widths.
  676. //
  677. typedef enum _DMA_WIDTH {
  678. Width8Bits,
  679. Width16Bits,
  680. Width32Bits,
  681. MaximumDmaWidth
  682. }DMA_WIDTH, *PDMA_WIDTH;
  683. //
  684. // Define DMA transfer speeds.
  685. //
  686. typedef enum _DMA_SPEED {
  687. Compatible,
  688. TypeA,
  689. TypeB,
  690. TypeC,
  691. TypeF,
  692. MaximumDmaSpeed
  693. }DMA_SPEED, *PDMA_SPEED;
  694. //
  695. // Define Interface reference/dereference routines for
  696. // Interfaces exported by IRP_MN_QUERY_INTERFACE
  697. //
  698. typedef VOID (*PINTERFACE_REFERENCE)(PVOID Context);
  699. typedef VOID (*PINTERFACE_DEREFERENCE)(PVOID Context);
  700. // end_wdm
  701. //
  702. // Define types of bus information.
  703. //
  704. typedef enum _BUS_DATA_TYPE {
  705. ConfigurationSpaceUndefined = -1,
  706. Cmos,
  707. EisaConfiguration,
  708. Pos,
  709. CbusConfiguration,
  710. PCIConfiguration,
  711. VMEConfiguration,
  712. NuBusConfiguration,
  713. PCMCIAConfiguration,
  714. MPIConfiguration,
  715. MPSAConfiguration,
  716. PNPISAConfiguration,
  717. SgiInternalConfiguration,
  718. MaximumBusDataType
  719. } BUS_DATA_TYPE, *PBUS_DATA_TYPE;
  720. #include <guiddef.h>
  721. //
  722. // Interrupt modes.
  723. //
  724. typedef enum _KINTERRUPT_MODE {
  725. LevelSensitive,
  726. Latched
  727. } KINTERRUPT_MODE;
  728. //
  729. // Structures used by the kernel drivers to describe which ports must be
  730. // hooked out directly from the V86 emulator to the driver.
  731. //
  732. typedef enum _EMULATOR_PORT_ACCESS_TYPE {
  733. Uchar,
  734. Ushort,
  735. Ulong
  736. } EMULATOR_PORT_ACCESS_TYPE, *PEMULATOR_PORT_ACCESS_TYPE;
  737. //
  738. // Access Modes
  739. //
  740. #define EMULATOR_READ_ACCESS 0x01
  741. #define EMULATOR_WRITE_ACCESS 0x02
  742. typedef struct _EMULATOR_ACCESS_ENTRY {
  743. ULONG BasePort;
  744. ULONG NumConsecutivePorts;
  745. EMULATOR_PORT_ACCESS_TYPE AccessType;
  746. UCHAR AccessMode;
  747. UCHAR StringSupport;
  748. PVOID Routine;
  749. } EMULATOR_ACCESS_ENTRY, *PEMULATOR_ACCESS_ENTRY;
  750. typedef struct _PCI_SLOT_NUMBER {
  751. union {
  752. struct {
  753. ULONG DeviceNumber:5;
  754. ULONG FunctionNumber:3;
  755. ULONG Reserved:24;
  756. } bits;
  757. ULONG AsULONG;
  758. } u;
  759. } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER;
  760. #define PCI_TYPE0_ADDRESSES 6
  761. #define PCI_TYPE1_ADDRESSES 2
  762. #define PCI_TYPE2_ADDRESSES 5
  763. typedef struct _PCI_COMMON_CONFIG {
  764. USHORT VendorID; // (ro)
  765. USHORT DeviceID; // (ro)
  766. USHORT Command; // Device control
  767. USHORT Status;
  768. UCHAR RevisionID; // (ro)
  769. UCHAR ProgIf; // (ro)
  770. UCHAR SubClass; // (ro)
  771. UCHAR BaseClass; // (ro)
  772. UCHAR CacheLineSize; // (ro+)
  773. UCHAR LatencyTimer; // (ro+)
  774. UCHAR HeaderType; // (ro)
  775. UCHAR BIST; // Built in self test
  776. union {
  777. struct _PCI_HEADER_TYPE_0 {
  778. ULONG BaseAddresses[PCI_TYPE0_ADDRESSES];
  779. ULONG CIS;
  780. USHORT SubVendorID;
  781. USHORT SubSystemID;
  782. ULONG ROMBaseAddress;
  783. UCHAR CapabilitiesPtr;
  784. UCHAR Reserved1[3];
  785. ULONG Reserved2;
  786. UCHAR InterruptLine; //
  787. UCHAR InterruptPin; // (ro)
  788. UCHAR MinimumGrant; // (ro)
  789. UCHAR MaximumLatency; // (ro)
  790. } type0;
  791. } u;
  792. UCHAR DeviceSpecific[192];
  793. } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
  794. #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET (PCI_COMMON_CONFIG, DeviceSpecific))
  795. #define PCI_MAX_DEVICES 32
  796. #define PCI_MAX_FUNCTION 8
  797. #define PCI_MAX_BRIDGE_NUMBER 0xFF
  798. #define PCI_INVALID_VENDORID 0xFFFF
  799. //
  800. // Bit encodings for PCI_COMMON_CONFIG.HeaderType
  801. //
  802. #define PCI_MULTIFUNCTION 0x80
  803. #define PCI_DEVICE_TYPE 0x00
  804. #define PCI_BRIDGE_TYPE 0x01
  805. #define PCI_CARDBUS_BRIDGE_TYPE 0x02
  806. #define PCI_CONFIGURATION_TYPE(PciData) \
  807. (((PPCI_COMMON_CONFIG)(PciData))->HeaderType & ~PCI_MULTIFUNCTION)
  808. #define PCI_MULTIFUNCTION_DEVICE(PciData) \
  809. ((((PPCI_COMMON_CONFIG)(PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
  810. //
  811. // Bit encodings for PCI_COMMON_CONFIG.Command
  812. //
  813. #define PCI_ENABLE_IO_SPACE 0x0001
  814. #define PCI_ENABLE_MEMORY_SPACE 0x0002
  815. #define PCI_ENABLE_BUS_MASTER 0x0004
  816. #define PCI_ENABLE_SPECIAL_CYCLES 0x0008
  817. #define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010
  818. #define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020
  819. #define PCI_ENABLE_PARITY 0x0040 // (ro+)
  820. #define PCI_ENABLE_WAIT_CYCLE 0x0080 // (ro+)
  821. #define PCI_ENABLE_SERR 0x0100 // (ro+)
  822. #define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200 // (ro)
  823. //
  824. // Bit encodings for PCI_COMMON_CONFIG.Status
  825. //
  826. #define PCI_STATUS_CAPABILITIES_LIST 0x0010 // (ro)
  827. #define PCI_STATUS_66MHZ_CAPABLE 0x0020 // (ro)
  828. #define PCI_STATUS_UDF_SUPPORTED 0x0040 // (ro)
  829. #define PCI_STATUS_FAST_BACK_TO_BACK 0x0080 // (ro)
  830. #define PCI_STATUS_DATA_PARITY_DETECTED 0x0100
  831. #define PCI_STATUS_DEVSEL 0x0600 // 2 bits wide
  832. #define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800
  833. #define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000
  834. #define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000
  835. #define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000
  836. #define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000
  837. //
  838. // The NT PCI Driver uses a WhichSpace parameter on its CONFIG_READ/WRITE
  839. // routines. The following values are defined-
  840. //
  841. #define PCI_WHICHSPACE_CONFIG 0x0
  842. #define PCI_WHICHSPACE_ROM 0x52696350
  843. // end_wdm
  844. //
  845. // PCI Capability IDs
  846. //
  847. #define PCI_CAPABILITY_ID_POWER_MANAGEMENT 0x01
  848. #define PCI_CAPABILITY_ID_AGP 0x02
  849. #define PCI_CAPABILITY_ID_MSI 0x05
  850. //
  851. // All PCI Capability structures have the following header.
  852. //
  853. // CapabilityID is used to identify the type of the structure (is
  854. // one of the PCI_CAPABILITY_ID values above.
  855. //
  856. // Next is the offset in PCI Configuration space (0x40 - 0xfc) of the
  857. // next capability structure in the list, or 0x00 if there are no more
  858. // entries.
  859. //
  860. typedef struct _PCI_CAPABILITIES_HEADER {
  861. UCHAR CapabilityID;
  862. UCHAR Next;
  863. } PCI_CAPABILITIES_HEADER, *PPCI_CAPABILITIES_HEADER;
  864. //
  865. // Power Management Capability
  866. //
  867. typedef struct _PCI_PMC {
  868. UCHAR Version:3;
  869. UCHAR PMEClock:1;
  870. UCHAR Rsvd1:1;
  871. UCHAR DeviceSpecificInitialization:1;
  872. UCHAR Rsvd2:2;
  873. struct _PM_SUPPORT {
  874. UCHAR Rsvd2:1;
  875. UCHAR D1:1;
  876. UCHAR D2:1;
  877. UCHAR PMED0:1;
  878. UCHAR PMED1:1;
  879. UCHAR PMED2:1;
  880. UCHAR PMED3Hot:1;
  881. UCHAR PMED3Cold:1;
  882. } Support;
  883. } PCI_PMC, *PPCI_PMC;
  884. typedef struct _PCI_PMCSR {
  885. USHORT PowerState:2;
  886. USHORT Rsvd1:6;
  887. USHORT PMEEnable:1;
  888. USHORT DataSelect:4;
  889. USHORT DataScale:2;
  890. USHORT PMEStatus:1;
  891. } PCI_PMCSR, *PPCI_PMCSR;
  892. typedef struct _PCI_PMCSR_BSE {
  893. UCHAR Rsvd1:6;
  894. UCHAR D3HotSupportsStopClock:1; // B2_B3#
  895. UCHAR BusPowerClockControlEnabled:1; // BPCC_EN
  896. } PCI_PMCSR_BSE, *PPCI_PMCSR_BSE;
  897. typedef struct _PCI_PM_CAPABILITY {
  898. PCI_CAPABILITIES_HEADER Header;
  899. //
  900. // Power Management Capabilities (Offset = 2)
  901. //
  902. union {
  903. PCI_PMC Capabilities;
  904. USHORT AsUSHORT;
  905. } PMC;
  906. //
  907. // Power Management Control/Status (Offset = 4)
  908. //
  909. union {
  910. PCI_PMCSR ControlStatus;
  911. USHORT AsUSHORT;
  912. } PMCSR;
  913. //
  914. // PMCSR PCI-PCI Bridge Support Extensions
  915. //
  916. union {
  917. PCI_PMCSR_BSE BridgeSupport;
  918. UCHAR AsUCHAR;
  919. } PMCSR_BSE;
  920. //
  921. // Optional read only 8 bit Data register. Contents controlled by
  922. // DataSelect and DataScale in ControlStatus.
  923. //
  924. UCHAR Data;
  925. } PCI_PM_CAPABILITY, *PPCI_PM_CAPABILITY;
  926. //
  927. // AGP Capability
  928. //
  929. typedef struct _PCI_AGP_CAPABILITY {
  930. PCI_CAPABILITIES_HEADER Header;
  931. USHORT Minor:4;
  932. USHORT Major:4;
  933. USHORT Rsvd1:8;
  934. struct _PCI_AGP_STATUS {
  935. ULONG Rate:3;
  936. ULONG Rsvd1:1;
  937. ULONG FastWrite:1;
  938. ULONG FourGB:1;
  939. ULONG Rsvd2:3;
  940. ULONG SideBandAddressing:1; // SBA
  941. ULONG Rsvd3:14;
  942. ULONG RequestQueueDepthMaximum:8; // RQ
  943. } AGPStatus;
  944. struct _PCI_AGP_COMMAND {
  945. ULONG Rate:3;
  946. ULONG Rsvd1:1;
  947. ULONG FastWriteEnable:1;
  948. ULONG FourGBEnable:1;
  949. ULONG Rsvd2:2;
  950. ULONG AGPEnable:1;
  951. ULONG SBAEnable:1;
  952. ULONG Rsvd3:14;
  953. ULONG RequestQueueDepth:8;
  954. } AGPCommand;
  955. } PCI_AGP_CAPABILITY, *PPCI_AGP_CAPABILITY;
  956. #define PCI_AGP_RATE_1X 0x1
  957. #define PCI_AGP_RATE_2X 0x2
  958. #define PCI_AGP_RATE_4X 0x4
  959. //
  960. // MSI (Message Signalled Interrupts) Capability
  961. //
  962. typedef struct _PCI_MSI_CAPABILITY {
  963. PCI_CAPABILITIES_HEADER Header;
  964. struct _PCI_MSI_MESSAGE_CONTROL {
  965. USHORT MSIEnable:1;
  966. USHORT MultipleMessageCapable:3;
  967. USHORT MultipleMessageEnable:3;
  968. USHORT CapableOf64Bits:1;
  969. USHORT Reserved:8;
  970. } MessageControl;
  971. union {
  972. struct _PCI_MSI_MESSAGE_ADDRESS {
  973. ULONG_PTR Reserved:2; // always zero, DWORD aligned address
  974. ULONG_PTR Address:30;
  975. } Register;
  976. ULONG_PTR Raw;
  977. } MessageAddress;
  978. //
  979. // The rest of the Capability structure differs depending on whether
  980. // 32bit or 64bit addressing is being used.
  981. //
  982. // (The CapableOf64Bits bit above determines this)
  983. //
  984. union {
  985. // For 64 bit devices
  986. struct _PCI_MSI_64BIT_DATA {
  987. ULONG MessageUpperAddress;
  988. USHORT MessageData;
  989. } Bit64;
  990. // For 32 bit devices
  991. struct _PCI_MSI_32BIT_DATA {
  992. USHORT MessageData;
  993. ULONG Unused;
  994. } Bit32;
  995. } Data;
  996. } PCI_MSI_CAPABILITY, *PPCI_PCI_CAPABILITY;
  997. // begin_wdm
  998. //
  999. // Base Class Code encodings for Base Class (from PCI spec rev 2.1).
  1000. //
  1001. #define PCI_CLASS_PRE_20 0x00
  1002. #define PCI_CLASS_MASS_STORAGE_CTLR 0x01
  1003. #define PCI_CLASS_NETWORK_CTLR 0x02
  1004. #define PCI_CLASS_DISPLAY_CTLR 0x03
  1005. #define PCI_CLASS_MULTIMEDIA_DEV 0x04
  1006. #define PCI_CLASS_MEMORY_CTLR 0x05
  1007. #define PCI_CLASS_BRIDGE_DEV 0x06
  1008. #define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07
  1009. #define PCI_CLASS_BASE_SYSTEM_DEV 0x08
  1010. #define PCI_CLASS_INPUT_DEV 0x09
  1011. #define PCI_CLASS_DOCKING_STATION 0x0a
  1012. #define PCI_CLASS_PROCESSOR 0x0b
  1013. #define PCI_CLASS_SERIAL_BUS_CTLR 0x0c
  1014. #define PCI_CLASS_WIRELESS_CTLR 0x0d
  1015. #define PCI_CLASS_INTELLIGENT_IO_CTLR 0x0e
  1016. #define PCI_CLASS_SATELLITE_COMMS_CTLR 0x0f
  1017. #define PCI_CLASS_ENCRYPTION_DECRYPTION 0x10
  1018. #define PCI_CLASS_DATA_ACQ_SIGNAL_PROC 0x11
  1019. // 0d thru fe reserved
  1020. #define PCI_CLASS_NOT_DEFINED 0xff
  1021. //
  1022. // Sub Class Code encodings (PCI rev 2.1).
  1023. //
  1024. // Class 00 - PCI_CLASS_PRE_20
  1025. #define PCI_SUBCLASS_PRE_20_NON_VGA 0x00
  1026. #define PCI_SUBCLASS_PRE_20_VGA 0x01
  1027. // Class 01 - PCI_CLASS_MASS_STORAGE_CTLR
  1028. #define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00
  1029. #define PCI_SUBCLASS_MSC_IDE_CTLR 0x01
  1030. #define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02
  1031. #define PCI_SUBCLASS_MSC_IPI_CTLR 0x03
  1032. #define PCI_SUBCLASS_MSC_RAID_CTLR 0x04
  1033. #define PCI_SUBCLASS_MSC_OTHER 0x80
  1034. // Class 02 - PCI_CLASS_NETWORK_CTLR
  1035. #define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00
  1036. #define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01
  1037. #define PCI_SUBCLASS_NET_FDDI_CTLR 0x02
  1038. #define PCI_SUBCLASS_NET_ATM_CTLR 0x03
  1039. #define PCI_SUBCLASS_NET_ISDN_CTLR 0x04
  1040. #define PCI_SUBCLASS_NET_OTHER 0x80
  1041. // Class 03 - PCI_CLASS_DISPLAY_CTLR
  1042. // N.B. Sub Class 00 could be VGA or 8514 depending on Interface byte
  1043. #define PCI_SUBCLASS_VID_VGA_CTLR 0x00
  1044. #define PCI_SUBCLASS_VID_XGA_CTLR 0x01
  1045. #define PCI_SUBLCASS_VID_3D_CTLR 0x02
  1046. #define PCI_SUBCLASS_VID_OTHER 0x80
  1047. // Class 04 - PCI_CLASS_MULTIMEDIA_DEV
  1048. #define PCI_SUBCLASS_MM_VIDEO_DEV 0x00
  1049. #define PCI_SUBCLASS_MM_AUDIO_DEV 0x01
  1050. #define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02
  1051. #define PCI_SUBCLASS_MM_OTHER 0x80
  1052. // Class 05 - PCI_CLASS_MEMORY_CTLR
  1053. #define PCI_SUBCLASS_MEM_RAM 0x00
  1054. #define PCI_SUBCLASS_MEM_FLASH 0x01
  1055. #define PCI_SUBCLASS_MEM_OTHER 0x80
  1056. // Class 06 - PCI_CLASS_BRIDGE_DEV
  1057. #define PCI_SUBCLASS_BR_HOST 0x00
  1058. #define PCI_SUBCLASS_BR_ISA 0x01
  1059. #define PCI_SUBCLASS_BR_EISA 0x02
  1060. #define PCI_SUBCLASS_BR_MCA 0x03
  1061. #define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04
  1062. #define PCI_SUBCLASS_BR_PCMCIA 0x05
  1063. #define PCI_SUBCLASS_BR_NUBUS 0x06
  1064. #define PCI_SUBCLASS_BR_CARDBUS 0x07
  1065. #define PCI_SUBCLASS_BR_RACEWAY 0x08
  1066. #define PCI_SUBCLASS_BR_OTHER 0x80
  1067. // Class 07 - PCI_CLASS_SIMPLE_COMMS_CTLR
  1068. // N.B. Sub Class 00 and 01 additional info in Interface byte
  1069. #define PCI_SUBCLASS_COM_SERIAL 0x00
  1070. #define PCI_SUBCLASS_COM_PARALLEL 0x01
  1071. #define PCI_SUBCLASS_COM_MULTIPORT 0x02
  1072. #define PCI_SUBCLASS_COM_MODEM 0x03
  1073. #define PCI_SUBCLASS_COM_OTHER 0x80
  1074. // Class 08 - PCI_CLASS_BASE_SYSTEM_DEV
  1075. // N.B. See Interface byte for additional info.
  1076. #define PCI_SUBCLASS_SYS_INTERRUPT_CTLR 0x00
  1077. #define PCI_SUBCLASS_SYS_DMA_CTLR 0x01
  1078. #define PCI_SUBCLASS_SYS_SYSTEM_TIMER 0x02
  1079. #define PCI_SUBCLASS_SYS_REAL_TIME_CLOCK 0x03
  1080. #define PCI_SUBCLASS_SYS_GEN_HOTPLUG_CTLR 0x04
  1081. #define PCI_SUBCLASS_SYS_OTHER 0x80
  1082. // Class 09 - PCI_CLASS_INPUT_DEV
  1083. #define PCI_SUBCLASS_INP_KEYBOARD 0x00
  1084. #define PCI_SUBCLASS_INP_DIGITIZER 0x01
  1085. #define PCI_SUBCLASS_INP_MOUSE 0x02
  1086. #define PCI_SUBCLASS_INP_SCANNER 0x03
  1087. #define PCI_SUBCLASS_INP_GAMEPORT 0x04
  1088. #define PCI_SUBCLASS_INP_OTHER 0x80
  1089. // Class 0a - PCI_CLASS_DOCKING_STATION
  1090. #define PCI_SUBCLASS_DOC_GENERIC 0x00
  1091. #define PCI_SUBCLASS_DOC_OTHER 0x80
  1092. // Class 0b - PCI_CLASS_PROCESSOR
  1093. #define PCI_SUBCLASS_PROC_386 0x00
  1094. #define PCI_SUBCLASS_PROC_486 0x01
  1095. #define PCI_SUBCLASS_PROC_PENTIUM 0x02
  1096. #define PCI_SUBCLASS_PROC_ALPHA 0x10
  1097. #define PCI_SUBCLASS_PROC_POWERPC 0x20
  1098. #define PCI_SUBCLASS_PROC_COPROCESSOR 0x40
  1099. // Class 0c - PCI_CLASS_SERIAL_BUS_CTLR
  1100. #define PCI_SUBCLASS_SB_IEEE1394 0x00
  1101. #define PCI_SUBCLASS_SB_ACCESS 0x01
  1102. #define PCI_SUBCLASS_SB_SSA 0x02
  1103. #define PCI_SUBCLASS_SB_USB 0x03
  1104. #define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04
  1105. #define PCI_SUBCLASS_SB_SMBUS 0x05
  1106. // Class 0d - PCI_CLASS_WIRELESS_CTLR
  1107. #define PCI_SUBCLASS_WIRELESS_IRDA 0x00
  1108. #define PCI_SUBCLASS_WIRELESS_CON_IR 0x01
  1109. #define PCI_SUBCLASS_WIRELESS_RF 0x10
  1110. #define PCI_SUBCLASS_WIRELESS_OTHER 0x80
  1111. // Class 0e - PCI_CLASS_INTELLIGENT_IO_CTLR
  1112. #define PCI_SUBCLASS_INTIO_I2O 0x00
  1113. // Class 0f - PCI_CLASS_SATELLITE_CTLR
  1114. #define PCI_SUBCLASS_SAT_TV 0x01
  1115. #define PCI_SUBCLASS_SAT_AUDIO 0x02
  1116. #define PCI_SUBCLASS_SAT_VOICE 0x03
  1117. #define PCI_SUBCLASS_SAT_DATA 0x04
  1118. // Class 10 - PCI_CLASS_ENCRYPTION_DECRYPTION
  1119. #define PCI_SUBCLASS_CRYPTO_NET_COMP 0x00
  1120. #define PCI_SUBCLASS_CRYPTO_ENTERTAINMENT 0x10
  1121. #define PCI_SUBCLASS_CRYPTO_OTHER 0x80
  1122. // Class 11 - PCI_CLASS_DATA_ACQ_SIGNAL_PROC
  1123. #define PCI_SUBCLASS_DASP_DPIO 0x00
  1124. #define PCI_SUBCLASS_DASP_OTHER 0x80
  1125. // end_ntndis
  1126. //
  1127. // Bit encodes for PCI_COMMON_CONFIG.u.type0.BaseAddresses
  1128. //
  1129. #define PCI_ADDRESS_IO_SPACE 0x00000001 // (ro)
  1130. #define PCI_ADDRESS_MEMORY_TYPE_MASK 0x00000006 // (ro)
  1131. #define PCI_ADDRESS_MEMORY_PREFETCHABLE 0x00000008 // (ro)
  1132. #define PCI_ADDRESS_IO_ADDRESS_MASK 0xfffffffc
  1133. #define PCI_ADDRESS_MEMORY_ADDRESS_MASK 0xfffffff0
  1134. #define PCI_ADDRESS_ROM_ADDRESS_MASK 0xfffff800
  1135. #define PCI_TYPE_32BIT 0
  1136. #define PCI_TYPE_20BIT 2
  1137. #define PCI_TYPE_64BIT 4
  1138. //
  1139. // Bit encodes for PCI_COMMON_CONFIG.u.type0.ROMBaseAddresses
  1140. //
  1141. #define PCI_ROMADDRESS_ENABLED 0x00000001
  1142. //
  1143. // Reference notes for PCI configuration fields:
  1144. //
  1145. // ro these field are read only. changes to these fields are ignored
  1146. //
  1147. // ro+ these field are intended to be read only and should be initialized
  1148. // by the system to their proper values. However, driver may change
  1149. // these settings.
  1150. //
  1151. // ---
  1152. //
  1153. // All resources comsumed by a PCI device start as unitialized
  1154. // under NT. An uninitialized memory or I/O base address can be
  1155. // determined by checking it's corrisponding enabled bit in the
  1156. // PCI_COMMON_CONFIG.Command value. An InterruptLine is unitialized
  1157. // if it contains the value of -1.
  1158. //
  1159. //
  1160. // Graphics support routines.
  1161. //
  1162. typedef
  1163. VOID
  1164. (*PBANKED_SECTION_ROUTINE) (
  1165. IN ULONG ReadBank,
  1166. IN ULONG WriteBank,
  1167. IN PVOID Context
  1168. );
  1169. //
  1170. // WMI minor function codes under IRP_MJ_SYSTEM_CONTROL
  1171. //
  1172. #define IRP_MN_QUERY_ALL_DATA 0x00
  1173. #define IRP_MN_QUERY_SINGLE_INSTANCE 0x01
  1174. #define IRP_MN_CHANGE_SINGLE_INSTANCE 0x02
  1175. #define IRP_MN_CHANGE_SINGLE_ITEM 0x03
  1176. #define IRP_MN_ENABLE_EVENTS 0x04
  1177. #define IRP_MN_DISABLE_EVENTS 0x05
  1178. #define IRP_MN_ENABLE_COLLECTION 0x06
  1179. #define IRP_MN_DISABLE_COLLECTION 0x07
  1180. #define IRP_MN_REGINFO 0x08
  1181. #define IRP_MN_EXECUTE_METHOD 0x09
  1182. // Minor code 0x0a is reserved
  1183. #define IRP_MN_REGINFO_EX 0x0b
  1184. // workaround overloaded definition (rpc generated headers all define INTERFACE
  1185. // to match the class name).
  1186. #undef INTERFACE
  1187. typedef struct _INTERFACE {
  1188. USHORT Size;
  1189. USHORT Version;
  1190. PVOID Context;
  1191. PINTERFACE_REFERENCE InterfaceReference;
  1192. PINTERFACE_DEREFERENCE InterfaceDereference;
  1193. // interface specific entries go here
  1194. } INTERFACE, *PINTERFACE;
  1195. //
  1196. // Defines the Type in the RESOURCE_DESCRIPTOR
  1197. //
  1198. // NOTE: For all CM_RESOURCE_TYPE values, there must be a
  1199. // corresponding ResType value in the 32-bit ConfigMgr headerfile
  1200. // (cfgmgr32.h). Values in the range [0x6,0x80) use the same values
  1201. // as their ConfigMgr counterparts. CM_RESOURCE_TYPE values with
  1202. // the high bit set (i.e., in the range [0x80,0xFF]), are
  1203. // non-arbitrated resources. These correspond to the same values
  1204. // in cfgmgr32.h that have their high bit set (however, since
  1205. // cfgmgr32.h uses 16 bits for ResType values, these values are in
  1206. // the range [0x8000,0x807F). Note that ConfigMgr ResType values
  1207. // cannot be in the range [0x8080,0xFFFF), because they would not
  1208. // be able to map into CM_RESOURCE_TYPE values. (0xFFFF itself is
  1209. // a special value, because it maps to CmResourceTypeDeviceSpecific.)
  1210. //
  1211. typedef int CM_RESOURCE_TYPE;
  1212. // CmResourceTypeNull is reserved
  1213. #define CmResourceTypeNull 0 // ResType_All or ResType_None (0x0000)
  1214. #define CmResourceTypePort 1 // ResType_IO (0x0002)
  1215. #define CmResourceTypeInterrupt 2 // ResType_IRQ (0x0004)
  1216. #define CmResourceTypeMemory 3 // ResType_Mem (0x0001)
  1217. #define CmResourceTypeDma 4 // ResType_DMA (0x0003)
  1218. #define CmResourceTypeDeviceSpecific 5 // ResType_ClassSpecific (0xFFFF)
  1219. #define CmResourceTypeBusNumber 6 // ResType_BusNumber (0x0006)
  1220. // end_wdm
  1221. #define CmResourceTypeMaximum 7
  1222. // begin_wdm
  1223. #define CmResourceTypeNonArbitrated 128 // Not arbitrated if 0x80 bit set
  1224. #define CmResourceTypeConfigData 128 // ResType_Reserved (0x8000)
  1225. #define CmResourceTypeDevicePrivate 129 // ResType_DevicePrivate (0x8001)
  1226. #define CmResourceTypePcCardConfig 130 // ResType_PcCardConfig (0x8002)
  1227. #define CmResourceTypeMfCardConfig 131 // ResType_MfCardConfig (0x8003)
  1228. //
  1229. // Defines the ShareDisposition in the RESOURCE_DESCRIPTOR
  1230. //
  1231. typedef enum _CM_SHARE_DISPOSITION {
  1232. CmResourceShareUndetermined = 0, // Reserved
  1233. CmResourceShareDeviceExclusive,
  1234. CmResourceShareDriverExclusive,
  1235. CmResourceShareShared
  1236. } CM_SHARE_DISPOSITION;
  1237. //
  1238. // Define the bit masks for Flags when type is CmResourceTypeInterrupt
  1239. //
  1240. #define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0
  1241. #define CM_RESOURCE_INTERRUPT_LATCHED 1
  1242. //
  1243. // Define the bit masks for Flags when type is CmResourceTypeMemory
  1244. //
  1245. #define CM_RESOURCE_MEMORY_READ_WRITE 0x0000
  1246. #define CM_RESOURCE_MEMORY_READ_ONLY 0x0001
  1247. #define CM_RESOURCE_MEMORY_WRITE_ONLY 0x0002
  1248. #define CM_RESOURCE_MEMORY_PREFETCHABLE 0x0004
  1249. #define CM_RESOURCE_MEMORY_COMBINEDWRITE 0x0008
  1250. #define CM_RESOURCE_MEMORY_24 0x0010
  1251. #define CM_RESOURCE_MEMORY_CACHEABLE 0x0020
  1252. //
  1253. // Define the bit masks for Flags when type is CmResourceTypePort
  1254. //
  1255. #define CM_RESOURCE_PORT_MEMORY 0x0000
  1256. #define CM_RESOURCE_PORT_IO 0x0001
  1257. #define CM_RESOURCE_PORT_10_BIT_DECODE 0x0004
  1258. #define CM_RESOURCE_PORT_12_BIT_DECODE 0x0008
  1259. #define CM_RESOURCE_PORT_16_BIT_DECODE 0x0010
  1260. #define CM_RESOURCE_PORT_POSITIVE_DECODE 0x0020
  1261. #define CM_RESOURCE_PORT_PASSIVE_DECODE 0x0040
  1262. #define CM_RESOURCE_PORT_WINDOW_DECODE 0x0080
  1263. //
  1264. // Define the bit masks for Flags when type is CmResourceTypeDma
  1265. //
  1266. #define CM_RESOURCE_DMA_8 0x0000
  1267. #define CM_RESOURCE_DMA_16 0x0001
  1268. #define CM_RESOURCE_DMA_32 0x0002
  1269. #define CM_RESOURCE_DMA_8_AND_16 0x0004
  1270. #define CM_RESOURCE_DMA_BUS_MASTER 0x0008
  1271. #define CM_RESOURCE_DMA_TYPE_A 0x0010
  1272. #define CM_RESOURCE_DMA_TYPE_B 0x0020
  1273. #define CM_RESOURCE_DMA_TYPE_F 0x0040
  1274. #include "pshpack1.h"
  1275. //
  1276. // Define Mca POS data block for slot
  1277. //
  1278. typedef struct _CM_MCA_POS_DATA {
  1279. USHORT AdapterId;
  1280. UCHAR PosData1;
  1281. UCHAR PosData2;
  1282. UCHAR PosData3;
  1283. UCHAR PosData4;
  1284. } CM_MCA_POS_DATA, *PCM_MCA_POS_DATA;
  1285. //
  1286. // Memory configuration of eisa data block structure
  1287. //
  1288. typedef struct _EISA_MEMORY_TYPE {
  1289. UCHAR ReadWrite: 1;
  1290. UCHAR Cached : 1;
  1291. UCHAR Reserved0 :1;
  1292. UCHAR Type:2;
  1293. UCHAR Shared:1;
  1294. UCHAR Reserved1 :1;
  1295. UCHAR MoreEntries : 1;
  1296. } EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE;
  1297. typedef struct _EISA_MEMORY_CONFIGURATION {
  1298. EISA_MEMORY_TYPE ConfigurationByte;
  1299. UCHAR DataSize;
  1300. USHORT AddressLowWord;
  1301. UCHAR AddressHighByte;
  1302. USHORT MemorySize;
  1303. } EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION;
  1304. //
  1305. // Interrupt configurationn of eisa data block structure
  1306. //
  1307. typedef struct _EISA_IRQ_DESCRIPTOR {
  1308. UCHAR Interrupt : 4;
  1309. UCHAR Reserved :1;
  1310. UCHAR LevelTriggered :1;
  1311. UCHAR Shared : 1;
  1312. UCHAR MoreEntries : 1;
  1313. } EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR;
  1314. typedef struct _EISA_IRQ_CONFIGURATION {
  1315. EISA_IRQ_DESCRIPTOR ConfigurationByte;
  1316. UCHAR Reserved;
  1317. } EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION;
  1318. //
  1319. // DMA description of eisa data block structure
  1320. //
  1321. typedef struct _DMA_CONFIGURATION_BYTE0 {
  1322. UCHAR Channel : 3;
  1323. UCHAR Reserved : 3;
  1324. UCHAR Shared :1;
  1325. UCHAR MoreEntries :1;
  1326. } DMA_CONFIGURATION_BYTE0;
  1327. typedef struct _DMA_CONFIGURATION_BYTE1 {
  1328. UCHAR Reserved0 : 2;
  1329. UCHAR TransferSize : 2;
  1330. UCHAR Timing : 2;
  1331. UCHAR Reserved1 : 2;
  1332. } DMA_CONFIGURATION_BYTE1;
  1333. typedef struct _EISA_DMA_CONFIGURATION {
  1334. DMA_CONFIGURATION_BYTE0 ConfigurationByte0;
  1335. DMA_CONFIGURATION_BYTE1 ConfigurationByte1;
  1336. } EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION;
  1337. //
  1338. // Port description of eisa data block structure
  1339. //
  1340. typedef struct _EISA_PORT_DESCRIPTOR {
  1341. UCHAR NumberPorts : 5;
  1342. UCHAR Reserved :1;
  1343. UCHAR Shared :1;
  1344. UCHAR MoreEntries : 1;
  1345. } EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR;
  1346. typedef struct _EISA_PORT_CONFIGURATION {
  1347. EISA_PORT_DESCRIPTOR Configuration;
  1348. USHORT PortAddress;
  1349. } EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION;
  1350. //
  1351. // Eisa slot information definition
  1352. // N.B. This structure is different from the one defined
  1353. // in ARC eisa addendum.
  1354. //
  1355. typedef struct _CM_EISA_SLOT_INFORMATION {
  1356. UCHAR ReturnCode;
  1357. UCHAR ReturnFlags;
  1358. UCHAR MajorRevision;
  1359. UCHAR MinorRevision;
  1360. USHORT Checksum;
  1361. UCHAR NumberFunctions;
  1362. UCHAR FunctionInformation;
  1363. ULONG CompressedId;
  1364. } CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION;
  1365. //
  1366. // Eisa function information definition
  1367. //
  1368. typedef struct _CM_EISA_FUNCTION_INFORMATION {
  1369. ULONG CompressedId;
  1370. UCHAR IdSlotFlags1;
  1371. UCHAR IdSlotFlags2;
  1372. UCHAR MinorRevision;
  1373. UCHAR MajorRevision;
  1374. UCHAR Selections[26];
  1375. UCHAR FunctionFlags;
  1376. UCHAR TypeString[80];
  1377. EISA_MEMORY_CONFIGURATION EisaMemory[9];
  1378. EISA_IRQ_CONFIGURATION EisaIrq[7];
  1379. EISA_DMA_CONFIGURATION EisaDma[4];
  1380. EISA_PORT_CONFIGURATION EisaPort[20];
  1381. UCHAR InitializationData[60];
  1382. } CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION;
  1383. //
  1384. // The following defines the way pnp bios information is stored in
  1385. // the registry \\HKEY_LOCAL_MACHINE\HARDWARE\Description\System\MultifunctionAdapter\x
  1386. // key, where x is an integer number indicating adapter instance. The
  1387. // "Identifier" of the key must equal to "PNP BIOS" and the
  1388. // "ConfigurationData" is organized as follow:
  1389. //
  1390. // CM_PNP_BIOS_INSTALLATION_CHECK +
  1391. // CM_PNP_BIOS_DEVICE_NODE for device 1 +
  1392. // CM_PNP_BIOS_DEVICE_NODE for device 2 +
  1393. // ...
  1394. // CM_PNP_BIOS_DEVICE_NODE for device n
  1395. //
  1396. //
  1397. // Pnp BIOS device node structure
  1398. //
  1399. typedef struct _CM_PNP_BIOS_DEVICE_NODE {
  1400. USHORT Size;
  1401. UCHAR Node;
  1402. ULONG ProductId;
  1403. UCHAR DeviceType[3];
  1404. USHORT DeviceAttributes;
  1405. // followed by AllocatedResourceBlock, PossibleResourceBlock
  1406. // and CompatibleDeviceId
  1407. } CM_PNP_BIOS_DEVICE_NODE,*PCM_PNP_BIOS_DEVICE_NODE;
  1408. //
  1409. // Pnp BIOS Installation check
  1410. //
  1411. typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK {
  1412. UCHAR Signature[4]; // $PnP (ascii)
  1413. UCHAR Revision;
  1414. UCHAR Length;
  1415. USHORT ControlField;
  1416. UCHAR Checksum;
  1417. ULONG EventFlagAddress; // Physical address
  1418. USHORT RealModeEntryOffset;
  1419. USHORT RealModeEntrySegment;
  1420. USHORT ProtectedModeEntryOffset;
  1421. ULONG ProtectedModeCodeBaseAddress;
  1422. ULONG OemDeviceId;
  1423. USHORT RealModeDataBaseAddress;
  1424. ULONG ProtectedModeDataBaseAddress;
  1425. } CM_PNP_BIOS_INSTALLATION_CHECK, *PCM_PNP_BIOS_INSTALLATION_CHECK;
  1426. #include "poppack.h"
  1427. //
  1428. // Masks for EISA function information
  1429. //
  1430. #define EISA_FUNCTION_ENABLED 0x80
  1431. #define EISA_FREE_FORM_DATA 0x40
  1432. #define EISA_HAS_PORT_INIT_ENTRY 0x20
  1433. #define EISA_HAS_PORT_RANGE 0x10
  1434. #define EISA_HAS_DMA_ENTRY 0x08
  1435. #define EISA_HAS_IRQ_ENTRY 0x04
  1436. #define EISA_HAS_MEMORY_ENTRY 0x02
  1437. #define EISA_HAS_TYPE_ENTRY 0x01
  1438. #define EISA_HAS_INFORMATION EISA_HAS_PORT_RANGE + \
  1439. EISA_HAS_DMA_ENTRY + \
  1440. EISA_HAS_IRQ_ENTRY + \
  1441. EISA_HAS_MEMORY_ENTRY + \
  1442. EISA_HAS_TYPE_ENTRY
  1443. //
  1444. // Masks for EISA memory configuration
  1445. //
  1446. #define EISA_MORE_ENTRIES 0x80
  1447. #define EISA_SYSTEM_MEMORY 0x00
  1448. #define EISA_MEMORY_TYPE_RAM 0x01
  1449. //
  1450. // Returned error code for EISA bios call
  1451. //
  1452. #define EISA_INVALID_SLOT 0x80
  1453. #define EISA_INVALID_FUNCTION 0x81
  1454. #define EISA_INVALID_CONFIGURATION 0x82
  1455. #define EISA_EMPTY_SLOT 0x83
  1456. #define EISA_INVALID_BIOS_CALL 0x86
  1457. //
  1458. // Defines Resource Options
  1459. //
  1460. #define IO_RESOURCE_PREFERRED 0x01
  1461. #define IO_RESOURCE_DEFAULT 0x02
  1462. #define IO_RESOURCE_ALTERNATIVE 0x08
  1463. //
  1464. // This structure defines one type of resource requested by the driver
  1465. //
  1466. typedef struct _IO_RESOURCE_DESCRIPTOR {
  1467. UCHAR Option;
  1468. UCHAR Type; // use CM_RESOURCE_TYPE
  1469. UCHAR ShareDisposition; // use CM_SHARE_DISPOSITION
  1470. UCHAR Spare1;
  1471. USHORT Flags; // use CM resource flag defines
  1472. USHORT Spare2; // align
  1473. union {
  1474. struct {
  1475. ULONG Length;
  1476. ULONG Alignment;
  1477. PHYSICAL_ADDRESS MinimumAddress;
  1478. PHYSICAL_ADDRESS MaximumAddress;
  1479. } Port;
  1480. struct {
  1481. ULONG Length;
  1482. ULONG Alignment;
  1483. PHYSICAL_ADDRESS MinimumAddress;
  1484. PHYSICAL_ADDRESS MaximumAddress;
  1485. } Memory;
  1486. struct {
  1487. ULONG MinimumVector;
  1488. ULONG MaximumVector;
  1489. } Interrupt;
  1490. struct {
  1491. ULONG MinimumChannel;
  1492. ULONG MaximumChannel;
  1493. } Dma;
  1494. struct {
  1495. ULONG Length;
  1496. ULONG Alignment;
  1497. PHYSICAL_ADDRESS MinimumAddress;
  1498. PHYSICAL_ADDRESS MaximumAddress;
  1499. } Generic;
  1500. struct {
  1501. ULONG Data[3];
  1502. } DevicePrivate;
  1503. //
  1504. // Bus Number information.
  1505. //
  1506. struct {
  1507. ULONG Length;
  1508. ULONG MinBusNumber;
  1509. ULONG MaxBusNumber;
  1510. ULONG Reserved;
  1511. } BusNumber;
  1512. struct {
  1513. ULONG Priority; // use LCPRI_Xxx values in cfg.h
  1514. ULONG Reserved1;
  1515. ULONG Reserved2;
  1516. } ConfigData;
  1517. } u;
  1518. } IO_RESOURCE_DESCRIPTOR, *PIO_RESOURCE_DESCRIPTOR;
  1519. #endif /* _MINIPORT_ */