Leaked source code of windows server 2003
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.

12998 lines
348 KiB

  1. /*++ BUILD Version: 0096 // Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. ndis.h
  5. Abstract:
  6. This module defines the structures, macros, and functions available
  7. to NDIS drivers.
  8. Revision History:
  9. --*/
  10. #if !defined(_NDIS_)
  11. #define _NDIS_
  12. #if !defined(NDIS_WDM)
  13. #define NDIS_WDM 0
  14. #endif
  15. //
  16. // If we're building a miniport on x86, set BINARY_COMPATIBLE so that
  17. // we don't use functions that aren't available on Windows 9x.
  18. //
  19. #if !defined(BINARY_COMPATIBLE)
  20. #if defined(NDIS_MINIPORT_DRIVER) && defined(_M_IX86)
  21. #define BINARY_COMPATIBLE 1
  22. #else
  23. #define BINARY_COMPATIBLE 0
  24. #endif
  25. #endif
  26. #if !defined(_M_IX86)
  27. #undef BINARY_COMPATIBLE
  28. #define BINARY_COMPATIBLE 0
  29. #endif
  30. //
  31. // BEGIN INTERNAL DEFINITIONS
  32. //
  33. //
  34. // BINARY_COMPATIBLE = 1 and NDIS_WDM = 1 then use wdm.h
  35. // BINARY_COMPATIBLE = 1 and NDIS_WDM = 0 then use ndis.h only
  36. // BINARY_COMPATIBLE = 0 and NDIS_WDM = 1 then use ntddk.h
  37. // BINARY_COMPATIBLE = 0 and NDIS_WDM = 0 then use ntddk.h
  38. //
  39. #if (BINARY_COMPATIBLE && !NDIS_WDM)
  40. //
  41. // BINARY_COMPATIBLE = 1 and NDIS_WDM = 0 then use ndis.h only
  42. //
  43. // The following internal definitions are included here in order to allow
  44. // the exported NDIS structures, macros, and functions to compile. They
  45. // must not be used directly by miniport drivers.
  46. //
  47. #define _NTDDK_
  48. #include <ctype.h>
  49. #ifndef IN
  50. #define IN
  51. #endif
  52. #ifndef OUT
  53. #define OUT
  54. #endif
  55. #ifndef OPTIONAL
  56. #define OPTIONAL
  57. #endif
  58. #ifndef NOTHING
  59. #define NOTHING
  60. #endif
  61. #ifndef CRITICAL
  62. #define CRITICAL
  63. #endif
  64. #ifndef ANYSIZE_ARRAY
  65. #define ANYSIZE_ARRAY 1 // winnt
  66. #endif
  67. // begin_winnt
  68. #if defined(_M_MRX000) && !(defined(MIDL_PASS) || defined(RC_INVOKED)) && defined(ENABLE_RESTRICTED)
  69. #define RESTRICTED_POINTER __restrict
  70. #else
  71. #define RESTRICTED_POINTER
  72. #endif
  73. #if defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64) || defined(_M_AMD64)
  74. #define UNALIGNED __unaligned
  75. #if defined(_WIN64)
  76. #define UNALIGNED64 __unaligned
  77. #else
  78. #define UNALIGNED64
  79. #endif
  80. #else
  81. #define UNALIGNED
  82. #define UNALIGNED64
  83. #endif
  84. #if defined(_WIN64) || defined(_M_ALPHA)
  85. #define MAX_NATURAL_ALIGNMENT sizeof(ULONGLONG)
  86. #define MEMORY_ALLOCATION_ALIGNMENT 16
  87. #else
  88. #define MAX_NATURAL_ALIGNMENT sizeof(ULONG)
  89. #define MEMORY_ALLOCATION_ALIGNMENT 8
  90. #endif
  91. //
  92. // TYPE_ALIGNMENT will return the alignment requirements of a given type for
  93. // the current platform.
  94. //
  95. #ifdef __cplusplus
  96. #if _MSC_VER >= 1300
  97. #define TYPE_ALIGNMENT( t ) __alignof(t)
  98. #endif
  99. #else
  100. #define TYPE_ALIGNMENT( t ) \
  101. FIELD_OFFSET( struct { char x; t test; }, test )
  102. #endif
  103. #if defined(_WIN64)
  104. #define PROBE_ALIGNMENT( _s ) (TYPE_ALIGNMENT( _s ) > TYPE_ALIGNMENT( ULONG ) ? \
  105. TYPE_ALIGNMENT( _s ) : TYPE_ALIGNMENT( ULONG ))
  106. #define PROBE_ALIGNMENT32( _s ) TYPE_ALIGNMENT( ULONG )
  107. #else
  108. #define PROBE_ALIGNMENT( _s ) TYPE_ALIGNMENT( ULONG )
  109. #endif
  110. //
  111. // C_ASSERT() can be used to perform many compile-time assertions:
  112. // type sizes, field offsets, etc.
  113. //
  114. // An assertion failure results in error C2118: negative subscript.
  115. //
  116. #define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
  117. #if !defined(_MAC) && (defined(_M_MRX000) || defined(_M_AMD64) || defined(_M_IA64)) && (_MSC_VER >= 1100) && !(defined(MIDL_PASS) || defined(RC_INVOKED))
  118. #define POINTER_64 __ptr64
  119. typedef unsigned __int64 POINTER_64_INT;
  120. #if defined(_WIN64)
  121. #define POINTER_32 __ptr32
  122. #else
  123. #define POINTER_32
  124. #endif
  125. #else
  126. #if defined(_MAC) && defined(_MAC_INT_64)
  127. #define POINTER_64 __ptr64
  128. typedef unsigned __int64 POINTER_64_INT;
  129. #else
  130. #define POINTER_64
  131. typedef unsigned long POINTER_64_INT;
  132. #endif
  133. #define POINTER_32
  134. #endif
  135. #if defined(_IA64_) || defined(_AMD64_)
  136. #define FIRMWARE_PTR
  137. #else
  138. #define FIRMWARE_PTR POINTER_32
  139. #endif
  140. #include <basetsd.h>
  141. // end_winnt
  142. #ifndef CONST
  143. #define CONST const
  144. #endif
  145. // begin_winnt
  146. #if (defined(_M_IX86) || defined(_M_IA64) || defined(_M_AMD64)) && !defined(MIDL_PASS)
  147. #define DECLSPEC_IMPORT __declspec(dllimport)
  148. #else
  149. #define DECLSPEC_IMPORT
  150. #endif
  151. #ifndef DECLSPEC_NORETURN
  152. #if (_MSC_VER >= 1200) && !defined(MIDL_PASS)
  153. #define DECLSPEC_NORETURN __declspec(noreturn)
  154. #else
  155. #define DECLSPEC_NORETURN
  156. #endif
  157. #endif
  158. #ifndef DECLSPEC_ALIGN
  159. #if (_MSC_VER >= 1300) && !defined(MIDL_PASS)
  160. #define DECLSPEC_ALIGN(x) __declspec(align(x))
  161. #else
  162. #define DECLSPEC_ALIGN(x)
  163. #endif
  164. #endif
  165. #ifndef DECLSPEC_CACHEALIGN
  166. #define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN(128)
  167. #endif
  168. #ifndef DECLSPEC_UUID
  169. #if (_MSC_VER >= 1100) && defined (__cplusplus)
  170. #define DECLSPEC_UUID(x) __declspec(uuid(x))
  171. #else
  172. #define DECLSPEC_UUID(x)
  173. #endif
  174. #endif
  175. #ifndef DECLSPEC_NOVTABLE
  176. #if (_MSC_VER >= 1100) && defined(__cplusplus)
  177. #define DECLSPEC_NOVTABLE __declspec(novtable)
  178. #else
  179. #define DECLSPEC_NOVTABLE
  180. #endif
  181. #endif
  182. #ifndef DECLSPEC_SELECTANY
  183. #if (_MSC_VER >= 1100)
  184. #define DECLSPEC_SELECTANY __declspec(selectany)
  185. #else
  186. #define DECLSPEC_SELECTANY
  187. #endif
  188. #endif
  189. #ifndef NOP_FUNCTION
  190. #if (_MSC_VER >= 1210)
  191. #define NOP_FUNCTION __noop
  192. #else
  193. #define NOP_FUNCTION (void)0
  194. #endif
  195. #endif
  196. #ifndef DECLSPEC_ADDRSAFE
  197. #if (_MSC_VER >= 1200) && (defined(_M_ALPHA) || defined(_M_AXP64))
  198. #define DECLSPEC_ADDRSAFE __declspec(address_safe)
  199. #else
  200. #define DECLSPEC_ADDRSAFE
  201. #endif
  202. #endif
  203. #ifndef DECLSPEC_NOINLINE
  204. #if (_MSC_VER >= 1300)
  205. #define DECLSPEC_NOINLINE __declspec(noinline)
  206. #else
  207. #define DECLSPEC_NOINLINE
  208. #endif
  209. #endif
  210. #ifndef FORCEINLINE
  211. #if (_MSC_VER >= 1200)
  212. #define FORCEINLINE __forceinline
  213. #else
  214. #define FORCEINLINE __inline
  215. #endif
  216. #endif
  217. #ifndef DECLSPEC_DEPRECATED
  218. #if (_MSC_VER >= 1300) && !defined(MIDL_PASS)
  219. #define DECLSPEC_DEPRECATED __declspec(deprecated)
  220. #define DEPRECATE_SUPPORTED
  221. #else
  222. #define DECLSPEC_DEPRECATED
  223. #undef DEPRECATE_SUPPORTED
  224. #endif
  225. #endif
  226. #ifdef DEPRECATE_DDK_FUNCTIONS
  227. #ifdef _NTDDK_
  228. #define DECLSPEC_DEPRECATED_DDK DECLSPEC_DEPRECATED
  229. #ifdef DEPRECATE_SUPPORTED
  230. #define PRAGMA_DEPRECATED_DDK 1
  231. #endif
  232. #else
  233. #define DECLSPEC_DEPRECATED_DDK
  234. #define PRAGMA_DEPRECATED_DDK 1
  235. #endif
  236. #else
  237. #define DECLSPEC_DEPRECATED_DDK
  238. #define PRAGMA_DEPRECATED_DDK 0
  239. #endif
  240. //
  241. // Void
  242. //
  243. typedef void *PVOID;
  244. typedef void * POINTER_64 PVOID64;
  245. // end_winnt
  246. #if defined(_M_IX86)
  247. #define FASTCALL _fastcall
  248. #else
  249. #define FASTCALL
  250. #endif
  251. #if ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)) && !defined(_M_AMD64)
  252. #define NTAPI __stdcall
  253. #else
  254. #define _cdecl
  255. #define NTAPI
  256. #endif
  257. //
  258. // Define API decoration for direct importing system DLL references.
  259. //
  260. #if !defined(_NTSYSTEM_)
  261. #define NTSYSAPI DECLSPEC_IMPORT
  262. #define NTSYSCALLAPI DECLSPEC_IMPORT
  263. #else
  264. #define NTSYSAPI
  265. #if defined(_NTDLLBUILD_)
  266. #define NTSYSCALLAPI
  267. #else
  268. #define NTSYSCALLAPI DECLSPEC_ADDRSAFE
  269. #endif
  270. #endif
  271. //
  272. // Basics
  273. //
  274. #ifndef VOID
  275. #define VOID void
  276. typedef char CHAR;
  277. typedef short SHORT;
  278. typedef long LONG;
  279. #endif
  280. //
  281. // UNICODE (Wide Character) types
  282. //
  283. #ifndef _MAC
  284. typedef wchar_t WCHAR; // wc, 16-bit UNICODE character
  285. #else
  286. // some Macintosh compilers don't define wchar_t in a convenient location, or define it as a char
  287. typedef unsigned short WCHAR; // wc, 16-bit UNICODE character
  288. #endif
  289. typedef WCHAR *PWCHAR;
  290. typedef WCHAR *LPWCH, *PWCH;
  291. typedef CONST WCHAR *LPCWCH, *PCWCH;
  292. typedef WCHAR *NWPSTR;
  293. typedef WCHAR *LPWSTR, *PWSTR;
  294. typedef WCHAR UNALIGNED *LPUWSTR, *PUWSTR;
  295. typedef CONST WCHAR *LPCWSTR, *PCWSTR;
  296. typedef CONST WCHAR UNALIGNED *LPCUWSTR, *PCUWSTR;
  297. //
  298. // ANSI (Multi-byte Character) types
  299. //
  300. typedef CHAR *PCHAR;
  301. typedef CHAR *LPCH, *PCH;
  302. typedef CONST CHAR *LPCCH, *PCCH;
  303. typedef CHAR *NPSTR;
  304. typedef CHAR *LPSTR, *PSTR;
  305. typedef CONST CHAR *LPCSTR, *PCSTR;
  306. //
  307. // Neutral ANSI/UNICODE types and macros
  308. //
  309. #ifdef UNICODE // r_winnt
  310. #ifndef _TCHAR_DEFINED
  311. typedef WCHAR TCHAR, *PTCHAR;
  312. typedef WCHAR TUCHAR, *PTUCHAR;
  313. #define _TCHAR_DEFINED
  314. #endif /* !_TCHAR_DEFINED */
  315. typedef LPWSTR LPTCH, PTCH;
  316. typedef LPWSTR PTSTR, LPTSTR;
  317. typedef LPCWSTR PCTSTR, LPCTSTR;
  318. typedef LPUWSTR PUTSTR, LPUTSTR;
  319. typedef LPCUWSTR PCUTSTR, LPCUTSTR;
  320. typedef LPWSTR LP;
  321. #define __TEXT(quote) L##quote // r_winnt
  322. #else /* UNICODE */ // r_winnt
  323. #ifndef _TCHAR_DEFINED
  324. typedef char TCHAR, *PTCHAR;
  325. typedef unsigned char TUCHAR, *PTUCHAR;
  326. #define _TCHAR_DEFINED
  327. #endif /* !_TCHAR_DEFINED */
  328. typedef LPSTR LPTCH, PTCH;
  329. typedef LPSTR PTSTR, LPTSTR, PUTSTR, LPUTSTR;
  330. typedef LPCSTR PCTSTR, LPCTSTR, PCUTSTR, LPCUTSTR;
  331. #define __TEXT(quote) quote // r_winnt
  332. #endif /* UNICODE */ // r_winnt
  333. #define TEXT(quote) __TEXT(quote) // r_winnt
  334. // end_winnt
  335. typedef double DOUBLE;
  336. typedef struct _QUAD { // QUAD is for those times we want
  337. double DoNotUseThisField; // an 8 byte aligned 8 byte long structure
  338. } QUAD; // which is NOT really a floating point
  339. // number. Use DOUBLE if you want an FP
  340. // number.
  341. //
  342. // Pointer to Basics
  343. //
  344. typedef SHORT *PSHORT; // winnt
  345. typedef LONG *PLONG; // winnt
  346. typedef QUAD *PQUAD;
  347. //
  348. // Unsigned Basics
  349. //
  350. // Tell windef.h that some types are already defined.
  351. #define BASETYPES
  352. typedef unsigned char UCHAR;
  353. typedef unsigned short USHORT;
  354. typedef unsigned long ULONG;
  355. typedef QUAD UQUAD;
  356. //
  357. // Pointer to Unsigned Basics
  358. //
  359. typedef UCHAR *PUCHAR;
  360. typedef USHORT *PUSHORT;
  361. typedef ULONG *PULONG;
  362. typedef UQUAD *PUQUAD;
  363. //
  364. // Signed characters
  365. //
  366. typedef signed char SCHAR;
  367. typedef SCHAR *PSCHAR;
  368. #ifndef NO_STRICT
  369. #ifndef STRICT
  370. #define STRICT 1
  371. #endif
  372. #endif
  373. //
  374. // Handle to an Object
  375. //
  376. // begin_winnt
  377. #ifdef STRICT
  378. typedef void *HANDLE;
  379. #define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
  380. #else
  381. typedef PVOID HANDLE;
  382. #define DECLARE_HANDLE(name) typedef HANDLE name
  383. #endif
  384. typedef HANDLE *PHANDLE;
  385. //
  386. // Flag (bit) fields
  387. //
  388. typedef UCHAR FCHAR;
  389. typedef USHORT FSHORT;
  390. typedef ULONG FLONG;
  391. // Component Object Model defines, and macros
  392. #ifndef _HRESULT_DEFINED
  393. #define _HRESULT_DEFINED
  394. typedef LONG HRESULT;
  395. #endif // !_HRESULT_DEFINED
  396. #ifdef __cplusplus
  397. #define EXTERN_C extern "C"
  398. #else
  399. #define EXTERN_C extern
  400. #endif
  401. #if defined(_WIN32) || defined(_MPPC_)
  402. // Win32 doesn't support __export
  403. #ifdef _68K_
  404. #define STDMETHODCALLTYPE __cdecl
  405. #else
  406. #define STDMETHODCALLTYPE __stdcall
  407. #endif
  408. #define STDMETHODVCALLTYPE __cdecl
  409. #define STDAPICALLTYPE __stdcall
  410. #define STDAPIVCALLTYPE __cdecl
  411. #else
  412. #define STDMETHODCALLTYPE __export __stdcall
  413. #define STDMETHODVCALLTYPE __export __cdecl
  414. #define STDAPICALLTYPE __export __stdcall
  415. #define STDAPIVCALLTYPE __export __cdecl
  416. #endif
  417. #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
  418. #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
  419. #define STDMETHODIMP HRESULT STDMETHODCALLTYPE
  420. #define STDMETHODIMP_(type) type STDMETHODCALLTYPE
  421. // The 'V' versions allow Variable Argument lists.
  422. #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE
  423. #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE
  424. #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE
  425. #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE
  426. // end_winnt
  427. //
  428. // Low order two bits of a handle are ignored by the system and available
  429. // for use by application code as tag bits. The remaining bits are opaque
  430. // and used to store a serial number and table index.
  431. //
  432. #define OBJ_HANDLE_TAGBITS 0x00000003L
  433. //
  434. // Cardinal Data Types [0 - 2**N-2)
  435. //
  436. typedef char CCHAR; // winnt
  437. typedef short CSHORT;
  438. typedef ULONG CLONG;
  439. typedef CCHAR *PCCHAR;
  440. typedef CSHORT *PCSHORT;
  441. typedef CLONG *PCLONG;
  442. //
  443. // NTSTATUS
  444. //
  445. typedef LONG NTSTATUS;
  446. /*lint -save -e624 */ // Don't complain about different typedefs.
  447. typedef NTSTATUS *PNTSTATUS;
  448. /*lint -restore */ // Resume checking for different typedefs.
  449. //
  450. // Status values are 32 bit values layed out as follows:
  451. //
  452. // 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  453. // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  454. // +---+-+-------------------------+-------------------------------+
  455. // |Sev|C| Facility | Code |
  456. // +---+-+-------------------------+-------------------------------+
  457. //
  458. // where
  459. //
  460. // Sev - is the severity code
  461. //
  462. // 00 - Success
  463. // 01 - Informational
  464. // 10 - Warning
  465. // 11 - Error
  466. //
  467. // C - is the Customer code flag
  468. //
  469. // Facility - is the facility code
  470. //
  471. // Code - is the facility's status code
  472. //
  473. //
  474. // Generic test for success on any status value (non-negative numbers
  475. // indicate success).
  476. //
  477. #define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
  478. //
  479. // Generic test for information on any status value.
  480. //
  481. #define NT_INFORMATION(Status) ((ULONG)(Status) >> 30 == 1)
  482. //
  483. // Generic test for warning on any status value.
  484. //
  485. #define NT_WARNING(Status) ((ULONG)(Status) >> 30 == 2)
  486. //
  487. // Generic test for error on any status value.
  488. //
  489. #define NT_ERROR(Status) ((ULONG)(Status) >> 30 == 3)
  490. // end_windbgkd
  491. // begin_winnt
  492. #define APPLICATION_ERROR_MASK 0x20000000
  493. #define ERROR_SEVERITY_SUCCESS 0x00000000
  494. #define ERROR_SEVERITY_INFORMATIONAL 0x40000000
  495. #define ERROR_SEVERITY_WARNING 0x80000000
  496. #define ERROR_SEVERITY_ERROR 0xC0000000
  497. // end_winnt
  498. #ifndef __SECSTATUS_DEFINED__
  499. typedef long SECURITY_STATUS;
  500. #define __SECSTATUS_DEFINED__
  501. #endif
  502. //
  503. // __int64 is only supported by 2.0 and later midl.
  504. // __midl is set by the 2.0 midl and not by 1.0 midl.
  505. //
  506. #define _ULONGLONG_
  507. #if (!defined (_MAC) && (!defined(MIDL_PASS) || defined(__midl)) && (!defined(_M_IX86) || (defined(_INTEGRAL_MAX_BITS) && _INTEGRAL_MAX_BITS >= 64)))
  508. typedef __int64 LONGLONG;
  509. typedef unsigned __int64 ULONGLONG;
  510. #define MAXLONGLONG (0x7fffffffffffffff)
  511. #else
  512. #if defined(_MAC) && defined(_MAC_INT_64)
  513. typedef __int64 LONGLONG;
  514. typedef unsigned __int64 ULONGLONG;
  515. #define MAXLONGLONG (0x7fffffffffffffff)
  516. #else
  517. typedef double LONGLONG;
  518. typedef double ULONGLONG;
  519. #endif //_MAC and int64
  520. #endif
  521. typedef LONGLONG *PLONGLONG;
  522. typedef ULONGLONG *PULONGLONG;
  523. // Update Sequence Number
  524. typedef LONGLONG USN;
  525. #if defined(MIDL_PASS)
  526. typedef struct _LARGE_INTEGER {
  527. #else // MIDL_PASS
  528. typedef union _LARGE_INTEGER {
  529. struct {
  530. ULONG LowPart;
  531. LONG HighPart;
  532. };
  533. struct {
  534. ULONG LowPart;
  535. LONG HighPart;
  536. } u;
  537. #endif //MIDL_PASS
  538. LONGLONG QuadPart;
  539. } LARGE_INTEGER;
  540. typedef LARGE_INTEGER *PLARGE_INTEGER;
  541. #if defined(MIDL_PASS)
  542. typedef struct _ULARGE_INTEGER {
  543. #else // MIDL_PASS
  544. typedef union _ULARGE_INTEGER {
  545. struct {
  546. ULONG LowPart;
  547. ULONG HighPart;
  548. };
  549. struct {
  550. ULONG LowPart;
  551. ULONG HighPart;
  552. } u;
  553. #endif //MIDL_PASS
  554. ULONGLONG QuadPart;
  555. } ULARGE_INTEGER;
  556. typedef ULARGE_INTEGER *PULARGE_INTEGER;
  557. //
  558. // Physical address.
  559. //
  560. typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS;
  561. //
  562. // Counted String
  563. //
  564. typedef USHORT RTL_STRING_LENGTH_TYPE;
  565. typedef struct _STRING {
  566. USHORT Length;
  567. USHORT MaximumLength;
  568. #ifdef MIDL_PASS
  569. [size_is(MaximumLength), length_is(Length) ]
  570. #endif // MIDL_PASS
  571. PCHAR Buffer;
  572. } STRING;
  573. typedef STRING *PSTRING;
  574. typedef STRING ANSI_STRING;
  575. typedef PSTRING PANSI_STRING;
  576. typedef STRING OEM_STRING;
  577. typedef PSTRING POEM_STRING;
  578. typedef CONST STRING* PCOEM_STRING;
  579. //
  580. // CONSTCounted String
  581. //
  582. typedef struct _CSTRING {
  583. USHORT Length;
  584. USHORT MaximumLength;
  585. CONST char *Buffer;
  586. } CSTRING;
  587. typedef CSTRING *PCSTRING;
  588. #define ANSI_NULL ((CHAR)0) // winnt
  589. typedef STRING CANSI_STRING;
  590. typedef PSTRING PCANSI_STRING;
  591. //
  592. // Unicode strings are counted 16-bit character strings. If they are
  593. // NULL terminated, Length does not include trailing NULL.
  594. //
  595. typedef struct _UNICODE_STRING {
  596. USHORT Length;
  597. USHORT MaximumLength;
  598. #ifdef MIDL_PASS
  599. [size_is(MaximumLength / 2), length_is((Length) / 2) ] USHORT * Buffer;
  600. #else // MIDL_PASS
  601. PWSTR Buffer;
  602. #endif // MIDL_PASS
  603. } UNICODE_STRING;
  604. typedef UNICODE_STRING *PUNICODE_STRING;
  605. typedef const UNICODE_STRING *PCUNICODE_STRING;
  606. #define UNICODE_NULL ((WCHAR)0) // winnt
  607. #if _WIN32_WINNT >= 0x0501
  608. #define UNICODE_STRING_MAX_BYTES ((USHORT) 65534) // winnt
  609. #define UNICODE_STRING_MAX_CHARS (32767) // winnt
  610. #define DECLARE_CONST_UNICODE_STRING(_variablename, _string) \
  611. const WCHAR _variablename ## _buffer[] = _string; \
  612. const UNICODE_STRING _variablename = { sizeof(_string) - sizeof(WCHAR), sizeof(_string), (PWSTR) _variablename ## _buffer };
  613. #endif // _WIN32_WINNT >= 0x0501
  614. // begin_ntminiport begin_ntminitape
  615. //
  616. // Boolean
  617. //
  618. typedef UCHAR BOOLEAN; // winnt
  619. typedef BOOLEAN *PBOOLEAN; // winnt
  620. // end_ntminiport end_ntminitape
  621. // begin_winnt
  622. //
  623. // Doubly linked list structure. Can be used as either a list head, or
  624. // as link words.
  625. //
  626. typedef struct _LIST_ENTRY {
  627. struct _LIST_ENTRY *Flink;
  628. struct _LIST_ENTRY *Blink;
  629. } LIST_ENTRY, *PLIST_ENTRY, *RESTRICTED_POINTER PRLIST_ENTRY;
  630. //
  631. // Singly linked list structure. Can be used as either a list head, or
  632. // as link words.
  633. //
  634. typedef struct _SINGLE_LIST_ENTRY {
  635. struct _SINGLE_LIST_ENTRY *Next;
  636. } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
  637. //
  638. // Constants
  639. //
  640. #define FALSE 0
  641. #define TRUE 1
  642. #ifndef NULL
  643. #ifdef __cplusplus
  644. #define NULL 0
  645. #define NULL64 0
  646. #else
  647. #define NULL ((void *)0)
  648. #define NULL64 ((void * POINTER_64)0)
  649. #endif
  650. #endif // NULL
  651. #include <guiddef.h>
  652. #ifndef __OBJECTID_DEFINED
  653. #define __OBJECTID_DEFINED
  654. typedef struct _OBJECTID { // size is 20
  655. GUID Lineage;
  656. ULONG Uniquifier;
  657. } OBJECTID;
  658. #endif // !_OBJECTID_DEFINED
  659. //
  660. // Determine if an argument is present by testing the value of the pointer
  661. // to the argument value.
  662. //
  663. #define ARGUMENT_PRESENT(ArgumentPointer) (\
  664. (CHAR *)((ULONG_PTR)(ArgumentPointer)) != (CHAR *)(NULL) )
  665. // begin_winnt begin_ntminiport
  666. //
  667. // Calculate the byte offset of a field in a structure of type type.
  668. //
  669. #define FIELD_OFFSET(type, field) ((LONG)(LONG_PTR)&(((type *)0)->field))
  670. //
  671. // Calculate the size of a field in a structure of type type, without
  672. // knowing or stating the type of the field.
  673. //
  674. #define RTL_FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
  675. //
  676. // Calculate the size of a structure of type type up through and
  677. // including a field.
  678. //
  679. #define RTL_SIZEOF_THROUGH_FIELD(type, field) \
  680. (FIELD_OFFSET(type, field) + RTL_FIELD_SIZE(type, field))
  681. //
  682. // RTL_CONTAINS_FIELD usage:
  683. //
  684. // if (RTL_CONTAINS_FIELD(pBlock, pBlock->cbSize, dwMumble)) { // safe to use pBlock->dwMumble
  685. //
  686. #define RTL_CONTAINS_FIELD(Struct, Size, Field) \
  687. ( (((PCHAR)(&(Struct)->Field)) + sizeof((Struct)->Field)) <= (((PCHAR)(Struct))+(Size)) )
  688. //
  689. // Return the number of elements in a statically sized array.
  690. // ULONG Buffer[100];
  691. // RTL_NUMBER_OF(Buffer) == 100
  692. // This is also popularly known as: NUMBER_OF, ARRSIZE, _countof, NELEM, etc.
  693. //
  694. #define RTL_NUMBER_OF(A) (sizeof(A)/sizeof((A)[0]))
  695. //
  696. // An expression that yields the type of a field in a struct.
  697. //
  698. #define RTL_FIELD_TYPE(type, field) (((type*)0)->field)
  699. // RTL_ to avoid collisions in the global namespace.
  700. //
  701. // Given typedef struct _FOO { BYTE Bar[123]; } FOO;
  702. // RTL_NUMBER_OF_FIELD(FOO, Bar) == 123
  703. //
  704. #define RTL_NUMBER_OF_FIELD(type, field) (RTL_NUMBER_OF(RTL_FIELD_TYPE(type, field)))
  705. //
  706. // eg:
  707. // typedef struct FOO {
  708. // ULONG Integer;
  709. // PVOID Pointer;
  710. // } FOO;
  711. //
  712. // RTL_PADDING_BETWEEN_FIELDS(FOO, Integer, Pointer) == 0 for Win32, 4 for Win64
  713. //
  714. #define RTL_PADDING_BETWEEN_FIELDS(T, F1, F2) \
  715. ((FIELD_OFFSET(T, F2) > FIELD_OFFSET(T, F1)) \
  716. ? (FIELD_OFFSET(T, F2) - FIELD_OFFSET(T, F1) - RTL_FIELD_SIZE(T, F1)) \
  717. : (FIELD_OFFSET(T, F1) - FIELD_OFFSET(T, F2) - RTL_FIELD_SIZE(T, F2)))
  718. // RTL_ to avoid collisions in the global namespace.
  719. #if defined(__cplusplus)
  720. #define RTL_CONST_CAST(type) const_cast<type>
  721. #else
  722. #define RTL_CONST_CAST(type) (type)
  723. #endif
  724. // end_winnt
  725. //
  726. // This works "generically" for Unicode and Ansi/Oem strings.
  727. // Usage:
  728. // const static UNICODE_STRING FooU = RTL_CONSTANT_STRING(L"Foo");
  729. // const static STRING Foo = RTL_CONSTANT_STRING( "Foo");
  730. // instead of the slower:
  731. // UNICODE_STRING FooU;
  732. // STRING Foo;
  733. // RtlInitUnicodeString(&FooU, L"Foo");
  734. // RtlInitString(&Foo , "Foo");
  735. //
  736. #define RTL_CONSTANT_STRING(s) { sizeof( s ) - sizeof( (s)[0] ), sizeof( s ), s }
  737. // begin_winnt
  738. // like sizeof
  739. // usually this would be * CHAR_BIT, but we don't necessarily have #include <limits.h>
  740. #define RTL_BITS_OF(sizeOfArg) (sizeof(sizeOfArg) * 8)
  741. #define RTL_BITS_OF_FIELD(type, field) (RTL_BITS_OF(RTL_FIELD_TYPE(type, field)))
  742. //
  743. // Calculate the address of the base of the structure given its type, and an
  744. // address of a field within the structure.
  745. //
  746. #define CONTAINING_RECORD(address, type, field) ((type *)( \
  747. (PCHAR)(address) - \
  748. (ULONG_PTR)(&((type *)0)->field)))
  749. //
  750. // Interrupt Request Level (IRQL)
  751. //
  752. typedef UCHAR KIRQL;
  753. typedef KIRQL *PKIRQL;
  754. //
  755. // Macros used to eliminate compiler warning generated when formal
  756. // parameters or local variables are not declared.
  757. //
  758. // Use DBG_UNREFERENCED_PARAMETER() when a parameter is not yet
  759. // referenced but will be once the module is completely developed.
  760. //
  761. // Use DBG_UNREFERENCED_LOCAL_VARIABLE() when a local variable is not yet
  762. // referenced but will be once the module is completely developed.
  763. //
  764. // Use UNREFERENCED_PARAMETER() if a parameter will never be referenced.
  765. //
  766. // DBG_UNREFERENCED_PARAMETER and DBG_UNREFERENCED_LOCAL_VARIABLE will
  767. // eventually be made into a null macro to help determine whether there
  768. // is unfinished work.
  769. //
  770. #if ! defined(lint)
  771. #define UNREFERENCED_PARAMETER(P) (P)
  772. #define DBG_UNREFERENCED_PARAMETER(P) (P)
  773. #define DBG_UNREFERENCED_LOCAL_VARIABLE(V) (V)
  774. #else // lint
  775. // Note: lint -e530 says don't complain about uninitialized variables for
  776. // this varible. Error 527 has to do with unreachable code.
  777. // -restore restores checking to the -save state
  778. #define UNREFERENCED_PARAMETER(P) \
  779. /*lint -save -e527 -e530 */ \
  780. { \
  781. (P) = (P); \
  782. } \
  783. /*lint -restore */
  784. #define DBG_UNREFERENCED_PARAMETER(P) \
  785. /*lint -save -e527 -e530 */ \
  786. { \
  787. (P) = (P); \
  788. } \
  789. /*lint -restore */
  790. #define DBG_UNREFERENCED_LOCAL_VARIABLE(V) \
  791. /*lint -save -e527 -e530 */ \
  792. { \
  793. (V) = (V); \
  794. } \
  795. /*lint -restore */
  796. #endif // lint
  797. //
  798. // Macro used to eliminate compiler warning 4715 within a switch statement
  799. // when all possible cases have already been accounted for.
  800. //
  801. // switch (a & 3) {
  802. // case 0: return 1;
  803. // case 1: return Foo();
  804. // case 2: return Bar();
  805. // case 3: return 1;
  806. // DEFAULT_UNREACHABLE;
  807. //
  808. #if (_MSC_VER > 1200)
  809. #define DEFAULT_UNREACHABLE default: __assume(0)
  810. #else
  811. //
  812. // Older compilers do not support __assume(), and there is no other free
  813. // method of eliminating the warning.
  814. //
  815. #define DEFAULT_UNREACHABLE
  816. #endif
  817. // end_winnt
  818. //
  819. // Define standard min and max macros
  820. //
  821. #ifndef NOMINMAX
  822. #ifndef min
  823. #define min(a,b) (((a) < (b)) ? (a) : (b))
  824. #endif
  825. #ifndef max
  826. #define max(a,b) (((a) > (b)) ? (a) : (b))
  827. #endif
  828. #endif // NOMINMAX
  829. //
  830. // Processor modes.
  831. //
  832. typedef CCHAR KPROCESSOR_MODE;
  833. typedef enum _MODE {
  834. KernelMode,
  835. UserMode,
  836. MaximumMode
  837. } MODE;
  838. //
  839. // DPC routine
  840. //
  841. struct _KDPC;
  842. typedef
  843. VOID
  844. (*PKDEFERRED_ROUTINE) (
  845. IN struct _KDPC *Dpc,
  846. IN PVOID DeferredContext,
  847. IN PVOID SystemArgument1,
  848. IN PVOID SystemArgument2
  849. );
  850. //
  851. // Define DPC importance.
  852. //
  853. // LowImportance - Queue DPC at end of target DPC queue.
  854. // MediumImportance - Queue DPC at end of target DPC queue.
  855. // HighImportance - Queue DPC at front of target DPC DPC queue.
  856. //
  857. // If there is currently a DPC active on the target processor, or a DPC
  858. // interrupt has already been requested on the target processor when a
  859. // DPC is queued, then no further action is necessary. The DPC will be
  860. // executed on the target processor when its queue entry is processed.
  861. //
  862. // If there is not a DPC active on the target processor and a DPC interrupt
  863. // has not been requested on the target processor, then the exact treatment
  864. // of the DPC is dependent on whether the host system is a UP system or an
  865. // MP system.
  866. //
  867. // UP system.
  868. //
  869. // If the DPC is of medium or high importance, the current DPC queue depth
  870. // is greater than the maximum target depth, or current DPC request rate is
  871. // less the minimum target rate, then a DPC interrupt is requested on the
  872. // host processor and the DPC will be processed when the interrupt occurs.
  873. // Otherwise, no DPC interupt is requested and the DPC execution will be
  874. // delayed until the DPC queue depth is greater that the target depth or the
  875. // minimum DPC rate is less than the target rate.
  876. //
  877. // MP system.
  878. //
  879. // If the DPC is being queued to another processor and the depth of the DPC
  880. // queue on the target processor is greater than the maximum target depth or
  881. // the DPC is of high importance, then a DPC interrupt is requested on the
  882. // target processor and the DPC will be processed when the interrupt occurs.
  883. // Otherwise, the DPC execution will be delayed on the target processor until
  884. // the DPC queue depth on the target processor is greater that the maximum
  885. // target depth or the minimum DPC rate on the target processor is less than
  886. // the target mimimum rate.
  887. //
  888. // If the DPC is being queued to the current processor and the DPC is not of
  889. // low importance, the current DPC queue depth is greater than the maximum
  890. // target depth, or the minimum DPC rate is less than the minimum target rate,
  891. // then a DPC interrupt is request on the current processor and the DPV will
  892. // be processed whne the interrupt occurs. Otherwise, no DPC interupt is
  893. // requested and the DPC execution will be delayed until the DPC queue depth
  894. // is greater that the target depth or the minimum DPC rate is less than the
  895. // target rate.
  896. //
  897. typedef enum _KDPC_IMPORTANCE {
  898. LowImportance,
  899. MediumImportance,
  900. HighImportance
  901. } KDPC_IMPORTANCE;
  902. //
  903. // Define DPC type indicies.
  904. //
  905. #define DPC_NORMAL 0
  906. #define DPC_THREADED 1
  907. //
  908. // Deferred Procedure Call (DPC) object
  909. //
  910. typedef struct _KDPC {
  911. CSHORT Type;
  912. UCHAR Number;
  913. UCHAR Importance;
  914. LIST_ENTRY DpcListEntry;
  915. PKDEFERRED_ROUTINE DeferredRoutine;
  916. PVOID DeferredContext;
  917. PVOID SystemArgument1;
  918. PVOID SystemArgument2;
  919. PVOID DpcData;
  920. } KDPC, *PKDPC, *RESTRICTED_POINTER PRKDPC;
  921. //
  922. // Interprocessor interrupt worker routine function prototype.
  923. //
  924. typedef PVOID PKIPI_CONTEXT;
  925. typedef
  926. VOID
  927. (*PKIPI_WORKER)(
  928. IN PKIPI_CONTEXT PacketContext,
  929. IN PVOID Parameter1,
  930. IN PVOID Parameter2,
  931. IN PVOID Parameter3
  932. );
  933. //
  934. // Define interprocessor interrupt performance counters.
  935. //
  936. typedef struct _KIPI_COUNTS {
  937. ULONG Freeze;
  938. ULONG Packet;
  939. ULONG DPC;
  940. ULONG APC;
  941. ULONG FlushSingleTb;
  942. ULONG FlushMultipleTb;
  943. ULONG FlushEntireTb;
  944. ULONG GenericCall;
  945. ULONG ChangeColor;
  946. ULONG SweepDcache;
  947. ULONG SweepIcache;
  948. ULONG SweepIcacheRange;
  949. ULONG FlushIoBuffers;
  950. ULONG GratuitousDPC;
  951. } KIPI_COUNTS, *PKIPI_COUNTS;
  952. //
  953. // I/O system definitions.
  954. //
  955. // Define a Memory Descriptor List (MDL)
  956. //
  957. // An MDL describes pages in a virtual buffer in terms of physical pages. The
  958. // pages associated with the buffer are described in an array that is allocated
  959. // just after the MDL header structure itself.
  960. //
  961. // One simply calculates the base of the array by adding one to the base
  962. // MDL pointer:
  963. //
  964. // Pages = (PPFN_NUMBER) (Mdl + 1);
  965. //
  966. // Notice that while in the context of the subject thread, the base virtual
  967. // address of a buffer mapped by an MDL may be referenced using the following:
  968. //
  969. // Mdl->StartVa | Mdl->ByteOffset
  970. //
  971. typedef struct _MDL {
  972. struct _MDL *Next;
  973. CSHORT Size;
  974. CSHORT MdlFlags;
  975. struct _EPROCESS *Process;
  976. PVOID MappedSystemVa;
  977. PVOID StartVa;
  978. ULONG ByteCount;
  979. ULONG ByteOffset;
  980. } MDL, *PMDL;
  981. #define MDL_MAPPED_TO_SYSTEM_VA 0x0001
  982. #define MDL_PAGES_LOCKED 0x0002
  983. #define MDL_SOURCE_IS_NONPAGED_POOL 0x0004
  984. #define MDL_ALLOCATED_FIXED_SIZE 0x0008
  985. #define MDL_PARTIAL 0x0010
  986. #define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020
  987. #define MDL_IO_PAGE_READ 0x0040
  988. #define MDL_WRITE_OPERATION 0x0080
  989. #define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100
  990. #define MDL_FREE_EXTRA_PTES 0x0200
  991. #define MDL_DESCRIBES_AWE 0x0400
  992. #define MDL_IO_SPACE 0x0800
  993. #define MDL_NETWORK_HEADER 0x1000
  994. #define MDL_MAPPING_CAN_FAIL 0x2000
  995. #define MDL_ALLOCATED_MUST_SUCCEED 0x4000
  996. #define MDL_MAPPING_FLAGS (MDL_MAPPED_TO_SYSTEM_VA | \
  997. MDL_PAGES_LOCKED | \
  998. MDL_SOURCE_IS_NONPAGED_POOL | \
  999. MDL_PARTIAL_HAS_BEEN_MAPPED | \
  1000. MDL_PARENT_MAPPED_SYSTEM_VA | \
  1001. MDL_SYSTEM_VA | \
  1002. MDL_IO_SPACE )
  1003. #define NTKERNELAPI DECLSPEC_IMPORT
  1004. #define NTHALAPI DECLSPEC_IMPORT
  1005. //
  1006. // Common dispatcher object header
  1007. //
  1008. // N.B. The size field contains the number of dwords in the structure.
  1009. //
  1010. typedef struct _DISPATCHER_HEADER {
  1011. union {
  1012. struct {
  1013. UCHAR Type;
  1014. UCHAR Absolute;
  1015. UCHAR Size;
  1016. union {
  1017. UCHAR Inserted;
  1018. BOOLEAN DebugActive;
  1019. };
  1020. };
  1021. volatile LONG Lock;
  1022. };
  1023. LONG SignalState;
  1024. LIST_ENTRY WaitListHead;
  1025. } DISPATCHER_HEADER;
  1026. //
  1027. // Event object
  1028. //
  1029. typedef struct _KEVENT {
  1030. DISPATCHER_HEADER Header;
  1031. } KEVENT, *PKEVENT, *RESTRICTED_POINTER PRKEVENT;
  1032. //
  1033. // Timer object
  1034. //
  1035. typedef struct _KTIMER {
  1036. DISPATCHER_HEADER Header;
  1037. ULARGE_INTEGER DueTime;
  1038. LIST_ENTRY TimerListEntry;
  1039. struct _KDPC *Dpc;
  1040. LONG Period;
  1041. } KTIMER, *PKTIMER, *RESTRICTED_POINTER PRKTIMER;
  1042. typedef enum _LOCK_OPERATION {
  1043. IoReadAccess,
  1044. IoWriteAccess,
  1045. IoModifyAccess
  1046. } LOCK_OPERATION;
  1047. typedef ULONG_PTR KSPIN_LOCK;
  1048. typedef KSPIN_LOCK *PKSPIN_LOCK;
  1049. //
  1050. // Define the I/O bus interface types.
  1051. //
  1052. typedef enum _INTERFACE_TYPE {
  1053. InterfaceTypeUndefined = -1,
  1054. Internal,
  1055. Isa,
  1056. Eisa,
  1057. MicroChannel,
  1058. TurboChannel,
  1059. PCIBus,
  1060. VMEBus,
  1061. NuBus,
  1062. PCMCIABus,
  1063. CBus,
  1064. MPIBus,
  1065. MPSABus,
  1066. ProcessorInternal,
  1067. InternalPowerBus,
  1068. PNPISABus,
  1069. PNPBus,
  1070. MaximumInterfaceType
  1071. }INTERFACE_TYPE, *PINTERFACE_TYPE;
  1072. //
  1073. // Define the DMA transfer widths.
  1074. //
  1075. typedef enum _DMA_WIDTH {
  1076. Width8Bits,
  1077. Width16Bits,
  1078. Width32Bits,
  1079. MaximumDmaWidth
  1080. }DMA_WIDTH, *PDMA_WIDTH;
  1081. //
  1082. // Define DMA transfer speeds.
  1083. //
  1084. typedef enum _DMA_SPEED {
  1085. Compatible,
  1086. TypeA,
  1087. TypeB,
  1088. TypeC,
  1089. TypeF,
  1090. MaximumDmaSpeed
  1091. }DMA_SPEED, *PDMA_SPEED;
  1092. //
  1093. // Define Interface reference/dereference routines for
  1094. // Interfaces exported by IRP_MN_QUERY_INTERFACE
  1095. //
  1096. typedef VOID (*PINTERFACE_REFERENCE)(PVOID Context);
  1097. typedef VOID (*PINTERFACE_DEREFERENCE)(PVOID Context);
  1098. // end_wdm
  1099. //
  1100. // Define types of bus information.
  1101. //
  1102. typedef enum _BUS_DATA_TYPE {
  1103. ConfigurationSpaceUndefined = -1,
  1104. Cmos,
  1105. EisaConfiguration,
  1106. Pos,
  1107. CbusConfiguration,
  1108. PCIConfiguration,
  1109. VMEConfiguration,
  1110. NuBusConfiguration,
  1111. PCMCIAConfiguration,
  1112. MPIConfiguration,
  1113. MPSAConfiguration,
  1114. PNPISAConfiguration,
  1115. SgiInternalConfiguration,
  1116. MaximumBusDataType
  1117. } BUS_DATA_TYPE, *PBUS_DATA_TYPE;
  1118. #ifndef _SLIST_HEADER_
  1119. #define _SLIST_HEADER_
  1120. #if defined(_WIN64)
  1121. //
  1122. // The type SINGLE_LIST_ENTRY is not suitable for use with SLISTs. For
  1123. // WIN64, an entry on an SLIST is required to be 16-byte aligned, while a
  1124. // SINGLE_LIST_ENTRY structure has only 8 byte alignment.
  1125. //
  1126. // Therefore, all SLIST code should use the SLIST_ENTRY type instead of the
  1127. // SINGLE_LIST_ENTRY type.
  1128. //
  1129. #pragma warning(push)
  1130. #pragma warning(disable:4324) // structure padded due to align()
  1131. typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY *PSLIST_ENTRY;
  1132. typedef struct DECLSPEC_ALIGN(16) _SLIST_ENTRY {
  1133. PSLIST_ENTRY Next;
  1134. } SLIST_ENTRY;
  1135. #pragma warning(pop)
  1136. #else
  1137. #define SLIST_ENTRY SINGLE_LIST_ENTRY
  1138. #define _SLIST_ENTRY _SINGLE_LIST_ENTRY
  1139. #define PSLIST_ENTRY PSINGLE_LIST_ENTRY
  1140. #endif
  1141. #if defined(_WIN64)
  1142. typedef struct DECLSPEC_ALIGN(16) _SLIST_HEADER {
  1143. ULONGLONG Alignment;
  1144. ULONGLONG Region;
  1145. } SLIST_HEADER;
  1146. typedef struct _SLIST_HEADER *PSLIST_HEADER;
  1147. #else
  1148. typedef union _SLIST_HEADER {
  1149. ULONGLONG Alignment;
  1150. struct {
  1151. SLIST_ENTRY Next;
  1152. USHORT Depth;
  1153. USHORT Sequence;
  1154. };
  1155. } SLIST_HEADER, *PSLIST_HEADER;
  1156. #endif
  1157. #endif
  1158. //
  1159. // If debugging support enabled, define an ASSERT macro that works. Otherwise
  1160. // define the ASSERT macro to expand to an empty expression.
  1161. //
  1162. // The ASSERT macro has been updated to be an expression instead of a statement.
  1163. //
  1164. NTSYSAPI
  1165. VOID
  1166. NTAPI
  1167. RtlAssert(
  1168. PVOID FailedAssertion,
  1169. PVOID FileName,
  1170. ULONG LineNumber,
  1171. PCHAR Message
  1172. );
  1173. #if DBG
  1174. #define ASSERT( exp ) \
  1175. ((!(exp)) ? \
  1176. (RtlAssert( #exp, __FILE__, __LINE__, NULL ),FALSE) : \
  1177. TRUE)
  1178. #define ASSERTMSG( msg, exp ) \
  1179. ((!(exp)) ? \
  1180. (RtlAssert( #exp, __FILE__, __LINE__, msg ),FALSE) : \
  1181. TRUE)
  1182. #define RTL_SOFT_ASSERT(_exp) \
  1183. ((!(_exp)) ? \
  1184. (DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #_exp),FALSE) : \
  1185. TRUE)
  1186. #define RTL_SOFT_ASSERTMSG(_msg, _exp) \
  1187. ((!(_exp)) ? \
  1188. (DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n Message: %s\n", __FILE__, __LINE__, #_exp, (_msg)),FALSE) : \
  1189. TRUE)
  1190. #define RTL_VERIFY ASSERT
  1191. #define RTL_VERIFYMSG ASSERTMSG
  1192. #define RTL_SOFT_VERIFY RTL_SOFT_ASSERT
  1193. #define RTL_SOFT_VERIFYMSG RTL_SOFT_ASSERTMSG
  1194. #else
  1195. #define ASSERT( exp ) ((void) 0)
  1196. #define ASSERTMSG( msg, exp ) ((void) 0)
  1197. #define RTL_SOFT_ASSERT(_exp) ((void) 0)
  1198. #define RTL_SOFT_ASSERTMSG(_msg, _exp) ((void) 0)
  1199. #define RTL_VERIFY( exp ) ((exp) ? TRUE : FALSE)
  1200. #define RTL_VERIFYMSG( msg, exp ) ((exp) ? TRUE : FALSE)
  1201. #define RTL_SOFT_VERIFY(_exp) ((_exp) ? TRUE : FALSE)
  1202. #define RTL_SOFT_VERIFYMSG(msg, _exp) ((_exp) ? TRUE : FALSE)
  1203. #endif // DBG
  1204. //
  1205. // Doubly-linked list manipulation routines.
  1206. //
  1207. //
  1208. // VOID
  1209. // InitializeListHead32(
  1210. // PLIST_ENTRY32 ListHead
  1211. // );
  1212. //
  1213. #define InitializeListHead32(ListHead) (\
  1214. (ListHead)->Flink = (ListHead)->Blink = PtrToUlong((ListHead)))
  1215. #if !defined(MIDL_PASS) && !defined(SORTPP_PASS)
  1216. VOID
  1217. FORCEINLINE
  1218. InitializeListHead(
  1219. IN PLIST_ENTRY ListHead
  1220. )
  1221. {
  1222. ListHead->Flink = ListHead->Blink = ListHead;
  1223. }
  1224. //
  1225. // BOOLEAN
  1226. // IsListEmpty(
  1227. // PLIST_ENTRY ListHead
  1228. // );
  1229. //
  1230. #define IsListEmpty(ListHead) \
  1231. ((ListHead)->Flink == (ListHead))
  1232. BOOLEAN
  1233. FORCEINLINE
  1234. RemoveEntryList(
  1235. IN PLIST_ENTRY Entry
  1236. )
  1237. {
  1238. PLIST_ENTRY Blink;
  1239. PLIST_ENTRY Flink;
  1240. Flink = Entry->Flink;
  1241. Blink = Entry->Blink;
  1242. Blink->Flink = Flink;
  1243. Flink->Blink = Blink;
  1244. return (BOOLEAN)(Flink == Blink);
  1245. }
  1246. PLIST_ENTRY
  1247. FORCEINLINE
  1248. RemoveHeadList(
  1249. IN PLIST_ENTRY ListHead
  1250. )
  1251. {
  1252. PLIST_ENTRY Flink;
  1253. PLIST_ENTRY Entry;
  1254. Entry = ListHead->Flink;
  1255. Flink = Entry->Flink;
  1256. ListHead->Flink = Flink;
  1257. Flink->Blink = ListHead;
  1258. return Entry;
  1259. }
  1260. PLIST_ENTRY
  1261. FORCEINLINE
  1262. RemoveTailList(
  1263. IN PLIST_ENTRY ListHead
  1264. )
  1265. {
  1266. PLIST_ENTRY Blink;
  1267. PLIST_ENTRY Entry;
  1268. Entry = ListHead->Blink;
  1269. Blink = Entry->Blink;
  1270. ListHead->Blink = Blink;
  1271. Blink->Flink = ListHead;
  1272. return Entry;
  1273. }
  1274. VOID
  1275. FORCEINLINE
  1276. InsertTailList(
  1277. IN PLIST_ENTRY ListHead,
  1278. IN PLIST_ENTRY Entry
  1279. )
  1280. {
  1281. PLIST_ENTRY Blink;
  1282. Blink = ListHead->Blink;
  1283. Entry->Flink = ListHead;
  1284. Entry->Blink = Blink;
  1285. Blink->Flink = Entry;
  1286. ListHead->Blink = Entry;
  1287. }
  1288. VOID
  1289. FORCEINLINE
  1290. InsertHeadList(
  1291. IN PLIST_ENTRY ListHead,
  1292. IN PLIST_ENTRY Entry
  1293. )
  1294. {
  1295. PLIST_ENTRY Flink;
  1296. Flink = ListHead->Flink;
  1297. Entry->Flink = Flink;
  1298. Entry->Blink = ListHead;
  1299. Flink->Blink = Entry;
  1300. ListHead->Flink = Entry;
  1301. }
  1302. //
  1303. //
  1304. // PSINGLE_LIST_ENTRY
  1305. // PopEntryList(
  1306. // PSINGLE_LIST_ENTRY ListHead
  1307. // );
  1308. //
  1309. #define PopEntryList(ListHead) \
  1310. (ListHead)->Next;\
  1311. {\
  1312. PSINGLE_LIST_ENTRY FirstEntry;\
  1313. FirstEntry = (ListHead)->Next;\
  1314. if (FirstEntry != NULL) { \
  1315. (ListHead)->Next = FirstEntry->Next;\
  1316. } \
  1317. }
  1318. //
  1319. // VOID
  1320. // PushEntryList(
  1321. // PSINGLE_LIST_ENTRY ListHead,
  1322. // PSINGLE_LIST_ENTRY Entry
  1323. // );
  1324. //
  1325. #define PushEntryList(ListHead,Entry) \
  1326. (Entry)->Next = (ListHead)->Next; \
  1327. (ListHead)->Next = (Entry)
  1328. #endif // !MIDL_PASS
  1329. #if defined (_MSC_VER) && ( _MSC_VER >= 900 )
  1330. PVOID
  1331. _ReturnAddress (
  1332. VOID
  1333. );
  1334. #pragma intrinsic(_ReturnAddress)
  1335. #endif
  1336. #if (defined(_M_AMD64) || defined(_M_IA64)) && !defined(_REALLY_GET_CALLERS_CALLER_)
  1337. #define RtlGetCallersAddress(CallersAddress, CallersCaller) \
  1338. *CallersAddress = (PVOID)_ReturnAddress(); \
  1339. *CallersCaller = NULL;
  1340. #else
  1341. NTSYSAPI
  1342. VOID
  1343. NTAPI
  1344. RtlGetCallersAddress(
  1345. OUT PVOID *CallersAddress,
  1346. OUT PVOID *CallersCaller
  1347. );
  1348. #endif
  1349. NTSYSAPI
  1350. ULONG
  1351. NTAPI
  1352. RtlWalkFrameChain (
  1353. OUT PVOID *Callers,
  1354. IN ULONG Count,
  1355. IN ULONG Flags
  1356. );
  1357. NTSYSAPI
  1358. NTSTATUS
  1359. NTAPI
  1360. RtlUnicodeStringToAnsiString(
  1361. PANSI_STRING DestinationString,
  1362. PCUNICODE_STRING SourceString,
  1363. BOOLEAN AllocateDestinationString
  1364. );
  1365. NTSYSAPI
  1366. LONG
  1367. NTAPI
  1368. RtlCompareUnicodeString(
  1369. PCUNICODE_STRING String1,
  1370. PCUNICODE_STRING String2,
  1371. BOOLEAN CaseInSensitive
  1372. );
  1373. NTSYSAPI
  1374. BOOLEAN
  1375. NTAPI
  1376. RtlEqualUnicodeString(
  1377. PCUNICODE_STRING String1,
  1378. PCUNICODE_STRING String2,
  1379. BOOLEAN CaseInSensitive
  1380. );
  1381. #define HASH_STRING_ALGORITHM_DEFAULT (0)
  1382. #define HASH_STRING_ALGORITHM_X65599 (1)
  1383. #define HASH_STRING_ALGORITHM_INVALID (0xffffffff)
  1384. NTSYSAPI
  1385. NTSTATUS
  1386. NTAPI
  1387. RtlHashUnicodeString(
  1388. IN const UNICODE_STRING *String,
  1389. IN BOOLEAN CaseInSensitive,
  1390. IN ULONG HashAlgorithm,
  1391. OUT PULONG HashValue
  1392. );
  1393. NTSYSAPI
  1394. BOOLEAN
  1395. NTAPI
  1396. RtlPrefixUnicodeString(
  1397. IN PCUNICODE_STRING String1,
  1398. IN PCUNICODE_STRING String2,
  1399. IN BOOLEAN CaseInSensitive
  1400. );
  1401. NTSYSAPI
  1402. NTSTATUS
  1403. NTAPI
  1404. RtlUpcaseUnicodeString(
  1405. PUNICODE_STRING DestinationString,
  1406. PCUNICODE_STRING SourceString,
  1407. BOOLEAN AllocateDestinationString
  1408. );
  1409. NTSYSAPI
  1410. VOID
  1411. NTAPI
  1412. RtlCopyUnicodeString(
  1413. PUNICODE_STRING DestinationString,
  1414. PCUNICODE_STRING SourceString
  1415. );
  1416. NTSYSAPI
  1417. NTSTATUS
  1418. NTAPI
  1419. RtlAppendUnicodeStringToString (
  1420. PUNICODE_STRING Destination,
  1421. PCUNICODE_STRING Source
  1422. );
  1423. NTSYSAPI
  1424. NTSTATUS
  1425. NTAPI
  1426. RtlAppendUnicodeToString (
  1427. PUNICODE_STRING Destination,
  1428. PCWSTR Source
  1429. );
  1430. NTSYSAPI
  1431. SIZE_T
  1432. NTAPI
  1433. RtlCompareMemory (
  1434. const VOID *Source1,
  1435. const VOID *Source2,
  1436. SIZE_T Length
  1437. );
  1438. #define RtlEqualMemory(Destination,Source,Length) (!memcmp((Destination),(Source),(Length)))
  1439. #if defined(_M_AMD64)
  1440. NTSYSAPI
  1441. VOID
  1442. NTAPI
  1443. RtlCopyMemory (
  1444. VOID UNALIGNED *Destination,
  1445. CONST VOID UNALIGNED *Source,
  1446. SIZE_T Length
  1447. );
  1448. NTSYSAPI
  1449. VOID
  1450. NTAPI
  1451. RtlMoveMemory (
  1452. VOID UNALIGNED *Destination,
  1453. CONST VOID UNALIGNED *Source,
  1454. SIZE_T Length
  1455. );
  1456. NTSYSAPI
  1457. VOID
  1458. NTAPI
  1459. RtlFillMemory (
  1460. VOID UNALIGNED *Destination,
  1461. SIZE_T Length,
  1462. IN UCHAR Fill
  1463. );
  1464. NTSYSAPI
  1465. VOID
  1466. NTAPI
  1467. RtlZeroMemory (
  1468. VOID UNALIGNED *Destination,
  1469. SIZE_T Length
  1470. );
  1471. #else
  1472. #define RtlMoveMemory(Destination,Source,Length) memmove((Destination),(Source),(Length))
  1473. #define RtlCopyMemory(Destination,Source,Length) memcpy((Destination),(Source),(Length))
  1474. #define RtlFillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length))
  1475. #define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))
  1476. #endif
  1477. #if !defined(MIDL_PASS)
  1478. FORCEINLINE
  1479. PVOID
  1480. RtlSecureZeroMemory(
  1481. IN PVOID ptr,
  1482. IN SIZE_T cnt
  1483. )
  1484. {
  1485. volatile char *vptr = (volatile char *)ptr;
  1486. while (cnt) {
  1487. *vptr = 0;
  1488. vptr++;
  1489. cnt--;
  1490. }
  1491. return ptr;
  1492. }
  1493. #endif
  1494. //
  1495. // Define kernel debugger print prototypes and macros.
  1496. //
  1497. // N.B. The following function cannot be directly imported because there are
  1498. // a few places in the source tree where this function is redefined.
  1499. //
  1500. VOID
  1501. NTAPI
  1502. DbgBreakPoint(
  1503. VOID
  1504. );
  1505. // end_wdm
  1506. NTSYSAPI
  1507. VOID
  1508. NTAPI
  1509. DbgBreakPointWithStatus(
  1510. IN ULONG Status
  1511. );
  1512. // begin_wdm
  1513. #define DBG_STATUS_CONTROL_C 1
  1514. #define DBG_STATUS_SYSRQ 2
  1515. #define DBG_STATUS_BUGCHECK_FIRST 3
  1516. #define DBG_STATUS_BUGCHECK_SECOND 4
  1517. #define DBG_STATUS_FATAL 5
  1518. #define DBG_STATUS_DEBUG_CONTROL 6
  1519. #define DBG_STATUS_WORKER 7
  1520. #if DBG
  1521. #define KdPrint(_x_) DbgPrint _x_
  1522. // end_wdm
  1523. #define KdPrintEx(_x_) DbgPrintEx _x_
  1524. #define vKdPrintEx(_x_) vDbgPrintEx _x_
  1525. #define vKdPrintExWithPrefix(_x_) vDbgPrintExWithPrefix _x_
  1526. // begin_wdm
  1527. #define KdBreakPoint() DbgBreakPoint()
  1528. // end_wdm
  1529. #define KdBreakPointWithStatus(s) DbgBreakPointWithStatus(s)
  1530. // begin_wdm
  1531. #else
  1532. #define KdPrint(_x_)
  1533. // end_wdm
  1534. #define KdPrintEx(_x_)
  1535. #define vKdPrintEx(_x_)
  1536. #define vKdPrintExWithPrefix(_x_)
  1537. // begin_wdm
  1538. #define KdBreakPoint()
  1539. // end_wdm
  1540. #define KdBreakPointWithStatus(s)
  1541. // begin_wdm
  1542. #endif
  1543. #ifndef _DBGNT_
  1544. ULONG
  1545. __cdecl
  1546. DbgPrint(
  1547. PCH Format,
  1548. ...
  1549. );
  1550. // end_wdm
  1551. ULONG
  1552. __cdecl
  1553. DbgPrintEx(
  1554. IN ULONG ComponentId,
  1555. IN ULONG Level,
  1556. IN PCH Format,
  1557. ...
  1558. );
  1559. #ifdef _VA_LIST_DEFINED
  1560. ULONG
  1561. vDbgPrintEx(
  1562. IN ULONG ComponentId,
  1563. IN ULONG Level,
  1564. IN PCH Format,
  1565. va_list arglist
  1566. );
  1567. ULONG
  1568. vDbgPrintExWithPrefix(
  1569. IN PCH Prefix,
  1570. IN ULONG ComponentId,
  1571. IN ULONG Level,
  1572. IN PCH Format,
  1573. va_list arglist
  1574. );
  1575. #endif
  1576. ULONG
  1577. __cdecl
  1578. DbgPrintReturnControlC(
  1579. PCH Format,
  1580. ...
  1581. );
  1582. NTSYSAPI
  1583. NTSTATUS
  1584. DbgQueryDebugFilterState(
  1585. IN ULONG ComponentId,
  1586. IN ULONG Level
  1587. );
  1588. NTSYSAPI
  1589. NTSTATUS
  1590. DbgSetDebugFilterState(
  1591. IN ULONG ComponentId,
  1592. IN ULONG Level,
  1593. IN BOOLEAN State
  1594. );
  1595. // begin_wdm
  1596. #endif // _DBGNT_
  1597. //
  1598. // Component name filter id enumeration and levels.
  1599. //
  1600. #define DPFLTR_ERROR_LEVEL 0
  1601. #define DPFLTR_WARNING_LEVEL 1
  1602. #define DPFLTR_TRACE_LEVEL 2
  1603. #define DPFLTR_INFO_LEVEL 3
  1604. #define DPFLTR_MASK 0x80000000
  1605. typedef enum _DPFLTR_TYPE {
  1606. DPFLTR_SYSTEM_ID = 0,
  1607. DPFLTR_SMSS_ID = 1,
  1608. DPFLTR_SETUP_ID = 2,
  1609. DPFLTR_NTFS_ID = 3,
  1610. DPFLTR_FSTUB_ID = 4,
  1611. DPFLTR_CRASHDUMP_ID = 5,
  1612. DPFLTR_CDAUDIO_ID = 6,
  1613. DPFLTR_CDROM_ID = 7,
  1614. DPFLTR_CLASSPNP_ID = 8,
  1615. DPFLTR_DISK_ID = 9,
  1616. DPFLTR_REDBOOK_ID = 10,
  1617. DPFLTR_STORPROP_ID = 11,
  1618. DPFLTR_SCSIPORT_ID = 12,
  1619. DPFLTR_SCSIMINIPORT_ID = 13,
  1620. DPFLTR_CONFIG_ID = 14,
  1621. DPFLTR_I8042PRT_ID = 15,
  1622. DPFLTR_SERMOUSE_ID = 16,
  1623. DPFLTR_LSERMOUS_ID = 17,
  1624. DPFLTR_KBDHID_ID = 18,
  1625. DPFLTR_MOUHID_ID = 19,
  1626. DPFLTR_KBDCLASS_ID = 20,
  1627. DPFLTR_MOUCLASS_ID = 21,
  1628. DPFLTR_TWOTRACK_ID = 22,
  1629. DPFLTR_WMILIB_ID = 23,
  1630. DPFLTR_ACPI_ID = 24,
  1631. DPFLTR_AMLI_ID = 25,
  1632. DPFLTR_HALIA64_ID = 26,
  1633. DPFLTR_VIDEO_ID = 27,
  1634. DPFLTR_SVCHOST_ID = 28,
  1635. DPFLTR_VIDEOPRT_ID = 29,
  1636. DPFLTR_TCPIP_ID = 30,
  1637. DPFLTR_DMSYNTH_ID = 31,
  1638. DPFLTR_NTOSPNP_ID = 32,
  1639. DPFLTR_FASTFAT_ID = 33,
  1640. DPFLTR_SAMSS_ID = 34,
  1641. DPFLTR_PNPMGR_ID = 35,
  1642. DPFLTR_NETAPI_ID = 36,
  1643. DPFLTR_SCSERVER_ID = 37,
  1644. DPFLTR_SCCLIENT_ID = 38,
  1645. DPFLTR_SERIAL_ID = 39,
  1646. DPFLTR_SERENUM_ID = 40,
  1647. DPFLTR_UHCD_ID = 41,
  1648. DPFLTR_RPCPROXY_ID = 42,
  1649. DPFLTR_AUTOCHK_ID = 43,
  1650. DPFLTR_DCOMSS_ID = 44,
  1651. DPFLTR_UNIMODEM_ID = 45,
  1652. DPFLTR_SIS_ID = 46,
  1653. DPFLTR_FLTMGR_ID = 47,
  1654. DPFLTR_WMICORE_ID = 48,
  1655. DPFLTR_BURNENG_ID = 49,
  1656. DPFLTR_IMAPI_ID = 50,
  1657. DPFLTR_SXS_ID = 51,
  1658. DPFLTR_FUSION_ID = 52,
  1659. DPFLTR_IDLETASK_ID = 53,
  1660. DPFLTR_SOFTPCI_ID = 54,
  1661. DPFLTR_TAPE_ID = 55,
  1662. DPFLTR_MCHGR_ID = 56,
  1663. DPFLTR_IDEP_ID = 57,
  1664. DPFLTR_PCIIDE_ID = 58,
  1665. DPFLTR_FLOPPY_ID = 59,
  1666. DPFLTR_FDC_ID = 60,
  1667. DPFLTR_TERMSRV_ID = 61,
  1668. DPFLTR_W32TIME_ID = 62,
  1669. DPFLTR_PREFETCHER_ID = 63,
  1670. DPFLTR_RSFILTER_ID = 64,
  1671. DPFLTR_FCPORT_ID = 65,
  1672. DPFLTR_PCI_ID = 66,
  1673. DPFLTR_DMIO_ID = 67,
  1674. DPFLTR_DMCONFIG_ID = 68,
  1675. DPFLTR_DMADMIN_ID = 69,
  1676. DPFLTR_WSOCKTRANSPORT_ID = 70,
  1677. DPFLTR_VSS_ID = 71,
  1678. DPFLTR_PNPMEM_ID = 72,
  1679. DPFLTR_PROCESSOR_ID = 73,
  1680. DPFLTR_DMSERVER_ID = 74,
  1681. DPFLTR_SR_ID = 75,
  1682. DPFLTR_INFINIBAND_ID = 76,
  1683. DPFLTR_IHVDRIVER_ID = 77,
  1684. DPFLTR_IHVVIDEO_ID = 78,
  1685. DPFLTR_IHVAUDIO_ID = 79,
  1686. DPFLTR_IHVNETWORK_ID = 80,
  1687. DPFLTR_IHVSTREAMING_ID = 81,
  1688. DPFLTR_IHVBUS_ID = 82,
  1689. DPFLTR_HPS_ID = 83,
  1690. DPFLTR_RTLTHREADPOOL_ID = 84,
  1691. DPFLTR_LDR_ID = 85,
  1692. DPFLTR_TCPIP6_ID = 86,
  1693. DPFLTR_ISAPNP_ID = 87,
  1694. DPFLTR_SHPC_ID = 88,
  1695. DPFLTR_STORPORT_ID = 89,
  1696. DPFLTR_STORMINIPORT_ID = 90,
  1697. DPFLTR_PRINTSPOOLER_ID = 91,
  1698. DPFLTR_VSSDYNDISK_ID = 92,
  1699. DPFLTR_VERIFIER_ID = 93,
  1700. DPFLTR_VDS_ID = 94,
  1701. DPFLTR_VDSBAS_ID = 95,
  1702. DPFLTR_VDSDYNDR_ID = 96,
  1703. DPFLTR_VDSUTIL_ID = 97,
  1704. DPFLTR_DFRGIFC_ID = 98,
  1705. DPFLTR_ENDOFTABLE_ID
  1706. } DPFLTR_TYPE;
  1707. //
  1708. // Define I/O Driver error log packet structure. This structure is filled in
  1709. // by the driver.
  1710. //
  1711. typedef struct _IO_ERROR_LOG_PACKET {
  1712. UCHAR MajorFunctionCode;
  1713. UCHAR RetryCount;
  1714. USHORT DumpDataSize;
  1715. USHORT NumberOfStrings;
  1716. USHORT StringOffset;
  1717. USHORT EventCategory;
  1718. NTSTATUS ErrorCode;
  1719. ULONG UniqueErrorValue;
  1720. NTSTATUS FinalStatus;
  1721. ULONG SequenceNumber;
  1722. ULONG IoControlCode;
  1723. LARGE_INTEGER DeviceOffset;
  1724. ULONG DumpData[1];
  1725. }IO_ERROR_LOG_PACKET, *PIO_ERROR_LOG_PACKET;
  1726. //
  1727. // Define the I/O error log message. This message is sent by the error log
  1728. // thread over the lpc port.
  1729. //
  1730. typedef struct _IO_ERROR_LOG_MESSAGE {
  1731. USHORT Type;
  1732. USHORT Size;
  1733. USHORT DriverNameLength;
  1734. LARGE_INTEGER TimeStamp;
  1735. ULONG DriverNameOffset;
  1736. IO_ERROR_LOG_PACKET EntryData;
  1737. }IO_ERROR_LOG_MESSAGE, *PIO_ERROR_LOG_MESSAGE;
  1738. //
  1739. // Define the maximum message size that will be sent over the LPC to the
  1740. // application reading the error log entries.
  1741. //
  1742. //
  1743. // Regardless of LPC size restrictions, ERROR_LOG_MAXIMUM_SIZE must remain
  1744. // a value that can fit in a UCHAR.
  1745. //
  1746. #define ERROR_LOG_LIMIT_SIZE (256-16)
  1747. //
  1748. // This limit, exclusive of IO_ERROR_LOG_MESSAGE_HEADER_LENGTH, also applies
  1749. // to IO_ERROR_LOG_MESSAGE_LENGTH
  1750. //
  1751. #define IO_ERROR_LOG_MESSAGE_HEADER_LENGTH (sizeof(IO_ERROR_LOG_MESSAGE) - \
  1752. sizeof(IO_ERROR_LOG_PACKET) + \
  1753. (sizeof(WCHAR) * 40))
  1754. #define ERROR_LOG_MESSAGE_LIMIT_SIZE \
  1755. (ERROR_LOG_LIMIT_SIZE + IO_ERROR_LOG_MESSAGE_HEADER_LENGTH)
  1756. //
  1757. // IO_ERROR_LOG_MESSAGE_LENGTH is
  1758. // min(PORT_MAXIMUM_MESSAGE_LENGTH, ERROR_LOG_MESSAGE_LIMIT_SIZE)
  1759. //
  1760. #define IO_ERROR_LOG_MESSAGE_LENGTH \
  1761. ((PORT_MAXIMUM_MESSAGE_LENGTH > ERROR_LOG_MESSAGE_LIMIT_SIZE) ? \
  1762. ERROR_LOG_MESSAGE_LIMIT_SIZE : \
  1763. PORT_MAXIMUM_MESSAGE_LENGTH)
  1764. //
  1765. // Define the maximum packet size a driver can allocate.
  1766. //
  1767. #define ERROR_LOG_MAXIMUM_SIZE (IO_ERROR_LOG_MESSAGE_LENGTH - \
  1768. IO_ERROR_LOG_MESSAGE_HEADER_LENGTH)
  1769. #if defined(_X86_)
  1770. //
  1771. // Types to use to contain PFNs and their counts.
  1772. //
  1773. typedef ULONG PFN_COUNT;
  1774. typedef LONG SPFN_NUMBER, *PSPFN_NUMBER;
  1775. typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
  1776. //
  1777. // Define maximum size of flush multiple TB request.
  1778. //
  1779. #define FLUSH_MULTIPLE_MAXIMUM 32
  1780. //
  1781. // Indicate that the i386 compiler supports the pragma textout construct.
  1782. //
  1783. #define ALLOC_PRAGMA 1
  1784. //
  1785. // Indicate that the i386 compiler supports the DATA_SEG("INIT") and
  1786. // DATA_SEG("PAGE") pragmas
  1787. //
  1788. #define ALLOC_DATA_PRAGMA 1
  1789. //
  1790. // I/O space read and write macros.
  1791. //
  1792. // These have to be actual functions on the 386, because we need
  1793. // to use assembler, but cannot return a value if we inline it.
  1794. //
  1795. // The READ/WRITE_REGISTER_* calls manipulate I/O registers in MEMORY space.
  1796. // (Use x86 move instructions, with LOCK prefix to force correct behavior
  1797. // w.r.t. caches and write buffers.)
  1798. //
  1799. // The READ/WRITE_PORT_* calls manipulate I/O registers in PORT space.
  1800. // (Use x86 in/out instructions.)
  1801. //
  1802. NTKERNELAPI
  1803. UCHAR
  1804. NTAPI
  1805. READ_REGISTER_UCHAR(
  1806. PUCHAR Register
  1807. );
  1808. NTKERNELAPI
  1809. USHORT
  1810. NTAPI
  1811. READ_REGISTER_USHORT(
  1812. PUSHORT Register
  1813. );
  1814. NTKERNELAPI
  1815. ULONG
  1816. NTAPI
  1817. READ_REGISTER_ULONG(
  1818. PULONG Register
  1819. );
  1820. NTKERNELAPI
  1821. VOID
  1822. NTAPI
  1823. READ_REGISTER_BUFFER_UCHAR(
  1824. PUCHAR Register,
  1825. PUCHAR Buffer,
  1826. ULONG Count
  1827. );
  1828. NTKERNELAPI
  1829. VOID
  1830. NTAPI
  1831. READ_REGISTER_BUFFER_USHORT(
  1832. PUSHORT Register,
  1833. PUSHORT Buffer,
  1834. ULONG Count
  1835. );
  1836. NTKERNELAPI
  1837. VOID
  1838. NTAPI
  1839. READ_REGISTER_BUFFER_ULONG(
  1840. PULONG Register,
  1841. PULONG Buffer,
  1842. ULONG Count
  1843. );
  1844. NTKERNELAPI
  1845. VOID
  1846. NTAPI
  1847. WRITE_REGISTER_UCHAR(
  1848. PUCHAR Register,
  1849. UCHAR Value
  1850. );
  1851. NTKERNELAPI
  1852. VOID
  1853. NTAPI
  1854. WRITE_REGISTER_USHORT(
  1855. PUSHORT Register,
  1856. USHORT Value
  1857. );
  1858. NTKERNELAPI
  1859. VOID
  1860. NTAPI
  1861. WRITE_REGISTER_ULONG(
  1862. PULONG Register,
  1863. ULONG Value
  1864. );
  1865. NTKERNELAPI
  1866. VOID
  1867. NTAPI
  1868. WRITE_REGISTER_BUFFER_UCHAR(
  1869. PUCHAR Register,
  1870. PUCHAR Buffer,
  1871. ULONG Count
  1872. );
  1873. NTKERNELAPI
  1874. VOID
  1875. NTAPI
  1876. WRITE_REGISTER_BUFFER_USHORT(
  1877. PUSHORT Register,
  1878. PUSHORT Buffer,
  1879. ULONG Count
  1880. );
  1881. NTKERNELAPI
  1882. VOID
  1883. NTAPI
  1884. WRITE_REGISTER_BUFFER_ULONG(
  1885. PULONG Register,
  1886. PULONG Buffer,
  1887. ULONG Count
  1888. );
  1889. NTHALAPI
  1890. UCHAR
  1891. NTAPI
  1892. READ_PORT_UCHAR(
  1893. PUCHAR Port
  1894. );
  1895. NTHALAPI
  1896. USHORT
  1897. NTAPI
  1898. READ_PORT_USHORT(
  1899. PUSHORT Port
  1900. );
  1901. NTHALAPI
  1902. ULONG
  1903. NTAPI
  1904. READ_PORT_ULONG(
  1905. PULONG Port
  1906. );
  1907. NTHALAPI
  1908. VOID
  1909. NTAPI
  1910. READ_PORT_BUFFER_UCHAR(
  1911. PUCHAR Port,
  1912. PUCHAR Buffer,
  1913. ULONG Count
  1914. );
  1915. NTHALAPI
  1916. VOID
  1917. NTAPI
  1918. READ_PORT_BUFFER_USHORT(
  1919. PUSHORT Port,
  1920. PUSHORT Buffer,
  1921. ULONG Count
  1922. );
  1923. NTHALAPI
  1924. VOID
  1925. NTAPI
  1926. READ_PORT_BUFFER_ULONG(
  1927. PULONG Port,
  1928. PULONG Buffer,
  1929. ULONG Count
  1930. );
  1931. NTHALAPI
  1932. VOID
  1933. NTAPI
  1934. WRITE_PORT_UCHAR(
  1935. PUCHAR Port,
  1936. UCHAR Value
  1937. );
  1938. NTHALAPI
  1939. VOID
  1940. NTAPI
  1941. WRITE_PORT_USHORT(
  1942. PUSHORT Port,
  1943. USHORT Value
  1944. );
  1945. NTHALAPI
  1946. VOID
  1947. NTAPI
  1948. WRITE_PORT_ULONG(
  1949. PULONG Port,
  1950. ULONG Value
  1951. );
  1952. NTHALAPI
  1953. VOID
  1954. NTAPI
  1955. WRITE_PORT_BUFFER_UCHAR(
  1956. PUCHAR Port,
  1957. PUCHAR Buffer,
  1958. ULONG Count
  1959. );
  1960. NTHALAPI
  1961. VOID
  1962. NTAPI
  1963. WRITE_PORT_BUFFER_USHORT(
  1964. PUSHORT Port,
  1965. PUSHORT Buffer,
  1966. ULONG Count
  1967. );
  1968. NTHALAPI
  1969. VOID
  1970. NTAPI
  1971. WRITE_PORT_BUFFER_ULONG(
  1972. PULONG Port,
  1973. PULONG Buffer,
  1974. ULONG Count
  1975. );
  1976. #define KeFlushIoBuffers(Mdl, ReadOperation, DmaOperation)
  1977. //
  1978. // i386 Specific portions of mm component
  1979. //
  1980. //
  1981. // Define the page size for the Intel 386 as 4096 (0x1000).
  1982. //
  1983. #define PAGE_SIZE 0x1000
  1984. //
  1985. // Define the number of trailing zeroes in a page aligned virtual address.
  1986. // This is used as the shift count when shifting virtual addresses to
  1987. // virtual page numbers.
  1988. //
  1989. #define PAGE_SHIFT 12L
  1990. //++
  1991. //
  1992. // VOID
  1993. // KeMemoryBarrier (
  1994. // VOID
  1995. // )
  1996. //
  1997. // VOID
  1998. // KeMemoryBarrierWithoutFence (
  1999. // VOID
  2000. // )
  2001. //
  2002. //
  2003. // Routine Description:
  2004. //
  2005. // These functions order memory accesses as seen by other processors.
  2006. //
  2007. // Arguments:
  2008. //
  2009. // None.
  2010. //
  2011. // Return Value:
  2012. //
  2013. // None.
  2014. //
  2015. //--
  2016. #ifdef __cplusplus
  2017. extern "C" {
  2018. #endif
  2019. VOID
  2020. _ReadWriteBarrier(
  2021. VOID
  2022. );
  2023. #ifdef __cplusplus
  2024. }
  2025. #endif
  2026. #pragma intrinsic (_ReadWriteBarrier)
  2027. FORCEINLINE
  2028. VOID
  2029. KeMemoryBarrier (
  2030. VOID
  2031. )
  2032. {
  2033. LONG Barrier;
  2034. __asm {
  2035. xchg Barrier, eax
  2036. }
  2037. }
  2038. #define KeMemoryBarrierWithoutFence() _ReadWriteBarrier()
  2039. #endif // defined(_X86_)
  2040. #if defined(_M_AMD64) && !defined(RC_INVOKED) && !defined(MIDL_PASS)
  2041. //
  2042. // Define intrinsic function to do in's and out's.
  2043. //
  2044. #ifdef __cplusplus
  2045. extern "C" {
  2046. #endif
  2047. UCHAR
  2048. __inbyte (
  2049. IN USHORT Port
  2050. );
  2051. USHORT
  2052. __inword (
  2053. IN USHORT Port
  2054. );
  2055. ULONG
  2056. __indword (
  2057. IN USHORT Port
  2058. );
  2059. VOID
  2060. __outbyte (
  2061. IN USHORT Port,
  2062. IN UCHAR Data
  2063. );
  2064. VOID
  2065. __outword (
  2066. IN USHORT Port,
  2067. IN USHORT Data
  2068. );
  2069. VOID
  2070. __outdword (
  2071. IN USHORT Port,
  2072. IN ULONG Data
  2073. );
  2074. VOID
  2075. __inbytestring (
  2076. IN USHORT Port,
  2077. IN PUCHAR Buffer,
  2078. IN ULONG Count
  2079. );
  2080. VOID
  2081. __inwordstring (
  2082. IN USHORT Port,
  2083. IN PUSHORT Buffer,
  2084. IN ULONG Count
  2085. );
  2086. VOID
  2087. __indwordstring (
  2088. IN USHORT Port,
  2089. IN PULONG Buffer,
  2090. IN ULONG Count
  2091. );
  2092. VOID
  2093. __outbytestring (
  2094. IN USHORT Port,
  2095. IN PUCHAR Buffer,
  2096. IN ULONG Count
  2097. );
  2098. VOID
  2099. __outwordstring (
  2100. IN USHORT Port,
  2101. IN PUSHORT Buffer,
  2102. IN ULONG Count
  2103. );
  2104. VOID
  2105. __outdwordstring (
  2106. IN USHORT Port,
  2107. IN PULONG Buffer,
  2108. IN ULONG Count
  2109. );
  2110. #ifdef __cplusplus
  2111. }
  2112. #endif
  2113. #pragma intrinsic(__inbyte)
  2114. #pragma intrinsic(__inword)
  2115. #pragma intrinsic(__indword)
  2116. #pragma intrinsic(__outbyte)
  2117. #pragma intrinsic(__outword)
  2118. #pragma intrinsic(__outdword)
  2119. #pragma intrinsic(__inbytestring)
  2120. #pragma intrinsic(__inwordstring)
  2121. #pragma intrinsic(__indwordstring)
  2122. #pragma intrinsic(__outbytestring)
  2123. #pragma intrinsic(__outwordstring)
  2124. #pragma intrinsic(__outdwordstring)
  2125. //
  2126. // Interlocked intrinsic functions.
  2127. //
  2128. #define InterlockedAnd _InterlockedAnd
  2129. #define InterlockedOr _InterlockedOr
  2130. #define InterlockedXor _InterlockedXor
  2131. #define InterlockedIncrement _InterlockedIncrement
  2132. #define InterlockedIncrementAcquire InterlockedIncrement
  2133. #define InterlockedIncrementRelease InterlockedIncrement
  2134. #define InterlockedDecrement _InterlockedDecrement
  2135. #define InterlockedDecrementAcquire InterlockedDecrement
  2136. #define InterlockedDecrementRelease InterlockedDecrement
  2137. #define InterlockedAdd _InterlockedAdd
  2138. #define InterlockedExchange _InterlockedExchange
  2139. #define InterlockedExchangeAdd _InterlockedExchangeAdd
  2140. #define InterlockedCompareExchange _InterlockedCompareExchange
  2141. #define InterlockedCompareExchangeAcquire InterlockedCompareExchange
  2142. #define InterlockedCompareExchangeRelease InterlockedCompareExchange
  2143. #define InterlockedAnd64 _InterlockedAnd64
  2144. #define InterlockedOr64 _InterlockedOr64
  2145. #define InterlockedXor64 _InterlockedXor64
  2146. #define InterlockedIncrement64 _InterlockedIncrement64
  2147. #define InterlockedDecrement64 _InterlockedDecrement64
  2148. #define InterlockedAdd64 _InterlockedAdd64
  2149. #define InterlockedExchange64 _InterlockedExchange64
  2150. #define InterlockedExchangeAcquire64 InterlockedExchange64
  2151. #define InterlockedExchangeAdd64 _InterlockedExchangeAdd64
  2152. #define InterlockedCompareExchange64 _InterlockedCompareExchange64
  2153. #define InterlockedCompareExchangeAcquire64 InterlockedCompareExchange64
  2154. #define InterlockedCompareExchangeRelease64 InterlockedCompareExchange64
  2155. #define InterlockedExchangePointer _InterlockedExchangePointer
  2156. #define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer
  2157. #ifdef __cplusplus
  2158. extern "C" {
  2159. #endif
  2160. LONG
  2161. InterlockedAnd (
  2162. IN OUT LONG volatile *Destination,
  2163. IN LONG Value
  2164. );
  2165. LONG
  2166. InterlockedOr (
  2167. IN OUT LONG volatile *Destination,
  2168. IN LONG Value
  2169. );
  2170. LONG
  2171. InterlockedXor (
  2172. IN OUT LONG volatile *Destination,
  2173. IN LONG Value
  2174. );
  2175. LONG64
  2176. InterlockedAnd64 (
  2177. IN OUT LONG64 volatile *Destination,
  2178. IN LONG64 Value
  2179. );
  2180. LONG64
  2181. InterlockedOr64 (
  2182. IN OUT LONG64 volatile *Destination,
  2183. IN LONG64 Value
  2184. );
  2185. LONG64
  2186. InterlockedXor64 (
  2187. IN OUT LONG64 volatile *Destination,
  2188. IN LONG64 Value
  2189. );
  2190. LONG
  2191. InterlockedIncrement(
  2192. IN OUT LONG volatile *Addend
  2193. );
  2194. LONG
  2195. InterlockedDecrement(
  2196. IN OUT LONG volatile *Addend
  2197. );
  2198. LONG
  2199. InterlockedExchange(
  2200. IN OUT LONG volatile *Target,
  2201. IN LONG Value
  2202. );
  2203. LONG
  2204. InterlockedExchangeAdd(
  2205. IN OUT LONG volatile *Addend,
  2206. IN LONG Value
  2207. );
  2208. #if !defined(_X86AMD64_)
  2209. __forceinline
  2210. LONG
  2211. InterlockedAdd(
  2212. IN OUT LONG volatile *Addend,
  2213. IN LONG Value
  2214. )
  2215. {
  2216. return InterlockedExchangeAdd(Addend, Value) + Value;
  2217. }
  2218. #endif
  2219. LONG
  2220. InterlockedCompareExchange (
  2221. IN OUT LONG volatile *Destination,
  2222. IN LONG ExChange,
  2223. IN LONG Comperand
  2224. );
  2225. LONG64
  2226. InterlockedIncrement64(
  2227. IN OUT LONG64 volatile *Addend
  2228. );
  2229. LONG64
  2230. InterlockedDecrement64(
  2231. IN OUT LONG64 volatile *Addend
  2232. );
  2233. LONG64
  2234. InterlockedExchange64(
  2235. IN OUT LONG64 volatile *Target,
  2236. IN LONG64 Value
  2237. );
  2238. LONG64
  2239. InterlockedExchangeAdd64(
  2240. IN OUT LONG64 volatile *Addend,
  2241. IN LONG64 Value
  2242. );
  2243. #if !defined(_X86AMD64_)
  2244. __forceinline
  2245. LONG64
  2246. InterlockedAdd64(
  2247. IN OUT LONG64 volatile *Addend,
  2248. IN LONG64 Value
  2249. )
  2250. {
  2251. return InterlockedExchangeAdd64(Addend, Value) + Value;
  2252. }
  2253. #endif
  2254. LONG64
  2255. InterlockedCompareExchange64 (
  2256. IN OUT LONG64 volatile *Destination,
  2257. IN LONG64 ExChange,
  2258. IN LONG64 Comperand
  2259. );
  2260. PVOID
  2261. InterlockedCompareExchangePointer (
  2262. IN OUT PVOID volatile *Destination,
  2263. IN PVOID Exchange,
  2264. IN PVOID Comperand
  2265. );
  2266. PVOID
  2267. InterlockedExchangePointer(
  2268. IN OUT PVOID volatile *Target,
  2269. IN PVOID Value
  2270. );
  2271. #pragma intrinsic(_InterlockedAnd)
  2272. #pragma intrinsic(_InterlockedOr)
  2273. #pragma intrinsic(_InterlockedXor)
  2274. #pragma intrinsic(_InterlockedIncrement)
  2275. #pragma intrinsic(_InterlockedDecrement)
  2276. #pragma intrinsic(_InterlockedExchange)
  2277. #pragma intrinsic(_InterlockedExchangeAdd)
  2278. #pragma intrinsic(_InterlockedCompareExchange)
  2279. #pragma intrinsic(_InterlockedAnd64)
  2280. #pragma intrinsic(_InterlockedOr64)
  2281. #pragma intrinsic(_InterlockedXor64)
  2282. #pragma intrinsic(_InterlockedIncrement64)
  2283. #pragma intrinsic(_InterlockedDecrement64)
  2284. #pragma intrinsic(_InterlockedExchange64)
  2285. #pragma intrinsic(_InterlockedExchangeAdd64)
  2286. #pragma intrinsic(_InterlockedCompareExchange64)
  2287. #pragma intrinsic(_InterlockedExchangePointer)
  2288. #pragma intrinsic(_InterlockedCompareExchangePointer)
  2289. #ifdef __cplusplus
  2290. }
  2291. #endif
  2292. #endif // defined(_M_AMD64) && !defined(RC_INVOKED) && !defined(MIDL_PASS)
  2293. #if defined(_AMD64_)
  2294. //
  2295. // Types to use to contain PFNs and their counts.
  2296. //
  2297. typedef ULONG PFN_COUNT;
  2298. typedef LONG64 SPFN_NUMBER, *PSPFN_NUMBER;
  2299. typedef ULONG64 PFN_NUMBER, *PPFN_NUMBER;
  2300. //
  2301. // Define maximum size of flush multiple TB request.
  2302. //
  2303. #define FLUSH_MULTIPLE_MAXIMUM 32
  2304. //
  2305. // Indicate that the AMD64 compiler supports the allocate pragmas.
  2306. //
  2307. #define ALLOC_PRAGMA 1
  2308. #define ALLOC_DATA_PRAGMA 1
  2309. //
  2310. // I/O space read and write macros.
  2311. //
  2312. // The READ/WRITE_REGISTER_* calls manipulate I/O registers in MEMORY space.
  2313. //
  2314. // The READ/WRITE_PORT_* calls manipulate I/O registers in PORT space.
  2315. //
  2316. __forceinline
  2317. UCHAR
  2318. READ_REGISTER_UCHAR (
  2319. volatile UCHAR *Register
  2320. )
  2321. {
  2322. return *Register;
  2323. }
  2324. __forceinline
  2325. USHORT
  2326. READ_REGISTER_USHORT (
  2327. volatile USHORT *Register
  2328. )
  2329. {
  2330. return *Register;
  2331. }
  2332. __forceinline
  2333. ULONG
  2334. READ_REGISTER_ULONG (
  2335. volatile ULONG *Register
  2336. )
  2337. {
  2338. return *Register;
  2339. }
  2340. __forceinline
  2341. VOID
  2342. READ_REGISTER_BUFFER_UCHAR (
  2343. PUCHAR Register,
  2344. PUCHAR Buffer,
  2345. ULONG Count
  2346. )
  2347. {
  2348. __movsb(Buffer, Register, Count);
  2349. return;
  2350. }
  2351. __forceinline
  2352. VOID
  2353. READ_REGISTER_BUFFER_USHORT (
  2354. PUSHORT Register,
  2355. PUSHORT Buffer,
  2356. ULONG Count
  2357. )
  2358. {
  2359. __movsw(Buffer, Register, Count);
  2360. return;
  2361. }
  2362. __forceinline
  2363. VOID
  2364. READ_REGISTER_BUFFER_ULONG (
  2365. PULONG Register,
  2366. PULONG Buffer,
  2367. ULONG Count
  2368. )
  2369. {
  2370. __movsd(Buffer, Register, Count);
  2371. return;
  2372. }
  2373. __forceinline
  2374. VOID
  2375. WRITE_REGISTER_UCHAR (
  2376. PUCHAR Register,
  2377. UCHAR Value
  2378. )
  2379. {
  2380. *Register = Value;
  2381. StoreFence();
  2382. return;
  2383. }
  2384. __forceinline
  2385. VOID
  2386. WRITE_REGISTER_USHORT (
  2387. PUSHORT Register,
  2388. USHORT Value
  2389. )
  2390. {
  2391. *Register = Value;
  2392. StoreFence();
  2393. return;
  2394. }
  2395. __forceinline
  2396. VOID
  2397. WRITE_REGISTER_ULONG (
  2398. PULONG Register,
  2399. ULONG Value
  2400. )
  2401. {
  2402. *Register = Value;
  2403. StoreFence();
  2404. return;
  2405. }
  2406. __forceinline
  2407. VOID
  2408. WRITE_REGISTER_BUFFER_UCHAR (
  2409. PUCHAR Register,
  2410. PUCHAR Buffer,
  2411. ULONG Count
  2412. )
  2413. {
  2414. __movsb(Register, Buffer, Count);
  2415. StoreFence();
  2416. return;
  2417. }
  2418. __forceinline
  2419. VOID
  2420. WRITE_REGISTER_BUFFER_USHORT (
  2421. PUSHORT Register,
  2422. PUSHORT Buffer,
  2423. ULONG Count
  2424. )
  2425. {
  2426. __movsw(Register, Buffer, Count);
  2427. StoreFence();
  2428. return;
  2429. }
  2430. __forceinline
  2431. VOID
  2432. WRITE_REGISTER_BUFFER_ULONG (
  2433. PULONG Register,
  2434. PULONG Buffer,
  2435. ULONG Count
  2436. )
  2437. {
  2438. __movsd(Register, Buffer, Count);
  2439. StoreFence();
  2440. return;
  2441. }
  2442. __forceinline
  2443. UCHAR
  2444. READ_PORT_UCHAR (
  2445. PUCHAR Port
  2446. )
  2447. {
  2448. return __inbyte((USHORT)((ULONG64)Port));
  2449. }
  2450. __forceinline
  2451. USHORT
  2452. READ_PORT_USHORT (
  2453. PUSHORT Port
  2454. )
  2455. {
  2456. return __inword((USHORT)((ULONG64)Port));
  2457. }
  2458. __forceinline
  2459. ULONG
  2460. READ_PORT_ULONG (
  2461. PULONG Port
  2462. )
  2463. {
  2464. return __indword((USHORT)((ULONG64)Port));
  2465. }
  2466. __forceinline
  2467. VOID
  2468. READ_PORT_BUFFER_UCHAR (
  2469. PUCHAR Port,
  2470. PUCHAR Buffer,
  2471. ULONG Count
  2472. )
  2473. {
  2474. __inbytestring((USHORT)((ULONG64)Port), Buffer, Count);
  2475. return;
  2476. }
  2477. __forceinline
  2478. VOID
  2479. READ_PORT_BUFFER_USHORT (
  2480. PUSHORT Port,
  2481. PUSHORT Buffer,
  2482. ULONG Count
  2483. )
  2484. {
  2485. __inwordstring((USHORT)((ULONG64)Port), Buffer, Count);
  2486. return;
  2487. }
  2488. __forceinline
  2489. VOID
  2490. READ_PORT_BUFFER_ULONG (
  2491. PULONG Port,
  2492. PULONG Buffer,
  2493. ULONG Count
  2494. )
  2495. {
  2496. __indwordstring((USHORT)((ULONG64)Port), Buffer, Count);
  2497. return;
  2498. }
  2499. __forceinline
  2500. VOID
  2501. WRITE_PORT_UCHAR (
  2502. PUCHAR Port,
  2503. UCHAR Value
  2504. )
  2505. {
  2506. __outbyte((USHORT)((ULONG64)Port), Value);
  2507. return;
  2508. }
  2509. __forceinline
  2510. VOID
  2511. WRITE_PORT_USHORT (
  2512. PUSHORT Port,
  2513. USHORT Value
  2514. )
  2515. {
  2516. __outword((USHORT)((ULONG64)Port), Value);
  2517. return;
  2518. }
  2519. __forceinline
  2520. VOID
  2521. WRITE_PORT_ULONG (
  2522. PULONG Port,
  2523. ULONG Value
  2524. )
  2525. {
  2526. __outdword((USHORT)((ULONG64)Port), Value);
  2527. return;
  2528. }
  2529. __forceinline
  2530. VOID
  2531. WRITE_PORT_BUFFER_UCHAR (
  2532. PUCHAR Port,
  2533. PUCHAR Buffer,
  2534. ULONG Count
  2535. )
  2536. {
  2537. __outbytestring((USHORT)((ULONG64)Port), Buffer, Count);
  2538. return;
  2539. }
  2540. __forceinline
  2541. VOID
  2542. WRITE_PORT_BUFFER_USHORT (
  2543. PUSHORT Port,
  2544. PUSHORT Buffer,
  2545. ULONG Count
  2546. )
  2547. {
  2548. __outwordstring((USHORT)((ULONG64)Port), Buffer, Count);
  2549. return;
  2550. }
  2551. __forceinline
  2552. VOID
  2553. WRITE_PORT_BUFFER_ULONG (
  2554. PULONG Port,
  2555. PULONG Buffer,
  2556. ULONG Count
  2557. )
  2558. {
  2559. __outdwordstring((USHORT)((ULONG64)Port), Buffer, Count);
  2560. return;
  2561. }
  2562. #define KeFlushIoBuffers(Mdl, ReadOperation, DmaOperation)
  2563. //
  2564. // AMD64 Specific portions of mm component.
  2565. //
  2566. // Define the page size for the AMD64 as 4096 (0x1000).
  2567. //
  2568. #define PAGE_SIZE 0x1000
  2569. //
  2570. // Define the number of trailing zeroes in a page aligned virtual address.
  2571. // This is used as the shift count when shifting virtual addresses to
  2572. // virtual page numbers.
  2573. //
  2574. #define PAGE_SHIFT 12L
  2575. //++
  2576. //
  2577. //
  2578. // VOID
  2579. // KeMemoryBarrier (
  2580. // VOID
  2581. // )
  2582. //
  2583. // VOID
  2584. // KeMemoryBarrierWithoutFence (
  2585. // VOID
  2586. // )
  2587. //
  2588. //
  2589. // Routine Description:
  2590. //
  2591. // These functions order memory accesses as seen by other processors.
  2592. //
  2593. // Arguments:
  2594. //
  2595. // None.
  2596. //
  2597. // Return Value:
  2598. //
  2599. // None.
  2600. //
  2601. //--
  2602. #if !defined(_CROSS_PLATFORM_)
  2603. #ifdef __cplusplus
  2604. extern "C" {
  2605. #endif
  2606. VOID
  2607. _ReadWriteBarrier (
  2608. VOID
  2609. );
  2610. #pragma intrinsic(_ReadWriteBarrier)
  2611. #ifdef __cplusplus
  2612. }
  2613. #endif
  2614. #define KeMemoryBarrier() _ReadWriteBarrier()
  2615. #define KeMemoryBarrierWithoutFence() _ReadWriteBarrier()
  2616. #else
  2617. #define KeMemoryBarrier()
  2618. #define KeMemoryBarrierWithoutFence()
  2619. #endif
  2620. #endif // defined(_AMD64_)
  2621. #if defined(_IA64_)
  2622. //
  2623. // Types to use to contain PFNs and their counts.
  2624. //
  2625. typedef ULONG PFN_COUNT;
  2626. typedef LONG_PTR SPFN_NUMBER, *PSPFN_NUMBER;
  2627. typedef ULONG_PTR PFN_NUMBER, *PPFN_NUMBER;
  2628. //
  2629. // Indicate that the IA64 compiler supports the pragma textout construct.
  2630. //
  2631. #define ALLOC_PRAGMA 1
  2632. //
  2633. // Define intrinsic calls and their prototypes
  2634. //
  2635. #include "ia64reg.h"
  2636. #ifdef __cplusplus
  2637. extern "C" {
  2638. #endif
  2639. unsigned __int64 __getReg (int);
  2640. void __setReg (int, unsigned __int64);
  2641. void __isrlz (void);
  2642. void __dsrlz (void);
  2643. void __fwb (void);
  2644. void __mf (void);
  2645. void __mfa (void);
  2646. void __synci (void);
  2647. __int64 __thash (__int64);
  2648. __int64 __ttag (__int64);
  2649. void __ptcl (__int64, __int64);
  2650. void __ptcg (__int64, __int64);
  2651. void __ptcga (__int64, __int64);
  2652. void __ptri (__int64, __int64);
  2653. void __ptrd (__int64, __int64);
  2654. void __invalat (void);
  2655. void __break (int);
  2656. void __fc (__int64);
  2657. void __fci (__int64);
  2658. void __sum (int);
  2659. void __rsm (int);
  2660. void _ReleaseSpinLock( unsigned __int64 *);
  2661. void __yield();
  2662. void __lfetch(int, void const *);
  2663. void __lfetchfault(int, void const *);
  2664. #ifdef _M_IA64
  2665. #pragma intrinsic (__getReg)
  2666. #pragma intrinsic (__setReg)
  2667. #pragma intrinsic (__isrlz)
  2668. #pragma intrinsic (__dsrlz)
  2669. #pragma intrinsic (__fwb)
  2670. #pragma intrinsic (__mf)
  2671. #pragma intrinsic (__mfa)
  2672. #pragma intrinsic (__synci)
  2673. #pragma intrinsic (__thash)
  2674. #pragma intrinsic (__ttag)
  2675. #pragma intrinsic (__ptcl)
  2676. #pragma intrinsic (__ptcg)
  2677. #pragma intrinsic (__ptcga)
  2678. #pragma intrinsic (__ptri)
  2679. #pragma intrinsic (__ptrd)
  2680. #pragma intrinsic (__invalat)
  2681. #pragma intrinsic (__break)
  2682. #pragma intrinsic (__fc)
  2683. #pragma intrinsic (__fci)
  2684. #pragma intrinsic (__sum)
  2685. #pragma intrinsic (__rsm)
  2686. #pragma intrinsic (_ReleaseSpinLock)
  2687. #pragma intrinsic (__yield)
  2688. #pragma intrinsic (__lfetch)
  2689. #pragma intrinsic (__lfetchfault)
  2690. #endif // _M_IA64
  2691. #ifdef __cplusplus
  2692. }
  2693. #endif
  2694. //
  2695. //
  2696. // VOID
  2697. // KeMemoryBarrierWithoutFence (
  2698. // VOID
  2699. // )
  2700. //
  2701. //
  2702. // Routine Description:
  2703. //
  2704. // This function cases ordering of memory acceses generated by the compiler.
  2705. //
  2706. //
  2707. // Arguments:
  2708. //
  2709. // None.
  2710. //
  2711. // Return Value:
  2712. //
  2713. // None.
  2714. //--
  2715. #ifdef __cplusplus
  2716. extern "C" {
  2717. #endif
  2718. VOID
  2719. _ReadWriteBarrier (
  2720. VOID
  2721. );
  2722. #ifdef __cplusplus
  2723. }
  2724. #endif
  2725. #pragma intrinsic(_ReadWriteBarrier)
  2726. #define KeMemoryBarrierWithoutFence() _ReadWriteBarrier()
  2727. //++
  2728. //
  2729. //
  2730. // VOID
  2731. // KeMemoryBarrier (
  2732. // VOID
  2733. // )
  2734. //
  2735. //
  2736. // Routine Description:
  2737. //
  2738. // This function cases ordering of memory acceses as generated by the compiler and
  2739. // as seen by other processors.
  2740. //
  2741. //
  2742. // Arguments:
  2743. //
  2744. // None.
  2745. //
  2746. // Return Value:
  2747. //
  2748. // None.
  2749. //--
  2750. #define KE_MEMORY_BARRIER_REQUIRED
  2751. #define KeMemoryBarrier() {_ReadWriteBarrier();__mf ();_ReadWriteBarrier();}
  2752. //
  2753. // Define the page size
  2754. //
  2755. #define PAGE_SIZE 0x2000
  2756. //
  2757. // Define the number of trailing zeroes in a page aligned virtual address.
  2758. // This is used as the shift count when shifting virtual addresses to
  2759. // virtual page numbers.
  2760. //
  2761. #define PAGE_SHIFT 13L
  2762. //
  2763. // Cache and write buffer flush functions.
  2764. //
  2765. NTKERNELAPI
  2766. VOID
  2767. KeFlushIoBuffers (
  2768. IN PMDL Mdl,
  2769. IN BOOLEAN ReadOperation,
  2770. IN BOOLEAN DmaOperation
  2771. );
  2772. //
  2773. // I/O space read and write macros.
  2774. //
  2775. NTHALAPI
  2776. UCHAR
  2777. READ_PORT_UCHAR (
  2778. PUCHAR RegisterAddress
  2779. );
  2780. NTHALAPI
  2781. USHORT
  2782. READ_PORT_USHORT (
  2783. PUSHORT RegisterAddress
  2784. );
  2785. NTHALAPI
  2786. ULONG
  2787. READ_PORT_ULONG (
  2788. PULONG RegisterAddress
  2789. );
  2790. NTHALAPI
  2791. VOID
  2792. READ_PORT_BUFFER_UCHAR (
  2793. PUCHAR portAddress,
  2794. PUCHAR readBuffer,
  2795. ULONG readCount
  2796. );
  2797. NTHALAPI
  2798. VOID
  2799. READ_PORT_BUFFER_USHORT (
  2800. PUSHORT portAddress,
  2801. PUSHORT readBuffer,
  2802. ULONG readCount
  2803. );
  2804. NTHALAPI
  2805. VOID
  2806. READ_PORT_BUFFER_ULONG (
  2807. PULONG portAddress,
  2808. PULONG readBuffer,
  2809. ULONG readCount
  2810. );
  2811. NTHALAPI
  2812. VOID
  2813. WRITE_PORT_UCHAR (
  2814. PUCHAR portAddress,
  2815. UCHAR Data
  2816. );
  2817. NTHALAPI
  2818. VOID
  2819. WRITE_PORT_USHORT (
  2820. PUSHORT portAddress,
  2821. USHORT Data
  2822. );
  2823. NTHALAPI
  2824. VOID
  2825. WRITE_PORT_ULONG (
  2826. PULONG portAddress,
  2827. ULONG Data
  2828. );
  2829. NTHALAPI
  2830. VOID
  2831. WRITE_PORT_BUFFER_UCHAR (
  2832. PUCHAR portAddress,
  2833. PUCHAR writeBuffer,
  2834. ULONG writeCount
  2835. );
  2836. NTHALAPI
  2837. VOID
  2838. WRITE_PORT_BUFFER_USHORT (
  2839. PUSHORT portAddress,
  2840. PUSHORT writeBuffer,
  2841. ULONG writeCount
  2842. );
  2843. NTHALAPI
  2844. VOID
  2845. WRITE_PORT_BUFFER_ULONG (
  2846. PULONG portAddress,
  2847. PULONG writeBuffer,
  2848. ULONG writeCount
  2849. );
  2850. #define READ_REGISTER_UCHAR(x) \
  2851. (__mf(), *(volatile UCHAR * const)(x))
  2852. #define READ_REGISTER_USHORT(x) \
  2853. (__mf(), *(volatile USHORT * const)(x))
  2854. #define READ_REGISTER_ULONG(x) \
  2855. (__mf(), *(volatile ULONG * const)(x))
  2856. #define READ_REGISTER_BUFFER_UCHAR(x, y, z) { \
  2857. PUCHAR registerBuffer = x; \
  2858. PUCHAR readBuffer = y; \
  2859. ULONG readCount; \
  2860. __mf(); \
  2861. for (readCount = z; readCount--; readBuffer++, registerBuffer++) { \
  2862. *readBuffer = *(volatile UCHAR * const)(registerBuffer); \
  2863. } \
  2864. }
  2865. #define READ_REGISTER_BUFFER_USHORT(x, y, z) { \
  2866. PUSHORT registerBuffer = x; \
  2867. PUSHORT readBuffer = y; \
  2868. ULONG readCount; \
  2869. __mf(); \
  2870. for (readCount = z; readCount--; readBuffer++, registerBuffer++) { \
  2871. *readBuffer = *(volatile USHORT * const)(registerBuffer); \
  2872. } \
  2873. }
  2874. #define READ_REGISTER_BUFFER_ULONG(x, y, z) { \
  2875. PULONG registerBuffer = x; \
  2876. PULONG readBuffer = y; \
  2877. ULONG readCount; \
  2878. __mf(); \
  2879. for (readCount = z; readCount--; readBuffer++, registerBuffer++) { \
  2880. *readBuffer = *(volatile ULONG * const)(registerBuffer); \
  2881. } \
  2882. }
  2883. #define WRITE_REGISTER_UCHAR(x, y) { \
  2884. *(volatile UCHAR * const)(x) = y; \
  2885. KeFlushWriteBuffer(); \
  2886. }
  2887. #define WRITE_REGISTER_USHORT(x, y) { \
  2888. *(volatile USHORT * const)(x) = y; \
  2889. KeFlushWriteBuffer(); \
  2890. }
  2891. #define WRITE_REGISTER_ULONG(x, y) { \
  2892. *(volatile ULONG * const)(x) = y; \
  2893. KeFlushWriteBuffer(); \
  2894. }
  2895. #define WRITE_REGISTER_BUFFER_UCHAR(x, y, z) { \
  2896. PUCHAR registerBuffer = x; \
  2897. PUCHAR writeBuffer = y; \
  2898. ULONG writeCount; \
  2899. for (writeCount = z; writeCount--; writeBuffer++, registerBuffer++) { \
  2900. *(volatile UCHAR * const)(registerBuffer) = *writeBuffer; \
  2901. } \
  2902. KeFlushWriteBuffer(); \
  2903. }
  2904. #define WRITE_REGISTER_BUFFER_USHORT(x, y, z) { \
  2905. PUSHORT registerBuffer = x; \
  2906. PUSHORT writeBuffer = y; \
  2907. ULONG writeCount; \
  2908. for (writeCount = z; writeCount--; writeBuffer++, registerBuffer++) { \
  2909. *(volatile USHORT * const)(registerBuffer) = *writeBuffer; \
  2910. } \
  2911. KeFlushWriteBuffer(); \
  2912. }
  2913. #define WRITE_REGISTER_BUFFER_ULONG(x, y, z) { \
  2914. PULONG registerBuffer = x; \
  2915. PULONG writeBuffer = y; \
  2916. ULONG writeCount; \
  2917. for (writeCount = z; writeCount--; writeBuffer++, registerBuffer++) { \
  2918. *(volatile ULONG * const)(registerBuffer) = *writeBuffer; \
  2919. } \
  2920. KeFlushWriteBuffer(); \
  2921. }
  2922. #endif // defined(_IA64_)
  2923. //
  2924. // Defines the Type in the RESOURCE_DESCRIPTOR
  2925. //
  2926. // NOTE: For all CM_RESOURCE_TYPE values, there must be a
  2927. // corresponding ResType value in the 32-bit ConfigMgr headerfile
  2928. // (cfgmgr32.h). Values in the range [0x6,0x80) use the same values
  2929. // as their ConfigMgr counterparts. CM_RESOURCE_TYPE values with
  2930. // the high bit set (i.e., in the range [0x80,0xFF]), are
  2931. // non-arbitrated resources. These correspond to the same values
  2932. // in cfgmgr32.h that have their high bit set (however, since
  2933. // cfgmgr32.h uses 16 bits for ResType values, these values are in
  2934. // the range [0x8000,0x807F). Note that ConfigMgr ResType values
  2935. // cannot be in the range [0x8080,0xFFFF), because they would not
  2936. // be able to map into CM_RESOURCE_TYPE values. (0xFFFF itself is
  2937. // a special value, because it maps to CmResourceTypeDeviceSpecific.)
  2938. //
  2939. typedef int CM_RESOURCE_TYPE;
  2940. // CmResourceTypeNull is reserved
  2941. #define CmResourceTypeNull 0 // ResType_All or ResType_None (0x0000)
  2942. #define CmResourceTypePort 1 // ResType_IO (0x0002)
  2943. #define CmResourceTypeInterrupt 2 // ResType_IRQ (0x0004)
  2944. #define CmResourceTypeMemory 3 // ResType_Mem (0x0001)
  2945. #define CmResourceTypeDma 4 // ResType_DMA (0x0003)
  2946. #define CmResourceTypeDeviceSpecific 5 // ResType_ClassSpecific (0xFFFF)
  2947. #define CmResourceTypeBusNumber 6 // ResType_BusNumber (0x0006)
  2948. // end_wdm
  2949. #define CmResourceTypeMaximum 7
  2950. // begin_wdm
  2951. #define CmResourceTypeNonArbitrated 128 // Not arbitrated if 0x80 bit set
  2952. #define CmResourceTypeConfigData 128 // ResType_Reserved (0x8000)
  2953. #define CmResourceTypeDevicePrivate 129 // ResType_DevicePrivate (0x8001)
  2954. #define CmResourceTypePcCardConfig 130 // ResType_PcCardConfig (0x8002)
  2955. #define CmResourceTypeMfCardConfig 131 // ResType_MfCardConfig (0x8003)
  2956. //
  2957. // Defines the ShareDisposition in the RESOURCE_DESCRIPTOR
  2958. //
  2959. typedef enum _CM_SHARE_DISPOSITION {
  2960. CmResourceShareUndetermined = 0, // Reserved
  2961. CmResourceShareDeviceExclusive,
  2962. CmResourceShareDriverExclusive,
  2963. CmResourceShareShared
  2964. } CM_SHARE_DISPOSITION;
  2965. //
  2966. // Define the bit masks for Flags when type is CmResourceTypeInterrupt
  2967. //
  2968. #define CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE 0
  2969. #define CM_RESOURCE_INTERRUPT_LATCHED 1
  2970. //
  2971. // Define the bit masks for Flags when type is CmResourceTypeMemory
  2972. //
  2973. #define CM_RESOURCE_MEMORY_READ_WRITE 0x0000
  2974. #define CM_RESOURCE_MEMORY_READ_ONLY 0x0001
  2975. #define CM_RESOURCE_MEMORY_WRITE_ONLY 0x0002
  2976. #define CM_RESOURCE_MEMORY_PREFETCHABLE 0x0004
  2977. #define CM_RESOURCE_MEMORY_COMBINEDWRITE 0x0008
  2978. #define CM_RESOURCE_MEMORY_24 0x0010
  2979. #define CM_RESOURCE_MEMORY_CACHEABLE 0x0020
  2980. //
  2981. // Define the bit masks for Flags when type is CmResourceTypePort
  2982. //
  2983. #define CM_RESOURCE_PORT_MEMORY 0x0000
  2984. #define CM_RESOURCE_PORT_IO 0x0001
  2985. #define CM_RESOURCE_PORT_10_BIT_DECODE 0x0004
  2986. #define CM_RESOURCE_PORT_12_BIT_DECODE 0x0008
  2987. #define CM_RESOURCE_PORT_16_BIT_DECODE 0x0010
  2988. #define CM_RESOURCE_PORT_POSITIVE_DECODE 0x0020
  2989. #define CM_RESOURCE_PORT_PASSIVE_DECODE 0x0040
  2990. #define CM_RESOURCE_PORT_WINDOW_DECODE 0x0080
  2991. //
  2992. // Define the bit masks for Flags when type is CmResourceTypeDma
  2993. //
  2994. #define CM_RESOURCE_DMA_8 0x0000
  2995. #define CM_RESOURCE_DMA_16 0x0001
  2996. #define CM_RESOURCE_DMA_32 0x0002
  2997. #define CM_RESOURCE_DMA_8_AND_16 0x0004
  2998. #define CM_RESOURCE_DMA_BUS_MASTER 0x0008
  2999. #define CM_RESOURCE_DMA_TYPE_A 0x0010
  3000. #define CM_RESOURCE_DMA_TYPE_B 0x0020
  3001. #define CM_RESOURCE_DMA_TYPE_F 0x0040
  3002. #include "pshpack4.h"
  3003. typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR {
  3004. UCHAR Type;
  3005. UCHAR ShareDisposition;
  3006. USHORT Flags;
  3007. union {
  3008. //
  3009. // Range of resources, inclusive. These are physical, bus relative.
  3010. // It is known that Port and Memory below have the exact same layout
  3011. // as Generic.
  3012. //
  3013. struct {
  3014. PHYSICAL_ADDRESS Start;
  3015. ULONG Length;
  3016. } Generic;
  3017. //
  3018. // end_wdm
  3019. // Range of port numbers, inclusive. These are physical, bus
  3020. // relative. The value should be the same as the one passed to
  3021. // HalTranslateBusAddress().
  3022. // begin_wdm
  3023. //
  3024. struct {
  3025. PHYSICAL_ADDRESS Start;
  3026. ULONG Length;
  3027. } Port;
  3028. //
  3029. // end_wdm
  3030. // IRQL and vector. Should be same values as were passed to
  3031. // HalGetInterruptVector().
  3032. // begin_wdm
  3033. //
  3034. struct {
  3035. ULONG Level;
  3036. ULONG Vector;
  3037. KAFFINITY Affinity;
  3038. } Interrupt;
  3039. //
  3040. // Range of memory addresses, inclusive. These are physical, bus
  3041. // relative. The value should be the same as the one passed to
  3042. // HalTranslateBusAddress().
  3043. //
  3044. struct {
  3045. PHYSICAL_ADDRESS Start; // 64 bit physical addresses.
  3046. ULONG Length;
  3047. } Memory;
  3048. //
  3049. // Physical DMA channel.
  3050. //
  3051. struct {
  3052. ULONG Channel;
  3053. ULONG Port;
  3054. ULONG Reserved1;
  3055. } Dma;
  3056. //
  3057. // Device driver private data, usually used to help it figure
  3058. // what the resource assignments decisions that were made.
  3059. //
  3060. struct {
  3061. ULONG Data[3];
  3062. } DevicePrivate;
  3063. //
  3064. // Bus Number information.
  3065. //
  3066. struct {
  3067. ULONG Start;
  3068. ULONG Length;
  3069. ULONG Reserved;
  3070. } BusNumber;
  3071. //
  3072. // Device Specific information defined by the driver.
  3073. // The DataSize field indicates the size of the data in bytes. The
  3074. // data is located immediately after the DeviceSpecificData field in
  3075. // the structure.
  3076. //
  3077. struct {
  3078. ULONG DataSize;
  3079. ULONG Reserved1;
  3080. ULONG Reserved2;
  3081. } DeviceSpecificData;
  3082. } u;
  3083. } CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR;
  3084. #include "poppack.h"
  3085. //
  3086. // A Partial Resource List is what can be found in the ARC firmware
  3087. // or will be generated by ntdetect.com.
  3088. // The configuration manager will transform this structure into a Full
  3089. // resource descriptor when it is about to store it in the regsitry.
  3090. //
  3091. // Note: There must a be a convention to the order of fields of same type,
  3092. // (defined on a device by device basis) so that the fields can make sense
  3093. // to a driver (i.e. when multiple memory ranges are necessary).
  3094. //
  3095. typedef struct _CM_PARTIAL_RESOURCE_LIST {
  3096. USHORT Version;
  3097. USHORT Revision;
  3098. ULONG Count;
  3099. CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1];
  3100. } CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST;
  3101. //
  3102. // A Full Resource Descriptor is what can be found in the registry.
  3103. // This is what will be returned to a driver when it queries the registry
  3104. // to get device information; it will be stored under a key in the hardware
  3105. // description tree.
  3106. //
  3107. // end_wdm
  3108. // Note: The BusNumber and Type are redundant information, but we will keep
  3109. // it since it allows the driver _not_ to append it when it is creating
  3110. // a resource list which could possibly span multiple buses.
  3111. //
  3112. // begin_wdm
  3113. // Note: There must a be a convention to the order of fields of same type,
  3114. // (defined on a device by device basis) so that the fields can make sense
  3115. // to a driver (i.e. when multiple memory ranges are necessary).
  3116. //
  3117. typedef struct _CM_FULL_RESOURCE_DESCRIPTOR {
  3118. INTERFACE_TYPE InterfaceType; // unused for WDM
  3119. ULONG BusNumber; // unused for WDM
  3120. CM_PARTIAL_RESOURCE_LIST PartialResourceList;
  3121. } CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR;
  3122. //
  3123. // The Resource list is what will be stored by the drivers into the
  3124. // resource map via the IO API.
  3125. //
  3126. typedef struct _CM_RESOURCE_LIST {
  3127. ULONG Count;
  3128. CM_FULL_RESOURCE_DESCRIPTOR List[1];
  3129. } CM_RESOURCE_LIST, *PCM_RESOURCE_LIST;
  3130. #include "pshpack1.h"
  3131. //
  3132. // Define Mca POS data block for slot
  3133. //
  3134. typedef struct _CM_MCA_POS_DATA {
  3135. USHORT AdapterId;
  3136. UCHAR PosData1;
  3137. UCHAR PosData2;
  3138. UCHAR PosData3;
  3139. UCHAR PosData4;
  3140. } CM_MCA_POS_DATA, *PCM_MCA_POS_DATA;
  3141. //
  3142. // Memory configuration of eisa data block structure
  3143. //
  3144. typedef struct _EISA_MEMORY_TYPE {
  3145. UCHAR ReadWrite: 1;
  3146. UCHAR Cached : 1;
  3147. UCHAR Reserved0 :1;
  3148. UCHAR Type:2;
  3149. UCHAR Shared:1;
  3150. UCHAR Reserved1 :1;
  3151. UCHAR MoreEntries : 1;
  3152. } EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE;
  3153. typedef struct _EISA_MEMORY_CONFIGURATION {
  3154. EISA_MEMORY_TYPE ConfigurationByte;
  3155. UCHAR DataSize;
  3156. USHORT AddressLowWord;
  3157. UCHAR AddressHighByte;
  3158. USHORT MemorySize;
  3159. } EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION;
  3160. //
  3161. // Interrupt configurationn of eisa data block structure
  3162. //
  3163. typedef struct _EISA_IRQ_DESCRIPTOR {
  3164. UCHAR Interrupt : 4;
  3165. UCHAR Reserved :1;
  3166. UCHAR LevelTriggered :1;
  3167. UCHAR Shared : 1;
  3168. UCHAR MoreEntries : 1;
  3169. } EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR;
  3170. typedef struct _EISA_IRQ_CONFIGURATION {
  3171. EISA_IRQ_DESCRIPTOR ConfigurationByte;
  3172. UCHAR Reserved;
  3173. } EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION;
  3174. //
  3175. // DMA description of eisa data block structure
  3176. //
  3177. typedef struct _DMA_CONFIGURATION_BYTE0 {
  3178. UCHAR Channel : 3;
  3179. UCHAR Reserved : 3;
  3180. UCHAR Shared :1;
  3181. UCHAR MoreEntries :1;
  3182. } DMA_CONFIGURATION_BYTE0;
  3183. typedef struct _DMA_CONFIGURATION_BYTE1 {
  3184. UCHAR Reserved0 : 2;
  3185. UCHAR TransferSize : 2;
  3186. UCHAR Timing : 2;
  3187. UCHAR Reserved1 : 2;
  3188. } DMA_CONFIGURATION_BYTE1;
  3189. typedef struct _EISA_DMA_CONFIGURATION {
  3190. DMA_CONFIGURATION_BYTE0 ConfigurationByte0;
  3191. DMA_CONFIGURATION_BYTE1 ConfigurationByte1;
  3192. } EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION;
  3193. //
  3194. // Port description of eisa data block structure
  3195. //
  3196. typedef struct _EISA_PORT_DESCRIPTOR {
  3197. UCHAR NumberPorts : 5;
  3198. UCHAR Reserved :1;
  3199. UCHAR Shared :1;
  3200. UCHAR MoreEntries : 1;
  3201. } EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR;
  3202. typedef struct _EISA_PORT_CONFIGURATION {
  3203. EISA_PORT_DESCRIPTOR Configuration;
  3204. USHORT PortAddress;
  3205. } EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION;
  3206. //
  3207. // Eisa slot information definition
  3208. // N.B. This structure is different from the one defined
  3209. // in ARC eisa addendum.
  3210. //
  3211. typedef struct _CM_EISA_SLOT_INFORMATION {
  3212. UCHAR ReturnCode;
  3213. UCHAR ReturnFlags;
  3214. UCHAR MajorRevision;
  3215. UCHAR MinorRevision;
  3216. USHORT Checksum;
  3217. UCHAR NumberFunctions;
  3218. UCHAR FunctionInformation;
  3219. ULONG CompressedId;
  3220. } CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION;
  3221. //
  3222. // Eisa function information definition
  3223. //
  3224. typedef struct _CM_EISA_FUNCTION_INFORMATION {
  3225. ULONG CompressedId;
  3226. UCHAR IdSlotFlags1;
  3227. UCHAR IdSlotFlags2;
  3228. UCHAR MinorRevision;
  3229. UCHAR MajorRevision;
  3230. UCHAR Selections[26];
  3231. UCHAR FunctionFlags;
  3232. UCHAR TypeString[80];
  3233. EISA_MEMORY_CONFIGURATION EisaMemory[9];
  3234. EISA_IRQ_CONFIGURATION EisaIrq[7];
  3235. EISA_DMA_CONFIGURATION EisaDma[4];
  3236. EISA_PORT_CONFIGURATION EisaPort[20];
  3237. UCHAR InitializationData[60];
  3238. } CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION;
  3239. //
  3240. // The following defines the way pnp bios information is stored in
  3241. // the registry \\HKEY_LOCAL_MACHINE\HARDWARE\Description\System\MultifunctionAdapter\x
  3242. // key, where x is an integer number indicating adapter instance. The
  3243. // "Identifier" of the key must equal to "PNP BIOS" and the
  3244. // "ConfigurationData" is organized as follow:
  3245. //
  3246. // CM_PNP_BIOS_INSTALLATION_CHECK +
  3247. // CM_PNP_BIOS_DEVICE_NODE for device 1 +
  3248. // CM_PNP_BIOS_DEVICE_NODE for device 2 +
  3249. // ...
  3250. // CM_PNP_BIOS_DEVICE_NODE for device n
  3251. //
  3252. //
  3253. // Pnp BIOS device node structure
  3254. //
  3255. typedef struct _CM_PNP_BIOS_DEVICE_NODE {
  3256. USHORT Size;
  3257. UCHAR Node;
  3258. ULONG ProductId;
  3259. UCHAR DeviceType[3];
  3260. USHORT DeviceAttributes;
  3261. // followed by AllocatedResourceBlock, PossibleResourceBlock
  3262. // and CompatibleDeviceId
  3263. } CM_PNP_BIOS_DEVICE_NODE,*PCM_PNP_BIOS_DEVICE_NODE;
  3264. //
  3265. // Pnp BIOS Installation check
  3266. //
  3267. typedef struct _CM_PNP_BIOS_INSTALLATION_CHECK {
  3268. UCHAR Signature[4]; // $PnP (ascii)
  3269. UCHAR Revision;
  3270. UCHAR Length;
  3271. USHORT ControlField;
  3272. UCHAR Checksum;
  3273. ULONG EventFlagAddress; // Physical address
  3274. USHORT RealModeEntryOffset;
  3275. USHORT RealModeEntrySegment;
  3276. USHORT ProtectedModeEntryOffset;
  3277. ULONG ProtectedModeCodeBaseAddress;
  3278. ULONG OemDeviceId;
  3279. USHORT RealModeDataBaseAddress;
  3280. ULONG ProtectedModeDataBaseAddress;
  3281. } CM_PNP_BIOS_INSTALLATION_CHECK, *PCM_PNP_BIOS_INSTALLATION_CHECK;
  3282. #include "poppack.h"
  3283. //
  3284. // Masks for EISA function information
  3285. //
  3286. #define EISA_FUNCTION_ENABLED 0x80
  3287. #define EISA_FREE_FORM_DATA 0x40
  3288. #define EISA_HAS_PORT_INIT_ENTRY 0x20
  3289. #define EISA_HAS_PORT_RANGE 0x10
  3290. #define EISA_HAS_DMA_ENTRY 0x08
  3291. #define EISA_HAS_IRQ_ENTRY 0x04
  3292. #define EISA_HAS_MEMORY_ENTRY 0x02
  3293. #define EISA_HAS_TYPE_ENTRY 0x01
  3294. #define EISA_HAS_INFORMATION EISA_HAS_PORT_RANGE + \
  3295. EISA_HAS_DMA_ENTRY + \
  3296. EISA_HAS_IRQ_ENTRY + \
  3297. EISA_HAS_MEMORY_ENTRY + \
  3298. EISA_HAS_TYPE_ENTRY
  3299. //
  3300. // Masks for EISA memory configuration
  3301. //
  3302. #define EISA_MORE_ENTRIES 0x80
  3303. #define EISA_SYSTEM_MEMORY 0x00
  3304. #define EISA_MEMORY_TYPE_RAM 0x01
  3305. //
  3306. // Returned error code for EISA bios call
  3307. //
  3308. #define EISA_INVALID_SLOT 0x80
  3309. #define EISA_INVALID_FUNCTION 0x81
  3310. #define EISA_INVALID_CONFIGURATION 0x82
  3311. #define EISA_EMPTY_SLOT 0x83
  3312. #define EISA_INVALID_BIOS_CALL 0x86
  3313. //
  3314. // Interrupt modes.
  3315. //
  3316. typedef enum _KINTERRUPT_MODE {
  3317. LevelSensitive,
  3318. Latched
  3319. } KINTERRUPT_MODE;
  3320. typedef struct _KINTERRUPT *PKINTERRUPT, *RESTRICTED_POINTER PRKINTERRUPT;
  3321. //
  3322. // On X86 the following routines are defined in the HAL and imported by
  3323. // all other modules.
  3324. //
  3325. #if defined(_X86_) && !defined(_NTHAL_)
  3326. #define _DECL_HAL_KE_IMPORT __declspec(dllimport)
  3327. #else
  3328. #define _DECL_HAL_KE_IMPORT
  3329. #endif
  3330. //
  3331. // spin lock functions
  3332. //
  3333. #if defined(_X86_) && (defined(_WDMDDK_) || defined(WIN9X_COMPAT_SPINLOCK))
  3334. NTKERNELAPI
  3335. VOID
  3336. NTAPI
  3337. KeInitializeSpinLock (
  3338. IN PKSPIN_LOCK SpinLock
  3339. );
  3340. #else
  3341. __inline
  3342. VOID
  3343. NTAPI
  3344. KeInitializeSpinLock (
  3345. IN PKSPIN_LOCK SpinLock
  3346. )
  3347. {
  3348. *SpinLock = 0;
  3349. }
  3350. #endif
  3351. #if defined(_X86_)
  3352. NTKERNELAPI
  3353. VOID
  3354. FASTCALL
  3355. KefAcquireSpinLockAtDpcLevel (
  3356. IN PKSPIN_LOCK SpinLock
  3357. );
  3358. NTKERNELAPI
  3359. VOID
  3360. FASTCALL
  3361. KefReleaseSpinLockFromDpcLevel (
  3362. IN PKSPIN_LOCK SpinLock
  3363. );
  3364. #define KeAcquireSpinLockAtDpcLevel(a) KefAcquireSpinLockAtDpcLevel(a)
  3365. #define KeReleaseSpinLockFromDpcLevel(a) KefReleaseSpinLockFromDpcLevel(a)
  3366. _DECL_HAL_KE_IMPORT
  3367. KIRQL
  3368. FASTCALL
  3369. KfAcquireSpinLock (
  3370. IN PKSPIN_LOCK SpinLock
  3371. );
  3372. _DECL_HAL_KE_IMPORT
  3373. VOID
  3374. FASTCALL
  3375. KfReleaseSpinLock (
  3376. IN PKSPIN_LOCK SpinLock,
  3377. IN KIRQL NewIrql
  3378. );
  3379. // end_wdm end_ntddk
  3380. _DECL_HAL_KE_IMPORT
  3381. KIRQL
  3382. FASTCALL
  3383. KeAcquireSpinLockRaiseToSynch (
  3384. IN PKSPIN_LOCK SpinLock
  3385. );
  3386. // begin_wdm begin_ntddk
  3387. #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
  3388. #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
  3389. NTKERNELAPI
  3390. BOOLEAN
  3391. FASTCALL
  3392. KeTestSpinLock (
  3393. IN PKSPIN_LOCK SpinLock
  3394. );
  3395. NTKERNELAPI
  3396. BOOLEAN
  3397. FASTCALL
  3398. KeTryToAcquireSpinLockAtDpcLevel (
  3399. IN PKSPIN_LOCK SpinLock
  3400. );
  3401. #else
  3402. //
  3403. // These functions are imported for IA64, ntddk, ntifs, nthal, ntosp, and wdm.
  3404. // They can be inlined for the system on AMD64.
  3405. //
  3406. #define KeAcquireSpinLock(SpinLock, OldIrql) \
  3407. *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock)
  3408. #if defined(_IA64_) || defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_) || defined(_WDMDDK_)
  3409. // end_wdm end_ntddk
  3410. NTKERNELAPI
  3411. KIRQL
  3412. FASTCALL
  3413. KeAcquireSpinLockRaiseToSynch (
  3414. IN PKSPIN_LOCK SpinLock
  3415. );
  3416. // begin_wdm begin_ntddk
  3417. NTKERNELAPI
  3418. VOID
  3419. KeAcquireSpinLockAtDpcLevel (
  3420. IN PKSPIN_LOCK SpinLock
  3421. );
  3422. NTKERNELAPI
  3423. KIRQL
  3424. KeAcquireSpinLockRaiseToDpc (
  3425. IN PKSPIN_LOCK SpinLock
  3426. );
  3427. NTKERNELAPI
  3428. VOID
  3429. KeReleaseSpinLock (
  3430. IN PKSPIN_LOCK SpinLock,
  3431. IN KIRQL NewIrql
  3432. );
  3433. NTKERNELAPI
  3434. VOID
  3435. KeReleaseSpinLockFromDpcLevel (
  3436. IN PKSPIN_LOCK SpinLock
  3437. );
  3438. NTKERNELAPI
  3439. BOOLEAN
  3440. FASTCALL
  3441. KeTestSpinLock (
  3442. IN PKSPIN_LOCK SpinLock
  3443. );
  3444. NTKERNELAPI
  3445. BOOLEAN
  3446. FASTCALL
  3447. KeTryToAcquireSpinLockAtDpcLevel (
  3448. IN PKSPIN_LOCK SpinLock
  3449. );
  3450. #else
  3451. #if defined(_AMD64_)
  3452. //
  3453. // The system version of these functions are defined in amd64.h for AMD64.
  3454. //
  3455. #endif
  3456. #endif
  3457. #endif
  3458. // end_wdm end_ntddk end_nthal end_ntifs
  3459. NTKERNELAPI
  3460. KIRQL
  3461. FASTCALL
  3462. KeAcquireSpinLockForDpc (
  3463. IN PKSPIN_LOCK SpinLock
  3464. );
  3465. NTKERNELAPI
  3466. VOID
  3467. FASTCALL
  3468. KeReleaseSpinLockForDpc (
  3469. IN PKSPIN_LOCK SpinLock,
  3470. IN KIRQL OldIrql
  3471. );
  3472. //
  3473. // Define I/O system data structure type codes. Each major data structure in
  3474. // the I/O system has a type code The type field in each structure is at the
  3475. // same offset. The following values can be used to determine which type of
  3476. // data structure a pointer refers to.
  3477. //
  3478. #define IO_TYPE_ADAPTER 0x00000001
  3479. #define IO_TYPE_CONTROLLER 0x00000002
  3480. #define IO_TYPE_DEVICE 0x00000003
  3481. #define IO_TYPE_DRIVER 0x00000004
  3482. #define IO_TYPE_FILE 0x00000005
  3483. #define IO_TYPE_IRP 0x00000006
  3484. #define IO_TYPE_MASTER_ADAPTER 0x00000007
  3485. #define IO_TYPE_OPEN_PACKET 0x00000008
  3486. #define IO_TYPE_TIMER 0x00000009
  3487. #define IO_TYPE_VPB 0x0000000a
  3488. #define IO_TYPE_ERROR_LOG 0x0000000b
  3489. #define IO_TYPE_ERROR_MESSAGE 0x0000000c
  3490. #define IO_TYPE_DEVICE_OBJECT_EXTENSION 0x0000000d
  3491. //
  3492. // Define the major function codes for IRPs.
  3493. //
  3494. #define IRP_MJ_CREATE 0x00
  3495. #define IRP_MJ_CREATE_NAMED_PIPE 0x01
  3496. #define IRP_MJ_CLOSE 0x02
  3497. #define IRP_MJ_READ 0x03
  3498. #define IRP_MJ_WRITE 0x04
  3499. #define IRP_MJ_QUERY_INFORMATION 0x05
  3500. #define IRP_MJ_SET_INFORMATION 0x06
  3501. #define IRP_MJ_QUERY_EA 0x07
  3502. #define IRP_MJ_SET_EA 0x08
  3503. #define IRP_MJ_FLUSH_BUFFERS 0x09
  3504. #define IRP_MJ_QUERY_VOLUME_INFORMATION 0x0a
  3505. #define IRP_MJ_SET_VOLUME_INFORMATION 0x0b
  3506. #define IRP_MJ_DIRECTORY_CONTROL 0x0c
  3507. #define IRP_MJ_FILE_SYSTEM_CONTROL 0x0d
  3508. #define IRP_MJ_DEVICE_CONTROL 0x0e
  3509. #define IRP_MJ_INTERNAL_DEVICE_CONTROL 0x0f
  3510. #define IRP_MJ_SHUTDOWN 0x10
  3511. #define IRP_MJ_LOCK_CONTROL 0x11
  3512. #define IRP_MJ_CLEANUP 0x12
  3513. #define IRP_MJ_CREATE_MAILSLOT 0x13
  3514. #define IRP_MJ_QUERY_SECURITY 0x14
  3515. #define IRP_MJ_SET_SECURITY 0x15
  3516. #define IRP_MJ_POWER 0x16
  3517. #define IRP_MJ_SYSTEM_CONTROL 0x17
  3518. #define IRP_MJ_DEVICE_CHANGE 0x18
  3519. #define IRP_MJ_QUERY_QUOTA 0x19
  3520. #define IRP_MJ_SET_QUOTA 0x1a
  3521. #define IRP_MJ_PNP 0x1b
  3522. #define IRP_MJ_PNP_POWER IRP_MJ_PNP // Obsolete....
  3523. #define IRP_MJ_MAXIMUM_FUNCTION 0x1b
  3524. //
  3525. // Make the Scsi major code the same as internal device control.
  3526. //
  3527. #define IRP_MJ_SCSI IRP_MJ_INTERNAL_DEVICE_CONTROL
  3528. //
  3529. // Define the minor function codes for IRPs. The lower 128 codes, from 0x00 to
  3530. // 0x7f are reserved to Microsoft. The upper 128 codes, from 0x80 to 0xff, are
  3531. // reserved to customers of Microsoft.
  3532. //
  3533. //
  3534. // Define driver cancel routine type.
  3535. //
  3536. typedef
  3537. VOID
  3538. (*PDRIVER_CANCEL) (
  3539. IN struct _DEVICE_OBJECT *DeviceObject,
  3540. IN struct _IRP *Irp
  3541. );
  3542. //
  3543. // Define driver dispatch routine type.
  3544. //
  3545. typedef
  3546. NTSTATUS
  3547. (*PDRIVER_DISPATCH) (
  3548. IN struct _DEVICE_OBJECT *DeviceObject,
  3549. IN struct _IRP *Irp
  3550. );
  3551. //
  3552. // Define driver start I/O routine type.
  3553. //
  3554. typedef
  3555. VOID
  3556. (*PDRIVER_STARTIO) (
  3557. IN struct _DEVICE_OBJECT *DeviceObject,
  3558. IN struct _IRP *Irp
  3559. );
  3560. //
  3561. // Define driver unload routine type.
  3562. //
  3563. typedef
  3564. VOID
  3565. (*PDRIVER_UNLOAD) (
  3566. IN struct _DRIVER_OBJECT *DriverObject
  3567. );
  3568. //
  3569. // Define driver AddDevice routine type.
  3570. //
  3571. typedef
  3572. NTSTATUS
  3573. (*PDRIVER_ADD_DEVICE) (
  3574. IN struct _DRIVER_OBJECT *DriverObject,
  3575. IN struct _DEVICE_OBJECT *PhysicalDeviceObject
  3576. );
  3577. typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT;
  3578. typedef struct _DEVICE_OBJECT *PDEVICE_OBJECT;
  3579. typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT;
  3580. typedef struct _FILE_OBJECT *PFILE_OBJECT;
  3581. #if defined(_WIN64)
  3582. #define POINTER_ALIGNMENT DECLSPEC_ALIGN(8)
  3583. #else
  3584. #define POINTER_ALIGNMENT
  3585. #endif
  3586. #if defined(_IA64_)
  3587. DECLSPEC_DEPRECATED_DDK // Use GetDmaRequirement
  3588. NTHALAPI
  3589. ULONG
  3590. HalGetDmaAlignmentRequirement (
  3591. VOID
  3592. );
  3593. #endif
  3594. #if defined(_M_IX86) || defined(_M_AMD64)
  3595. #define HalGetDmaAlignmentRequirement() 1L
  3596. #endif
  3597. NTHALAPI
  3598. VOID
  3599. KeFlushWriteBuffer (
  3600. VOID
  3601. );
  3602. //
  3603. // Stall processor execution function.
  3604. //
  3605. NTHALAPI
  3606. VOID
  3607. KeStallExecutionProcessor (
  3608. IN ULONG MicroSeconds
  3609. );
  3610. typedef struct _MAP_REGISTER_ENTRY {
  3611. PVOID MapRegister;
  3612. BOOLEAN WriteToDevice;
  3613. } MAP_REGISTER_ENTRY, *PMAP_REGISTER_ENTRY;
  3614. typedef struct _SCATTER_GATHER_ELEMENT {
  3615. PHYSICAL_ADDRESS Address;
  3616. ULONG Length;
  3617. ULONG_PTR Reserved;
  3618. } SCATTER_GATHER_ELEMENT, *PSCATTER_GATHER_ELEMENT;
  3619. #if _MSC_VER >= 1200
  3620. #pragma warning(push)
  3621. #endif
  3622. #pragma warning(disable:4200)
  3623. typedef struct _SCATTER_GATHER_LIST {
  3624. ULONG NumberOfElements;
  3625. ULONG_PTR Reserved;
  3626. SCATTER_GATHER_ELEMENT Elements[];
  3627. } SCATTER_GATHER_LIST, *PSCATTER_GATHER_LIST;
  3628. #if _MSC_VER >= 1200
  3629. #pragma warning(pop)
  3630. #else
  3631. #pragma warning(default:4200)
  3632. #endif
  3633. //
  3634. // Pool Allocation routines (in pool.c)
  3635. //
  3636. typedef enum _POOL_TYPE {
  3637. NonPagedPool,
  3638. PagedPool,
  3639. NonPagedPoolMustSucceed,
  3640. DontUseThisType,
  3641. NonPagedPoolCacheAligned,
  3642. PagedPoolCacheAligned,
  3643. NonPagedPoolCacheAlignedMustS,
  3644. MaxPoolType
  3645. // end_wdm
  3646. ,
  3647. //
  3648. // Note these per session types are carefully chosen so that the appropriate
  3649. // masking still applies as well as MaxPoolType above.
  3650. //
  3651. NonPagedPoolSession = 32,
  3652. PagedPoolSession = NonPagedPoolSession + 1,
  3653. NonPagedPoolMustSucceedSession = PagedPoolSession + 1,
  3654. DontUseThisTypeSession = NonPagedPoolMustSucceedSession + 1,
  3655. NonPagedPoolCacheAlignedSession = DontUseThisTypeSession + 1,
  3656. PagedPoolCacheAlignedSession = NonPagedPoolCacheAlignedSession + 1,
  3657. NonPagedPoolCacheAlignedMustSSession = PagedPoolCacheAlignedSession + 1,
  3658. // begin_wdm
  3659. } POOL_TYPE;
  3660. #define POOL_COLD_ALLOCATION 256 // Note this cannot encode into the header.
  3661. //
  3662. #if defined(_WIN64)
  3663. #define ExInterlockedAddLargeStatistic(Addend, Increment) \
  3664. (VOID) InterlockedAdd64(&(Addend)->QuadPart, Increment)
  3665. #else
  3666. #ifdef __cplusplus
  3667. extern "C" {
  3668. #endif
  3669. LONG
  3670. _InterlockedAddLargeStatistic (
  3671. IN PLONGLONG Addend,
  3672. IN ULONG Increment
  3673. );
  3674. #ifdef __cplusplus
  3675. }
  3676. #endif
  3677. #pragma intrinsic (_InterlockedAddLargeStatistic)
  3678. #define ExInterlockedAddLargeStatistic(Addend,Increment) \
  3679. (VOID) _InterlockedAddLargeStatistic ((PLONGLONG)&(Addend)->QuadPart, Increment)
  3680. #endif
  3681. //
  3682. // Define interlocked sequenced listhead functions.
  3683. //
  3684. // A sequenced interlocked list is a singly linked list with a header that
  3685. // contains the current depth and a sequence number. Each time an entry is
  3686. // inserted or removed from the list the depth is updated and the sequence
  3687. // number is incremented. This enables AMD64, IA64, and Pentium and later
  3688. // machines to insert and remove from the list without the use of spinlocks.
  3689. //
  3690. #if !defined(_WINBASE_)
  3691. /*++
  3692. Routine Description:
  3693. This function initializes a sequenced singly linked listhead.
  3694. Arguments:
  3695. SListHead - Supplies a pointer to a sequenced singly linked listhead.
  3696. Return Value:
  3697. None.
  3698. --*/
  3699. #if defined(_WIN64) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_))
  3700. NTKERNELAPI
  3701. VOID
  3702. InitializeSListHead (
  3703. IN PSLIST_HEADER SListHead
  3704. );
  3705. #else
  3706. __inline
  3707. VOID
  3708. InitializeSListHead (
  3709. IN PSLIST_HEADER SListHead
  3710. )
  3711. {
  3712. #ifdef _WIN64
  3713. //
  3714. // Slist headers must be 16 byte aligned.
  3715. //
  3716. if ((ULONG_PTR) SListHead & 0x0f) {
  3717. DbgPrint( "InitializeSListHead unaligned Slist header. Address = %p, Caller = %p\n", SListHead, _ReturnAddress());
  3718. RtlRaiseStatus(STATUS_DATATYPE_MISALIGNMENT);
  3719. }
  3720. #endif
  3721. SListHead->Alignment = 0;
  3722. //
  3723. // For IA-64 we save the region number of the elements of the list in a
  3724. // separate field. This imposes the requirement that all elements stored
  3725. // in the list are from the same region.
  3726. #if defined(_IA64_)
  3727. SListHead->Region = (ULONG_PTR)SListHead & VRN_MASK;
  3728. #elif defined(_AMD64_)
  3729. SListHead->Region = 0;
  3730. #endif
  3731. return;
  3732. }
  3733. #endif
  3734. #endif // !defined(_WINBASE_)
  3735. #define ExInitializeSListHead InitializeSListHead
  3736. PSLIST_ENTRY
  3737. FirstEntrySList (
  3738. IN const SLIST_HEADER *SListHead
  3739. );
  3740. /*++
  3741. Routine Description:
  3742. This function queries the current number of entries contained in a
  3743. sequenced single linked list.
  3744. Arguments:
  3745. SListHead - Supplies a pointer to the sequenced listhead which is
  3746. be queried.
  3747. Return Value:
  3748. The current number of entries in the sequenced singly linked list is
  3749. returned as the function value.
  3750. --*/
  3751. #if defined(_WIN64)
  3752. #if (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_) || defined(_NTOSP_))
  3753. NTKERNELAPI
  3754. USHORT
  3755. ExQueryDepthSList (
  3756. IN PSLIST_HEADER SListHead
  3757. );
  3758. #else
  3759. __inline
  3760. USHORT
  3761. ExQueryDepthSList (
  3762. IN PSLIST_HEADER SListHead
  3763. )
  3764. {
  3765. return (USHORT)(SListHead->Alignment & 0xffff);
  3766. }
  3767. #endif
  3768. #else
  3769. #define ExQueryDepthSList(_listhead_) (_listhead_)->Depth
  3770. #endif
  3771. #if defined(_WIN64)
  3772. #define ExInterlockedPopEntrySList(Head, Lock) \
  3773. ExpInterlockedPopEntrySList(Head)
  3774. #define ExInterlockedPushEntrySList(Head, Entry, Lock) \
  3775. ExpInterlockedPushEntrySList(Head, Entry)
  3776. #define ExInterlockedFlushSList(Head) \
  3777. ExpInterlockedFlushSList(Head)
  3778. #if !defined(_WINBASE_)
  3779. #define InterlockedPopEntrySList(Head) \
  3780. ExpInterlockedPopEntrySList(Head)
  3781. #define InterlockedPushEntrySList(Head, Entry) \
  3782. ExpInterlockedPushEntrySList(Head, Entry)
  3783. #define InterlockedFlushSList(Head) \
  3784. ExpInterlockedFlushSList(Head)
  3785. #define QueryDepthSList(Head) \
  3786. ExQueryDepthSList(Head)
  3787. #endif // !defined(_WINBASE_)
  3788. NTKERNELAPI
  3789. PSLIST_ENTRY
  3790. ExpInterlockedPopEntrySList (
  3791. IN PSLIST_HEADER ListHead
  3792. );
  3793. NTKERNELAPI
  3794. PSLIST_ENTRY
  3795. ExpInterlockedPushEntrySList (
  3796. IN PSLIST_HEADER ListHead,
  3797. IN PSLIST_ENTRY ListEntry
  3798. );
  3799. NTKERNELAPI
  3800. PSLIST_ENTRY
  3801. ExpInterlockedFlushSList (
  3802. IN PSLIST_HEADER ListHead
  3803. );
  3804. #else
  3805. #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
  3806. NTKERNELAPI
  3807. PSLIST_ENTRY
  3808. FASTCALL
  3809. ExInterlockedPopEntrySList (
  3810. IN PSLIST_HEADER ListHead,
  3811. IN PKSPIN_LOCK Lock
  3812. );
  3813. NTKERNELAPI
  3814. PSLIST_ENTRY
  3815. FASTCALL
  3816. ExInterlockedPushEntrySList (
  3817. IN PSLIST_HEADER ListHead,
  3818. IN PSLIST_ENTRY ListEntry,
  3819. IN PKSPIN_LOCK Lock
  3820. );
  3821. #else
  3822. #define ExInterlockedPopEntrySList(ListHead, Lock) \
  3823. InterlockedPopEntrySList(ListHead)
  3824. #define ExInterlockedPushEntrySList(ListHead, ListEntry, Lock) \
  3825. InterlockedPushEntrySList(ListHead, ListEntry)
  3826. #endif
  3827. NTKERNELAPI
  3828. PSLIST_ENTRY
  3829. FASTCALL
  3830. ExInterlockedFlushSList (
  3831. IN PSLIST_HEADER ListHead
  3832. );
  3833. #if !defined(_WINBASE_)
  3834. NTKERNELAPI
  3835. PSLIST_ENTRY
  3836. FASTCALL
  3837. InterlockedPopEntrySList (
  3838. IN PSLIST_HEADER ListHead
  3839. );
  3840. NTKERNELAPI
  3841. PSLIST_ENTRY
  3842. FASTCALL
  3843. InterlockedPushEntrySList (
  3844. IN PSLIST_HEADER ListHead,
  3845. IN PSLIST_ENTRY ListEntry
  3846. );
  3847. #define InterlockedFlushSList(Head) \
  3848. ExInterlockedFlushSList(Head)
  3849. #define QueryDepthSList(Head) \
  3850. ExQueryDepthSList(Head)
  3851. #endif // !defined(_WINBASE_)
  3852. #endif // defined(_WIN64)
  3853. // end_ntddk end_wdm end_ntosp
  3854. PSLIST_ENTRY
  3855. FASTCALL
  3856. InterlockedPushListSList (
  3857. IN PSLIST_HEADER ListHead,
  3858. IN PSLIST_ENTRY List,
  3859. IN PSLIST_ENTRY ListEnd,
  3860. IN ULONG Count
  3861. );
  3862. //
  3863. // Define interlocked lookaside list structure and allocation functions.
  3864. //
  3865. VOID
  3866. ExAdjustLookasideDepth (
  3867. VOID
  3868. );
  3869. // begin_ntddk begin_wdm begin_ntosp
  3870. typedef
  3871. PVOID
  3872. (*PALLOCATE_FUNCTION) (
  3873. IN POOL_TYPE PoolType,
  3874. IN SIZE_T NumberOfBytes,
  3875. IN ULONG Tag
  3876. );
  3877. typedef
  3878. VOID
  3879. (*PFREE_FUNCTION) (
  3880. IN PVOID Buffer
  3881. );
  3882. #if !defined(_WIN64) && (defined(_NTDDK_) || defined(_NTIFS_) || defined(_NDIS_))
  3883. typedef struct _GENERAL_LOOKASIDE {
  3884. #else
  3885. typedef struct DECLSPEC_CACHEALIGN _GENERAL_LOOKASIDE {
  3886. #endif
  3887. SLIST_HEADER ListHead;
  3888. USHORT Depth;
  3889. USHORT MaximumDepth;
  3890. ULONG TotalAllocates;
  3891. union {
  3892. ULONG AllocateMisses;
  3893. ULONG AllocateHits;
  3894. };
  3895. ULONG TotalFrees;
  3896. union {
  3897. ULONG FreeMisses;
  3898. ULONG FreeHits;
  3899. };
  3900. POOL_TYPE Type;
  3901. ULONG Tag;
  3902. ULONG Size;
  3903. PALLOCATE_FUNCTION Allocate;
  3904. PFREE_FUNCTION Free;
  3905. LIST_ENTRY ListEntry;
  3906. ULONG LastTotalAllocates;
  3907. union {
  3908. ULONG LastAllocateMisses;
  3909. ULONG LastAllocateHits;
  3910. };
  3911. ULONG Future[2];
  3912. } GENERAL_LOOKASIDE, *PGENERAL_LOOKASIDE;
  3913. #if !defined(_WIN64) && (defined(_NTDDK_) || defined(_NTIFS_) || defined(_NDIS_))
  3914. typedef struct _NPAGED_LOOKASIDE_LIST {
  3915. #else
  3916. typedef struct DECLSPEC_CACHEALIGN _NPAGED_LOOKASIDE_LIST {
  3917. #endif
  3918. GENERAL_LOOKASIDE L;
  3919. #if !defined(_AMD64_) && !defined(_IA64_)
  3920. KSPIN_LOCK Lock__ObsoleteButDoNotDelete;
  3921. #endif
  3922. } NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST;
  3923. NTKERNELAPI
  3924. VOID
  3925. ExInitializeNPagedLookasideList (
  3926. IN PNPAGED_LOOKASIDE_LIST Lookaside,
  3927. IN PALLOCATE_FUNCTION Allocate,
  3928. IN PFREE_FUNCTION Free,
  3929. IN ULONG Flags,
  3930. IN SIZE_T Size,
  3931. IN ULONG Tag,
  3932. IN USHORT Depth
  3933. );
  3934. NTKERNELAPI
  3935. VOID
  3936. ExDeleteNPagedLookasideList (
  3937. IN PNPAGED_LOOKASIDE_LIST Lookaside
  3938. );
  3939. __inline
  3940. PVOID
  3941. ExAllocateFromNPagedLookasideList(
  3942. IN PNPAGED_LOOKASIDE_LIST Lookaside
  3943. )
  3944. /*++
  3945. Routine Description:
  3946. This function removes (pops) the first entry from the specified
  3947. nonpaged lookaside list.
  3948. Arguments:
  3949. Lookaside - Supplies a pointer to a nonpaged lookaside list structure.
  3950. Return Value:
  3951. If an entry is removed from the specified lookaside list, then the
  3952. address of the entry is returned as the function value. Otherwise,
  3953. NULL is returned.
  3954. --*/
  3955. {
  3956. PVOID Entry;
  3957. Lookaside->L.TotalAllocates += 1;
  3958. #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
  3959. Entry = ExInterlockedPopEntrySList(&Lookaside->L.ListHead,
  3960. &Lookaside->Lock__ObsoleteButDoNotDelete);
  3961. #else
  3962. Entry = InterlockedPopEntrySList(&Lookaside->L.ListHead);
  3963. #endif
  3964. if (Entry == NULL) {
  3965. Lookaside->L.AllocateMisses += 1;
  3966. Entry = (Lookaside->L.Allocate)(Lookaside->L.Type,
  3967. Lookaside->L.Size,
  3968. Lookaside->L.Tag);
  3969. }
  3970. return Entry;
  3971. }
  3972. __inline
  3973. VOID
  3974. ExFreeToNPagedLookasideList(
  3975. IN PNPAGED_LOOKASIDE_LIST Lookaside,
  3976. IN PVOID Entry
  3977. )
  3978. /*++
  3979. Routine Description:
  3980. This function inserts (pushes) the specified entry into the specified
  3981. nonpaged lookaside list.
  3982. Arguments:
  3983. Lookaside - Supplies a pointer to a nonpaged lookaside list structure.
  3984. Entry - Supples a pointer to the entry that is inserted in the
  3985. lookaside list.
  3986. Return Value:
  3987. None.
  3988. --*/
  3989. {
  3990. Lookaside->L.TotalFrees += 1;
  3991. if (ExQueryDepthSList(&Lookaside->L.ListHead) >= Lookaside->L.Depth) {
  3992. Lookaside->L.FreeMisses += 1;
  3993. (Lookaside->L.Free)(Entry);
  3994. } else {
  3995. #if defined(_WIN2K_COMPAT_SLIST_USAGE) && defined(_X86_)
  3996. ExInterlockedPushEntrySList(&Lookaside->L.ListHead,
  3997. (PSLIST_ENTRY)Entry,
  3998. &Lookaside->Lock__ObsoleteButDoNotDelete);
  3999. #else
  4000. InterlockedPushEntrySList(&Lookaside->L.ListHead,
  4001. (PSLIST_ENTRY)Entry);
  4002. #endif
  4003. }
  4004. return;
  4005. }
  4006. typedef struct _PCI_SLOT_NUMBER {
  4007. union {
  4008. struct {
  4009. ULONG DeviceNumber:5;
  4010. ULONG FunctionNumber:3;
  4011. ULONG Reserved:24;
  4012. } bits;
  4013. ULONG AsULONG;
  4014. } u;
  4015. } PCI_SLOT_NUMBER, *PPCI_SLOT_NUMBER;
  4016. #define PCI_TYPE0_ADDRESSES 6
  4017. #define PCI_TYPE1_ADDRESSES 2
  4018. #define PCI_TYPE2_ADDRESSES 5
  4019. typedef struct _PCI_COMMON_CONFIG {
  4020. USHORT VendorID; // (ro)
  4021. USHORT DeviceID; // (ro)
  4022. USHORT Command; // Device control
  4023. USHORT Status;
  4024. UCHAR RevisionID; // (ro)
  4025. UCHAR ProgIf; // (ro)
  4026. UCHAR SubClass; // (ro)
  4027. UCHAR BaseClass; // (ro)
  4028. UCHAR CacheLineSize; // (ro+)
  4029. UCHAR LatencyTimer; // (ro+)
  4030. UCHAR HeaderType; // (ro)
  4031. UCHAR BIST; // Built in self test
  4032. union {
  4033. struct _PCI_HEADER_TYPE_0 {
  4034. ULONG BaseAddresses[PCI_TYPE0_ADDRESSES];
  4035. ULONG CIS;
  4036. USHORT SubVendorID;
  4037. USHORT SubSystemID;
  4038. ULONG ROMBaseAddress;
  4039. UCHAR CapabilitiesPtr;
  4040. UCHAR Reserved1[3];
  4041. ULONG Reserved2;
  4042. UCHAR InterruptLine; //
  4043. UCHAR InterruptPin; // (ro)
  4044. UCHAR MinimumGrant; // (ro)
  4045. UCHAR MaximumLatency; // (ro)
  4046. } type0;
  4047. } u;
  4048. UCHAR DeviceSpecific[192];
  4049. } PCI_COMMON_CONFIG, *PPCI_COMMON_CONFIG;
  4050. #define PCI_COMMON_HDR_LENGTH (FIELD_OFFSET (PCI_COMMON_CONFIG, DeviceSpecific))
  4051. #define PCI_MAX_DEVICES 32
  4052. #define PCI_MAX_FUNCTION 8
  4053. #define PCI_MAX_BRIDGE_NUMBER 0xFF
  4054. #define PCI_INVALID_VENDORID 0xFFFF
  4055. //
  4056. // Bit encodings for PCI_COMMON_CONFIG.HeaderType
  4057. //
  4058. #define PCI_MULTIFUNCTION 0x80
  4059. #define PCI_DEVICE_TYPE 0x00
  4060. #define PCI_BRIDGE_TYPE 0x01
  4061. #define PCI_CARDBUS_BRIDGE_TYPE 0x02
  4062. #define PCI_CONFIGURATION_TYPE(PciData) \
  4063. (((PPCI_COMMON_CONFIG)(PciData))->HeaderType & ~PCI_MULTIFUNCTION)
  4064. #define PCI_MULTIFUNCTION_DEVICE(PciData) \
  4065. ((((PPCI_COMMON_CONFIG)(PciData))->HeaderType & PCI_MULTIFUNCTION) != 0)
  4066. //
  4067. // Bit encodings for PCI_COMMON_CONFIG.Command
  4068. //
  4069. #define PCI_ENABLE_IO_SPACE 0x0001
  4070. #define PCI_ENABLE_MEMORY_SPACE 0x0002
  4071. #define PCI_ENABLE_BUS_MASTER 0x0004
  4072. #define PCI_ENABLE_SPECIAL_CYCLES 0x0008
  4073. #define PCI_ENABLE_WRITE_AND_INVALIDATE 0x0010
  4074. #define PCI_ENABLE_VGA_COMPATIBLE_PALETTE 0x0020
  4075. #define PCI_ENABLE_PARITY 0x0040 // (ro+)
  4076. #define PCI_ENABLE_WAIT_CYCLE 0x0080 // (ro+)
  4077. #define PCI_ENABLE_SERR 0x0100 // (ro+)
  4078. #define PCI_ENABLE_FAST_BACK_TO_BACK 0x0200 // (ro)
  4079. //
  4080. // Bit encodings for PCI_COMMON_CONFIG.Status
  4081. //
  4082. #define PCI_STATUS_CAPABILITIES_LIST 0x0010 // (ro)
  4083. #define PCI_STATUS_66MHZ_CAPABLE 0x0020 // (ro)
  4084. #define PCI_STATUS_UDF_SUPPORTED 0x0040 // (ro)
  4085. #define PCI_STATUS_FAST_BACK_TO_BACK 0x0080 // (ro)
  4086. #define PCI_STATUS_DATA_PARITY_DETECTED 0x0100
  4087. #define PCI_STATUS_DEVSEL 0x0600 // 2 bits wide
  4088. #define PCI_STATUS_SIGNALED_TARGET_ABORT 0x0800
  4089. #define PCI_STATUS_RECEIVED_TARGET_ABORT 0x1000
  4090. #define PCI_STATUS_RECEIVED_MASTER_ABORT 0x2000
  4091. #define PCI_STATUS_SIGNALED_SYSTEM_ERROR 0x4000
  4092. #define PCI_STATUS_DETECTED_PARITY_ERROR 0x8000
  4093. //
  4094. // The NT PCI Driver uses a WhichSpace parameter on its CONFIG_READ/WRITE
  4095. // routines. The following values are defined-
  4096. //
  4097. #define PCI_WHICHSPACE_CONFIG 0x0
  4098. #define PCI_WHICHSPACE_ROM 0x52696350
  4099. // end_wdm
  4100. //
  4101. // PCI Capability IDs
  4102. //
  4103. #define PCI_CAPABILITY_ID_POWER_MANAGEMENT 0x01
  4104. #define PCI_CAPABILITY_ID_AGP 0x02
  4105. #define PCI_CAPABILITY_ID_MSI 0x05
  4106. #define PCI_CAPABILITY_ID_AGP_TARGET 0x0E
  4107. //
  4108. // All PCI Capability structures have the following header.
  4109. //
  4110. // CapabilityID is used to identify the type of the structure (is
  4111. // one of the PCI_CAPABILITY_ID values above.
  4112. //
  4113. // Next is the offset in PCI Configuration space (0x40 - 0xfc) of the
  4114. // next capability structure in the list, or 0x00 if there are no more
  4115. // entries.
  4116. //
  4117. typedef struct _PCI_CAPABILITIES_HEADER {
  4118. UCHAR CapabilityID;
  4119. UCHAR Next;
  4120. } PCI_CAPABILITIES_HEADER, *PPCI_CAPABILITIES_HEADER;
  4121. //
  4122. // Power Management Capability
  4123. //
  4124. typedef struct _PCI_PMC {
  4125. UCHAR Version:3;
  4126. UCHAR PMEClock:1;
  4127. UCHAR Rsvd1:1;
  4128. UCHAR DeviceSpecificInitialization:1;
  4129. UCHAR Rsvd2:2;
  4130. struct _PM_SUPPORT {
  4131. UCHAR Rsvd2:1;
  4132. UCHAR D1:1;
  4133. UCHAR D2:1;
  4134. UCHAR PMED0:1;
  4135. UCHAR PMED1:1;
  4136. UCHAR PMED2:1;
  4137. UCHAR PMED3Hot:1;
  4138. UCHAR PMED3Cold:1;
  4139. } Support;
  4140. } PCI_PMC, *PPCI_PMC;
  4141. typedef struct _PCI_PMCSR {
  4142. USHORT PowerState:2;
  4143. USHORT Rsvd1:6;
  4144. USHORT PMEEnable:1;
  4145. USHORT DataSelect:4;
  4146. USHORT DataScale:2;
  4147. USHORT PMEStatus:1;
  4148. } PCI_PMCSR, *PPCI_PMCSR;
  4149. typedef struct _PCI_PMCSR_BSE {
  4150. UCHAR Rsvd1:6;
  4151. UCHAR D3HotSupportsStopClock:1; // B2_B3#
  4152. UCHAR BusPowerClockControlEnabled:1; // BPCC_EN
  4153. } PCI_PMCSR_BSE, *PPCI_PMCSR_BSE;
  4154. typedef struct _PCI_PM_CAPABILITY {
  4155. PCI_CAPABILITIES_HEADER Header;
  4156. //
  4157. // Power Management Capabilities (Offset = 2)
  4158. //
  4159. union {
  4160. PCI_PMC Capabilities;
  4161. USHORT AsUSHORT;
  4162. } PMC;
  4163. //
  4164. // Power Management Control/Status (Offset = 4)
  4165. //
  4166. union {
  4167. PCI_PMCSR ControlStatus;
  4168. USHORT AsUSHORT;
  4169. } PMCSR;
  4170. //
  4171. // PMCSR PCI-PCI Bridge Support Extensions
  4172. //
  4173. union {
  4174. PCI_PMCSR_BSE BridgeSupport;
  4175. UCHAR AsUCHAR;
  4176. } PMCSR_BSE;
  4177. //
  4178. // Optional read only 8 bit Data register. Contents controlled by
  4179. // DataSelect and DataScale in ControlStatus.
  4180. //
  4181. UCHAR Data;
  4182. } PCI_PM_CAPABILITY, *PPCI_PM_CAPABILITY;
  4183. //
  4184. // AGP Capability
  4185. //
  4186. typedef struct _PCI_AGP_CAPABILITY {
  4187. PCI_CAPABILITIES_HEADER Header;
  4188. USHORT Minor:4;
  4189. USHORT Major:4;
  4190. USHORT Rsvd1:8;
  4191. struct _PCI_AGP_STATUS {
  4192. ULONG Rate:3;
  4193. ULONG Agp3Mode:1;
  4194. ULONG FastWrite:1;
  4195. ULONG FourGB:1;
  4196. ULONG HostTransDisable:1;
  4197. ULONG Gart64:1;
  4198. ULONG ITA_Coherent:1;
  4199. ULONG SideBandAddressing:1; // SBA
  4200. ULONG CalibrationCycle:3;
  4201. ULONG AsyncRequestSize:3;
  4202. ULONG Rsvd1:1;
  4203. ULONG Isoch:1;
  4204. ULONG Rsvd2:6;
  4205. ULONG RequestQueueDepthMaximum:8; // RQ
  4206. } AGPStatus;
  4207. struct _PCI_AGP_COMMAND {
  4208. ULONG Rate:3;
  4209. ULONG Rsvd1:1;
  4210. ULONG FastWriteEnable:1;
  4211. ULONG FourGBEnable:1;
  4212. ULONG Rsvd2:1;
  4213. ULONG Gart64:1;
  4214. ULONG AGPEnable:1;
  4215. ULONG SBAEnable:1;
  4216. ULONG CalibrationCycle:3;
  4217. ULONG AsyncReqSize:3;
  4218. ULONG Rsvd3:8;
  4219. ULONG RequestQueueDepth:8;
  4220. } AGPCommand;
  4221. } PCI_AGP_CAPABILITY, *PPCI_AGP_CAPABILITY;
  4222. //
  4223. // An AGPv3 Target must have an extended capability,
  4224. // but it's only present for a Master when the Isoch
  4225. // bit is set in its status register
  4226. //
  4227. typedef enum _EXTENDED_AGP_REGISTER {
  4228. IsochStatus,
  4229. AgpControl,
  4230. ApertureSize,
  4231. AperturePageSize,
  4232. GartLow,
  4233. GartHigh,
  4234. IsochCommand
  4235. } EXTENDED_AGP_REGISTER, *PEXTENDED_AGP_REGISTER;
  4236. typedef struct _PCI_AGP_ISOCH_STATUS {
  4237. ULONG ErrorCode: 2;
  4238. ULONG Rsvd1: 1;
  4239. ULONG Isoch_L: 3;
  4240. ULONG Isoch_Y: 2;
  4241. ULONG Isoch_N: 8;
  4242. ULONG Rsvd2: 16;
  4243. } PCI_AGP_ISOCH_STATUS, *PPCI_AGP_ISOCH_STATUS;
  4244. typedef struct _PCI_AGP_CONTROL {
  4245. ULONG Rsvd1: 7;
  4246. ULONG GTLB_Enable: 1;
  4247. ULONG AP_Enable: 1;
  4248. ULONG CAL_Disable: 1;
  4249. ULONG Rsvd2: 22;
  4250. } PCI_AGP_CONTROL, *PPCI_AGP_CONTROL;
  4251. typedef struct _PCI_AGP_APERTURE_PAGE_SIZE {
  4252. USHORT PageSizeMask: 11;
  4253. USHORT Rsvd1: 1;
  4254. USHORT PageSizeSelect: 4;
  4255. } PCI_AGP_APERTURE_PAGE_SIZE, *PPCI_AGP_APERTURE_PAGE_SIZE;
  4256. typedef struct _PCI_AGP_ISOCH_COMMAND {
  4257. USHORT Rsvd1: 6;
  4258. USHORT Isoch_Y: 2;
  4259. USHORT Isoch_N: 8;
  4260. } PCI_AGP_ISOCH_COMMAND, *PPCI_AGP_ISOCH_COMMAND;
  4261. typedef struct PCI_AGP_EXTENDED_CAPABILITY {
  4262. PCI_AGP_ISOCH_STATUS IsochStatus;
  4263. //
  4264. // Target only ----------------<<-begin->>
  4265. //
  4266. PCI_AGP_CONTROL AgpControl;
  4267. USHORT ApertureSize;
  4268. PCI_AGP_APERTURE_PAGE_SIZE AperturePageSize;
  4269. ULONG GartLow;
  4270. ULONG GartHigh;
  4271. //
  4272. // ------------------------------<<-end->>
  4273. //
  4274. PCI_AGP_ISOCH_COMMAND IsochCommand;
  4275. } PCI_AGP_EXTENDED_CAPABILITY, *PPCI_AGP_EXTENDED_CAPABILITY;
  4276. #define PCI_AGP_RATE_1X 0x1
  4277. #define PCI_AGP_RATE_2X 0x2
  4278. #define PCI_AGP_RATE_4X 0x4
  4279. //
  4280. // MSI (Message Signalled Interrupts) Capability
  4281. //
  4282. typedef struct _PCI_MSI_CAPABILITY {
  4283. PCI_CAPABILITIES_HEADER Header;
  4284. struct _PCI_MSI_MESSAGE_CONTROL {
  4285. USHORT MSIEnable:1;
  4286. USHORT MultipleMessageCapable:3;
  4287. USHORT MultipleMessageEnable:3;
  4288. USHORT CapableOf64Bits:1;
  4289. USHORT Reserved:8;
  4290. } MessageControl;
  4291. union {
  4292. struct _PCI_MSI_MESSAGE_ADDRESS {
  4293. ULONG_PTR Reserved:2; // always zero, DWORD aligned address
  4294. ULONG_PTR Address:30;
  4295. } Register;
  4296. ULONG_PTR Raw;
  4297. } MessageAddress;
  4298. //
  4299. // The rest of the Capability structure differs depending on whether
  4300. // 32bit or 64bit addressing is being used.
  4301. //
  4302. // (The CapableOf64Bits bit above determines this)
  4303. //
  4304. union {
  4305. // For 64 bit devices
  4306. struct _PCI_MSI_64BIT_DATA {
  4307. ULONG MessageUpperAddress;
  4308. USHORT MessageData;
  4309. } Bit64;
  4310. // For 32 bit devices
  4311. struct _PCI_MSI_32BIT_DATA {
  4312. USHORT MessageData;
  4313. ULONG Unused;
  4314. } Bit32;
  4315. } Data;
  4316. } PCI_MSI_CAPABILITY, *PPCI_PCI_CAPABILITY;
  4317. // begin_wdm
  4318. //
  4319. // Base Class Code encodings for Base Class (from PCI spec rev 2.1).
  4320. //
  4321. #define PCI_CLASS_PRE_20 0x00
  4322. #define PCI_CLASS_MASS_STORAGE_CTLR 0x01
  4323. #define PCI_CLASS_NETWORK_CTLR 0x02
  4324. #define PCI_CLASS_DISPLAY_CTLR 0x03
  4325. #define PCI_CLASS_MULTIMEDIA_DEV 0x04
  4326. #define PCI_CLASS_MEMORY_CTLR 0x05
  4327. #define PCI_CLASS_BRIDGE_DEV 0x06
  4328. #define PCI_CLASS_SIMPLE_COMMS_CTLR 0x07
  4329. #define PCI_CLASS_BASE_SYSTEM_DEV 0x08
  4330. #define PCI_CLASS_INPUT_DEV 0x09
  4331. #define PCI_CLASS_DOCKING_STATION 0x0a
  4332. #define PCI_CLASS_PROCESSOR 0x0b
  4333. #define PCI_CLASS_SERIAL_BUS_CTLR 0x0c
  4334. #define PCI_CLASS_WIRELESS_CTLR 0x0d
  4335. #define PCI_CLASS_INTELLIGENT_IO_CTLR 0x0e
  4336. #define PCI_CLASS_SATELLITE_COMMS_CTLR 0x0f
  4337. #define PCI_CLASS_ENCRYPTION_DECRYPTION 0x10
  4338. #define PCI_CLASS_DATA_ACQ_SIGNAL_PROC 0x11
  4339. // 0d thru fe reserved
  4340. #define PCI_CLASS_NOT_DEFINED 0xff
  4341. //
  4342. // Sub Class Code encodings (PCI rev 2.1).
  4343. //
  4344. // Class 00 - PCI_CLASS_PRE_20
  4345. #define PCI_SUBCLASS_PRE_20_NON_VGA 0x00
  4346. #define PCI_SUBCLASS_PRE_20_VGA 0x01
  4347. // Class 01 - PCI_CLASS_MASS_STORAGE_CTLR
  4348. #define PCI_SUBCLASS_MSC_SCSI_BUS_CTLR 0x00
  4349. #define PCI_SUBCLASS_MSC_IDE_CTLR 0x01
  4350. #define PCI_SUBCLASS_MSC_FLOPPY_CTLR 0x02
  4351. #define PCI_SUBCLASS_MSC_IPI_CTLR 0x03
  4352. #define PCI_SUBCLASS_MSC_RAID_CTLR 0x04
  4353. #define PCI_SUBCLASS_MSC_OTHER 0x80
  4354. // Class 02 - PCI_CLASS_NETWORK_CTLR
  4355. #define PCI_SUBCLASS_NET_ETHERNET_CTLR 0x00
  4356. #define PCI_SUBCLASS_NET_TOKEN_RING_CTLR 0x01
  4357. #define PCI_SUBCLASS_NET_FDDI_CTLR 0x02
  4358. #define PCI_SUBCLASS_NET_ATM_CTLR 0x03
  4359. #define PCI_SUBCLASS_NET_ISDN_CTLR 0x04
  4360. #define PCI_SUBCLASS_NET_OTHER 0x80
  4361. // Class 03 - PCI_CLASS_DISPLAY_CTLR
  4362. // N.B. Sub Class 00 could be VGA or 8514 depending on Interface byte
  4363. #define PCI_SUBCLASS_VID_VGA_CTLR 0x00
  4364. #define PCI_SUBCLASS_VID_XGA_CTLR 0x01
  4365. #define PCI_SUBLCASS_VID_3D_CTLR 0x02
  4366. #define PCI_SUBCLASS_VID_OTHER 0x80
  4367. // Class 04 - PCI_CLASS_MULTIMEDIA_DEV
  4368. #define PCI_SUBCLASS_MM_VIDEO_DEV 0x00
  4369. #define PCI_SUBCLASS_MM_AUDIO_DEV 0x01
  4370. #define PCI_SUBCLASS_MM_TELEPHONY_DEV 0x02
  4371. #define PCI_SUBCLASS_MM_OTHER 0x80
  4372. // Class 05 - PCI_CLASS_MEMORY_CTLR
  4373. #define PCI_SUBCLASS_MEM_RAM 0x00
  4374. #define PCI_SUBCLASS_MEM_FLASH 0x01
  4375. #define PCI_SUBCLASS_MEM_OTHER 0x80
  4376. // Class 06 - PCI_CLASS_BRIDGE_DEV
  4377. #define PCI_SUBCLASS_BR_HOST 0x00
  4378. #define PCI_SUBCLASS_BR_ISA 0x01
  4379. #define PCI_SUBCLASS_BR_EISA 0x02
  4380. #define PCI_SUBCLASS_BR_MCA 0x03
  4381. #define PCI_SUBCLASS_BR_PCI_TO_PCI 0x04
  4382. #define PCI_SUBCLASS_BR_PCMCIA 0x05
  4383. #define PCI_SUBCLASS_BR_NUBUS 0x06
  4384. #define PCI_SUBCLASS_BR_CARDBUS 0x07
  4385. #define PCI_SUBCLASS_BR_RACEWAY 0x08
  4386. #define PCI_SUBCLASS_BR_OTHER 0x80
  4387. // Class 07 - PCI_CLASS_SIMPLE_COMMS_CTLR
  4388. // N.B. Sub Class 00 and 01 additional info in Interface byte
  4389. #define PCI_SUBCLASS_COM_SERIAL 0x00
  4390. #define PCI_SUBCLASS_COM_PARALLEL 0x01
  4391. #define PCI_SUBCLASS_COM_MULTIPORT 0x02
  4392. #define PCI_SUBCLASS_COM_MODEM 0x03
  4393. #define PCI_SUBCLASS_COM_OTHER 0x80
  4394. // Class 08 - PCI_CLASS_BASE_SYSTEM_DEV
  4395. // N.B. See Interface byte for additional info.
  4396. #define PCI_SUBCLASS_SYS_INTERRUPT_CTLR 0x00
  4397. #define PCI_SUBCLASS_SYS_DMA_CTLR 0x01
  4398. #define PCI_SUBCLASS_SYS_SYSTEM_TIMER 0x02
  4399. #define PCI_SUBCLASS_SYS_REAL_TIME_CLOCK 0x03
  4400. #define PCI_SUBCLASS_SYS_GEN_HOTPLUG_CTLR 0x04
  4401. #define PCI_SUBCLASS_SYS_OTHER 0x80
  4402. // Class 09 - PCI_CLASS_INPUT_DEV
  4403. #define PCI_SUBCLASS_INP_KEYBOARD 0x00
  4404. #define PCI_SUBCLASS_INP_DIGITIZER 0x01
  4405. #define PCI_SUBCLASS_INP_MOUSE 0x02
  4406. #define PCI_SUBCLASS_INP_SCANNER 0x03
  4407. #define PCI_SUBCLASS_INP_GAMEPORT 0x04
  4408. #define PCI_SUBCLASS_INP_OTHER 0x80
  4409. // Class 0a - PCI_CLASS_DOCKING_STATION
  4410. #define PCI_SUBCLASS_DOC_GENERIC 0x00
  4411. #define PCI_SUBCLASS_DOC_OTHER 0x80
  4412. // Class 0b - PCI_CLASS_PROCESSOR
  4413. #define PCI_SUBCLASS_PROC_386 0x00
  4414. #define PCI_SUBCLASS_PROC_486 0x01
  4415. #define PCI_SUBCLASS_PROC_PENTIUM 0x02
  4416. #define PCI_SUBCLASS_PROC_ALPHA 0x10
  4417. #define PCI_SUBCLASS_PROC_POWERPC 0x20
  4418. #define PCI_SUBCLASS_PROC_COPROCESSOR 0x40
  4419. // Class 0c - PCI_CLASS_SERIAL_BUS_CTLR
  4420. #define PCI_SUBCLASS_SB_IEEE1394 0x00
  4421. #define PCI_SUBCLASS_SB_ACCESS 0x01
  4422. #define PCI_SUBCLASS_SB_SSA 0x02
  4423. #define PCI_SUBCLASS_SB_USB 0x03
  4424. #define PCI_SUBCLASS_SB_FIBRE_CHANNEL 0x04
  4425. #define PCI_SUBCLASS_SB_SMBUS 0x05
  4426. // Class 0d - PCI_CLASS_WIRELESS_CTLR
  4427. #define PCI_SUBCLASS_WIRELESS_IRDA 0x00
  4428. #define PCI_SUBCLASS_WIRELESS_CON_IR 0x01
  4429. #define PCI_SUBCLASS_WIRELESS_RF 0x10
  4430. #define PCI_SUBCLASS_WIRELESS_OTHER 0x80
  4431. // Class 0e - PCI_CLASS_INTELLIGENT_IO_CTLR
  4432. #define PCI_SUBCLASS_INTIO_I2O 0x00
  4433. // Class 0f - PCI_CLASS_SATELLITE_CTLR
  4434. #define PCI_SUBCLASS_SAT_TV 0x01
  4435. #define PCI_SUBCLASS_SAT_AUDIO 0x02
  4436. #define PCI_SUBCLASS_SAT_VOICE 0x03
  4437. #define PCI_SUBCLASS_SAT_DATA 0x04
  4438. // Class 10 - PCI_CLASS_ENCRYPTION_DECRYPTION
  4439. #define PCI_SUBCLASS_CRYPTO_NET_COMP 0x00
  4440. #define PCI_SUBCLASS_CRYPTO_ENTERTAINMENT 0x10
  4441. #define PCI_SUBCLASS_CRYPTO_OTHER 0x80
  4442. // Class 11 - PCI_CLASS_DATA_ACQ_SIGNAL_PROC
  4443. #define PCI_SUBCLASS_DASP_DPIO 0x00
  4444. #define PCI_SUBCLASS_DASP_OTHER 0x80
  4445. typedef enum _MM_PAGE_PRIORITY {
  4446. LowPagePriority,
  4447. NormalPagePriority = 16,
  4448. HighPagePriority = 32
  4449. } MM_PAGE_PRIORITY;
  4450. #else // BINARY_COMPATIBLE && !NDIS_WDM
  4451. #if (!BINARY_COMPATIBLE)
  4452. //
  4453. // BINARY_COMPATIBLE = 0 and NDIS_WDM = 1 then use ntddk.h
  4454. // BINARY_COMPATIBLE = 0 and NDIS_WDM = 0 then use ntddk.h
  4455. //
  4456. //
  4457. // The definitions available in ntddk.h must not be used directly by non-WDM miniport drivers.
  4458. //
  4459. #include <ntddk.h>
  4460. #else // !BINARY_COMPATIBLE
  4461. //
  4462. // BINARY_COMPATIBLE = 1 and NDIS_WDM = 1 then use wdm.h
  4463. //
  4464. #include <wdm.h>
  4465. #endif // else !BINARY_COMPATIBLE
  4466. #endif // else BINARY_COMPATIBLE && !NDIS_WDM
  4467. //
  4468. // END INTERNAL DEFINITIONS
  4469. //
  4470. // The following definitions may be used by NDIS drivers, except as noted.
  4471. //
  4472. #ifndef __NET_PNP__
  4473. #define __NET_PNP__
  4474. //
  4475. // PnP and PM event codes that can be indicated up to transports
  4476. // and clients.
  4477. //
  4478. typedef enum _NET_PNP_EVENT_CODE
  4479. {
  4480. NetEventSetPower,
  4481. NetEventQueryPower,
  4482. NetEventQueryRemoveDevice,
  4483. NetEventCancelRemoveDevice,
  4484. NetEventReconfigure,
  4485. NetEventBindList,
  4486. NetEventBindsComplete,
  4487. NetEventPnPCapabilities,
  4488. NetEventMaximum
  4489. } NET_PNP_EVENT_CODE, *PNET_PNP_EVENT_CODE;
  4490. //
  4491. // Networking PnP event indication structure.
  4492. //
  4493. typedef struct _NET_PNP_EVENT
  4494. {
  4495. //
  4496. // Event code describing action to take.
  4497. //
  4498. NET_PNP_EVENT_CODE NetEvent;
  4499. //
  4500. // Event specific data.
  4501. //
  4502. PVOID Buffer;
  4503. //
  4504. // Length of event specific data.
  4505. //
  4506. ULONG BufferLength;
  4507. //
  4508. // Reserved values are for use by respective components only.
  4509. //
  4510. // Note: these reserved areas must be pointer aligned.
  4511. //
  4512. ULONG_PTR NdisReserved[4];
  4513. ULONG_PTR TransportReserved[4];
  4514. ULONG_PTR TdiReserved[4];
  4515. ULONG_PTR TdiClientReserved[4];
  4516. } NET_PNP_EVENT, *PNET_PNP_EVENT;
  4517. //
  4518. // The following structure defines the device power states.
  4519. //
  4520. typedef enum _NET_DEVICE_POWER_STATE
  4521. {
  4522. NetDeviceStateUnspecified = 0,
  4523. NetDeviceStateD0,
  4524. NetDeviceStateD1,
  4525. NetDeviceStateD2,
  4526. NetDeviceStateD3,
  4527. NetDeviceStateMaximum
  4528. } NET_DEVICE_POWER_STATE, *PNET_DEVICE_POWER_STATE;
  4529. #endif // __NET_PNP__
  4530. //
  4531. // Indicate that we're building for NT. NDIS_NT is always used for
  4532. // miniport builds.
  4533. //
  4534. #define NDIS_NT 1
  4535. #if defined(NDIS_DOS)
  4536. #undef NDIS_DOS
  4537. #endif
  4538. //
  4539. // Define status codes and event log codes.
  4540. //
  4541. #include <ntstatus.h>
  4542. #include <netevent.h>
  4543. //
  4544. // Define a couple of extra types.
  4545. //
  4546. #if !defined(_WINDEF_) // these are defined in windows.h too
  4547. typedef signed int INT, *PINT;
  4548. typedef unsigned int UINT, *PUINT;
  4549. #endif
  4550. typedef UNICODE_STRING NDIS_STRING, *PNDIS_STRING;
  4551. //
  4552. // Portability extentions
  4553. //
  4554. #define NDIS_INIT_FUNCTION(_F) alloc_text(INIT,_F)
  4555. #define NDIS_PAGABLE_FUNCTION(_F) alloc_text(PAGE,_F)
  4556. #define NDIS_PAGEABLE_FUNCTION(_F) alloc_text(PAGE,_F)
  4557. //
  4558. // This file contains the definition of an NDIS_OID as
  4559. // well as #defines for all the current OID values.
  4560. //
  4561. //
  4562. // Define NDIS_STATUS and NDIS_HANDLE here
  4563. //
  4564. typedef PVOID NDIS_HANDLE, *PNDIS_HANDLE;
  4565. typedef int NDIS_STATUS, *PNDIS_STATUS; // note default size
  4566. //
  4567. // for Miniports versions 5.0 and up, provide a consistent way to match
  4568. // Ndis version in their characteristics with their makefile defines
  4569. //
  4570. #if (!defined(NDIS_MINIPORT_MAJOR_VERSION) && !defined(NDIS_MINIPORT_MINOR_VERSION))
  4571. #if (defined(NDIS51_MINIPORT))
  4572. #define NDIS_MINIPORT_MAJOR_VERSION 5
  4573. #define NDIS_MINIPORT_MINOR_VERSION 1
  4574. #elif (defined(NDIS50_MINIPORT))
  4575. #define NDIS_MINIPORT_MAJOR_VERSION 5
  4576. #define NDIS_MINIPORT_MINOR_VERSION 0
  4577. #endif
  4578. #endif
  4579. //
  4580. // for protocol versions 5.0 and up, provide a consistent way to match
  4581. // Ndis version in their characteristics with their makefile defines
  4582. //
  4583. #if (!defined(NDIS_PROTOCOL_MAJOR_VERSION) && !defined(NDIS_PROTOCOL_MINOR_VERSION))
  4584. #if (defined(NDIS51))
  4585. #define NDIS_PROTOCOL_MAJOR_VERSION 5
  4586. #define NDIS_PROTOCOL_MINOR_VERSION 1
  4587. #elif (defined(NDIS50))
  4588. #define NDIS_PROTOCOL_MAJOR_VERSION 5
  4589. #define NDIS_PROTOCOL_MINOR_VERSION 0
  4590. #endif
  4591. #endif
  4592. #include <ntddndis.h>
  4593. //
  4594. // Ndis defines for configuration manager data structures
  4595. //
  4596. typedef CM_MCA_POS_DATA NDIS_MCA_POS_DATA, *PNDIS_MCA_POS_DATA;
  4597. typedef CM_EISA_SLOT_INFORMATION NDIS_EISA_SLOT_INFORMATION, *PNDIS_EISA_SLOT_INFORMATION;
  4598. typedef CM_EISA_FUNCTION_INFORMATION NDIS_EISA_FUNCTION_INFORMATION, *PNDIS_EISA_FUNCTION_INFORMATION;
  4599. //
  4600. // Define an exported function.
  4601. //
  4602. #if defined(NDIS_WRAPPER)
  4603. #define EXPORT
  4604. #else
  4605. #define EXPORT DECLSPEC_IMPORT
  4606. #endif
  4607. //
  4608. // Memory manipulation functions.
  4609. //
  4610. #define NdisMoveMemory(Destination, Source, Length) RtlCopyMemory(Destination, Source, Length)
  4611. #define NdisZeroMemory(Destination, Length) RtlZeroMemory(Destination, Length)
  4612. #define NdisEqualMemory(Source1, Source2, Length) RtlEqualMemory(Source1, Source2, Length)
  4613. #define NdisFillMemory(Destination, Length, Fill) RtlFillMemory(Destination, Length, Fill)
  4614. #define NdisRetrieveUlong(Destination, Source) RtlRetrieveUlong(Destination, Source)
  4615. #define NdisStoreUlong(Destination, Value) RtlStoreUlong(Destination, Value)
  4616. #define NDIS_STRING_CONST(x) {sizeof(L##x)-2, sizeof(L##x), L##x}
  4617. //
  4618. // On a RISC machine, I/O mapped memory can't be accessed with
  4619. // the Rtl routines.
  4620. //
  4621. #if defined(_M_IX86) || defined(_M_AMD64)
  4622. #define NdisMoveMappedMemory(Destination,Source,Length) RtlCopyMemory(Destination,Source,Length)
  4623. #define NdisZeroMappedMemory(Destination,Length) RtlZeroMemory(Destination,Length)
  4624. #elif defined(_M_IA64)
  4625. #define NdisMoveMappedMemory(Destination,Source,Length) \
  4626. { \
  4627. PUCHAR _Src = (Source); \
  4628. PUCHAR _Dest = (Destination); \
  4629. PUCHAR _End = _Dest + (Length); \
  4630. while (_Dest < _End) \
  4631. { \
  4632. *_Dest++ = *_Src++; \
  4633. } \
  4634. }
  4635. #define NdisZeroMappedMemory(Destination,Length) \
  4636. { \
  4637. PUCHAR _Dest = (Destination); \
  4638. PUCHAR _End = _Dest + (Length); \
  4639. while (_Dest < _End) \
  4640. { \
  4641. *_Dest++ = 0; \
  4642. } \
  4643. }
  4644. #endif
  4645. #define NdisMoveToMappedMemory(Destination,Source,Length) \
  4646. NdisMoveMappedMemory(Destination,Source,Length)
  4647. #define NdisMoveFromMappedMemory(Destination,Source,Length) \
  4648. NdisMoveMappedMemory(Destination,Source,Length)
  4649. //
  4650. // definition of the basic spin lock structure
  4651. //
  4652. typedef struct _NDIS_SPIN_LOCK
  4653. {
  4654. KSPIN_LOCK SpinLock;
  4655. KIRQL OldIrql;
  4656. } NDIS_SPIN_LOCK, * PNDIS_SPIN_LOCK;
  4657. //
  4658. // definition of the ndis event structure
  4659. //
  4660. typedef struct _NDIS_EVENT
  4661. {
  4662. KEVENT Event;
  4663. } NDIS_EVENT, *PNDIS_EVENT;
  4664. #pragma warning(push)
  4665. #pragma warning(disable:4115) // named type definition in parenthesis
  4666. typedef VOID (*NDIS_PROC)(struct _NDIS_WORK_ITEM *, PVOID);
  4667. #pragma warning(pop)
  4668. //
  4669. // Definition of an ndis work-item
  4670. //
  4671. typedef struct _NDIS_WORK_ITEM
  4672. {
  4673. PVOID Context;
  4674. NDIS_PROC Routine;
  4675. UCHAR WrapperReserved[8*sizeof(PVOID)];
  4676. } NDIS_WORK_ITEM, *PNDIS_WORK_ITEM;
  4677. #define NdisInterruptLatched Latched
  4678. #define NdisInterruptLevelSensitive LevelSensitive
  4679. typedef KINTERRUPT_MODE NDIS_INTERRUPT_MODE, *PNDIS_INTERRUPT_MODE;
  4680. //
  4681. // Configuration definitions
  4682. //
  4683. //
  4684. // Possible data types
  4685. //
  4686. typedef enum _NDIS_PARAMETER_TYPE
  4687. {
  4688. NdisParameterInteger,
  4689. NdisParameterHexInteger,
  4690. NdisParameterString,
  4691. NdisParameterMultiString,
  4692. NdisParameterBinary
  4693. } NDIS_PARAMETER_TYPE, *PNDIS_PARAMETER_TYPE;
  4694. typedef struct
  4695. {
  4696. USHORT Length;
  4697. PVOID Buffer;
  4698. } BINARY_DATA;
  4699. //
  4700. // To store configuration information
  4701. //
  4702. typedef struct _NDIS_CONFIGURATION_PARAMETER
  4703. {
  4704. NDIS_PARAMETER_TYPE ParameterType;
  4705. union
  4706. {
  4707. ULONG IntegerData;
  4708. NDIS_STRING StringData;
  4709. BINARY_DATA BinaryData;
  4710. } ParameterData;
  4711. } NDIS_CONFIGURATION_PARAMETER, *PNDIS_CONFIGURATION_PARAMETER;
  4712. //
  4713. // Definitions for the "ProcessorType" keyword
  4714. //
  4715. typedef enum _NDIS_PROCESSOR_TYPE
  4716. {
  4717. NdisProcessorX86,
  4718. NdisProcessorMips,
  4719. NdisProcessorAlpha,
  4720. NdisProcessorPpc,
  4721. NdisProcessorAmd64
  4722. } NDIS_PROCESSOR_TYPE, *PNDIS_PROCESSOR_TYPE;
  4723. //
  4724. // Definitions for the "Environment" keyword
  4725. //
  4726. typedef enum _NDIS_ENVIRONMENT_TYPE
  4727. {
  4728. NdisEnvironmentWindows,
  4729. NdisEnvironmentWindowsNt
  4730. } NDIS_ENVIRONMENT_TYPE, *PNDIS_ENVIRONMENT_TYPE;
  4731. //
  4732. // Possible Hardware Architecture. Define these to
  4733. // match the HAL INTERFACE_TYPE enum.
  4734. //
  4735. typedef enum _NDIS_INTERFACE_TYPE
  4736. {
  4737. NdisInterfaceInternal = Internal,
  4738. NdisInterfaceIsa = Isa,
  4739. NdisInterfaceEisa = Eisa,
  4740. NdisInterfaceMca = MicroChannel,
  4741. NdisInterfaceTurboChannel = TurboChannel,
  4742. NdisInterfacePci = PCIBus,
  4743. NdisInterfacePcMcia = PCMCIABus,
  4744. NdisInterfaceCBus = CBus,
  4745. NdisInterfaceMPIBus = MPIBus,
  4746. NdisInterfaceMPSABus = MPSABus,
  4747. NdisInterfaceProcessorInternal = ProcessorInternal,
  4748. NdisInterfaceInternalPowerBus = InternalPowerBus,
  4749. NdisInterfacePNPISABus = PNPISABus,
  4750. NdisInterfacePNPBus = PNPBus,
  4751. NdisMaximumInterfaceType
  4752. } NDIS_INTERFACE_TYPE, *PNDIS_INTERFACE_TYPE;
  4753. //
  4754. // Definition for shutdown handler
  4755. //
  4756. typedef
  4757. VOID
  4758. (*ADAPTER_SHUTDOWN_HANDLER) (
  4759. IN PVOID ShutdownContext
  4760. );
  4761. //
  4762. // Stuff for PCI configuring
  4763. //
  4764. typedef CM_PARTIAL_RESOURCE_LIST NDIS_RESOURCE_LIST, *PNDIS_RESOURCE_LIST;
  4765. //
  4766. // The structure passed up on a WAN_LINE_UP indication
  4767. //
  4768. typedef struct _NDIS_WAN_LINE_UP
  4769. {
  4770. IN ULONG LinkSpeed; // 100 bps units
  4771. IN ULONG MaximumTotalSize; // suggested max for send packets
  4772. IN NDIS_WAN_QUALITY Quality;
  4773. IN USHORT SendWindow; // suggested by the MAC
  4774. IN UCHAR RemoteAddress[6];
  4775. IN OUT UCHAR LocalAddress[6];
  4776. IN ULONG ProtocolBufferLength; // Length of protocol info buffer
  4777. IN PUCHAR ProtocolBuffer; // Information used by protocol
  4778. IN USHORT ProtocolType; // Protocol ID
  4779. IN OUT NDIS_STRING DeviceName;
  4780. } NDIS_WAN_LINE_UP, *PNDIS_WAN_LINE_UP;
  4781. //
  4782. // The structure passed up on a WAN_LINE_DOWN indication
  4783. //
  4784. typedef struct _NDIS_WAN_LINE_DOWN
  4785. {
  4786. IN UCHAR RemoteAddress[6];
  4787. IN UCHAR LocalAddress[6];
  4788. } NDIS_WAN_LINE_DOWN, *PNDIS_WAN_LINE_DOWN;
  4789. //
  4790. // The structure passed up on a WAN_FRAGMENT indication
  4791. //
  4792. typedef struct _NDIS_WAN_FRAGMENT
  4793. {
  4794. IN UCHAR RemoteAddress[6];
  4795. IN UCHAR LocalAddress[6];
  4796. } NDIS_WAN_FRAGMENT, *PNDIS_WAN_FRAGMENT;
  4797. //
  4798. // The structure passed up on a WAN_GET_STATS indication
  4799. //
  4800. typedef struct _NDIS_WAN_GET_STATS
  4801. {
  4802. IN UCHAR LocalAddress[6];
  4803. OUT ULONG BytesSent;
  4804. OUT ULONG BytesRcvd;
  4805. OUT ULONG FramesSent;
  4806. OUT ULONG FramesRcvd;
  4807. OUT ULONG CRCErrors; // Serial-like info only
  4808. OUT ULONG TimeoutErrors; // Serial-like info only
  4809. OUT ULONG AlignmentErrors; // Serial-like info only
  4810. OUT ULONG SerialOverrunErrors; // Serial-like info only
  4811. OUT ULONG FramingErrors; // Serial-like info only
  4812. OUT ULONG BufferOverrunErrors; // Serial-like info only
  4813. OUT ULONG BytesTransmittedUncompressed; // Compression info only
  4814. OUT ULONG BytesReceivedUncompressed; // Compression info only
  4815. OUT ULONG BytesTransmittedCompressed; // Compression info only
  4816. OUT ULONG BytesReceivedCompressed; // Compression info only
  4817. } NDIS_WAN_GET_STATS, *PNDIS_WAN_GET_STATS;
  4818. //
  4819. // DMA Channel information
  4820. //
  4821. typedef struct _NDIS_DMA_DESCRIPTION
  4822. {
  4823. BOOLEAN DemandMode;
  4824. BOOLEAN AutoInitialize;
  4825. BOOLEAN DmaChannelSpecified;
  4826. DMA_WIDTH DmaWidth;
  4827. DMA_SPEED DmaSpeed;
  4828. ULONG DmaPort;
  4829. ULONG DmaChannel;
  4830. } NDIS_DMA_DESCRIPTION, *PNDIS_DMA_DESCRIPTION;
  4831. //
  4832. // Internal structure representing an NDIS DMA channel
  4833. //
  4834. typedef struct _NDIS_DMA_BLOCK
  4835. {
  4836. PVOID MapRegisterBase;
  4837. KEVENT AllocationEvent;
  4838. PVOID SystemAdapterObject;
  4839. PVOID Miniport;
  4840. BOOLEAN InProgress;
  4841. } NDIS_DMA_BLOCK, *PNDIS_DMA_BLOCK;
  4842. #if defined(NDIS_WRAPPER)
  4843. //
  4844. // definitions for PnP state
  4845. //
  4846. typedef enum _NDIS_PNP_DEVICE_STATE
  4847. {
  4848. NdisPnPDeviceAdded,
  4849. NdisPnPDeviceStarted,
  4850. NdisPnPDeviceQueryStopped,
  4851. NdisPnPDeviceStopped,
  4852. NdisPnPDeviceQueryRemoved,
  4853. NdisPnPDeviceRemoved,
  4854. NdisPnPDeviceSurpriseRemoved
  4855. } NDIS_PNP_DEVICE_STATE;
  4856. //
  4857. // flags to use in PnPCapabilities Flag
  4858. //
  4859. #define NDIS_DEVICE_NOT_STOPPABLE 0x00000001 // the debvice is not stoppable i.e. ISA
  4860. #define NDIS_DEVICE_NOT_REMOVEABLE 0x00000002 // the device can not be safely removed
  4861. #define NDIS_DEVICE_NOT_SUSPENDABLE 0x00000004 // the device can not be safely suspended
  4862. #define NDIS_DEVICE_DISABLE_PM 0x00000008 // disable all PM features
  4863. #define NDIS_DEVICE_DISABLE_WAKE_UP 0x00000010 // disable device waking up the system
  4864. #define NDIS_DEVICE_DISABLE_WAKE_ON_RECONNECT 0x00000020 // disable device waking up the -system- due to a cable re-connect
  4865. #define NDIS_DEVICE_RESERVED 0x00000040 // should not be used
  4866. #define NDIS_DEVICE_DISABLE_WAKE_ON_MAGIC_PACKET 0x00000080 // disable device waking up the -system- due to a magic packet
  4867. #define NDIS_DEVICE_DISABLE_WAKE_ON_PATTERN_MATCH 0x00000100 // disable device waking up the -system- due to a pattern match
  4868. #endif // NDIS_WRAPPER defined
  4869. //
  4870. // Ndis Buffer is actually an Mdl
  4871. //
  4872. typedef MDL NDIS_BUFFER, *PNDIS_BUFFER;
  4873. struct _NDIS_PACKET;
  4874. typedef NDIS_HANDLE PNDIS_PACKET_POOL;
  4875. //
  4876. //
  4877. // wrapper-specific part of a packet
  4878. //
  4879. typedef struct _NDIS_PACKET_PRIVATE
  4880. {
  4881. UINT PhysicalCount; // number of physical pages in packet.
  4882. UINT TotalLength; // Total amount of data in the packet.
  4883. PNDIS_BUFFER Head; // first buffer in the chain
  4884. PNDIS_BUFFER Tail; // last buffer in the chain
  4885. // if Head is NULL the chain is empty; Tail doesn't have to be NULL also
  4886. PNDIS_PACKET_POOL Pool; // so we know where to free it back to
  4887. UINT Count;
  4888. ULONG Flags;
  4889. BOOLEAN ValidCounts;
  4890. UCHAR NdisPacketFlags; // See fPACKET_xxx bits below
  4891. USHORT NdisPacketOobOffset;
  4892. } NDIS_PACKET_PRIVATE, * PNDIS_PACKET_PRIVATE;
  4893. //
  4894. // The bits define the bits in the Flags
  4895. //
  4896. #define NDIS_FLAGS_PROTOCOL_ID_MASK 0x0000000F // The low 4 bits are defined for protocol-id
  4897. // The values are defined in ntddndis.h
  4898. #define NDIS_FLAGS_MULTICAST_PACKET 0x00000010 // don't use
  4899. #define NDIS_FLAGS_RESERVED2 0x00000020 // don't use
  4900. #define NDIS_FLAGS_RESERVED3 0x00000040 // don't use
  4901. #define NDIS_FLAGS_DONT_LOOPBACK 0x00000080 // Write only
  4902. #define NDIS_FLAGS_IS_LOOPBACK_PACKET 0x00000100 // Read only
  4903. #define NDIS_FLAGS_LOOPBACK_ONLY 0x00000200 // Write only
  4904. #define NDIS_FLAGS_RESERVED4 0x00000400 // don't use
  4905. #define NDIS_FLAGS_DOUBLE_BUFFERED 0x00000800 // used by ndis
  4906. #define NDIS_FLAGS_SENT_AT_DPC 0x00001000 // the protocol sent this packet at DPC
  4907. #define NDIS_FLAGS_USES_SG_BUFFER_LIST 0x00002000 // used by Ndis
  4908. #define NDIS_FLAGS_CONTAINS_ARCNET_HEADER 0x00004000 // used by Ndis
  4909. //
  4910. // Low-bits in the NdisPacketFlags are reserved by NDIS Wrapper for internal use
  4911. //
  4912. #define fPACKET_WRAPPER_RESERVED 0x3F
  4913. #define fPACKET_CONTAINS_MEDIA_SPECIFIC_INFO 0x40
  4914. #define fPACKET_ALLOCATED_BY_NDIS 0x80
  4915. //
  4916. // Definition for layout of the media-specific data. More than one class of media-specific
  4917. // information can be tagged onto a packet.
  4918. //
  4919. typedef enum _NDIS_CLASS_ID
  4920. {
  4921. NdisClass802_3Priority,
  4922. NdisClassWirelessWanMbxMailbox,
  4923. NdisClassIrdaPacketInfo,
  4924. NdisClassAtmAALInfo
  4925. } NDIS_CLASS_ID;
  4926. typedef struct _MEDIA_SPECIFIC_INFORMATION
  4927. {
  4928. UINT NextEntryOffset;
  4929. NDIS_CLASS_ID ClassId;
  4930. UINT Size;
  4931. UCHAR ClassInformation[1];
  4932. } MEDIA_SPECIFIC_INFORMATION, *PMEDIA_SPECIFIC_INFORMATION;
  4933. typedef struct _NDIS_PACKET_OOB_DATA
  4934. {
  4935. union
  4936. {
  4937. ULONGLONG TimeToSend;
  4938. ULONGLONG TimeSent;
  4939. };
  4940. ULONGLONG TimeReceived;
  4941. UINT HeaderSize;
  4942. UINT SizeMediaSpecificInfo;
  4943. PVOID MediaSpecificInformation;
  4944. NDIS_STATUS Status;
  4945. } NDIS_PACKET_OOB_DATA, *PNDIS_PACKET_OOB_DATA;
  4946. #define NDIS_GET_PACKET_PROTOCOL_TYPE(_Packet_) ((_Packet_)->Private.Flags & NDIS_PROTOCOL_ID_MASK)
  4947. #define NDIS_OOB_DATA_FROM_PACKET(_p) \
  4948. (PNDIS_PACKET_OOB_DATA)((PUCHAR)(_p) + \
  4949. (_p)->Private.NdisPacketOobOffset)
  4950. #define NDIS_GET_PACKET_HEADER_SIZE(_Packet) \
  4951. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  4952. (_Packet)->Private.NdisPacketOobOffset))->HeaderSize
  4953. #define NDIS_GET_PACKET_STATUS(_Packet) \
  4954. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  4955. (_Packet)->Private.NdisPacketOobOffset))->Status
  4956. #define NDIS_GET_PACKET_TIME_TO_SEND(_Packet) \
  4957. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  4958. (_Packet)->Private.NdisPacketOobOffset))->TimeToSend
  4959. #define NDIS_GET_PACKET_TIME_SENT(_Packet) \
  4960. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  4961. (_Packet)->Private.NdisPacketOobOffset))->TimeSent
  4962. #define NDIS_GET_PACKET_TIME_RECEIVED(_Packet) \
  4963. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  4964. (_Packet)->Private.NdisPacketOobOffset))->TimeReceived
  4965. #define NDIS_GET_PACKET_MEDIA_SPECIFIC_INFO(_Packet, \
  4966. _pMediaSpecificInfo, \
  4967. _pSizeMediaSpecificInfo) \
  4968. { \
  4969. if (!((_Packet)->Private.NdisPacketFlags & fPACKET_ALLOCATED_BY_NDIS) ||\
  4970. !((_Packet)->Private.NdisPacketFlags & fPACKET_CONTAINS_MEDIA_SPECIFIC_INFO))\
  4971. { \
  4972. *(_pMediaSpecificInfo) = NULL; \
  4973. *(_pSizeMediaSpecificInfo) = 0; \
  4974. } \
  4975. else \
  4976. { \
  4977. *(_pMediaSpecificInfo) =((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) +\
  4978. (_Packet)->Private.NdisPacketOobOffset))->MediaSpecificInformation;\
  4979. *(_pSizeMediaSpecificInfo) = ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) +\
  4980. (_Packet)->Private.NdisPacketOobOffset))->SizeMediaSpecificInfo;\
  4981. } \
  4982. }
  4983. #define NDIS_SET_PACKET_HEADER_SIZE(_Packet, _HdrSize) \
  4984. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  4985. (_Packet)->Private.NdisPacketOobOffset))->HeaderSize = (_HdrSize)
  4986. #define NDIS_SET_PACKET_STATUS(_Packet, _Status) \
  4987. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  4988. (_Packet)->Private.NdisPacketOobOffset))->Status = (_Status)
  4989. #define NDIS_SET_PACKET_TIME_TO_SEND(_Packet, _TimeToSend) \
  4990. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  4991. (_Packet)->Private.NdisPacketOobOffset))->TimeToSend = (_TimeToSend)
  4992. #define NDIS_SET_PACKET_TIME_SENT(_Packet, _TimeSent) \
  4993. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  4994. (_Packet)->Private.NdisPacketOobOffset))->TimeSent = (_TimeSent)
  4995. #define NDIS_SET_PACKET_TIME_RECEIVED(_Packet, _TimeReceived) \
  4996. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  4997. (_Packet)->Private.NdisPacketOobOffset))->TimeReceived = (_TimeReceived)
  4998. #define NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(_Packet, \
  4999. _MediaSpecificInfo, \
  5000. _SizeMediaSpecificInfo) \
  5001. { \
  5002. if ((_Packet)->Private.NdisPacketFlags & fPACKET_ALLOCATED_BY_NDIS) \
  5003. { \
  5004. (_Packet)->Private.NdisPacketFlags |= fPACKET_CONTAINS_MEDIA_SPECIFIC_INFO;\
  5005. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  5006. (_Packet)->Private.NdisPacketOobOffset))->MediaSpecificInformation = (_MediaSpecificInfo);\
  5007. ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
  5008. (_Packet)->Private.NdisPacketOobOffset))->SizeMediaSpecificInfo = (_SizeMediaSpecificInfo);\
  5009. } \
  5010. }
  5011. //
  5012. // packet definition
  5013. //
  5014. typedef struct _NDIS_PACKET
  5015. {
  5016. NDIS_PACKET_PRIVATE Private;
  5017. union
  5018. {
  5019. struct // For Connection-less miniports
  5020. {
  5021. UCHAR MiniportReserved[2*sizeof(PVOID)];
  5022. UCHAR WrapperReserved[2*sizeof(PVOID)];
  5023. };
  5024. struct
  5025. {
  5026. //
  5027. // For de-serialized miniports. And by implication conn-oriented miniports.
  5028. //
  5029. UCHAR MiniportReservedEx[3*sizeof(PVOID)];
  5030. UCHAR WrapperReservedEx[sizeof(PVOID)];
  5031. };
  5032. struct
  5033. {
  5034. UCHAR MacReserved[4*sizeof(PVOID)];
  5035. };
  5036. };
  5037. ULONG_PTR Reserved[2]; // For compatibility with Win95
  5038. UCHAR ProtocolReserved[1];
  5039. } NDIS_PACKET, *PNDIS_PACKET, **PPNDIS_PACKET;
  5040. //
  5041. // NDIS per-packet information.
  5042. //
  5043. typedef enum _NDIS_PER_PACKET_INFO
  5044. {
  5045. TcpIpChecksumPacketInfo,
  5046. IpSecPacketInfo,
  5047. TcpLargeSendPacketInfo,
  5048. ClassificationHandlePacketInfo,
  5049. NdisReserved,
  5050. ScatterGatherListPacketInfo,
  5051. Ieee8021QInfo,
  5052. OriginalPacketInfo,
  5053. PacketCancelId,
  5054. MaxPerPacketInfo
  5055. } NDIS_PER_PACKET_INFO, *PNDIS_PER_PACKET_INFO;
  5056. typedef struct _NDIS_PACKET_EXTENSION
  5057. {
  5058. PVOID NdisPacketInfo[MaxPerPacketInfo];
  5059. } NDIS_PACKET_EXTENSION, *PNDIS_PACKET_EXTENSION;
  5060. #define NDIS_PACKET_EXTENSION_FROM_PACKET(_P) ((PNDIS_PACKET_EXTENSION)((PUCHAR)(_P) + (_P)->Private.NdisPacketOobOffset + sizeof(NDIS_PACKET_OOB_DATA)))
  5061. #define NDIS_PER_PACKET_INFO_FROM_PACKET(_P, _Id) ((PNDIS_PACKET_EXTENSION)((PUCHAR)(_P) + (_P)->Private.NdisPacketOobOffset + sizeof(NDIS_PACKET_OOB_DATA)))->NdisPacketInfo[(_Id)]
  5062. #define NDIS_GET_ORIGINAL_PACKET(_P) NDIS_PER_PACKET_INFO_FROM_PACKET(_P, OriginalPacketInfo)
  5063. #define NDIS_SET_ORIGINAL_PACKET(_P, _OP) NDIS_PER_PACKET_INFO_FROM_PACKET(_P, OriginalPacketInfo) = _OP
  5064. #define NDIS_GET_PACKET_CANCEL_ID(_P) NDIS_PER_PACKET_INFO_FROM_PACKET(_P, PacketCancelId)
  5065. #define NDIS_SET_PACKET_CANCEL_ID(_P, _cId) NDIS_PER_PACKET_INFO_FROM_PACKET(_P, PacketCancelId) = _cId
  5066. typedef struct _NDIS_PACKET_STACK
  5067. {
  5068. ULONG_PTR IMReserved[2];
  5069. ULONG_PTR NdisReserved[4];
  5070. } NDIS_PACKET_STACK, *PNDIS_PACKET_STACK;
  5071. //
  5072. // Per-packet information for TcpIpChecksumPacketInfo.
  5073. //
  5074. typedef struct _NDIS_TCP_IP_CHECKSUM_PACKET_INFO
  5075. {
  5076. union
  5077. {
  5078. struct
  5079. {
  5080. ULONG NdisPacketChecksumV4:1;
  5081. ULONG NdisPacketChecksumV6:1;
  5082. ULONG NdisPacketTcpChecksum:1;
  5083. ULONG NdisPacketUdpChecksum:1;
  5084. ULONG NdisPacketIpChecksum:1;
  5085. } Transmit;
  5086. struct
  5087. {
  5088. ULONG NdisPacketTcpChecksumFailed:1;
  5089. ULONG NdisPacketUdpChecksumFailed:1;
  5090. ULONG NdisPacketIpChecksumFailed:1;
  5091. ULONG NdisPacketTcpChecksumSucceeded:1;
  5092. ULONG NdisPacketUdpChecksumSucceeded:1;
  5093. ULONG NdisPacketIpChecksumSucceeded:1;
  5094. ULONG NdisPacketLoopback:1;
  5095. } Receive;
  5096. ULONG Value;
  5097. };
  5098. } NDIS_TCP_IP_CHECKSUM_PACKET_INFO, *PNDIS_TCP_IP_CHECKSUM_PACKET_INFO;
  5099. //
  5100. // Per-packet information for Ieee8021QInfo.
  5101. //
  5102. typedef struct _NDIS_PACKET_8021Q_INFO
  5103. {
  5104. union
  5105. {
  5106. struct
  5107. {
  5108. UINT32 UserPriority:3; // 802.1p priority
  5109. UINT32 CanonicalFormatId:1; // always 0
  5110. UINT32 VlanId:12; // VLAN Identification
  5111. UINT32 Reserved:16; // set to 0
  5112. } TagHeader;
  5113. PVOID Value;
  5114. };
  5115. } NDIS_PACKET_8021Q_INFO, *PNDIS_PACKET_8021Q_INFO;
  5116. //
  5117. // Old definitions, to be obsoleted.
  5118. //
  5119. #define Ieee8021pPriority Ieee8021QInfo
  5120. typedef UINT IEEE8021PPRIORITY;
  5121. #define MAX_HASHES 4
  5122. #define TRUNCATED_HASH_LEN 12
  5123. #define CRYPTO_SUCCESS 0
  5124. #define CRYPTO_GENERIC_ERROR 1
  5125. #define CRYPTO_TRANSPORT_AH_AUTH_FAILED 2
  5126. #define CRYPTO_TRANSPORT_ESP_AUTH_FAILED 3
  5127. #define CRYPTO_TUNNEL_AH_AUTH_FAILED 4
  5128. #define CRYPTO_TUNNEL_ESP_AUTH_FAILED 5
  5129. #define CRYPTO_INVALID_PACKET_SYNTAX 6
  5130. #define CRYPTO_INVALID_PROTOCOL 7
  5131. typedef struct _NDIS_IPSEC_PACKET_INFO
  5132. {
  5133. union
  5134. {
  5135. struct
  5136. {
  5137. NDIS_HANDLE OffloadHandle;
  5138. NDIS_HANDLE NextOffloadHandle;
  5139. } Transmit;
  5140. struct
  5141. {
  5142. ULONG SA_DELETE_REQ:1;
  5143. ULONG CRYPTO_DONE:1;
  5144. ULONG NEXT_CRYPTO_DONE:1;
  5145. ULONG CryptoStatus;
  5146. } Receive;
  5147. };
  5148. } NDIS_IPSEC_PACKET_INFO, *PNDIS_IPSEC_PACKET_INFO;
  5149. ///
  5150. // NDIS Task Off-Load data structures.
  5151. ///
  5152. #define NDIS_TASK_OFFLOAD_VERSION 1
  5153. //
  5154. // The following defines are used in the Task field above to define
  5155. // the type of task offloading necessary.
  5156. //
  5157. typedef enum _NDIS_TASK
  5158. {
  5159. TcpIpChecksumNdisTask,
  5160. IpSecNdisTask,
  5161. TcpLargeSendNdisTask,
  5162. MaxNdisTask
  5163. } NDIS_TASK, *PNDIS_TASK;
  5164. typedef enum _NDIS_ENCAPSULATION
  5165. {
  5166. UNSPECIFIED_Encapsulation,
  5167. NULL_Encapsulation,
  5168. IEEE_802_3_Encapsulation,
  5169. IEEE_802_5_Encapsulation,
  5170. LLC_SNAP_ROUTED_Encapsulation,
  5171. LLC_SNAP_BRIDGED_Encapsulation
  5172. } NDIS_ENCAPSULATION;
  5173. //
  5174. // Encapsulation header format
  5175. //
  5176. typedef struct _NDIS_ENCAPSULATION_FORMAT
  5177. {
  5178. NDIS_ENCAPSULATION Encapsulation; // Encapsulation type
  5179. struct
  5180. {
  5181. ULONG FixedHeaderSize:1;
  5182. ULONG Reserved:31;
  5183. } Flags;
  5184. ULONG EncapsulationHeaderSize; // Encapsulation header size
  5185. } NDIS_ENCAPSULATION_FORMAT,*PNDIS_ENCAPSULATION_FORMAT;
  5186. //
  5187. // OFFLOAD header structure for OID_TCP_TASK_OFFLOAD
  5188. //
  5189. typedef struct _NDIS_TASK_OFFLOAD_HEADER
  5190. {
  5191. ULONG Version; // set to NDIS_TASK_OFFLOAD_VERSION
  5192. ULONG Size; // Size of this structure
  5193. ULONG Reserved; // Reserved for future use
  5194. ULONG OffsetFirstTask; // Offset to the first
  5195. NDIS_ENCAPSULATION_FORMAT EncapsulationFormat; // Encapsulation information.
  5196. // NDIS_TASK_OFFLOAD structure(s)
  5197. } NDIS_TASK_OFFLOAD_HEADER, *PNDIS_TASK_OFFLOAD_HEADER;
  5198. //
  5199. // Task offload Structure, which follows the above header in ndis query
  5200. //
  5201. typedef struct _NDIS_TASK_OFFLOAD
  5202. {
  5203. ULONG Version; // NDIS_TASK_OFFLOAD_VERSION
  5204. ULONG Size; // Size of this structure. Used for version checking.
  5205. NDIS_TASK Task; // Task.
  5206. ULONG OffsetNextTask; // Offset to the next NDIS_TASK_OFFLOAD
  5207. ULONG TaskBufferLength; // Length of the task offload information.
  5208. UCHAR TaskBuffer[1]; // The task offload information.
  5209. } NDIS_TASK_OFFLOAD, *PNDIS_TASK_OFFLOAD;
  5210. //
  5211. // Offload structure for NDIS_TASK_TCP_IP_CHECKSUM
  5212. //
  5213. typedef struct _NDIS_TASK_TCP_IP_CHECKSUM
  5214. {
  5215. struct
  5216. {
  5217. ULONG IpOptionsSupported:1;
  5218. ULONG TcpOptionsSupported:1;
  5219. ULONG TcpChecksum:1;
  5220. ULONG UdpChecksum:1;
  5221. ULONG IpChecksum:1;
  5222. } V4Transmit;
  5223. struct
  5224. {
  5225. ULONG IpOptionsSupported:1;
  5226. ULONG TcpOptionsSupported:1;
  5227. ULONG TcpChecksum:1;
  5228. ULONG UdpChecksum:1;
  5229. ULONG IpChecksum:1;
  5230. } V4Receive;
  5231. struct
  5232. {
  5233. ULONG IpOptionsSupported:1;
  5234. ULONG TcpOptionsSupported:1;
  5235. ULONG TcpChecksum:1;
  5236. ULONG UdpChecksum:1;
  5237. } V6Transmit;
  5238. struct
  5239. {
  5240. ULONG IpOptionsSupported:1;
  5241. ULONG TcpOptionsSupported:1;
  5242. ULONG TcpChecksum:1;
  5243. ULONG UdpChecksum:1;
  5244. } V6Receive;
  5245. } NDIS_TASK_TCP_IP_CHECKSUM, *PNDIS_TASK_TCP_IP_CHECKSUM;
  5246. //
  5247. // Off-load structure for NDIS_TASK_TCP_LARGE_SEND
  5248. //
  5249. typedef struct _NDIS_TASK_TCP_LARGE_SEND
  5250. {
  5251. ULONG Version;
  5252. ULONG MaxOffLoadSize;
  5253. ULONG MinSegmentCount;
  5254. BOOLEAN TcpOptions;
  5255. BOOLEAN IpOptions;
  5256. } NDIS_TASK_TCP_LARGE_SEND, *PNDIS_TASK_TCP_LARGE_SEND;
  5257. typedef struct _NDIS_TASK_IPSEC
  5258. {
  5259. struct
  5260. {
  5261. ULONG AH_ESP_COMBINED;
  5262. ULONG TRANSPORT_TUNNEL_COMBINED;
  5263. ULONG V4_OPTIONS;
  5264. ULONG RESERVED;
  5265. } Supported;
  5266. struct
  5267. {
  5268. ULONG MD5:1;
  5269. ULONG SHA_1:1;
  5270. ULONG Transport:1;
  5271. ULONG Tunnel:1;
  5272. ULONG Send:1;
  5273. ULONG Receive:1;
  5274. } V4AH;
  5275. struct
  5276. {
  5277. ULONG DES:1;
  5278. ULONG RESERVED:1;
  5279. ULONG TRIPLE_DES:1;
  5280. ULONG NULL_ESP:1;
  5281. ULONG Transport:1;
  5282. ULONG Tunnel:1;
  5283. ULONG Send:1;
  5284. ULONG Receive:1;
  5285. } V4ESP;
  5286. } NDIS_TASK_IPSEC, *PNDIS_TASK_IPSEC;
  5287. #define IPSEC_TPT_UDPESP_ENCAPTYPE_IKE 0x00000001
  5288. #define IPSEC_TUN_UDPESP_ENCAPTYPE_IKE 0x00000002
  5289. #define IPSEC_TPTOVERTUN_UDPESP_ENCAPTYPE_IKE 0x00000004
  5290. #define IPSEC_TPT_UDPESP_OVER_PURE_TUN_ENCAPTYPE_IKE 0x00000008
  5291. #define IPSEC_TPT_UDPESP_ENCAPTYPE_OTHER 0x00000010
  5292. #define IPSEC_TUN_UDPESP_ENCAPTYPE_OTHER 0x00000020
  5293. #define IPSEC_TPTOVERTUN_UDPESP_ENCAPTYPE_OTHER 0x00000040
  5294. #define IPSEC_TPT_UDPESP_OVER_PURE_TUN_ENCAPTYPE_OTHER 0x00000080
  5295. typedef UINT IEEE8021PPRIORITY;
  5296. //
  5297. // WAN Packet. This is used by WAN miniports only. This is the legacy model.
  5298. // Co-Ndis is the preferred model for WAN miniports
  5299. //
  5300. typedef struct _NDIS_WAN_PACKET
  5301. {
  5302. LIST_ENTRY WanPacketQueue;
  5303. PUCHAR CurrentBuffer;
  5304. ULONG CurrentLength;
  5305. PUCHAR StartBuffer;
  5306. PUCHAR EndBuffer;
  5307. PVOID ProtocolReserved1;
  5308. PVOID ProtocolReserved2;
  5309. PVOID ProtocolReserved3;
  5310. PVOID ProtocolReserved4;
  5311. PVOID MacReserved1;
  5312. PVOID MacReserved2;
  5313. PVOID MacReserved3;
  5314. PVOID MacReserved4;
  5315. } NDIS_WAN_PACKET, *PNDIS_WAN_PACKET;
  5316. //
  5317. // Routines to get/set packet flags
  5318. //
  5319. /*++
  5320. UINT
  5321. NdisGetPacketFlags(
  5322. IN PNDIS_PACKET Packet
  5323. );
  5324. --*/
  5325. #define NdisGetPacketFlags(_Packet) (_Packet)->Private.Flags
  5326. /*++
  5327. VOID
  5328. NdisSetPacketFlags(
  5329. IN PNDIS_PACKET Packet,
  5330. IN UINT Flags
  5331. );
  5332. --*/
  5333. #define NdisSetPacketFlags(_Packet, _Flags) (_Packet)->Private.Flags |= (_Flags)
  5334. #define NdisClearPacketFlags(_Packet, _Flags) (_Packet)->Private.Flags &= ~(_Flags)
  5335. //
  5336. // Request types used by NdisRequest; constants are added for
  5337. // all entry points in the MAC, for those that want to create
  5338. // their own internal requests.
  5339. //
  5340. typedef enum _NDIS_REQUEST_TYPE
  5341. {
  5342. NdisRequestQueryInformation,
  5343. NdisRequestSetInformation,
  5344. NdisRequestQueryStatistics,
  5345. NdisRequestOpen,
  5346. NdisRequestClose,
  5347. NdisRequestSend,
  5348. NdisRequestTransferData,
  5349. NdisRequestReset,
  5350. NdisRequestGeneric1,
  5351. NdisRequestGeneric2,
  5352. NdisRequestGeneric3,
  5353. NdisRequestGeneric4
  5354. } NDIS_REQUEST_TYPE, *PNDIS_REQUEST_TYPE;
  5355. //
  5356. // Structure of requests sent via NdisRequest
  5357. //
  5358. typedef struct _NDIS_REQUEST
  5359. {
  5360. UCHAR MacReserved[4*sizeof(PVOID)];
  5361. NDIS_REQUEST_TYPE RequestType;
  5362. union _DATA
  5363. {
  5364. struct _QUERY_INFORMATION
  5365. {
  5366. NDIS_OID Oid;
  5367. PVOID InformationBuffer;
  5368. UINT InformationBufferLength;
  5369. UINT BytesWritten;
  5370. UINT BytesNeeded;
  5371. } QUERY_INFORMATION;
  5372. struct _SET_INFORMATION
  5373. {
  5374. NDIS_OID Oid;
  5375. PVOID InformationBuffer;
  5376. UINT InformationBufferLength;
  5377. UINT BytesRead;
  5378. UINT BytesNeeded;
  5379. } SET_INFORMATION;
  5380. } DATA;
  5381. #if (defined(NDIS50) || defined(NDIS51) || defined(NDIS50_MINIPORT) || defined(NDIS51_MINIPORT))
  5382. UCHAR NdisReserved[9*sizeof(PVOID)];
  5383. union
  5384. {
  5385. UCHAR CallMgrReserved[2*sizeof(PVOID)];
  5386. UCHAR ProtocolReserved[2*sizeof(PVOID)];
  5387. };
  5388. UCHAR MiniportReserved[2*sizeof(PVOID)];
  5389. #endif
  5390. } NDIS_REQUEST, *PNDIS_REQUEST;
  5391. //
  5392. // NDIS Address Family definitions.
  5393. //
  5394. typedef ULONG NDIS_AF, *PNDIS_AF;
  5395. #define CO_ADDRESS_FAMILY_Q2931 ((NDIS_AF)0x1) // ATM
  5396. #define CO_ADDRESS_FAMILY_PSCHED ((NDIS_AF)0x2) // Packet scheduler
  5397. #define CO_ADDRESS_FAMILY_L2TP ((NDIS_AF)0x3)
  5398. #define CO_ADDRESS_FAMILY_IRDA ((NDIS_AF)0x4)
  5399. #define CO_ADDRESS_FAMILY_1394 ((NDIS_AF)0x5)
  5400. #define CO_ADDRESS_FAMILY_PPP ((NDIS_AF)0x6)
  5401. #define CO_ADDRESS_FAMILY_INFINIBAND ((NDIS_AF)0x7)
  5402. #define CO_ADDRESS_FAMILY_TAPI ((NDIS_AF)0x800)
  5403. #define CO_ADDRESS_FAMILY_TAPI_PROXY ((NDIS_AF)0x801)
  5404. //
  5405. // The following is OR'ed with the base AF to denote proxy support
  5406. //
  5407. #define CO_ADDRESS_FAMILY_PROXY 0x80000000
  5408. //
  5409. // Address family structure registered/opened via
  5410. // NdisCmRegisterAddressFamily
  5411. // NdisClOpenAddressFamily
  5412. //
  5413. typedef struct
  5414. {
  5415. NDIS_AF AddressFamily; // one of the CO_ADDRESS_FAMILY_xxx values above
  5416. ULONG MajorVersion; // the major version of call manager
  5417. ULONG MinorVersion; // the minor version of call manager
  5418. } CO_ADDRESS_FAMILY, *PCO_ADDRESS_FAMILY;
  5419. //
  5420. // Definition for a SAP
  5421. //
  5422. typedef struct
  5423. {
  5424. ULONG SapType;
  5425. ULONG SapLength;
  5426. UCHAR Sap[1];
  5427. } CO_SAP, *PCO_SAP;
  5428. //
  5429. // Definitions for physical address.
  5430. //
  5431. typedef PHYSICAL_ADDRESS NDIS_PHYSICAL_ADDRESS, *PNDIS_PHYSICAL_ADDRESS;
  5432. typedef struct _NDIS_PHYSICAL_ADDRESS_UNIT
  5433. {
  5434. NDIS_PHYSICAL_ADDRESS PhysicalAddress;
  5435. UINT Length;
  5436. } NDIS_PHYSICAL_ADDRESS_UNIT, *PNDIS_PHYSICAL_ADDRESS_UNIT;
  5437. /*++
  5438. ULONG
  5439. NdisGetPhysicalAddressHigh(
  5440. IN NDIS_PHYSICAL_ADDRESS PhysicalAddress
  5441. );
  5442. --*/
  5443. #define NdisGetPhysicalAddressHigh(_PhysicalAddress) \
  5444. ((_PhysicalAddress).HighPart)
  5445. /*++
  5446. VOID
  5447. NdisSetPhysicalAddressHigh(
  5448. IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
  5449. IN ULONG Value
  5450. );
  5451. --*/
  5452. #define NdisSetPhysicalAddressHigh(_PhysicalAddress, _Value) \
  5453. ((_PhysicalAddress).HighPart) = (_Value)
  5454. /*++
  5455. ULONG
  5456. NdisGetPhysicalAddressLow(
  5457. IN NDIS_PHYSICAL_ADDRESS PhysicalAddress
  5458. );
  5459. --*/
  5460. #define NdisGetPhysicalAddressLow(_PhysicalAddress) \
  5461. ((_PhysicalAddress).LowPart)
  5462. /*++
  5463. VOID
  5464. NdisSetPhysicalAddressLow(
  5465. IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
  5466. IN ULONG Value
  5467. );
  5468. --*/
  5469. #define NdisSetPhysicalAddressLow(_PhysicalAddress, _Value) \
  5470. ((_PhysicalAddress).LowPart) = (_Value)
  5471. //
  5472. // Macro to initialize an NDIS_PHYSICAL_ADDRESS constant
  5473. //
  5474. #define NDIS_PHYSICAL_ADDRESS_CONST(_Low, _High) \
  5475. { (ULONG)(_Low), (LONG)(_High) }
  5476. //
  5477. // block used for references...
  5478. //
  5479. typedef struct _REFERENCE
  5480. {
  5481. KSPIN_LOCK SpinLock;
  5482. USHORT ReferenceCount;
  5483. BOOLEAN Closing;
  5484. } REFERENCE, * PREFERENCE;
  5485. //
  5486. // block used for references using a ULONG
  5487. //
  5488. typedef struct _ULONG_REFERENCE
  5489. {
  5490. KSPIN_LOCK SpinLock;
  5491. ULONG ReferenceCount;
  5492. BOOLEAN Closing;
  5493. } ULONG_REFERENCE, *PULONG_REFERENCE;
  5494. //
  5495. // Types of Memory (not mutually exclusive)
  5496. //
  5497. #define NDIS_MEMORY_CONTIGUOUS 0x00000001
  5498. #define NDIS_MEMORY_NONCACHED 0x00000002
  5499. //
  5500. // Open options
  5501. //
  5502. #define NDIS_OPEN_RECEIVE_NOT_REENTRANT 0x00000001
  5503. //
  5504. // NDIS_STATUS values
  5505. //
  5506. #define NDIS_STATUS_SUCCESS ((NDIS_STATUS)STATUS_SUCCESS)
  5507. #define NDIS_STATUS_PENDING ((NDIS_STATUS) STATUS_PENDING)
  5508. #define NDIS_STATUS_NOT_RECOGNIZED ((NDIS_STATUS)0x00010001L)
  5509. #define NDIS_STATUS_NOT_COPIED ((NDIS_STATUS)0x00010002L)
  5510. #define NDIS_STATUS_NOT_ACCEPTED ((NDIS_STATUS)0x00010003L)
  5511. #define NDIS_STATUS_CALL_ACTIVE ((NDIS_STATUS)0x00010007L)
  5512. #define NDIS_STATUS_ONLINE ((NDIS_STATUS)0x40010003L)
  5513. #define NDIS_STATUS_RESET_START ((NDIS_STATUS)0x40010004L)
  5514. #define NDIS_STATUS_RESET_END ((NDIS_STATUS)0x40010005L)
  5515. #define NDIS_STATUS_RING_STATUS ((NDIS_STATUS)0x40010006L)
  5516. #define NDIS_STATUS_CLOSED ((NDIS_STATUS)0x40010007L)
  5517. #define NDIS_STATUS_WAN_LINE_UP ((NDIS_STATUS)0x40010008L)
  5518. #define NDIS_STATUS_WAN_LINE_DOWN ((NDIS_STATUS)0x40010009L)
  5519. #define NDIS_STATUS_WAN_FRAGMENT ((NDIS_STATUS)0x4001000AL)
  5520. #define NDIS_STATUS_MEDIA_CONNECT ((NDIS_STATUS)0x4001000BL)
  5521. #define NDIS_STATUS_MEDIA_DISCONNECT ((NDIS_STATUS)0x4001000CL)
  5522. #define NDIS_STATUS_HARDWARE_LINE_UP ((NDIS_STATUS)0x4001000DL)
  5523. #define NDIS_STATUS_HARDWARE_LINE_DOWN ((NDIS_STATUS)0x4001000EL)
  5524. #define NDIS_STATUS_INTERFACE_UP ((NDIS_STATUS)0x4001000FL)
  5525. #define NDIS_STATUS_INTERFACE_DOWN ((NDIS_STATUS)0x40010010L)
  5526. #define NDIS_STATUS_MEDIA_BUSY ((NDIS_STATUS)0x40010011L)
  5527. #define NDIS_STATUS_MEDIA_SPECIFIC_INDICATION ((NDIS_STATUS)0x40010012L)
  5528. #define NDIS_STATUS_WW_INDICATION NDIS_STATUS_MEDIA_SPECIFIC_INDICATION
  5529. #define NDIS_STATUS_LINK_SPEED_CHANGE ((NDIS_STATUS)0x40010013L)
  5530. #define NDIS_STATUS_WAN_GET_STATS ((NDIS_STATUS)0x40010014L)
  5531. #define NDIS_STATUS_WAN_CO_FRAGMENT ((NDIS_STATUS)0x40010015L)
  5532. #define NDIS_STATUS_WAN_CO_LINKPARAMS ((NDIS_STATUS)0x40010016L)
  5533. #define NDIS_STATUS_NOT_RESETTABLE ((NDIS_STATUS)0x80010001L)
  5534. #define NDIS_STATUS_SOFT_ERRORS ((NDIS_STATUS)0x80010003L)
  5535. #define NDIS_STATUS_HARD_ERRORS ((NDIS_STATUS)0x80010004L)
  5536. #define NDIS_STATUS_BUFFER_OVERFLOW ((NDIS_STATUS)STATUS_BUFFER_OVERFLOW)
  5537. #define NDIS_STATUS_FAILURE ((NDIS_STATUS) STATUS_UNSUCCESSFUL)
  5538. #define NDIS_STATUS_RESOURCES ((NDIS_STATUS)STATUS_INSUFFICIENT_RESOURCES)
  5539. #define NDIS_STATUS_CLOSING ((NDIS_STATUS)0xC0010002L)
  5540. #define NDIS_STATUS_BAD_VERSION ((NDIS_STATUS)0xC0010004L)
  5541. #define NDIS_STATUS_BAD_CHARACTERISTICS ((NDIS_STATUS)0xC0010005L)
  5542. #define NDIS_STATUS_ADAPTER_NOT_FOUND ((NDIS_STATUS)0xC0010006L)
  5543. #define NDIS_STATUS_OPEN_FAILED ((NDIS_STATUS)0xC0010007L)
  5544. #define NDIS_STATUS_DEVICE_FAILED ((NDIS_STATUS)0xC0010008L)
  5545. #define NDIS_STATUS_MULTICAST_FULL ((NDIS_STATUS)0xC0010009L)
  5546. #define NDIS_STATUS_MULTICAST_EXISTS ((NDIS_STATUS)0xC001000AL)
  5547. #define NDIS_STATUS_MULTICAST_NOT_FOUND ((NDIS_STATUS)0xC001000BL)
  5548. #define NDIS_STATUS_REQUEST_ABORTED ((NDIS_STATUS)0xC001000CL)
  5549. #define NDIS_STATUS_RESET_IN_PROGRESS ((NDIS_STATUS)0xC001000DL)
  5550. #define NDIS_STATUS_CLOSING_INDICATING ((NDIS_STATUS)0xC001000EL)
  5551. #define NDIS_STATUS_NOT_SUPPORTED ((NDIS_STATUS)STATUS_NOT_SUPPORTED)
  5552. #define NDIS_STATUS_INVALID_PACKET ((NDIS_STATUS)0xC001000FL)
  5553. #define NDIS_STATUS_OPEN_LIST_FULL ((NDIS_STATUS)0xC0010010L)
  5554. #define NDIS_STATUS_ADAPTER_NOT_READY ((NDIS_STATUS)0xC0010011L)
  5555. #define NDIS_STATUS_ADAPTER_NOT_OPEN ((NDIS_STATUS)0xC0010012L)
  5556. #define NDIS_STATUS_NOT_INDICATING ((NDIS_STATUS)0xC0010013L)
  5557. #define NDIS_STATUS_INVALID_LENGTH ((NDIS_STATUS)0xC0010014L)
  5558. #define NDIS_STATUS_INVALID_DATA ((NDIS_STATUS)0xC0010015L)
  5559. #define NDIS_STATUS_BUFFER_TOO_SHORT ((NDIS_STATUS)0xC0010016L)
  5560. #define NDIS_STATUS_INVALID_OID ((NDIS_STATUS)0xC0010017L)
  5561. #define NDIS_STATUS_ADAPTER_REMOVED ((NDIS_STATUS)0xC0010018L)
  5562. #define NDIS_STATUS_UNSUPPORTED_MEDIA ((NDIS_STATUS)0xC0010019L)
  5563. #define NDIS_STATUS_GROUP_ADDRESS_IN_USE ((NDIS_STATUS)0xC001001AL)
  5564. #define NDIS_STATUS_FILE_NOT_FOUND ((NDIS_STATUS)0xC001001BL)
  5565. #define NDIS_STATUS_ERROR_READING_FILE ((NDIS_STATUS)0xC001001CL)
  5566. #define NDIS_STATUS_ALREADY_MAPPED ((NDIS_STATUS)0xC001001DL)
  5567. #define NDIS_STATUS_RESOURCE_CONFLICT ((NDIS_STATUS)0xC001001EL)
  5568. #define NDIS_STATUS_NO_CABLE ((NDIS_STATUS)0xC001001FL)
  5569. #define NDIS_STATUS_INVALID_SAP ((NDIS_STATUS)0xC0010020L)
  5570. #define NDIS_STATUS_SAP_IN_USE ((NDIS_STATUS)0xC0010021L)
  5571. #define NDIS_STATUS_INVALID_ADDRESS ((NDIS_STATUS)0xC0010022L)
  5572. #define NDIS_STATUS_VC_NOT_ACTIVATED ((NDIS_STATUS)0xC0010023L)
  5573. #define NDIS_STATUS_DEST_OUT_OF_ORDER ((NDIS_STATUS)0xC0010024L) // cause 27
  5574. #define NDIS_STATUS_VC_NOT_AVAILABLE ((NDIS_STATUS)0xC0010025L) // cause 35,45
  5575. #define NDIS_STATUS_CELLRATE_NOT_AVAILABLE ((NDIS_STATUS)0xC0010026L) // cause 37
  5576. #define NDIS_STATUS_INCOMPATABLE_QOS ((NDIS_STATUS)0xC0010027L) // cause 49
  5577. #define NDIS_STATUS_AAL_PARAMS_UNSUPPORTED ((NDIS_STATUS)0xC0010028L) // cause 93
  5578. #define NDIS_STATUS_NO_ROUTE_TO_DESTINATION ((NDIS_STATUS)0xC0010029L) // cause 3
  5579. #define NDIS_STATUS_TOKEN_RING_OPEN_ERROR ((NDIS_STATUS)0xC0011000L)
  5580. #define NDIS_STATUS_INVALID_DEVICE_REQUEST ((NDIS_STATUS)STATUS_INVALID_DEVICE_REQUEST)
  5581. #define NDIS_STATUS_NETWORK_UNREACHABLE ((NDIS_STATUS)STATUS_NETWORK_UNREACHABLE)
  5582. //
  5583. // used in error logging
  5584. //
  5585. #define NDIS_ERROR_CODE ULONG
  5586. #define NDIS_ERROR_CODE_RESOURCE_CONFLICT EVENT_NDIS_RESOURCE_CONFLICT
  5587. #define NDIS_ERROR_CODE_OUT_OF_RESOURCES EVENT_NDIS_OUT_OF_RESOURCE
  5588. #define NDIS_ERROR_CODE_HARDWARE_FAILURE EVENT_NDIS_HARDWARE_FAILURE
  5589. #define NDIS_ERROR_CODE_ADAPTER_NOT_FOUND EVENT_NDIS_ADAPTER_NOT_FOUND
  5590. #define NDIS_ERROR_CODE_INTERRUPT_CONNECT EVENT_NDIS_INTERRUPT_CONNECT
  5591. #define NDIS_ERROR_CODE_DRIVER_FAILURE EVENT_NDIS_DRIVER_FAILURE
  5592. #define NDIS_ERROR_CODE_BAD_VERSION EVENT_NDIS_BAD_VERSION
  5593. #define NDIS_ERROR_CODE_TIMEOUT EVENT_NDIS_TIMEOUT
  5594. #define NDIS_ERROR_CODE_NETWORK_ADDRESS EVENT_NDIS_NETWORK_ADDRESS
  5595. #define NDIS_ERROR_CODE_UNSUPPORTED_CONFIGURATION EVENT_NDIS_UNSUPPORTED_CONFIGURATION
  5596. #define NDIS_ERROR_CODE_INVALID_VALUE_FROM_ADAPTER EVENT_NDIS_INVALID_VALUE_FROM_ADAPTER
  5597. #define NDIS_ERROR_CODE_MISSING_CONFIGURATION_PARAMETER EVENT_NDIS_MISSING_CONFIGURATION_PARAMETER
  5598. #define NDIS_ERROR_CODE_BAD_IO_BASE_ADDRESS EVENT_NDIS_BAD_IO_BASE_ADDRESS
  5599. #define NDIS_ERROR_CODE_RECEIVE_SPACE_SMALL EVENT_NDIS_RECEIVE_SPACE_SMALL
  5600. #define NDIS_ERROR_CODE_ADAPTER_DISABLED EVENT_NDIS_ADAPTER_DISABLED
  5601. #if BINARY_COMPATIBLE
  5602. #if USE_KLOCKS
  5603. #define DISPATCH_LEVEL 2
  5604. #define NdisAllocateSpinLock(_SpinLock) KeInitializeSpinLock(&(_SpinLock)->SpinLock)
  5605. #define NdisFreeSpinLock(_SpinLock)
  5606. #define NdisAcquireSpinLock(_SpinLock) KeAcquireSpinLock(&(_SpinLock)->SpinLock, &(_SpinLock)->OldIrql)
  5607. #define NdisReleaseSpinLock(_SpinLock) KeReleaseSpinLock(&(_SpinLock)->SpinLock,(_SpinLock)->OldIrql)
  5608. #define NdisDprAcquireSpinLock(_SpinLock) \
  5609. { \
  5610. KeAcquireSpinLockAtDpcLevel(&(_SpinLock)->SpinLock); \
  5611. (_SpinLock)->OldIrql = DISPATCH_LEVEL; \
  5612. }
  5613. #define NdisDprReleaseSpinLock(_SpinLock) KeReleaseSpinLockFromDpcLevel(&(_SpinLock)->SpinLock)
  5614. #else
  5615. //
  5616. // Ndis Spin Locks
  5617. //
  5618. EXPORT
  5619. VOID
  5620. NdisAllocateSpinLock(
  5621. IN PNDIS_SPIN_LOCK SpinLock
  5622. );
  5623. EXPORT
  5624. VOID
  5625. NdisFreeSpinLock(
  5626. IN PNDIS_SPIN_LOCK SpinLock
  5627. );
  5628. EXPORT
  5629. VOID
  5630. NdisAcquireSpinLock(
  5631. IN PNDIS_SPIN_LOCK SpinLock
  5632. );
  5633. EXPORT
  5634. VOID
  5635. NdisReleaseSpinLock(
  5636. IN PNDIS_SPIN_LOCK SpinLock
  5637. );
  5638. EXPORT
  5639. VOID
  5640. NdisDprAcquireSpinLock(
  5641. IN PNDIS_SPIN_LOCK SpinLock
  5642. );
  5643. EXPORT
  5644. VOID
  5645. NdisDprReleaseSpinLock(
  5646. IN PNDIS_SPIN_LOCK SpinLock
  5647. );
  5648. #endif
  5649. EXPORT
  5650. VOID
  5651. NdisGetCurrentSystemTime(
  5652. PLARGE_INTEGER pSystemTime
  5653. );
  5654. //
  5655. // Interlocked support functions
  5656. //
  5657. EXPORT
  5658. LONG
  5659. NdisInterlockedIncrement(
  5660. IN PLONG Addend
  5661. );
  5662. EXPORT
  5663. LONG
  5664. NdisInterlockedDecrement(
  5665. IN PLONG Addend
  5666. );
  5667. EXPORT
  5668. VOID
  5669. NdisInterlockedAddUlong(
  5670. IN PULONG Addend,
  5671. IN ULONG Increment,
  5672. IN PNDIS_SPIN_LOCK SpinLock
  5673. );
  5674. EXPORT
  5675. PLIST_ENTRY
  5676. NdisInterlockedInsertHeadList(
  5677. IN PLIST_ENTRY ListHead,
  5678. IN PLIST_ENTRY ListEntry,
  5679. IN PNDIS_SPIN_LOCK SpinLock
  5680. );
  5681. EXPORT
  5682. PLIST_ENTRY
  5683. NdisInterlockedInsertTailList(
  5684. IN PLIST_ENTRY ListHead,
  5685. IN PLIST_ENTRY ListEntry,
  5686. IN PNDIS_SPIN_LOCK SpinLock
  5687. );
  5688. EXPORT
  5689. PLIST_ENTRY
  5690. NdisInterlockedRemoveHeadList(
  5691. IN PLIST_ENTRY ListHead,
  5692. IN PNDIS_SPIN_LOCK SpinLock
  5693. );
  5694. EXPORT
  5695. LARGE_INTEGER
  5696. NdisInterlockedAddLargeInteger(
  5697. IN PLARGE_INTEGER Addend,
  5698. IN ULONG Increment,
  5699. IN PKSPIN_LOCK Lock
  5700. );
  5701. #else // BINARY_COMPATIBLE
  5702. #define NdisAllocateSpinLock(_SpinLock) KeInitializeSpinLock(&(_SpinLock)->SpinLock)
  5703. #define NdisFreeSpinLock(_SpinLock)
  5704. #define NdisAcquireSpinLock(_SpinLock) KeAcquireSpinLock(&(_SpinLock)->SpinLock, &(_SpinLock)->OldIrql)
  5705. #define NdisReleaseSpinLock(_SpinLock) KeReleaseSpinLock(&(_SpinLock)->SpinLock,(_SpinLock)->OldIrql)
  5706. #define NdisDprAcquireSpinLock(_SpinLock) \
  5707. { \
  5708. KeAcquireSpinLockAtDpcLevel(&(_SpinLock)->SpinLock); \
  5709. (_SpinLock)->OldIrql = DISPATCH_LEVEL; \
  5710. }
  5711. #define NdisDprReleaseSpinLock(_SpinLock) KeReleaseSpinLockFromDpcLevel(&(_SpinLock)->SpinLock)
  5712. #define NdisGetCurrentSystemTime(_pSystemTime) \
  5713. { \
  5714. KeQuerySystemTime(_pSystemTime); \
  5715. }
  5716. //
  5717. // Interlocked support functions
  5718. //
  5719. #define NdisInterlockedIncrement(Addend) InterlockedIncrement(Addend)
  5720. #define NdisInterlockedDecrement(Addend) InterlockedDecrement(Addend)
  5721. #define NdisInterlockedAddUlong(_Addend, _Increment, _SpinLock) \
  5722. ExInterlockedAddUlong(_Addend, _Increment, &(_SpinLock)->SpinLock)
  5723. #define NdisInterlockedInsertHeadList(_ListHead, _ListEntry, _SpinLock) \
  5724. ExInterlockedInsertHeadList(_ListHead, _ListEntry, &(_SpinLock)->SpinLock)
  5725. #define NdisInterlockedInsertTailList(_ListHead, _ListEntry, _SpinLock) \
  5726. ExInterlockedInsertTailList(_ListHead, _ListEntry, &(_SpinLock)->SpinLock)
  5727. #define NdisInterlockedRemoveHeadList(_ListHead, _SpinLock) \
  5728. ExInterlockedRemoveHeadList(_ListHead, &(_SpinLock)->SpinLock)
  5729. #define NdisInterlockedPushEntryList(ListHead, ListEntry, Lock) \
  5730. ExInterlockedPushEntryList(ListHead, ListEntry, &(Lock)->SpinLock)
  5731. #define NdisInterlockedPopEntryList(ListHead, Lock) \
  5732. ExInterlockedPopEntryList(ListHead, &(Lock)->SpinLock)
  5733. #endif // BINARY_COMPATIBLE
  5734. #ifndef MAXIMUM_PROCESSORS
  5735. #ifdef _WIN64
  5736. #define MAXIMUM_PROCESSORS 64
  5737. #else
  5738. #define MAXIMUM_PROCESSORS 32
  5739. #endif
  5740. #endif
  5741. typedef union _NDIS_RW_LOCK_REFCOUNT
  5742. {
  5743. UINT RefCount;
  5744. UCHAR cacheLine[16]; // One refCount per cache line
  5745. } NDIS_RW_LOCK_REFCOUNT;
  5746. typedef struct _NDIS_RW_LOCK
  5747. {
  5748. union
  5749. {
  5750. struct
  5751. {
  5752. KSPIN_LOCK SpinLock;
  5753. PVOID Context;
  5754. };
  5755. UCHAR Reserved[16];
  5756. };
  5757. NDIS_RW_LOCK_REFCOUNT RefCount[MAXIMUM_PROCESSORS];
  5758. } NDIS_RW_LOCK, *PNDIS_RW_LOCK;
  5759. typedef struct _LOCK_STATE
  5760. {
  5761. USHORT LockState;
  5762. KIRQL OldIrql;
  5763. } LOCK_STATE, *PLOCK_STATE;
  5764. EXPORT
  5765. VOID
  5766. NdisInitializeReadWriteLock(
  5767. IN PNDIS_RW_LOCK Lock
  5768. );
  5769. EXPORT
  5770. VOID
  5771. NdisAcquireReadWriteLock(
  5772. IN PNDIS_RW_LOCK Lock,
  5773. IN BOOLEAN fWrite, // TRUE -> Write, FALSE -> Read
  5774. IN PLOCK_STATE LockState
  5775. );
  5776. EXPORT
  5777. VOID
  5778. NdisReleaseReadWriteLock(
  5779. IN PNDIS_RW_LOCK Lock,
  5780. IN PLOCK_STATE LockState
  5781. );
  5782. #define NdisInterlockedAddLargeStatistic(_Addend, _Increment) \
  5783. ExInterlockedAddLargeStatistic((PLARGE_INTEGER)_Addend, _Increment)
  5784. //
  5785. // S-List support
  5786. //
  5787. #define NdisInterlockedPushEntrySList(SListHead, SListEntry, Lock) \
  5788. ExInterlockedPushEntrySList(SListHead, SListEntry, &(Lock)->SpinLock)
  5789. #define NdisInterlockedPopEntrySList(SListHead, Lock) \
  5790. ExInterlockedPopEntrySList(SListHead, &(Lock)->SpinLock)
  5791. #define NdisInterlockedFlushSList(SListHead) ExInterlockedFlushSList(SListHead)
  5792. #define NdisInitializeSListHead(SListHead) ExInitializeSListHead(SListHead)
  5793. #define NdisQueryDepthSList(SListHead) ExQueryDepthSList(SListHead)
  5794. EXPORT
  5795. VOID
  5796. NdisGetCurrentProcessorCpuUsage(
  5797. OUT PULONG pCpuUsage
  5798. );
  5799. EXPORT
  5800. VOID
  5801. NdisGetCurrentProcessorCounts(
  5802. OUT PULONG pIdleCount,
  5803. OUT PULONG pKernelAndUser,
  5804. OUT PULONG pIndex
  5805. );
  5806. EXPORT
  5807. VOID
  5808. NdisGetSystemUpTime(
  5809. OUT PULONG pSystemUpTime
  5810. );
  5811. //
  5812. // List manipulation
  5813. //
  5814. /*++
  5815. VOID
  5816. NdisInitializeListHead(
  5817. IN PLIST_ENTRY ListHead
  5818. );
  5819. --*/
  5820. #define NdisInitializeListHead(_ListHead) InitializeListHead(_ListHead)
  5821. //
  5822. // Configuration Requests
  5823. //
  5824. EXPORT
  5825. VOID
  5826. NdisOpenConfiguration(
  5827. OUT PNDIS_STATUS Status,
  5828. OUT PNDIS_HANDLE ConfigurationHandle,
  5829. IN NDIS_HANDLE WrapperConfigurationContext
  5830. );
  5831. EXPORT
  5832. VOID
  5833. NdisOpenConfigurationKeyByName(
  5834. OUT PNDIS_STATUS Status,
  5835. IN NDIS_HANDLE ConfigurationHandle,
  5836. IN PNDIS_STRING SubKeyName,
  5837. OUT PNDIS_HANDLE SubKeyHandle
  5838. );
  5839. EXPORT
  5840. VOID
  5841. NdisOpenConfigurationKeyByIndex(
  5842. OUT PNDIS_STATUS Status,
  5843. IN NDIS_HANDLE ConfigurationHandle,
  5844. IN ULONG Index,
  5845. OUT PNDIS_STRING KeyName,
  5846. OUT PNDIS_HANDLE KeyHandle
  5847. );
  5848. EXPORT
  5849. VOID
  5850. NdisReadConfiguration(
  5851. OUT PNDIS_STATUS Status,
  5852. OUT PNDIS_CONFIGURATION_PARAMETER *ParameterValue,
  5853. IN NDIS_HANDLE ConfigurationHandle,
  5854. IN PNDIS_STRING Keyword,
  5855. IN NDIS_PARAMETER_TYPE ParameterType
  5856. );
  5857. EXPORT
  5858. VOID
  5859. NdisWriteConfiguration(
  5860. OUT PNDIS_STATUS Status,
  5861. IN NDIS_HANDLE ConfigurationHandle,
  5862. IN PNDIS_STRING Keyword,
  5863. IN PNDIS_CONFIGURATION_PARAMETER ParameterValue
  5864. );
  5865. EXPORT
  5866. VOID
  5867. NdisCloseConfiguration(
  5868. IN NDIS_HANDLE ConfigurationHandle
  5869. );
  5870. EXPORT
  5871. VOID
  5872. NdisReadNetworkAddress(
  5873. OUT PNDIS_STATUS Status,
  5874. OUT PVOID * NetworkAddress,
  5875. OUT PUINT NetworkAddressLength,
  5876. IN NDIS_HANDLE ConfigurationHandle
  5877. );
  5878. EXPORT
  5879. VOID
  5880. NdisReadEisaSlotInformation(
  5881. OUT PNDIS_STATUS Status,
  5882. IN NDIS_HANDLE WrapperConfigurationContext,
  5883. OUT PUINT SlotNumber,
  5884. OUT PNDIS_EISA_FUNCTION_INFORMATION EisaData
  5885. );
  5886. EXPORT
  5887. VOID
  5888. NdisReadEisaSlotInformationEx(
  5889. OUT PNDIS_STATUS Status,
  5890. IN NDIS_HANDLE WrapperConfigurationContext,
  5891. OUT PUINT SlotNumber,
  5892. OUT PNDIS_EISA_FUNCTION_INFORMATION *EisaData,
  5893. OUT PUINT NumberOfFunctions
  5894. );
  5895. EXPORT
  5896. ULONG
  5897. NdisReadPciSlotInformation(
  5898. IN NDIS_HANDLE NdisAdapterHandle,
  5899. IN ULONG SlotNumber,
  5900. IN ULONG Offset,
  5901. IN PVOID Buffer,
  5902. IN ULONG Length
  5903. );
  5904. EXPORT
  5905. ULONG
  5906. NdisWritePciSlotInformation(
  5907. IN NDIS_HANDLE NdisAdapterHandle,
  5908. IN ULONG SlotNumber,
  5909. IN ULONG Offset,
  5910. IN PVOID Buffer,
  5911. IN ULONG Length
  5912. );
  5913. EXPORT
  5914. ULONG
  5915. NdisReadPcmciaAttributeMemory(
  5916. IN NDIS_HANDLE NdisAdapterHandle,
  5917. IN ULONG Offset,
  5918. IN PVOID Buffer,
  5919. IN ULONG Length
  5920. );
  5921. EXPORT
  5922. ULONG
  5923. NdisWritePcmciaAttributeMemory(
  5924. IN NDIS_HANDLE NdisAdapterHandle,
  5925. IN ULONG Offset,
  5926. IN PVOID Buffer,
  5927. IN ULONG Length
  5928. );
  5929. //
  5930. // Buffer Pool
  5931. //
  5932. EXPORT
  5933. VOID
  5934. NdisAllocateBufferPool(
  5935. OUT PNDIS_STATUS Status,
  5936. OUT PNDIS_HANDLE PoolHandle,
  5937. IN UINT NumberOfDescriptors
  5938. );
  5939. EXPORT
  5940. VOID
  5941. NdisFreeBufferPool(
  5942. IN NDIS_HANDLE PoolHandle
  5943. );
  5944. EXPORT
  5945. VOID
  5946. NdisAllocateBuffer(
  5947. OUT PNDIS_STATUS Status,
  5948. OUT PNDIS_BUFFER * Buffer,
  5949. IN NDIS_HANDLE PoolHandle,
  5950. IN PVOID VirtualAddress,
  5951. IN UINT Length
  5952. );
  5953. EXPORT
  5954. VOID
  5955. NdisCopyBuffer(
  5956. OUT PNDIS_STATUS Status,
  5957. OUT PNDIS_BUFFER * Buffer,
  5958. IN NDIS_HANDLE PoolHandle,
  5959. IN PVOID MemoryDescriptor,
  5960. IN UINT Offset,
  5961. IN UINT Length
  5962. );
  5963. //
  5964. // VOID
  5965. // NdisCopyLookaheadData(
  5966. // IN PVOID Destination,
  5967. // IN PVOID Source,
  5968. // IN ULONG Length,
  5969. // IN ULONG ReceiveFlags
  5970. // );
  5971. //
  5972. #if defined(_M_IX86) || defined(_M_AMD64)
  5973. #define NdisCopyLookaheadData(_Destination, _Source, _Length, _MacOptions) \
  5974. RtlCopyMemory(_Destination, _Source, _Length)
  5975. #else
  5976. #define NdisCopyLookaheadData(_Destination, _Source, _Length, _MacOptions) \
  5977. { \
  5978. if ((_MacOptions) & NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA) \
  5979. { \
  5980. RtlCopyMemory(_Destination, _Source, _Length); \
  5981. } \
  5982. else \
  5983. { \
  5984. PUCHAR _Src = (PUCHAR)(_Source); \
  5985. PUCHAR _Dest = (PUCHAR)(_Destination); \
  5986. PUCHAR _End = _Dest + (_Length); \
  5987. while (_Dest < _End) \
  5988. { \
  5989. *_Dest++ = *_Src++; \
  5990. } \
  5991. } \
  5992. }
  5993. #endif
  5994. //
  5995. // Packet Pool
  5996. //
  5997. EXPORT
  5998. VOID
  5999. NdisAllocatePacketPool(
  6000. OUT PNDIS_STATUS Status,
  6001. OUT PNDIS_HANDLE PoolHandle,
  6002. IN UINT NumberOfDescriptors,
  6003. IN UINT ProtocolReservedLength
  6004. );
  6005. EXPORT
  6006. VOID
  6007. NdisAllocatePacketPoolEx(
  6008. OUT PNDIS_STATUS Status,
  6009. OUT PNDIS_HANDLE PoolHandle,
  6010. IN UINT NumberOfDescriptors,
  6011. IN UINT NumberOfOverflowDescriptors,
  6012. IN UINT ProtocolReservedLength
  6013. );
  6014. EXPORT
  6015. VOID
  6016. NdisSetPacketPoolProtocolId(
  6017. IN NDIS_HANDLE PacketPoolHandle,
  6018. IN UINT ProtocolId
  6019. );
  6020. EXPORT
  6021. UINT
  6022. NdisPacketPoolUsage(
  6023. IN NDIS_HANDLE PoolHandle
  6024. );
  6025. EXPORT
  6026. UINT
  6027. NdisPacketSize(
  6028. IN UINT ProtocolReservedSize
  6029. );
  6030. EXPORT
  6031. NDIS_HANDLE
  6032. NdisGetPoolFromPacket(
  6033. IN PNDIS_PACKET Packet
  6034. );
  6035. EXPORT
  6036. PNDIS_PACKET_STACK
  6037. NdisIMGetCurrentPacketStack(
  6038. IN PNDIS_PACKET Packet,
  6039. OUT BOOLEAN * StacksRemaining
  6040. );
  6041. EXPORT
  6042. VOID
  6043. NdisFreePacketPool(
  6044. IN NDIS_HANDLE PoolHandle
  6045. );
  6046. EXPORT
  6047. VOID
  6048. NdisFreePacket(
  6049. IN PNDIS_PACKET Packet
  6050. );
  6051. EXPORT
  6052. VOID
  6053. NdisDprFreePacket(
  6054. IN PNDIS_PACKET Packet
  6055. );
  6056. EXPORT
  6057. VOID
  6058. NdisDprFreePacketNonInterlocked(
  6059. IN PNDIS_PACKET Packet
  6060. );
  6061. EXPORT
  6062. VOID
  6063. NdisAllocatePacket(
  6064. OUT PNDIS_STATUS Status,
  6065. OUT PNDIS_PACKET * Packet,
  6066. IN NDIS_HANDLE PoolHandle
  6067. );
  6068. EXPORT
  6069. VOID
  6070. NdisDprAllocatePacket(
  6071. OUT PNDIS_STATUS Status,
  6072. OUT PNDIS_PACKET * Packet,
  6073. IN NDIS_HANDLE PoolHandle
  6074. );
  6075. EXPORT
  6076. VOID
  6077. NdisDprAllocatePacketNonInterlocked(
  6078. OUT PNDIS_STATUS Status,
  6079. OUT PNDIS_PACKET * Packet,
  6080. IN NDIS_HANDLE PoolHandle
  6081. );
  6082. // VOID
  6083. // NdisReinitializePacket(
  6084. // IN OUT PNDIS_PACKET Packet
  6085. // );
  6086. #define NdisReinitializePacket(Packet) \
  6087. { \
  6088. (Packet)->Private.Head = (PNDIS_BUFFER)NULL; \
  6089. (Packet)->Private.ValidCounts = FALSE; \
  6090. }
  6091. //
  6092. // Block Pool APIs
  6093. //
  6094. typedef
  6095. VOID
  6096. (__stdcall *NDIS_BLOCK_INITIALIZER) (
  6097. IN PUCHAR Block,
  6098. IN SIZE_T NumberOfBytes
  6099. );
  6100. NDIS_HANDLE
  6101. NdisCreateBlockPool(
  6102. IN USHORT BlockSize,
  6103. IN USHORT FreeBlockLinkOffset,
  6104. IN ULONG Tag,
  6105. IN NDIS_BLOCK_INITIALIZER InitFunction OPTIONAL
  6106. );
  6107. VOID
  6108. NdisDestroyBlockPool(
  6109. IN NDIS_HANDLE BlockPoolHandle
  6110. );
  6111. PUCHAR
  6112. NdisAllocateFromBlockPool(
  6113. IN NDIS_HANDLE BlockPoolHandle
  6114. );
  6115. VOID
  6116. NdisFreeToBlockPool(
  6117. IN PUCHAR Block
  6118. );
  6119. #if BINARY_COMPATIBLE
  6120. EXPORT
  6121. VOID
  6122. NdisFreeBuffer(
  6123. IN PNDIS_BUFFER Buffer
  6124. );
  6125. EXPORT
  6126. VOID
  6127. NdisQueryBuffer(
  6128. IN PNDIS_BUFFER Buffer,
  6129. OUT PVOID * VirtualAddress OPTIONAL,
  6130. OUT PUINT Length
  6131. );
  6132. EXPORT
  6133. VOID
  6134. NdisQueryBufferSafe(
  6135. IN PNDIS_BUFFER Buffer,
  6136. OUT PVOID * VirtualAddress OPTIONAL,
  6137. OUT PUINT Length,
  6138. IN MM_PAGE_PRIORITY Priority
  6139. );
  6140. EXPORT
  6141. VOID
  6142. NdisQueryBufferOffset(
  6143. IN PNDIS_BUFFER Buffer,
  6144. OUT PUINT Offset,
  6145. OUT PUINT Length
  6146. );
  6147. //
  6148. // This is a combination of NdisQueryPacket and NdisQueryBuffer and
  6149. // optimized for protocols to get the first Buffer, its VA and its size.
  6150. //
  6151. VOID
  6152. NdisGetFirstBufferFromPacket(
  6153. IN PNDIS_PACKET Packet,
  6154. OUT PNDIS_BUFFER * FirstBuffer,
  6155. OUT PVOID * FirstBufferVA,
  6156. OUT PUINT FirstBufferLength,
  6157. OUT PUINT TotalBufferLength
  6158. );
  6159. VOID
  6160. NdisGetFirstBufferFromPacketSafe(
  6161. IN PNDIS_PACKET Packet,
  6162. OUT PNDIS_BUFFER * FirstBuffer,
  6163. OUT PVOID * FirstBufferVA,
  6164. OUT PUINT FirstBufferLength,
  6165. OUT PUINT TotalBufferLength,
  6166. IN MM_PAGE_PRIORITY Priority
  6167. );
  6168. //
  6169. // This is used to determine how many physical pieces
  6170. // an NDIS_BUFFER will take up when mapped.
  6171. //
  6172. EXPORT
  6173. ULONG
  6174. NDIS_BUFFER_TO_SPAN_PAGES(
  6175. IN PNDIS_BUFFER Buffer
  6176. );
  6177. EXPORT
  6178. VOID
  6179. NdisGetBufferPhysicalArraySize(
  6180. IN PNDIS_BUFFER Buffer,
  6181. OUT PUINT ArraySize
  6182. );
  6183. #else // BINARY_COMPATIBLE
  6184. #define NdisFreeBuffer(Buffer) IoFreeMdl(Buffer)
  6185. #define NdisQueryBuffer(_Buffer, _VirtualAddress, _Length) \
  6186. { \
  6187. if (ARGUMENT_PRESENT(_VirtualAddress)) \
  6188. { \
  6189. *(PVOID *)(_VirtualAddress) = MmGetSystemAddressForMdl(_Buffer); \
  6190. } \
  6191. *(_Length) = MmGetMdlByteCount(_Buffer); \
  6192. }
  6193. #define NdisQueryBufferSafe(_Buffer, _VirtualAddress, _Length, _Priority) \
  6194. { \
  6195. if (ARGUMENT_PRESENT(_VirtualAddress)) \
  6196. { \
  6197. *(PVOID *)(_VirtualAddress) = MmGetSystemAddressForMdlSafe(_Buffer, _Priority); \
  6198. } \
  6199. *(_Length) = MmGetMdlByteCount(_Buffer); \
  6200. }
  6201. #define NdisQueryBufferOffset(_Buffer, _Offset, _Length) \
  6202. { \
  6203. *(_Offset) = MmGetMdlByteOffset(_Buffer); \
  6204. *(_Length) = MmGetMdlByteCount(_Buffer); \
  6205. }
  6206. #define NdisGetFirstBufferFromPacket(_Packet, \
  6207. _FirstBuffer, \
  6208. _FirstBufferVA, \
  6209. _FirstBufferLength, \
  6210. _TotalBufferLength) \
  6211. { \
  6212. PNDIS_BUFFER _pBuf; \
  6213. \
  6214. _pBuf = (_Packet)->Private.Head; \
  6215. *(_FirstBuffer) = _pBuf; \
  6216. if (_pBuf) \
  6217. { \
  6218. *(_FirstBufferVA) = MmGetSystemAddressForMdl(_pBuf); \
  6219. *(_FirstBufferLength) = \
  6220. *(_TotalBufferLength) = MmGetMdlByteCount(_pBuf); \
  6221. for (_pBuf = _pBuf->Next; \
  6222. _pBuf != NULL; \
  6223. _pBuf = _pBuf->Next) \
  6224. { \
  6225. *(_TotalBufferLength) += MmGetMdlByteCount(_pBuf); \
  6226. } \
  6227. } \
  6228. else \
  6229. { \
  6230. *(_FirstBufferVA) = 0; \
  6231. *(_FirstBufferLength) = 0; \
  6232. *(_TotalBufferLength) = 0; \
  6233. } \
  6234. }
  6235. #define NdisGetFirstBufferFromPacketSafe(_Packet, \
  6236. _FirstBuffer, \
  6237. _FirstBufferVA, \
  6238. _FirstBufferLength, \
  6239. _TotalBufferLength, \
  6240. _Priority) \
  6241. { \
  6242. PNDIS_BUFFER _pBuf; \
  6243. \
  6244. _pBuf = (_Packet)->Private.Head; \
  6245. *(_FirstBuffer) = _pBuf; \
  6246. if (_pBuf) \
  6247. { \
  6248. *(_FirstBufferVA) = MmGetSystemAddressForMdlSafe(_pBuf, _Priority); \
  6249. *(_FirstBufferLength) = *(_TotalBufferLength) = MmGetMdlByteCount(_pBuf); \
  6250. for (_pBuf = _pBuf->Next; \
  6251. _pBuf != NULL; \
  6252. _pBuf = _pBuf->Next) \
  6253. { \
  6254. *(_TotalBufferLength) += MmGetMdlByteCount(_pBuf); \
  6255. } \
  6256. } \
  6257. else \
  6258. { \
  6259. *(_FirstBufferVA) = 0; \
  6260. *(_FirstBufferLength) = 0; \
  6261. *(_TotalBufferLength) = 0; \
  6262. } \
  6263. }
  6264. #define NDIS_BUFFER_TO_SPAN_PAGES(_Buffer) \
  6265. (MmGetMdlByteCount(_Buffer)==0 ? \
  6266. 1 : \
  6267. (ADDRESS_AND_SIZE_TO_SPAN_PAGES( \
  6268. MmGetMdlVirtualAddress(_Buffer), \
  6269. MmGetMdlByteCount(_Buffer))))
  6270. #define NdisGetBufferPhysicalArraySize(Buffer, ArraySize) \
  6271. (*(ArraySize) = NDIS_BUFFER_TO_SPAN_PAGES(Buffer))
  6272. #endif // BINARY_COMPATIBLE
  6273. /*++
  6274. NDIS_BUFFER_LINKAGE(
  6275. IN PNDIS_BUFFER Buffer
  6276. );
  6277. --*/
  6278. #define NDIS_BUFFER_LINKAGE(Buffer) ((Buffer)->Next)
  6279. /*++
  6280. VOID
  6281. NdisRecalculatePacketCounts(
  6282. IN OUT PNDIS_PACKET Packet
  6283. );
  6284. --*/
  6285. #define NdisRecalculatePacketCounts(Packet) \
  6286. { \
  6287. { \
  6288. PNDIS_BUFFER TmpBuffer = (Packet)->Private.Head; \
  6289. if (TmpBuffer) \
  6290. { \
  6291. while (TmpBuffer->Next) \
  6292. { \
  6293. TmpBuffer = TmpBuffer->Next; \
  6294. } \
  6295. (Packet)->Private.Tail = TmpBuffer; \
  6296. } \
  6297. (Packet)->Private.ValidCounts = FALSE; \
  6298. } \
  6299. }
  6300. /*++
  6301. VOID
  6302. NdisChainBufferAtFront(
  6303. IN OUT PNDIS_PACKET Packet,
  6304. IN OUT PNDIS_BUFFER Buffer
  6305. );
  6306. --*/
  6307. #define NdisChainBufferAtFront(Packet, Buffer) \
  6308. { \
  6309. PNDIS_BUFFER TmpBuffer = (Buffer); \
  6310. \
  6311. for (;;) \
  6312. { \
  6313. if (TmpBuffer->Next == (PNDIS_BUFFER)NULL) \
  6314. break; \
  6315. TmpBuffer = TmpBuffer->Next; \
  6316. } \
  6317. if ((Packet)->Private.Head == NULL) \
  6318. { \
  6319. (Packet)->Private.Tail = TmpBuffer; \
  6320. } \
  6321. TmpBuffer->Next = (Packet)->Private.Head; \
  6322. (Packet)->Private.Head = (Buffer); \
  6323. (Packet)->Private.ValidCounts = FALSE; \
  6324. }
  6325. /*++
  6326. VOID
  6327. NdisChainBufferAtBack(
  6328. IN OUT PNDIS_PACKET Packet,
  6329. IN OUT PNDIS_BUFFER Buffer
  6330. );
  6331. --*/
  6332. #define NdisChainBufferAtBack(Packet, Buffer) \
  6333. { \
  6334. PNDIS_BUFFER TmpBuffer = (Buffer); \
  6335. \
  6336. for (;;) \
  6337. { \
  6338. if (TmpBuffer->Next == NULL) \
  6339. break; \
  6340. TmpBuffer = TmpBuffer->Next; \
  6341. } \
  6342. if ((Packet)->Private.Head != NULL) \
  6343. { \
  6344. (Packet)->Private.Tail->Next = (Buffer); \
  6345. } \
  6346. else \
  6347. { \
  6348. (Packet)->Private.Head = (Buffer); \
  6349. } \
  6350. (Packet)->Private.Tail = TmpBuffer; \
  6351. (Packet)->Private.ValidCounts = FALSE; \
  6352. }
  6353. EXPORT
  6354. VOID
  6355. NdisUnchainBufferAtFront(
  6356. IN OUT PNDIS_PACKET Packet,
  6357. OUT PNDIS_BUFFER * Buffer
  6358. );
  6359. EXPORT
  6360. VOID
  6361. NdisUnchainBufferAtBack(
  6362. IN OUT PNDIS_PACKET Packet,
  6363. OUT PNDIS_BUFFER * Buffer
  6364. );
  6365. /*++
  6366. VOID
  6367. NdisQueryPacket(
  6368. IN PNDIS_PACKET _Packet,
  6369. OUT PUINT _PhysicalBufferCount OPTIONAL,
  6370. OUT PUINT _BufferCount OPTIONAL,
  6371. OUT PNDIS_BUFFER * _FirstBuffer OPTIONAL,
  6372. OUT PUINT _TotalPacketLength OPTIONAL
  6373. );
  6374. --*/
  6375. #pragma warning(push)
  6376. #pragma warning(disable:4127)
  6377. __inline
  6378. VOID
  6379. NdisQueryPacket(
  6380. IN PNDIS_PACKET _Packet,
  6381. OUT PUINT _PhysicalBufferCount OPTIONAL,
  6382. OUT PUINT _BufferCount OPTIONAL,
  6383. OUT PNDIS_BUFFER * _FirstBuffer OPTIONAL,
  6384. OUT PUINT _TotalPacketLength OPTIONAL
  6385. )
  6386. {
  6387. if ((_FirstBuffer) != NULL)
  6388. {
  6389. PNDIS_BUFFER * __FirstBuffer = (_FirstBuffer);
  6390. *(__FirstBuffer) = (_Packet)->Private.Head;
  6391. }
  6392. if ((_TotalPacketLength) || (_BufferCount) || (_PhysicalBufferCount))
  6393. {
  6394. if (!(_Packet)->Private.ValidCounts)
  6395. {
  6396. PNDIS_BUFFER TmpBuffer = (_Packet)->Private.Head;
  6397. UINT PTotalLength = 0, PPhysicalCount = 0, PAddedCount = 0;
  6398. UINT PacketLength, Offset;
  6399. while (TmpBuffer != (PNDIS_BUFFER)NULL)
  6400. {
  6401. NdisQueryBufferOffset(TmpBuffer, &Offset, &PacketLength);
  6402. PTotalLength += PacketLength;
  6403. PPhysicalCount += (UINT)NDIS_BUFFER_TO_SPAN_PAGES(TmpBuffer);
  6404. ++PAddedCount;
  6405. TmpBuffer = TmpBuffer->Next;
  6406. }
  6407. (_Packet)->Private.Count = PAddedCount;
  6408. (_Packet)->Private.TotalLength = PTotalLength;
  6409. (_Packet)->Private.PhysicalCount = PPhysicalCount;
  6410. (_Packet)->Private.ValidCounts = TRUE;
  6411. }
  6412. if (_PhysicalBufferCount)
  6413. {
  6414. PUINT __PhysicalBufferCount = (_PhysicalBufferCount);
  6415. *(__PhysicalBufferCount) = (_Packet)->Private.PhysicalCount;
  6416. }
  6417. if (_BufferCount)
  6418. {
  6419. PUINT __BufferCount = (_BufferCount);
  6420. *(__BufferCount) = (_Packet)->Private.Count;
  6421. }
  6422. if (_TotalPacketLength)
  6423. {
  6424. PUINT __TotalPacketLength = (_TotalPacketLength);
  6425. *(__TotalPacketLength) = (_Packet)->Private.TotalLength;
  6426. }
  6427. }
  6428. }
  6429. #pragma warning(pop)
  6430. /*++
  6431. VOID
  6432. NdisQueryPacketLength(
  6433. IN PNDIS_PACKET _Packet,
  6434. OUT PUINT _TotalPacketLength OPTIONAL
  6435. );
  6436. --*/
  6437. #define NdisQueryPacketLength(_Packet, \
  6438. _TotalPacketLength) \
  6439. { \
  6440. if (!(_Packet)->Private.ValidCounts) \
  6441. { \
  6442. NdisQueryPacket(_Packet, NULL, NULL, NULL, _TotalPacketLength); \
  6443. } \
  6444. else *(_TotalPacketLength) = (_Packet)->Private.TotalLength; \
  6445. }
  6446. /*++
  6447. VOID
  6448. NdisGetNextBuffer(
  6449. IN PNDIS_BUFFER CurrentBuffer,
  6450. OUT PNDIS_BUFFER * NextBuffer
  6451. );
  6452. --*/
  6453. #define NdisGetNextBuffer(CurrentBuffer, NextBuffer) \
  6454. { \
  6455. *(NextBuffer) = (CurrentBuffer)->Next; \
  6456. }
  6457. #if BINARY_COMPATIBLE
  6458. VOID
  6459. NdisAdjustBufferLength(
  6460. IN PNDIS_BUFFER Buffer,
  6461. IN UINT Length
  6462. );
  6463. #else // BINARY_COMPATIBLE
  6464. #define NdisAdjustBufferLength(Buffer, Length) (((Buffer)->ByteCount) = (Length))
  6465. #endif // BINARY_COMPATIBLE
  6466. EXPORT
  6467. VOID
  6468. NdisCopyFromPacketToPacket(
  6469. IN PNDIS_PACKET Destination,
  6470. IN UINT DestinationOffset,
  6471. IN UINT BytesToCopy,
  6472. IN PNDIS_PACKET Source,
  6473. IN UINT SourceOffset,
  6474. OUT PUINT BytesCopied
  6475. );
  6476. EXPORT
  6477. VOID
  6478. NdisCopyFromPacketToPacketSafe(
  6479. IN PNDIS_PACKET Destination,
  6480. IN UINT DestinationOffset,
  6481. IN UINT BytesToCopy,
  6482. IN PNDIS_PACKET Source,
  6483. IN UINT SourceOffset,
  6484. OUT PUINT BytesCopied,
  6485. IN MM_PAGE_PRIORITY Priority
  6486. );
  6487. EXPORT
  6488. NDIS_STATUS
  6489. NdisAllocateMemory(
  6490. OUT PVOID * VirtualAddress,
  6491. IN UINT Length,
  6492. IN UINT MemoryFlags,
  6493. IN NDIS_PHYSICAL_ADDRESS HighestAcceptableAddress
  6494. );
  6495. EXPORT
  6496. NDIS_STATUS
  6497. NdisAllocateMemoryWithTag(
  6498. OUT PVOID * VirtualAddress,
  6499. IN UINT Length,
  6500. IN ULONG Tag
  6501. );
  6502. EXPORT
  6503. VOID
  6504. NdisFreeMemory(
  6505. IN PVOID VirtualAddress,
  6506. IN UINT Length,
  6507. IN UINT MemoryFlags
  6508. );
  6509. /*++
  6510. VOID
  6511. NdisStallExecution(
  6512. IN UINT MicrosecondsToStall
  6513. )
  6514. --*/
  6515. #define NdisStallExecution(MicroSecondsToStall) KeStallExecutionProcessor(MicroSecondsToStall)
  6516. EXPORT
  6517. VOID
  6518. NdisInitializeEvent(
  6519. IN PNDIS_EVENT Event
  6520. );
  6521. EXPORT
  6522. VOID
  6523. NdisSetEvent(
  6524. IN PNDIS_EVENT Event
  6525. );
  6526. EXPORT
  6527. VOID
  6528. NdisResetEvent(
  6529. IN PNDIS_EVENT Event
  6530. );
  6531. EXPORT
  6532. BOOLEAN
  6533. NdisWaitEvent(
  6534. IN PNDIS_EVENT Event,
  6535. IN UINT msToWait
  6536. );
  6537. /*++
  6538. VOID
  6539. NdisInitializeWorkItem(
  6540. IN PNDIS_WORK_ITEM WorkItem,
  6541. IN NDIS_PROC Routine,
  6542. IN PVOID Context
  6543. );
  6544. --*/
  6545. #define NdisInitializeWorkItem(_WI_, _R_, _C_) \
  6546. { \
  6547. (_WI_)->Context = _C_; \
  6548. (_WI_)->Routine = _R_; \
  6549. }
  6550. EXPORT
  6551. NDIS_STATUS
  6552. NdisScheduleWorkItem(
  6553. IN PNDIS_WORK_ITEM WorkItem
  6554. );
  6555. //
  6556. // Simple I/O support
  6557. //
  6558. EXPORT
  6559. VOID
  6560. NdisOpenFile(
  6561. OUT PNDIS_STATUS Status,
  6562. OUT PNDIS_HANDLE FileHandle,
  6563. OUT PUINT FileLength,
  6564. IN PNDIS_STRING FileName,
  6565. IN NDIS_PHYSICAL_ADDRESS HighestAcceptableAddress
  6566. );
  6567. EXPORT
  6568. VOID
  6569. NdisCloseFile(
  6570. IN NDIS_HANDLE FileHandle
  6571. );
  6572. EXPORT
  6573. VOID
  6574. NdisMapFile(
  6575. OUT PNDIS_STATUS Status,
  6576. OUT PVOID * MappedBuffer,
  6577. IN NDIS_HANDLE FileHandle
  6578. );
  6579. EXPORT
  6580. VOID
  6581. NdisUnmapFile(
  6582. IN NDIS_HANDLE FileHandle
  6583. );
  6584. //
  6585. // Portability extensions
  6586. //
  6587. /*++
  6588. VOID
  6589. NdisFlushBuffer(
  6590. IN PNDIS_BUFFER Buffer,
  6591. IN BOOLEAN WriteToDevice
  6592. )
  6593. --*/
  6594. #define NdisFlushBuffer(Buffer,WriteToDevice) \
  6595. KeFlushIoBuffers((Buffer),!(WriteToDevice), TRUE)
  6596. EXPORT
  6597. ULONG
  6598. NdisGetSharedDataAlignment(
  6599. VOID
  6600. );
  6601. //
  6602. // Write Port
  6603. //
  6604. /*++
  6605. VOID
  6606. NdisWritePortUchar(
  6607. IN NDIS_HANDLE NdisAdapterHandle,
  6608. IN ULONG Port,
  6609. IN UCHAR Data
  6610. )
  6611. --*/
  6612. #define NdisWritePortUchar(Handle,Port,Data) \
  6613. WRITE_PORT_UCHAR((PUCHAR)(NDIS_PORT_TO_PORT(Handle,Port)),(UCHAR)(Data))
  6614. /*++
  6615. VOID
  6616. NdisWritePortUshort(
  6617. IN NDIS_HANDLE NdisAdapterHandle,
  6618. IN ULONG Port,
  6619. IN USHORT Data
  6620. )
  6621. --*/
  6622. #define NdisWritePortUshort(Handle,Port,Data) \
  6623. WRITE_PORT_USHORT((PUSHORT)(NDIS_PORT_TO_PORT(Handle,Port)),(USHORT)(Data))
  6624. /*++
  6625. VOID
  6626. NdisWritePortUlong(
  6627. IN NDIS_HANDLE NdisAdapterHandle,
  6628. IN ULONG Port,
  6629. IN ULONG Data
  6630. )
  6631. --*/
  6632. #define NdisWritePortUlong(Handle,Port,Data) \
  6633. WRITE_PORT_ULONG((PULONG)(NDIS_PORT_TO_PORT(Handle,Port)),(ULONG)(Data))
  6634. //
  6635. // Write Port Buffers
  6636. //
  6637. /*++
  6638. VOID
  6639. NdisWritePortBufferUchar(
  6640. IN NDIS_HANDLE NdisAdapterHandle,
  6641. IN ULONG Port,
  6642. IN PUCHAR Buffer,
  6643. IN ULONG Length
  6644. )
  6645. --*/
  6646. #define NdisWritePortBufferUchar(Handle,Port,Buffer,Length) \
  6647. NdisRawWritePortBufferUchar(NDIS_PORT_TO_PORT((Handle),(Port)),(Buffer),(Length))
  6648. /*++
  6649. VOID
  6650. NdisWritePortBufferUshort(
  6651. IN NDIS_HANDLE NdisAdapterHandle,
  6652. IN ULONG Port,
  6653. IN PUSHORT Buffer,
  6654. IN ULONG Length
  6655. )
  6656. --*/
  6657. #define NdisWritePortBufferUshort(Handle,Port,Buffer,Length) \
  6658. NdisRawWritePortBufferUshort(NDIS_PORT_TO_PORT((Handle),(Port)),(Buffer),(Length))
  6659. /*++
  6660. VOID
  6661. NdisWritePortBufferUlong(
  6662. IN NDIS_HANDLE NdisAdapterHandle,
  6663. IN ULONG Port,
  6664. IN PULONG Buffer,
  6665. IN ULONG Length
  6666. )
  6667. --*/
  6668. #define NdisWritePortBufferUlong(Handle,Port,Buffer,Length) \
  6669. NdisRawWritePortBufferUlong(NDIS_PORT_TO_PORT((Handle),(Port)),(Buffer),(Length))
  6670. //
  6671. // Read Ports
  6672. //
  6673. /*++
  6674. VOID
  6675. NdisReadPortUchar(
  6676. IN NDIS_HANDLE NdisAdapterHandle,
  6677. IN ULONG Port,
  6678. OUT PUCHAR Data
  6679. )
  6680. --*/
  6681. #define NdisReadPortUchar(Handle,Port, Data) \
  6682. NdisRawReadPortUchar(NDIS_PORT_TO_PORT((Handle),(Port)),(Data))
  6683. /*++
  6684. VOID
  6685. NdisReadPortUshort(
  6686. IN NDIS_HANDLE NdisAdapterHandle,
  6687. IN ULONG Port,
  6688. OUT PUSHORT Data
  6689. )
  6690. --*/
  6691. #define NdisReadPortUshort(Handle,Port,Data) \
  6692. NdisRawReadPortUshort(NDIS_PORT_TO_PORT((Handle),(Port)),(Data))
  6693. /*++
  6694. VOID
  6695. NdisReadPortUlong(
  6696. IN NDIS_HANDLE NdisAdapterHandle,
  6697. IN ULONG Port,
  6698. OUT PULONG Data
  6699. )
  6700. --*/
  6701. #define NdisReadPortUlong(Handle,Port,Data) \
  6702. NdisRawReadPortUlong(NDIS_PORT_TO_PORT((Handle),(Port)),(Data))
  6703. //
  6704. // Read Buffer Ports
  6705. //
  6706. /*++
  6707. VOID
  6708. NdisReadPortBufferUchar(
  6709. IN NDIS_HANDLE NdisAdapterHandle,
  6710. IN ULONG Port,
  6711. OUT PUCHAR Buffer,
  6712. IN ULONG Length
  6713. )
  6714. --*/
  6715. #define NdisReadPortBufferUchar(Handle,Port,Buffer,Length) \
  6716. NdisRawReadPortBufferUchar(NDIS_PORT_TO_PORT((Handle),(Port)),(Buffer),(Length))
  6717. /*++
  6718. VOID
  6719. NdisReadPortBufferUshort(
  6720. IN NDIS_HANDLE NdisAdapterHandle,
  6721. IN ULONG Port,
  6722. OUT PUSHORT Buffer,
  6723. IN ULONG Length
  6724. )
  6725. --*/
  6726. #define NdisReadPortBufferUshort(Handle,Port,Buffer,Length) \
  6727. NdisRawReadPortBufferUshort(NDIS_PORT_TO_PORT((Handle),(Port)),(Buffer),(Length))
  6728. /*++
  6729. VOID
  6730. NdisReadPortBufferUlong(
  6731. IN NDIS_HANDLE NdisAdapterHandle,
  6732. IN ULONG Port,
  6733. OUT PULONG Buffer,
  6734. IN ULONG Length
  6735. )
  6736. --*/
  6737. #define NdisReadPortBufferUlong(Handle,Port,Buffer) \
  6738. NdisRawReadPortBufferUlong(NDIS_PORT_TO_PORT((Handle),(Port)),(Buffer),(Length))
  6739. //
  6740. // Raw Routines
  6741. //
  6742. //
  6743. // Write Port Raw
  6744. //
  6745. /*++
  6746. VOID
  6747. NdisRawWritePortUchar(
  6748. IN ULONG_PTR Port,
  6749. IN UCHAR Data
  6750. )
  6751. --*/
  6752. #define NdisRawWritePortUchar(Port,Data) \
  6753. WRITE_PORT_UCHAR((PUCHAR)(Port),(UCHAR)(Data))
  6754. /*++
  6755. VOID
  6756. NdisRawWritePortUshort(
  6757. IN ULONG_PTR Port,
  6758. IN USHORT Data
  6759. )
  6760. --*/
  6761. #define NdisRawWritePortUshort(Port,Data) \
  6762. WRITE_PORT_USHORT((PUSHORT)(Port),(USHORT)(Data))
  6763. /*++
  6764. VOID
  6765. NdisRawWritePortUlong(
  6766. IN ULONG_PTR Port,
  6767. IN ULONG Data
  6768. )
  6769. --*/
  6770. #define NdisRawWritePortUlong(Port,Data) \
  6771. WRITE_PORT_ULONG((PULONG)(Port),(ULONG)(Data))
  6772. //
  6773. // Raw Write Port Buffers
  6774. //
  6775. /*++
  6776. VOID
  6777. NdisRawWritePortBufferUchar(
  6778. IN ULONG_PTR Port,
  6779. IN PUCHAR Buffer,
  6780. IN ULONG Length
  6781. )
  6782. --*/
  6783. #define NdisRawWritePortBufferUchar(Port,Buffer,Length) \
  6784. WRITE_PORT_BUFFER_UCHAR((PUCHAR)(Port),(PUCHAR)(Buffer),(Length))
  6785. /*++
  6786. VOID
  6787. NdisRawWritePortBufferUshort(
  6788. IN ULONG_PTR Port,
  6789. IN PUSHORT Buffer,
  6790. IN ULONG Length
  6791. )
  6792. --*/
  6793. #if defined(_M_IX86) || defined(_M_AMD64)
  6794. #define NdisRawWritePortBufferUshort(Port,Buffer,Length) \
  6795. WRITE_PORT_BUFFER_USHORT((PUSHORT)(Port),(PUSHORT)(Buffer),(Length))
  6796. #else
  6797. #define NdisRawWritePortBufferUshort(Port,Buffer,Length) \
  6798. { \
  6799. ULONG_PTR _Port = (ULONG_PTR)(Port); \
  6800. PUSHORT _Current = (Buffer); \
  6801. PUSHORT _End = _Current + (Length); \
  6802. for ( ; _Current < _End; ++_Current) \
  6803. { \
  6804. WRITE_PORT_USHORT((PUSHORT)_Port,*(UNALIGNED USHORT *)_Current);\
  6805. } \
  6806. }
  6807. #endif
  6808. /*++
  6809. VOID
  6810. NdisRawWritePortBufferUlong(
  6811. IN ULONG_PTR Port,
  6812. IN PULONG Buffer,
  6813. IN ULONG Length
  6814. )
  6815. --*/
  6816. #if defined(_M_IX86) || defined(_M_AMD64)
  6817. #define NdisRawWritePortBufferUlong(Port,Buffer,Length) \
  6818. WRITE_PORT_BUFFER_ULONG((PULONG)(Port),(PULONG)(Buffer),(Length))
  6819. #else
  6820. #define NdisRawWritePortBufferUlong(Port,Buffer,Length) \
  6821. { \
  6822. ULONG_PTR _Port = (ULONG_PTR)(Port); \
  6823. PULONG _Current = (Buffer); \
  6824. PULONG _End = _Current + (Length); \
  6825. for ( ; _Current < _End; ++_Current) \
  6826. { \
  6827. WRITE_PORT_ULONG((PULONG)_Port,*(UNALIGNED ULONG *)_Current); \
  6828. } \
  6829. }
  6830. #endif
  6831. //
  6832. // Raw Read Ports
  6833. //
  6834. /*++
  6835. VOID
  6836. NdisRawReadPortUchar(
  6837. IN ULONG_PTR Port,
  6838. OUT PUCHAR Data
  6839. )
  6840. --*/
  6841. #define NdisRawReadPortUchar(Port, Data) \
  6842. *(Data) = READ_PORT_UCHAR((PUCHAR)(Port))
  6843. /*++
  6844. VOID
  6845. NdisRawReadPortUshort(
  6846. IN ULONG_PTR Port,
  6847. OUT PUSHORT Data
  6848. )
  6849. --*/
  6850. #define NdisRawReadPortUshort(Port,Data) \
  6851. *(Data) = READ_PORT_USHORT((PUSHORT)(Port))
  6852. /*++
  6853. VOID
  6854. NdisRawReadPortUlong(
  6855. IN ULONG_PTR Port,
  6856. OUT PULONG Data
  6857. )
  6858. --*/
  6859. #define NdisRawReadPortUlong(Port,Data) \
  6860. *(Data) = READ_PORT_ULONG((PULONG)(Port))
  6861. //
  6862. // Raw Read Buffer Ports
  6863. //
  6864. /*++
  6865. VOID
  6866. NdisRawReadPortBufferUchar(
  6867. IN ULONG_PTR Port,
  6868. OUT PUCHAR Buffer,
  6869. IN ULONG Length
  6870. )
  6871. --*/
  6872. #define NdisRawReadPortBufferUchar(Port,Buffer,Length) \
  6873. READ_PORT_BUFFER_UCHAR((PUCHAR)(Port),(PUCHAR)(Buffer),(Length))
  6874. /*++
  6875. VOID
  6876. NdisRawReadPortBufferUshort(
  6877. IN ULONG_PTR Port,
  6878. OUT PUSHORT Buffer,
  6879. IN ULONG Length
  6880. )
  6881. --*/
  6882. #if defined(_M_IX86) || defined(_M_AMD64)
  6883. #define NdisRawReadPortBufferUshort(Port,Buffer,Length) \
  6884. READ_PORT_BUFFER_USHORT((PUSHORT)(Port),(PUSHORT)(Buffer),(Length))
  6885. #else
  6886. #define NdisRawReadPortBufferUshort(Port,Buffer,Length) \
  6887. { \
  6888. ULONG_PTR _Port = (ULONG_PTR)(Port); \
  6889. PUSHORT _Current = (Buffer); \
  6890. PUSHORT _End = _Current + (Length); \
  6891. for ( ; _Current < _End; ++_Current) \
  6892. { \
  6893. *(UNALIGNED USHORT *)_Current = READ_PORT_USHORT((PUSHORT)_Port); \
  6894. } \
  6895. }
  6896. #endif
  6897. /*++
  6898. VOID
  6899. NdisRawReadPortBufferUlong(
  6900. IN ULONG_PTR Port,
  6901. OUT PULONG Buffer,
  6902. IN ULONG Length
  6903. )
  6904. --*/
  6905. #if defined(_M_IX86) || defined(_M_AMD64)
  6906. #define NdisRawReadPortBufferUlong(Port,Buffer,Length) \
  6907. READ_PORT_BUFFER_ULONG((PULONG)(Port),(PULONG)(Buffer),(Length))
  6908. #else
  6909. #define NdisRawReadPortBufferUlong(Port,Buffer,Length) \
  6910. { \
  6911. ULONG_PTR _Port = (ULONG_PTR)(Port); \
  6912. PULONG _Current = (Buffer); \
  6913. PULONG _End = _Current + (Length); \
  6914. for ( ; _Current < _End; ++_Current) \
  6915. { \
  6916. *(UNALIGNED ULONG *)_Current = READ_PORT_ULONG((PULONG)_Port); \
  6917. } \
  6918. }
  6919. #endif
  6920. //
  6921. // Write Registers
  6922. //
  6923. /*++
  6924. VOID
  6925. NdisWriteRegisterUchar(
  6926. IN PUCHAR Register,
  6927. IN UCHAR Data
  6928. )
  6929. --*/
  6930. #if defined(_M_IX86) || defined(_M_AMD64)
  6931. #define NdisWriteRegisterUchar(Register,Data) \
  6932. WRITE_REGISTER_UCHAR((Register),(Data))
  6933. #else
  6934. #define NdisWriteRegisterUchar(Register,Data) \
  6935. { \
  6936. WRITE_REGISTER_UCHAR((Register),(Data)); \
  6937. READ_REGISTER_UCHAR(Register); \
  6938. }
  6939. #endif
  6940. /*++
  6941. VOID
  6942. NdisWriteRegisterUshort(
  6943. IN PUCHAR Register,
  6944. IN USHORT Data
  6945. )
  6946. --*/
  6947. #if defined(_M_IX86) || defined(_M_AMD64)
  6948. #define NdisWriteRegisterUshort(Register,Data) \
  6949. WRITE_REGISTER_USHORT((Register),(Data))
  6950. #else
  6951. #define NdisWriteRegisterUshort(Register,Data) \
  6952. { \
  6953. WRITE_REGISTER_USHORT((Register),(Data)); \
  6954. READ_REGISTER_USHORT(Register); \
  6955. }
  6956. #endif
  6957. /*++
  6958. VOID
  6959. NdisWriteRegisterUlong(
  6960. IN PUCHAR Register,
  6961. IN ULONG Data
  6962. )
  6963. --*/
  6964. #if defined(_M_IX86) || defined(_M_AMD64)
  6965. #define NdisWriteRegisterUlong(Register,Data) WRITE_REGISTER_ULONG((Register),(Data))
  6966. #else
  6967. #define NdisWriteRegisterUlong(Register,Data) \
  6968. { \
  6969. WRITE_REGISTER_ULONG((Register),(Data)); \
  6970. READ_REGISTER_ULONG(Register); \
  6971. }
  6972. #endif
  6973. /*++
  6974. VOID
  6975. NdisReadRegisterUchar(
  6976. IN PUCHAR Register,
  6977. OUT PUCHAR Data
  6978. )
  6979. --*/
  6980. #if defined(_M_IX86) || defined(_M_AMD64)
  6981. #define NdisReadRegisterUchar(Register,Data) *(Data) = *((volatile UCHAR * const)(Register))
  6982. #else
  6983. #define NdisReadRegisterUchar(Register,Data) *(Data) = READ_REGISTER_UCHAR((PUCHAR)(Register))
  6984. #endif
  6985. /*++
  6986. VOID
  6987. NdisReadRegisterUshort(
  6988. IN PUSHORT Register,
  6989. OUT PUSHORT Data
  6990. )
  6991. --*/
  6992. #if defined(_M_IX86) || defined(_M_AMD64)
  6993. #define NdisReadRegisterUshort(Register,Data) *(Data) = *((volatile USHORT * const)(Register))
  6994. #else
  6995. #define NdisReadRegisterUshort(Register,Data) *(Data) = READ_REGISTER_USHORT((PUSHORT)(Register))
  6996. #endif
  6997. /*++
  6998. VOID
  6999. NdisReadRegisterUlong(
  7000. IN PULONG Register,
  7001. OUT PULONG Data
  7002. )
  7003. --*/
  7004. #if defined(_M_IX86) || defined(_M_AMD64)
  7005. #define NdisReadRegisterUlong(Register,Data) *(Data) = *((volatile ULONG * const)(Register))
  7006. #else
  7007. #define NdisReadRegisterUlong(Register,Data) *(Data) = READ_REGISTER_ULONG((PULONG)(Register))
  7008. #endif
  7009. #define NdisEqualAnsiString(_String1,_String2, _CaseInsensitive) \
  7010. RtlEqualAnsiString(_String1, _String2, _CaseInsensitive)
  7011. #define NdisEqualString(_String1, _String2, _CaseInsensitive) \
  7012. RtlEqualUnicodeString(_String1, _String2, _CaseInsensitive)
  7013. #define NdisEqualUnicodeString(_String1, _String2, _CaseInsensitive) \
  7014. RtlEqualUnicodeString(_String1, _String2, _CaseInsensitive)
  7015. EXPORT
  7016. VOID __cdecl
  7017. NdisWriteErrorLogEntry(
  7018. IN NDIS_HANDLE NdisAdapterHandle,
  7019. IN NDIS_ERROR_CODE ErrorCode,
  7020. IN ULONG NumberOfErrorValues,
  7021. ...
  7022. );
  7023. EXPORT
  7024. VOID
  7025. NdisInitializeString(
  7026. OUT PNDIS_STRING Destination,
  7027. IN PUCHAR Source
  7028. );
  7029. #define NdisFreeString(String) NdisFreeMemory((String).Buffer, (String).MaximumLength, 0)
  7030. #define NdisPrintString(String) DbgPrint("%ls",(String).Buffer)
  7031. /*++
  7032. VOID
  7033. NdisCreateLookaheadBufferFromSharedMemory(
  7034. IN PVOID pSharedMemory,
  7035. IN UINT LookaheadLength,
  7036. OUT PVOID * pLookaheadBuffer
  7037. );
  7038. --*/
  7039. #define NdisCreateLookaheadBufferFromSharedMemory(_S, _L, _B) ((*(_B)) = (_S))
  7040. /*++
  7041. VOID
  7042. NdisDestroyLookaheadBufferFromSharedMemory(
  7043. IN PVOID pLookaheadBuffer
  7044. );
  7045. --*/
  7046. #define NdisDestroyLookaheadBufferFromSharedMemory(_B)
  7047. //
  7048. // The following declarations are shared between ndismac.h and ndismini.h. They
  7049. // are meant to be for internal use only. They should not be used directly by
  7050. // miniport drivers.
  7051. //
  7052. //
  7053. // declare these first since they point to each other
  7054. //
  7055. typedef struct _NDIS_WRAPPER_HANDLE NDIS_WRAPPER_HANDLE, *PNDIS_WRAPPER_HANDLE;
  7056. typedef struct _NDIS_PROTOCOL_BLOCK NDIS_PROTOCOL_BLOCK, *PNDIS_PROTOCOL_BLOCK;
  7057. typedef struct _NDIS_OPEN_BLOCK NDIS_OPEN_BLOCK, *PNDIS_OPEN_BLOCK;
  7058. typedef struct _NDIS_M_DRIVER_BLOCK NDIS_M_DRIVER_BLOCK, *PNDIS_M_DRIVER_BLOCK;
  7059. typedef struct _NDIS_MINIPORT_BLOCK NDIS_MINIPORT_BLOCK,*PNDIS_MINIPORT_BLOCK;
  7060. typedef struct _CO_CALL_PARAMETERS CO_CALL_PARAMETERS, *PCO_CALL_PARAMETERS;
  7061. typedef struct _CO_MEDIA_PARAMETERS CO_MEDIA_PARAMETERS, *PCO_MEDIA_PARAMETERS;
  7062. typedef struct _NDIS_CALL_MANAGER_CHARACTERISTICS *PNDIS_CALL_MANAGER_CHARACTERISTICS;
  7063. typedef struct _NDIS_AF_LIST NDIS_AF_LIST, *PNDIS_AF_LIST;
  7064. typedef struct _X_FILTER ETH_FILTER, *PETH_FILTER;
  7065. typedef struct _X_FILTER FDDI_FILTER, *PFDDI_FILTER;
  7066. typedef struct _X_FILTER TR_FILTER, *PTR_FILTER;
  7067. typedef struct _X_FILTER NULL_FILTER, *PNULL_FILTER;
  7068. //
  7069. // Timers.
  7070. //
  7071. typedef
  7072. VOID
  7073. (*PNDIS_TIMER_FUNCTION) (
  7074. IN PVOID SystemSpecific1,
  7075. IN PVOID FunctionContext,
  7076. IN PVOID SystemSpecific2,
  7077. IN PVOID SystemSpecific3
  7078. );
  7079. typedef struct _NDIS_TIMER
  7080. {
  7081. KTIMER Timer;
  7082. KDPC Dpc;
  7083. } NDIS_TIMER, *PNDIS_TIMER;
  7084. EXPORT
  7085. VOID
  7086. NdisInitializeTimer(
  7087. IN OUT PNDIS_TIMER Timer,
  7088. IN PNDIS_TIMER_FUNCTION TimerFunction,
  7089. IN PVOID FunctionContext
  7090. );
  7091. VOID
  7092. NdisCancelTimer(
  7093. IN PNDIS_TIMER Timer,
  7094. OUT PBOOLEAN TimerCancelled
  7095. );
  7096. EXPORT
  7097. VOID
  7098. NdisSetTimer(
  7099. IN PNDIS_TIMER Timer,
  7100. IN UINT MillisecondsToDelay
  7101. );
  7102. EXPORT
  7103. VOID
  7104. NdisSetTimerEx(
  7105. IN PNDIS_TIMER Timer,
  7106. IN UINT MillisecondsToDelay,
  7107. IN PVOID FunctionContext
  7108. );
  7109. //
  7110. // DMA operations.
  7111. //
  7112. EXPORT
  7113. VOID
  7114. NdisAllocateDmaChannel(
  7115. OUT PNDIS_STATUS Status,
  7116. OUT PNDIS_HANDLE NdisDmaHandle,
  7117. IN NDIS_HANDLE NdisAdapterHandle,
  7118. IN PNDIS_DMA_DESCRIPTION DmaDescription,
  7119. IN ULONG MaximumLength
  7120. );
  7121. EXPORT
  7122. VOID
  7123. NdisSetupDmaTransfer(
  7124. OUT PNDIS_STATUS Status,
  7125. IN NDIS_HANDLE NdisDmaHandle,
  7126. IN PNDIS_BUFFER Buffer,
  7127. IN ULONG Offset,
  7128. IN ULONG Length,
  7129. IN BOOLEAN WriteToDevice
  7130. );
  7131. EXPORT
  7132. VOID
  7133. NdisCompleteDmaTransfer(
  7134. OUT PNDIS_STATUS Status,
  7135. IN NDIS_HANDLE NdisDmaHandle,
  7136. IN PNDIS_BUFFER Buffer,
  7137. IN ULONG Offset,
  7138. IN ULONG Length,
  7139. IN BOOLEAN WriteToDevice
  7140. );
  7141. //
  7142. // Wrapper initialization and termination.
  7143. //
  7144. EXPORT
  7145. VOID
  7146. NdisInitializeWrapper(
  7147. OUT PNDIS_HANDLE NdisWrapperHandle,
  7148. IN PVOID SystemSpecific1,
  7149. IN PVOID SystemSpecific2,
  7150. IN PVOID SystemSpecific3
  7151. );
  7152. EXPORT
  7153. VOID
  7154. NdisTerminateWrapper(
  7155. IN NDIS_HANDLE NdisWrapperHandle,
  7156. IN PVOID SystemSpecific
  7157. );
  7158. //
  7159. // Shared memory
  7160. //
  7161. #define NdisUpdateSharedMemory(_H, _L, _V, _P)
  7162. //
  7163. // System processor count
  7164. //
  7165. EXPORT
  7166. CCHAR
  7167. NdisSystemProcessorCount(
  7168. VOID
  7169. );
  7170. EXPORT
  7171. PVOID
  7172. NdisGetRoutineAddress(
  7173. IN PNDIS_STRING NdisRoutineName
  7174. );
  7175. EXPORT
  7176. UINT
  7177. NdisGetVersion(
  7178. VOID
  7179. );
  7180. //
  7181. // Ansi/Unicode support routines
  7182. //
  7183. #if BINARY_COMPATIBLE
  7184. EXPORT
  7185. VOID
  7186. NdisInitAnsiString(
  7187. IN OUT PANSI_STRING DestinationString,
  7188. IN PCSTR SourceString
  7189. );
  7190. EXPORT
  7191. VOID
  7192. NdisInitUnicodeString(
  7193. IN OUT PUNICODE_STRING DestinationString,
  7194. IN PCWSTR SourceString
  7195. );
  7196. EXPORT
  7197. NDIS_STATUS
  7198. NdisAnsiStringToUnicodeString(
  7199. IN OUT PUNICODE_STRING DestinationString,
  7200. IN PANSI_STRING SourceString
  7201. );
  7202. EXPORT
  7203. NDIS_STATUS
  7204. NdisUnicodeStringToAnsiString(
  7205. IN OUT PANSI_STRING DestinationString,
  7206. IN PUNICODE_STRING SourceString
  7207. );
  7208. EXPORT
  7209. NDIS_STATUS
  7210. NdisUpcaseUnicodeString(
  7211. OUT PUNICODE_STRING DestinationString,
  7212. IN PUNICODE_STRING SourceString
  7213. );
  7214. #else // BINARY_COMPATIBLE
  7215. #define NdisInitAnsiString(_as, s) RtlInitString(_as, s)
  7216. #define NdisInitUnicodeString(_us, s) RtlInitUnicodeString(_us, s)
  7217. #define NdisAnsiStringToUnicodeString(_us, _as) RtlAnsiStringToUnicodeString(_us, _as, FALSE)
  7218. #define NdisUnicodeStringToAnsiString(_as, _us) RtlUnicodeStringToAnsiString(_as, _us, FALSE)
  7219. #define NdisUpcaseUnicodeString(_d, _s) RtlUpcaseUnicodeString(_d, _s, FALSE)
  7220. #endif // BINARY_COMPATIBLE
  7221. //
  7222. // Non-paged lookaside list support routines
  7223. //
  7224. #define NdisInitializeNPagedLookasideList(_L, _AR, _FR, _Fl, _S, _T, _D) \
  7225. ExInitializeNPagedLookasideList(_L, _AR, _FR, _Fl, _S, _T, _D)
  7226. #define NdisDeleteNPagedLookasideList(_L) ExDeleteNPagedLookasideList(_L)
  7227. #define NdisAllocateFromNPagedLookasideList(_L) ExAllocateFromNPagedLookasideList(_L)
  7228. #define NdisFreeToNPagedLookasideList(_L, _E) ExFreeToNPagedLookasideList(_L, _E)
  7229. EXPORT
  7230. VOID
  7231. NdisSetPacketStatus(
  7232. IN PNDIS_PACKET Packet,
  7233. IN NDIS_STATUS Status,
  7234. IN NDIS_HANDLE Handle,
  7235. IN ULONG Code
  7236. );
  7237. #define NDIS_MAX_EVENT_LOG_DATA_SIZE ((ERROR_LOG_MAXIMUM_SIZE - sizeof(IO_ERROR_LOG_PACKET) + sizeof(ULONG)) & ~3)
  7238. #if NDIS_RECV_SCALE
  7239. #define NDIS_MAX_PROCESSOR_COUNT 32
  7240. typedef struct _NDIS_RECEIVE_SCALE_HASH_MAP
  7241. {
  7242. CCHAR TargetCpu[NDIS_MAX_PROCESSOR_COUNT];
  7243. } NDIS_RECEIVE_SCALE_HASH_MAP, *PNDIS_RECEIVE_SCALE_HASH_MAP;
  7244. //
  7245. // used in OID_GEN_RECEIVE_SCALE_PARAMETERS
  7246. //
  7247. typedef struct _NDIS_RECEIVE_SCALE_PARAMETERS
  7248. {
  7249. USHORT EthType;
  7250. USHORT CurrentHashFunction;
  7251. NDIS_RECEIVE_SCALE_HASH_MAP HashMap;
  7252. } NDIS_RECEIVE_SCALE_PARAMETERS, *PNDIS_RECEIVE_SCALE_PARAMETERS;
  7253. #endif
  7254. #define NDIS_CURRENT_PROCESSOR KeGetCurrentProcessorNumber()
  7255. #if defined(NDIS_WRAPPER)
  7256. typedef struct _OID_LIST OID_LIST, *POID_LIST;
  7257. #endif // NDIS_WRAPPER defined
  7258. //
  7259. // Function types for NDIS_PROTOCOL_CHARACTERISTICS
  7260. //
  7261. typedef
  7262. VOID
  7263. (*OPEN_ADAPTER_COMPLETE_HANDLER)(
  7264. IN NDIS_HANDLE ProtocolBindingContext,
  7265. IN NDIS_STATUS Status,
  7266. IN NDIS_STATUS OpenErrorStatus
  7267. );
  7268. typedef
  7269. VOID
  7270. (*CLOSE_ADAPTER_COMPLETE_HANDLER)(
  7271. IN NDIS_HANDLE ProtocolBindingContext,
  7272. IN NDIS_STATUS Status
  7273. );
  7274. typedef
  7275. VOID
  7276. (*RESET_COMPLETE_HANDLER)(
  7277. IN NDIS_HANDLE ProtocolBindingContext,
  7278. IN NDIS_STATUS Status
  7279. );
  7280. typedef
  7281. VOID
  7282. (*REQUEST_COMPLETE_HANDLER)(
  7283. IN NDIS_HANDLE ProtocolBindingContext,
  7284. IN PNDIS_REQUEST NdisRequest,
  7285. IN NDIS_STATUS Status
  7286. );
  7287. typedef
  7288. VOID
  7289. (*STATUS_HANDLER)(
  7290. IN NDIS_HANDLE ProtocolBindingContext,
  7291. IN NDIS_STATUS GeneralStatus,
  7292. IN PVOID StatusBuffer,
  7293. IN UINT StatusBufferSize
  7294. );
  7295. typedef
  7296. VOID
  7297. (*STATUS_COMPLETE_HANDLER)(
  7298. IN NDIS_HANDLE ProtocolBindingContext
  7299. );
  7300. typedef
  7301. VOID
  7302. (*SEND_COMPLETE_HANDLER)(
  7303. IN NDIS_HANDLE ProtocolBindingContext,
  7304. IN PNDIS_PACKET Packet,
  7305. IN NDIS_STATUS Status
  7306. );
  7307. typedef
  7308. VOID
  7309. (*WAN_SEND_COMPLETE_HANDLER) (
  7310. IN NDIS_HANDLE ProtocolBindingContext,
  7311. IN PNDIS_WAN_PACKET Packet,
  7312. IN NDIS_STATUS Status
  7313. );
  7314. typedef
  7315. VOID
  7316. (*TRANSFER_DATA_COMPLETE_HANDLER)(
  7317. IN NDIS_HANDLE ProtocolBindingContext,
  7318. IN PNDIS_PACKET Packet,
  7319. IN NDIS_STATUS Status,
  7320. IN UINT BytesTransferred
  7321. );
  7322. typedef
  7323. VOID
  7324. (*WAN_TRANSFER_DATA_COMPLETE_HANDLER)(
  7325. VOID
  7326. );
  7327. typedef
  7328. NDIS_STATUS
  7329. (*RECEIVE_HANDLER)(
  7330. IN NDIS_HANDLE ProtocolBindingContext,
  7331. IN NDIS_HANDLE MacReceiveContext,
  7332. IN PVOID HeaderBuffer,
  7333. IN UINT HeaderBufferSize,
  7334. IN PVOID LookAheadBuffer,
  7335. IN UINT LookaheadBufferSize,
  7336. IN UINT PacketSize
  7337. );
  7338. typedef
  7339. NDIS_STATUS
  7340. (*WAN_RECEIVE_HANDLER)(
  7341. IN NDIS_HANDLE NdisLinkHandle,
  7342. IN PUCHAR Packet,
  7343. IN ULONG PacketSize
  7344. );
  7345. typedef
  7346. VOID
  7347. (*RECEIVE_COMPLETE_HANDLER)(
  7348. IN NDIS_HANDLE ProtocolBindingContext
  7349. );
  7350. //
  7351. // Protocol characteristics for down-level NDIS 3.0 protocols
  7352. //
  7353. typedef struct _NDIS30_PROTOCOL_CHARACTERISTICS
  7354. {
  7355. UCHAR MajorNdisVersion;
  7356. UCHAR MinorNdisVersion;
  7357. USHORT Filler;
  7358. union
  7359. {
  7360. UINT Reserved;
  7361. UINT Flags;
  7362. };
  7363. OPEN_ADAPTER_COMPLETE_HANDLER OpenAdapterCompleteHandler;
  7364. CLOSE_ADAPTER_COMPLETE_HANDLER CloseAdapterCompleteHandler;
  7365. union
  7366. {
  7367. SEND_COMPLETE_HANDLER SendCompleteHandler;
  7368. WAN_SEND_COMPLETE_HANDLER WanSendCompleteHandler;
  7369. };
  7370. union
  7371. {
  7372. TRANSFER_DATA_COMPLETE_HANDLER TransferDataCompleteHandler;
  7373. WAN_TRANSFER_DATA_COMPLETE_HANDLER WanTransferDataCompleteHandler;
  7374. };
  7375. RESET_COMPLETE_HANDLER ResetCompleteHandler;
  7376. REQUEST_COMPLETE_HANDLER RequestCompleteHandler;
  7377. union
  7378. {
  7379. RECEIVE_HANDLER ReceiveHandler;
  7380. WAN_RECEIVE_HANDLER WanReceiveHandler;
  7381. };
  7382. RECEIVE_COMPLETE_HANDLER ReceiveCompleteHandler;
  7383. STATUS_HANDLER StatusHandler;
  7384. STATUS_COMPLETE_HANDLER StatusCompleteHandler;
  7385. NDIS_STRING Name;
  7386. } NDIS30_PROTOCOL_CHARACTERISTICS;
  7387. //
  7388. // Function types extensions for NDIS 4.0 Protocols
  7389. //
  7390. typedef
  7391. INT
  7392. (*RECEIVE_PACKET_HANDLER)(
  7393. IN NDIS_HANDLE ProtocolBindingContext,
  7394. IN PNDIS_PACKET Packet
  7395. );
  7396. typedef
  7397. VOID
  7398. (*BIND_HANDLER)(
  7399. OUT PNDIS_STATUS Status,
  7400. IN NDIS_HANDLE BindContext,
  7401. IN PNDIS_STRING DeviceName,
  7402. IN PVOID SystemSpecific1,
  7403. IN PVOID SystemSpecific2
  7404. );
  7405. typedef
  7406. VOID
  7407. (*UNBIND_HANDLER)(
  7408. OUT PNDIS_STATUS Status,
  7409. IN NDIS_HANDLE ProtocolBindingContext,
  7410. IN NDIS_HANDLE UnbindContext
  7411. );
  7412. typedef
  7413. NDIS_STATUS
  7414. (*PNP_EVENT_HANDLER)(
  7415. IN NDIS_HANDLE ProtocolBindingContext,
  7416. IN PNET_PNP_EVENT NetPnPEvent
  7417. );
  7418. typedef
  7419. VOID
  7420. (*UNLOAD_PROTOCOL_HANDLER)(
  7421. VOID
  7422. );
  7423. //
  7424. // Protocol characteristics for NDIS 4.0 protocols
  7425. //
  7426. typedef struct _NDIS40_PROTOCOL_CHARACTERISTICS
  7427. {
  7428. #ifdef __cplusplus
  7429. NDIS30_PROTOCOL_CHARACTERISTICS Ndis30Chars;
  7430. #else
  7431. NDIS30_PROTOCOL_CHARACTERISTICS;
  7432. #endif
  7433. //
  7434. // Start of NDIS 4.0 extensions.
  7435. //
  7436. RECEIVE_PACKET_HANDLER ReceivePacketHandler;
  7437. //
  7438. // PnP protocol entry-points
  7439. //
  7440. BIND_HANDLER BindAdapterHandler;
  7441. UNBIND_HANDLER UnbindAdapterHandler;
  7442. PNP_EVENT_HANDLER PnPEventHandler;
  7443. UNLOAD_PROTOCOL_HANDLER UnloadHandler;
  7444. } NDIS40_PROTOCOL_CHARACTERISTICS;
  7445. //
  7446. // Protocol (5.0) handler proto-types - used by clients as well as call manager modules
  7447. //
  7448. typedef
  7449. VOID
  7450. (*CO_SEND_COMPLETE_HANDLER)(
  7451. IN NDIS_STATUS Status,
  7452. IN NDIS_HANDLE ProtocolVcContext,
  7453. IN PNDIS_PACKET Packet
  7454. );
  7455. typedef
  7456. VOID
  7457. (*CO_STATUS_HANDLER)(
  7458. IN NDIS_HANDLE ProtocolBindingContext,
  7459. IN NDIS_HANDLE ProtocolVcContext OPTIONAL,
  7460. IN NDIS_STATUS GeneralStatus,
  7461. IN PVOID StatusBuffer,
  7462. IN UINT StatusBufferSize
  7463. );
  7464. typedef
  7465. UINT
  7466. (*CO_RECEIVE_PACKET_HANDLER)(
  7467. IN NDIS_HANDLE ProtocolBindingContext,
  7468. IN NDIS_HANDLE ProtocolVcContext,
  7469. IN PNDIS_PACKET Packet
  7470. );
  7471. typedef
  7472. NDIS_STATUS
  7473. (*CO_REQUEST_HANDLER)(
  7474. IN NDIS_HANDLE ProtocolAfContext,
  7475. IN NDIS_HANDLE ProtocolVcContext OPTIONAL,
  7476. IN NDIS_HANDLE ProtocolPartyContext OPTIONAL,
  7477. IN OUT PNDIS_REQUEST NdisRequest
  7478. );
  7479. typedef
  7480. VOID
  7481. (*CO_REQUEST_COMPLETE_HANDLER)(
  7482. IN NDIS_STATUS Status,
  7483. IN NDIS_HANDLE ProtocolAfContext OPTIONAL,
  7484. IN NDIS_HANDLE ProtocolVcContext OPTIONAL,
  7485. IN NDIS_HANDLE ProtocolPartyContext OPTIONAL,
  7486. IN PNDIS_REQUEST NdisRequest
  7487. );
  7488. //
  7489. // CO_CREATE_VC_HANDLER and CO_DELETE_VC_HANDLER are synchronous calls
  7490. //
  7491. typedef
  7492. NDIS_STATUS
  7493. (*CO_CREATE_VC_HANDLER)(
  7494. IN NDIS_HANDLE ProtocolAfContext,
  7495. IN NDIS_HANDLE NdisVcHandle,
  7496. OUT PNDIS_HANDLE ProtocolVcContext
  7497. );
  7498. typedef
  7499. NDIS_STATUS
  7500. (*CO_DELETE_VC_HANDLER)(
  7501. IN NDIS_HANDLE ProtocolVcContext
  7502. );
  7503. typedef
  7504. VOID
  7505. (*CO_AF_REGISTER_NOTIFY_HANDLER)(
  7506. IN NDIS_HANDLE ProtocolBindingContext,
  7507. IN PCO_ADDRESS_FAMILY AddressFamily
  7508. );
  7509. typedef struct _NDIS50_PROTOCOL_CHARACTERISTICS
  7510. {
  7511. #ifdef __cplusplus
  7512. NDIS40_PROTOCOL_CHARACTERISTICS Ndis40Chars;
  7513. #else
  7514. NDIS40_PROTOCOL_CHARACTERISTICS;
  7515. #endif
  7516. //
  7517. // Placeholders for protocol extensions for PnP/PM etc.
  7518. //
  7519. PVOID ReservedHandlers[4];
  7520. //
  7521. // Start of NDIS 5.0 extensions.
  7522. //
  7523. CO_SEND_COMPLETE_HANDLER CoSendCompleteHandler;
  7524. CO_STATUS_HANDLER CoStatusHandler;
  7525. CO_RECEIVE_PACKET_HANDLER CoReceivePacketHandler;
  7526. CO_AF_REGISTER_NOTIFY_HANDLER CoAfRegisterNotifyHandler;
  7527. } NDIS50_PROTOCOL_CHARACTERISTICS;
  7528. #if (defined(NDIS50) || defined(NDIS51))
  7529. typedef NDIS50_PROTOCOL_CHARACTERISTICS NDIS_PROTOCOL_CHARACTERISTICS;
  7530. #else
  7531. #if NDIS40
  7532. typedef NDIS40_PROTOCOL_CHARACTERISTICS NDIS_PROTOCOL_CHARACTERISTICS;
  7533. #else
  7534. typedef NDIS30_PROTOCOL_CHARACTERISTICS NDIS_PROTOCOL_CHARACTERISTICS;
  7535. #endif
  7536. #endif
  7537. typedef NDIS_PROTOCOL_CHARACTERISTICS *PNDIS_PROTOCOL_CHARACTERISTICS;
  7538. //
  7539. // Requests used by Protocol Modules
  7540. //
  7541. EXPORT
  7542. VOID
  7543. NdisRegisterProtocol(
  7544. OUT PNDIS_STATUS Status,
  7545. OUT PNDIS_HANDLE NdisProtocolHandle,
  7546. IN PNDIS_PROTOCOL_CHARACTERISTICS ProtocolCharacteristics,
  7547. IN UINT CharacteristicsLength
  7548. );
  7549. EXPORT
  7550. VOID
  7551. NdisDeregisterProtocol(
  7552. OUT PNDIS_STATUS Status,
  7553. IN NDIS_HANDLE NdisProtocolHandle
  7554. );
  7555. EXPORT
  7556. VOID
  7557. NdisOpenAdapter(
  7558. OUT PNDIS_STATUS Status,
  7559. OUT PNDIS_STATUS OpenErrorStatus,
  7560. OUT PNDIS_HANDLE NdisBindingHandle,
  7561. OUT PUINT SelectedMediumIndex,
  7562. IN PNDIS_MEDIUM MediumArray,
  7563. IN UINT MediumArraySize,
  7564. IN NDIS_HANDLE NdisProtocolHandle,
  7565. IN NDIS_HANDLE ProtocolBindingContext,
  7566. IN PNDIS_STRING AdapterName,
  7567. IN UINT OpenOptions,
  7568. IN PSTRING AddressingInformation OPTIONAL
  7569. );
  7570. EXPORT
  7571. VOID
  7572. NdisCloseAdapter(
  7573. OUT PNDIS_STATUS Status,
  7574. IN NDIS_HANDLE NdisBindingHandle
  7575. );
  7576. EXPORT
  7577. VOID
  7578. NdisCompleteBindAdapter(
  7579. IN NDIS_HANDLE BindAdapterContext,
  7580. IN NDIS_STATUS Status,
  7581. IN NDIS_STATUS OpenStatus
  7582. );
  7583. EXPORT
  7584. VOID
  7585. NdisCompleteUnbindAdapter(
  7586. IN NDIS_HANDLE UnbindAdapterContext,
  7587. IN NDIS_STATUS Status
  7588. );
  7589. EXPORT
  7590. VOID
  7591. NdisSetProtocolFilter(
  7592. OUT PNDIS_STATUS Status,
  7593. IN NDIS_HANDLE NdisBindingHandle,
  7594. IN RECEIVE_HANDLER ReceiveHandler,
  7595. IN RECEIVE_PACKET_HANDLER ReceivePacketHandler,
  7596. IN NDIS_MEDIUM Medium,
  7597. IN UINT Offset,
  7598. IN UINT Size,
  7599. IN PUCHAR Pattern
  7600. );
  7601. EXPORT
  7602. VOID
  7603. NdisOpenProtocolConfiguration(
  7604. OUT PNDIS_STATUS Status,
  7605. OUT PNDIS_HANDLE ConfigurationHandle,
  7606. IN PNDIS_STRING ProtocolSection
  7607. );
  7608. EXPORT
  7609. VOID
  7610. NdisGetDriverHandle(
  7611. IN NDIS_HANDLE NdisBindingHandle,
  7612. OUT PNDIS_HANDLE NdisDriverHandle
  7613. );
  7614. EXPORT
  7615. VOID
  7616. NdisReEnumerateProtocolBindings(
  7617. IN NDIS_HANDLE NdisProtocolHandle
  7618. );
  7619. EXPORT
  7620. NDIS_STATUS
  7621. NdisWriteEventLogEntry(
  7622. IN PVOID LogHandle,
  7623. IN NDIS_STATUS EventCode,
  7624. IN ULONG UniqueEventValue,
  7625. IN USHORT NumStrings,
  7626. IN PVOID StringsList OPTIONAL,
  7627. IN ULONG DataSize,
  7628. IN PVOID Data OPTIONAL
  7629. );
  7630. //
  7631. // The following routine is used by transports to complete pending
  7632. // network PnP events.
  7633. //
  7634. EXPORT
  7635. VOID
  7636. NdisCompletePnPEvent(
  7637. IN NDIS_STATUS Status,
  7638. IN NDIS_HANDLE NdisBindingHandle,
  7639. IN PNET_PNP_EVENT NetPnPEvent
  7640. );
  7641. //
  7642. // The following routine is used by a transport to query the localized
  7643. // friendly instance name of the adapter that they are bound to. There
  7644. // are two variations of this, one uses the binding handle and the other
  7645. // the binding context. Some transports need this before they bind - like
  7646. // TCP/IP for instance.
  7647. //
  7648. EXPORT
  7649. NDIS_STATUS
  7650. NdisQueryAdapterInstanceName(
  7651. OUT PNDIS_STRING pAdapterInstanceName,
  7652. IN NDIS_HANDLE NdisBindingHandle
  7653. );
  7654. EXPORT
  7655. NDIS_STATUS
  7656. NdisQueryBindInstanceName(
  7657. OUT PNDIS_STRING pAdapterInstanceName,
  7658. IN NDIS_HANDLE BindingContext
  7659. );
  7660. //
  7661. // The following is used by TDI/NDIS interface as part of Network PnP.
  7662. // For use by TDI alone.
  7663. //
  7664. typedef
  7665. NTSTATUS
  7666. (*TDI_REGISTER_CALLBACK)(
  7667. IN PUNICODE_STRING DeviceName,
  7668. OUT HANDLE * TdiHandle
  7669. );
  7670. typedef
  7671. NTSTATUS
  7672. (*TDI_PNP_HANDLER)(
  7673. IN PUNICODE_STRING UpperComponent,
  7674. IN PUNICODE_STRING LowerComponent,
  7675. IN PUNICODE_STRING BindList,
  7676. IN PVOID ReconfigBuffer,
  7677. IN UINT ReconfigBufferSize,
  7678. IN UINT Operation
  7679. );
  7680. EXPORT
  7681. VOID
  7682. NdisRegisterTdiCallBack(
  7683. IN TDI_REGISTER_CALLBACK RegisterCallback,
  7684. IN TDI_PNP_HANDLER PnPHandler
  7685. );
  7686. EXPORT
  7687. VOID
  7688. NdisRegisterTdiPnpHandler(
  7689. IN TDI_PNP_HANDLER PnPHandler
  7690. );
  7691. EXPORT
  7692. VOID
  7693. NdisDeregisterTdiCallBack(
  7694. VOID
  7695. );
  7696. VOID
  7697. NdisReset(
  7698. OUT PNDIS_STATUS Status,
  7699. IN NDIS_HANDLE NdisBindingHandle
  7700. );
  7701. VOID
  7702. NdisRequest(
  7703. OUT PNDIS_STATUS Status,
  7704. IN NDIS_HANDLE NdisBindingHandle,
  7705. IN PNDIS_REQUEST NdisRequest
  7706. );
  7707. #if BINARY_COMPATIBLE
  7708. VOID
  7709. NdisSend(
  7710. OUT PNDIS_STATUS Status,
  7711. IN NDIS_HANDLE NdisBindingHandle,
  7712. IN PNDIS_PACKET Packet
  7713. );
  7714. VOID
  7715. NdisSendPackets(
  7716. IN NDIS_HANDLE NdisBindingHandle,
  7717. IN PPNDIS_PACKET PacketArray,
  7718. IN UINT NumberOfPackets
  7719. );
  7720. VOID
  7721. NdisTransferData(
  7722. OUT PNDIS_STATUS Status,
  7723. IN NDIS_HANDLE NdisBindingHandle,
  7724. IN NDIS_HANDLE MacReceiveContext,
  7725. IN UINT ByteOffset,
  7726. IN UINT BytesToTransfer,
  7727. IN OUT PNDIS_PACKET Packet,
  7728. OUT PUINT BytesTransferred
  7729. );
  7730. #else // BINARY_COMPATIBLE
  7731. #ifdef __cplusplus
  7732. #define NdisSend(Status, NdisBindingHandle, Packet) \
  7733. { \
  7734. *(Status) = \
  7735. (((PNDIS_OPEN_BLOCK)(NdisBindingHandle))->NdisCommonOpenBlock.SendHandler)( \
  7736. ((PNDIS_OPEN_BLOCK)(NdisBindingHandle))->NdisCommonOpenBlock.BindingHandle, \
  7737. (Packet)); \
  7738. }
  7739. #define NdisSendPackets(NdisBindingHandle, PacketArray, NumberOfPackets) \
  7740. { \
  7741. (((PNDIS_OPEN_BLOCK)(NdisBindingHandle))->NdisCommonOpenBlock.SendPacketsHandler)( \
  7742. (PNDIS_OPEN_BLOCK)(NdisBindingHandle), \
  7743. (PacketArray), \
  7744. (NumberOfPackets)); \
  7745. }
  7746. #define WanMiniportSend(Status, \
  7747. NdisBindingHandle, \
  7748. NdisLinkHandle, \
  7749. WanPacket) \
  7750. { \
  7751. *(Status) = \
  7752. ((((PNDIS_OPEN_BLOCK)(NdisBindingHandle))->NdisCommonOpenBlock.WanSendHandler))( \
  7753. ((PNDIS_OPEN_BLOCK)(NdisBindingHandle))->NdisCommonOpenBlock.BindingHandle, \
  7754. (NdisLinkHandle), \
  7755. (PNDIS_PACKET)(WanPacket)); \
  7756. }
  7757. #define NdisTransferData(Status, \
  7758. NdisBindingHandle, \
  7759. MacReceiveContext, \
  7760. ByteOffset, \
  7761. BytesToTransfer, \
  7762. Packet, \
  7763. BytesTransferred) \
  7764. { \
  7765. *(Status) = \
  7766. (((PNDIS_OPEN_BLOCK)(NdisBindingHandle))->NdisCommonOpenBlock.TransferDataHandler)( \
  7767. ((PNDIS_OPEN_BLOCK)(NdisBindingHandle))->NdisCommonOpenBlock.BindingHandle, \
  7768. (MacReceiveContext), \
  7769. (ByteOffset), \
  7770. (BytesToTransfer), \
  7771. (Packet), \
  7772. (BytesTransferred)); \
  7773. }
  7774. #else
  7775. #define NdisSend(Status, NdisBindingHandle, Packet) \
  7776. { \
  7777. *(Status) = \
  7778. (((PNDIS_OPEN_BLOCK)(NdisBindingHandle))->SendHandler)( \
  7779. ((PNDIS_OPEN_BLOCK)(NdisBindingHandle))->BindingHandle, \
  7780. (Packet)); \
  7781. }
  7782. #define NdisSendPackets(NdisBindingHandle, PacketArray, NumberOfPackets) \
  7783. { \
  7784. (((PNDIS_OPEN_BLOCK)(NdisBindingHandle))->SendPacketsHandler)( \
  7785. (PNDIS_OPEN_BLOCK)(NdisBindingHandle), \
  7786. (PacketArray), \
  7787. (NumberOfPackets)); \
  7788. }
  7789. #define WanMiniportSend(Status, \
  7790. NdisBindingHandle, \
  7791. NdisLinkHandle, \
  7792. WanPacket) \
  7793. { \
  7794. *(Status) = \
  7795. ((((PNDIS_OPEN_BLOCK)(NdisBindingHandle))->WanSendHandler))( \
  7796. ((PNDIS_OPEN_BLOCK)(NdisBindingHandle))->BindingHandle, \
  7797. (NdisLinkHandle), \
  7798. (PNDIS_PACKET)(WanPacket)); \
  7799. }
  7800. #define NdisTransferData(Status, \
  7801. NdisBindingHandle, \
  7802. MacReceiveContext, \
  7803. ByteOffset, \
  7804. BytesToTransfer, \
  7805. Packet, \
  7806. BytesTransferred) \
  7807. { \
  7808. *(Status) = \
  7809. (((PNDIS_OPEN_BLOCK)(NdisBindingHandle))->TransferDataHandler)( \
  7810. ((PNDIS_OPEN_BLOCK)(NdisBindingHandle))->BindingHandle, \
  7811. (MacReceiveContext), \
  7812. (ByteOffset), \
  7813. (BytesToTransfer), \
  7814. (Packet), \
  7815. (BytesTransferred)); \
  7816. }
  7817. #endif // ifdef __cplusplus
  7818. #endif // BINARY_COMPATIBLE
  7819. //
  7820. // Routines to access packet flags
  7821. //
  7822. /*++
  7823. VOID
  7824. NdisSetSendFlags(
  7825. IN PNDIS_PACKET Packet,
  7826. IN UINT Flags
  7827. );
  7828. --*/
  7829. #define NdisSetSendFlags(_Packet,_Flags) (_Packet)->Private.Flags = (_Flags)
  7830. /*++
  7831. VOID
  7832. NdisQuerySendFlags(
  7833. IN PNDIS_PACKET Packet,
  7834. OUT PUINT Flags
  7835. );
  7836. --*/
  7837. #define NdisQuerySendFlags(_Packet,_Flags) *(_Flags) = (_Packet)->Private.Flags
  7838. //
  7839. // The following is the minimum size of packets a miniport must allocate
  7840. // when it indicates packets via NdisMIndicatePacket or NdisMCoIndicatePacket
  7841. //
  7842. #define PROTOCOL_RESERVED_SIZE_IN_PACKET (4 * sizeof(PVOID))
  7843. EXPORT
  7844. VOID
  7845. NdisReturnPackets(
  7846. IN PNDIS_PACKET * PacketsToReturn,
  7847. IN UINT NumberOfPackets
  7848. );
  7849. EXPORT
  7850. PNDIS_PACKET
  7851. NdisGetReceivedPacket(
  7852. IN NDIS_HANDLE NdisBindingHandle,
  7853. IN NDIS_HANDLE MacContext
  7854. );
  7855. //
  7856. // Macros to portably manipulate NDIS buffers.
  7857. //
  7858. #if BINARY_COMPATIBLE
  7859. EXPORT
  7860. ULONG
  7861. NdisBufferLength(
  7862. IN PNDIS_BUFFER Buffer
  7863. );
  7864. EXPORT
  7865. PVOID
  7866. NdisBufferVirtualAddress(
  7867. IN PNDIS_BUFFER Buffer
  7868. );
  7869. #else // BINARY_COMPATIBLE
  7870. #define NdisBufferLength(Buffer) MmGetMdlByteCount(Buffer)
  7871. #define NdisBufferVirtualAddress(_Buffer) MmGetSystemAddressForMdl(_Buffer)
  7872. #define NdisBufferVirtualAddressSafe(_Buffer, _Priority) MmGetSystemAddressForMdlSafe(_Buffer, _Priority)
  7873. #endif // BINARY_COMPATIBLE
  7874. //
  7875. // Ndis 5.1 entry points for setting/gettign packet's CancelId and cancelling send packets
  7876. //
  7877. // #if (defined(NDIS50) || defined(NDIS51) || defined(NDIS50_MINIPORT) || defined(NDIS51_MINIPORT))
  7878. /*
  7879. EXPORT
  7880. VOID
  7881. NdisSetPacketCancelId(
  7882. IN PNDIS_PACKET Packet,
  7883. IN PVOID CancelId
  7884. );
  7885. */
  7886. #define NdisSetPacketCancelId(_Packet, _CancelId) NDIS_SET_PACKET_CANCEL_ID(_Packet, _CancelId);
  7887. /*
  7888. EXPORT
  7889. PVOID
  7890. NdisGetPacketCancelId(
  7891. IN PNDIS_PACKET Packet
  7892. );
  7893. */
  7894. #define NdisGetPacketCancelId(_Packet) NDIS_GET_PACKET_CANCEL_ID(_Packet);
  7895. EXPORT
  7896. VOID
  7897. NdisCancelSendPackets(
  7898. IN NDIS_HANDLE NdisBindingHandle,
  7899. IN PVOID CancelId
  7900. );
  7901. EXPORT
  7902. NDIS_STATUS
  7903. NdisQueryPendingIOCount(
  7904. IN PVOID NdisBindingHandle,
  7905. IN OUT PULONG IoCount
  7906. );
  7907. EXPORT
  7908. UCHAR
  7909. NdisGeneratePartialCancelId(
  7910. VOID
  7911. );
  7912. #if 0
  7913. #if NDIS_RECV_SCALE
  7914. EXPORT
  7915. NDIS_STATUS
  7916. NdisSetReceiveScaleParameters(
  7917. IN NDIS_HANDLE NdisBindingHandle,
  7918. IN PNDIS_RECEIVE_SCALE_PARAMETERS ReceiveScaleParameters
  7919. );
  7920. #endif
  7921. #endif
  7922. // #endif // NDIS51
  7923. //
  7924. // The following definitions are available only to full MAC drivers. They
  7925. // must not be used by miniport drivers.
  7926. //
  7927. #if defined(NDIS_WRAPPER)
  7928. typedef
  7929. BOOLEAN
  7930. (*PNDIS_INTERRUPT_SERVICE)(
  7931. IN PVOID InterruptContext
  7932. );
  7933. typedef
  7934. VOID
  7935. (*PNDIS_DEFERRED_PROCESSING)(
  7936. IN PVOID SystemSpecific1,
  7937. IN PVOID InterruptContext,
  7938. IN PVOID SystemSpecific2,
  7939. IN PVOID SystemSpecific3
  7940. );
  7941. #endif // defined(NDIS_WRAPPER)
  7942. //
  7943. // The following handlers are used in the OPEN_BLOCK
  7944. //
  7945. typedef
  7946. NDIS_STATUS
  7947. (*WAN_SEND_HANDLER)(
  7948. IN NDIS_HANDLE NdisBindingHandle,
  7949. IN NDIS_HANDLE LinkHandle,
  7950. IN PVOID Packet
  7951. );
  7952. typedef
  7953. NDIS_STATUS
  7954. (*SEND_HANDLER)(
  7955. IN NDIS_HANDLE NdisBindingHandle,
  7956. IN PNDIS_PACKET Packet
  7957. );
  7958. typedef
  7959. NDIS_STATUS
  7960. (*TRANSFER_DATA_HANDLER)(
  7961. IN NDIS_HANDLE NdisBindingHandle,
  7962. IN NDIS_HANDLE MacReceiveContext,
  7963. IN UINT ByteOffset,
  7964. IN UINT BytesToTransfer,
  7965. OUT PNDIS_PACKET Packet,
  7966. OUT PUINT BytesTransferred
  7967. );
  7968. typedef
  7969. NDIS_STATUS
  7970. (*RESET_HANDLER)(
  7971. IN NDIS_HANDLE NdisBindingHandle
  7972. );
  7973. typedef
  7974. NDIS_STATUS
  7975. (*REQUEST_HANDLER)(
  7976. IN NDIS_HANDLE NdisBindingHandle,
  7977. IN PNDIS_REQUEST NdisRequest
  7978. );
  7979. typedef
  7980. VOID
  7981. (*SEND_PACKETS_HANDLER)(
  7982. IN NDIS_HANDLE MiniportAdapterContext,
  7983. IN PPNDIS_PACKET PacketArray,
  7984. IN UINT NumberOfPackets
  7985. );
  7986. typedef struct _NDIS_COMMON_OPEN_BLOCK
  7987. {
  7988. PVOID MacHandle; // needed for backward compatibility
  7989. NDIS_HANDLE BindingHandle; // Miniport's open context
  7990. PNDIS_MINIPORT_BLOCK MiniportHandle; // pointer to the miniport
  7991. PNDIS_PROTOCOL_BLOCK ProtocolHandle; // pointer to our protocol
  7992. NDIS_HANDLE ProtocolBindingContext;// context when calling ProtXX funcs
  7993. PNDIS_OPEN_BLOCK MiniportNextOpen; // used by adapter's OpenQueue
  7994. PNDIS_OPEN_BLOCK ProtocolNextOpen; // used by protocol's OpenQueue
  7995. NDIS_HANDLE MiniportAdapterContext; // context for miniport
  7996. BOOLEAN Reserved1;
  7997. BOOLEAN Reserved2;
  7998. BOOLEAN Reserved3;
  7999. BOOLEAN Reserved4;
  8000. PNDIS_STRING BindDeviceName;
  8001. KSPIN_LOCK Reserved5;
  8002. PNDIS_STRING RootDeviceName;
  8003. //
  8004. // These are referenced by the macros used by protocols to call.
  8005. // All of the ones referenced by the macros are internal NDIS handlers for the miniports
  8006. //
  8007. union
  8008. {
  8009. SEND_HANDLER SendHandler;
  8010. WAN_SEND_HANDLER WanSendHandler;
  8011. };
  8012. TRANSFER_DATA_HANDLER TransferDataHandler;
  8013. //
  8014. // These are referenced internally by NDIS
  8015. //
  8016. SEND_COMPLETE_HANDLER SendCompleteHandler;
  8017. TRANSFER_DATA_COMPLETE_HANDLER TransferDataCompleteHandler;
  8018. RECEIVE_HANDLER ReceiveHandler;
  8019. RECEIVE_COMPLETE_HANDLER ReceiveCompleteHandler;
  8020. WAN_RECEIVE_HANDLER WanReceiveHandler;
  8021. REQUEST_COMPLETE_HANDLER RequestCompleteHandler;
  8022. //
  8023. // NDIS 4.0 extensions
  8024. //
  8025. RECEIVE_PACKET_HANDLER ReceivePacketHandler;
  8026. SEND_PACKETS_HANDLER SendPacketsHandler;
  8027. //
  8028. // More Cached Handlers
  8029. //
  8030. RESET_HANDLER ResetHandler;
  8031. REQUEST_HANDLER RequestHandler;
  8032. RESET_COMPLETE_HANDLER ResetCompleteHandler;
  8033. STATUS_HANDLER StatusHandler;
  8034. STATUS_COMPLETE_HANDLER StatusCompleteHandler;
  8035. #if defined(NDIS_WRAPPER)
  8036. ULONG Flags;
  8037. LONG References;
  8038. KSPIN_LOCK SpinLock; // guards Closing
  8039. NDIS_HANDLE FilterHandle;
  8040. ULONG ProtocolOptions;
  8041. USHORT CurrentLookahead;
  8042. USHORT ConnectDampTicks;
  8043. USHORT DisconnectDampTicks;
  8044. //
  8045. // These are optimizations for getting to driver routines. They are not
  8046. // necessary, but are here to save a dereference through the Driver block.
  8047. //
  8048. W_SEND_HANDLER WSendHandler;
  8049. W_TRANSFER_DATA_HANDLER WTransferDataHandler;
  8050. //
  8051. // NDIS 4.0 miniport entry-points
  8052. //
  8053. W_SEND_PACKETS_HANDLER WSendPacketsHandler;
  8054. W_CANCEL_SEND_PACKETS_HANDLER CancelSendPacketsHandler;
  8055. //
  8056. // Contains the wake-up events that are enabled for the open.
  8057. //
  8058. ULONG WakeUpEnable;
  8059. //
  8060. // event to be signalled when close complets
  8061. //
  8062. PKEVENT CloseCompleteEvent;
  8063. QUEUED_CLOSE QC;
  8064. LONG AfReferences;
  8065. PNDIS_OPEN_BLOCK NextGlobalOpen;
  8066. #endif
  8067. } NDIS_COMMON_OPEN_BLOCK;
  8068. //
  8069. // one of these per open on an adapter/protocol
  8070. //
  8071. struct _NDIS_OPEN_BLOCK
  8072. {
  8073. #ifdef __cplusplus
  8074. NDIS_COMMON_OPEN_BLOCK NdisCommonOpenBlock;
  8075. #else
  8076. NDIS_COMMON_OPEN_BLOCK;
  8077. #endif
  8078. #if defined(NDIS_WRAPPER)
  8079. //
  8080. // The stuff below is for CO drivers/protocols. This part is not allocated for CL drivers.
  8081. //
  8082. struct _NDIS_OPEN_CO
  8083. {
  8084. //
  8085. // this is the list of the call manager opens done on this adapter
  8086. //
  8087. struct _NDIS_CO_AF_BLOCK * NextAf;
  8088. //
  8089. // NDIS 5.0 miniport entry-points, filled in at open time.
  8090. //
  8091. W_CO_CREATE_VC_HANDLER MiniportCoCreateVcHandler;
  8092. W_CO_REQUEST_HANDLER MiniportCoRequestHandler;
  8093. //
  8094. // NDIS 5.0 protocol completion routines, filled in at RegisterAf/OpenAf time
  8095. //
  8096. CO_CREATE_VC_HANDLER CoCreateVcHandler;
  8097. CO_DELETE_VC_HANDLER CoDeleteVcHandler;
  8098. CM_ACTIVATE_VC_COMPLETE_HANDLER CmActivateVcCompleteHandler;
  8099. CM_DEACTIVATE_VC_COMPLETE_HANDLER CmDeactivateVcCompleteHandler;
  8100. CO_REQUEST_COMPLETE_HANDLER CoRequestCompleteHandler;
  8101. //
  8102. // lists for queuing connections. There is both a queue for currently
  8103. // active connections and a queue for connections that are not active.
  8104. //
  8105. LIST_ENTRY ActiveVcHead;
  8106. LIST_ENTRY InactiveVcHead;
  8107. LONG PendingAfNotifications;
  8108. PKEVENT AfNotifyCompleteEvent;
  8109. };
  8110. #endif
  8111. };
  8112. //
  8113. // The following definitions are available only to miniport drivers. They
  8114. // must not be used by full MAC drivers.
  8115. //
  8116. #if defined(NDIS_MINIPORT_DRIVER) || defined(NDIS_WRAPPER)
  8117. #if ARCNET
  8118. #include <afilter.h>
  8119. #endif
  8120. #include <xfilter.h>
  8121. #define NDIS_M_MAX_LOOKAHEAD 526
  8122. //
  8123. // Function types for NDIS_MINIPORT_CHARACTERISTICS
  8124. //
  8125. typedef
  8126. BOOLEAN
  8127. (*W_CHECK_FOR_HANG_HANDLER)(
  8128. IN NDIS_HANDLE MiniportAdapterContext
  8129. );
  8130. typedef
  8131. VOID
  8132. (*W_DISABLE_INTERRUPT_HANDLER)(
  8133. IN NDIS_HANDLE MiniportAdapterContext
  8134. );
  8135. typedef
  8136. VOID
  8137. (*W_ENABLE_INTERRUPT_HANDLER)(
  8138. IN NDIS_HANDLE MiniportAdapterContext
  8139. );
  8140. typedef
  8141. VOID
  8142. (*W_HALT_HANDLER)(
  8143. IN NDIS_HANDLE MiniportAdapterContext
  8144. );
  8145. typedef
  8146. VOID
  8147. (*W_HANDLE_INTERRUPT_HANDLER)(
  8148. IN NDIS_HANDLE MiniportAdapterContext
  8149. );
  8150. typedef
  8151. NDIS_STATUS
  8152. (*W_INITIALIZE_HANDLER)(
  8153. OUT PNDIS_STATUS OpenErrorStatus,
  8154. OUT PUINT SelectedMediumIndex,
  8155. IN PNDIS_MEDIUM MediumArray,
  8156. IN UINT MediumArraySize,
  8157. IN NDIS_HANDLE MiniportAdapterContext,
  8158. IN NDIS_HANDLE WrapperConfigurationContext
  8159. );
  8160. typedef
  8161. VOID
  8162. (*W_ISR_HANDLER)(
  8163. OUT PBOOLEAN InterruptRecognized,
  8164. OUT PBOOLEAN QueueMiniportHandleInterrupt,
  8165. IN NDIS_HANDLE MiniportAdapterContext
  8166. );
  8167. typedef
  8168. NDIS_STATUS
  8169. (*W_QUERY_INFORMATION_HANDLER)(
  8170. IN NDIS_HANDLE MiniportAdapterContext,
  8171. IN NDIS_OID Oid,
  8172. IN PVOID InformationBuffer,
  8173. IN ULONG InformationBufferLength,
  8174. OUT PULONG BytesWritten,
  8175. OUT PULONG BytesNeeded
  8176. );
  8177. typedef
  8178. NDIS_STATUS
  8179. (*W_RECONFIGURE_HANDLER)(
  8180. OUT PNDIS_STATUS OpenErrorStatus,
  8181. IN NDIS_HANDLE MiniportAdapterContext OPTIONAL,
  8182. IN NDIS_HANDLE WrapperConfigurationContext
  8183. );
  8184. typedef
  8185. NDIS_STATUS
  8186. (*W_RESET_HANDLER)(
  8187. OUT PBOOLEAN AddressingReset,
  8188. IN NDIS_HANDLE MiniportAdapterContext
  8189. );
  8190. typedef
  8191. NDIS_STATUS
  8192. (*W_SEND_HANDLER)(
  8193. IN NDIS_HANDLE MiniportAdapterContext,
  8194. IN PNDIS_PACKET Packet,
  8195. IN UINT Flags
  8196. );
  8197. typedef
  8198. NDIS_STATUS
  8199. (*WM_SEND_HANDLER)(
  8200. IN NDIS_HANDLE MiniportAdapterContext,
  8201. IN NDIS_HANDLE NdisLinkHandle,
  8202. IN PNDIS_WAN_PACKET Packet
  8203. );
  8204. typedef
  8205. NDIS_STATUS
  8206. (*W_SET_INFORMATION_HANDLER)(
  8207. IN NDIS_HANDLE MiniportAdapterContext,
  8208. IN NDIS_OID Oid,
  8209. IN PVOID InformationBuffer,
  8210. IN ULONG InformationBufferLength,
  8211. OUT PULONG BytesRead,
  8212. OUT PULONG BytesNeeded
  8213. );
  8214. typedef
  8215. NDIS_STATUS
  8216. (*W_TRANSFER_DATA_HANDLER)(
  8217. OUT PNDIS_PACKET Packet,
  8218. OUT PUINT BytesTransferred,
  8219. IN NDIS_HANDLE MiniportAdapterContext,
  8220. IN NDIS_HANDLE MiniportReceiveContext,
  8221. IN UINT ByteOffset,
  8222. IN UINT BytesToTransfer
  8223. );
  8224. typedef
  8225. NDIS_STATUS
  8226. (*WM_TRANSFER_DATA_HANDLER)(
  8227. VOID
  8228. );
  8229. typedef struct _NDIS30_MINIPORT_CHARACTERISTICS
  8230. {
  8231. UCHAR MajorNdisVersion;
  8232. UCHAR MinorNdisVersion;
  8233. USHORT Filler;
  8234. UINT Reserved;
  8235. W_CHECK_FOR_HANG_HANDLER CheckForHangHandler;
  8236. W_DISABLE_INTERRUPT_HANDLER DisableInterruptHandler;
  8237. W_ENABLE_INTERRUPT_HANDLER EnableInterruptHandler;
  8238. W_HALT_HANDLER HaltHandler;
  8239. W_HANDLE_INTERRUPT_HANDLER HandleInterruptHandler;
  8240. W_INITIALIZE_HANDLER InitializeHandler;
  8241. W_ISR_HANDLER ISRHandler;
  8242. W_QUERY_INFORMATION_HANDLER QueryInformationHandler;
  8243. W_RECONFIGURE_HANDLER ReconfigureHandler;
  8244. W_RESET_HANDLER ResetHandler;
  8245. union
  8246. {
  8247. W_SEND_HANDLER SendHandler;
  8248. WM_SEND_HANDLER WanSendHandler;
  8249. };
  8250. W_SET_INFORMATION_HANDLER SetInformationHandler;
  8251. union
  8252. {
  8253. W_TRANSFER_DATA_HANDLER TransferDataHandler;
  8254. WM_TRANSFER_DATA_HANDLER WanTransferDataHandler;
  8255. };
  8256. } NDIS30_MINIPORT_CHARACTERISTICS;
  8257. //
  8258. // Miniport extensions for NDIS 4.0
  8259. //
  8260. typedef
  8261. VOID
  8262. (*W_RETURN_PACKET_HANDLER)(
  8263. IN NDIS_HANDLE MiniportAdapterContext,
  8264. IN PNDIS_PACKET Packet
  8265. );
  8266. //
  8267. // NDIS 4.0 extension
  8268. //
  8269. typedef
  8270. VOID
  8271. (*W_SEND_PACKETS_HANDLER)(
  8272. IN NDIS_HANDLE MiniportAdapterContext,
  8273. IN PPNDIS_PACKET PacketArray,
  8274. IN UINT NumberOfPackets
  8275. );
  8276. typedef
  8277. VOID
  8278. (*W_ALLOCATE_COMPLETE_HANDLER)(
  8279. IN NDIS_HANDLE MiniportAdapterContext,
  8280. IN PVOID VirtualAddress,
  8281. IN PNDIS_PHYSICAL_ADDRESS PhysicalAddress,
  8282. IN ULONG Length,
  8283. IN PVOID Context
  8284. );
  8285. typedef struct _NDIS40_MINIPORT_CHARACTERISTICS
  8286. {
  8287. #ifdef __cplusplus
  8288. NDIS30_MINIPORT_CHARACTERISTICS Ndis30Chars;
  8289. #else
  8290. NDIS30_MINIPORT_CHARACTERISTICS;
  8291. #endif
  8292. //
  8293. // Extensions for NDIS 4.0
  8294. //
  8295. W_RETURN_PACKET_HANDLER ReturnPacketHandler;
  8296. W_SEND_PACKETS_HANDLER SendPacketsHandler;
  8297. W_ALLOCATE_COMPLETE_HANDLER AllocateCompleteHandler;
  8298. } NDIS40_MINIPORT_CHARACTERISTICS;
  8299. //
  8300. // Miniport extensions for NDIS 5.0
  8301. //
  8302. //
  8303. // NDIS 5.0 extension - however available for miniports only
  8304. //
  8305. //
  8306. // W_CO_CREATE_VC_HANDLER is a synchronous call
  8307. //
  8308. typedef
  8309. NDIS_STATUS
  8310. (*W_CO_CREATE_VC_HANDLER)(
  8311. IN NDIS_HANDLE MiniportAdapterContext,
  8312. IN NDIS_HANDLE NdisVcHandle,
  8313. OUT PNDIS_HANDLE MiniportVcContext
  8314. );
  8315. typedef
  8316. NDIS_STATUS
  8317. (*W_CO_DELETE_VC_HANDLER)(
  8318. IN NDIS_HANDLE MiniportVcContext
  8319. );
  8320. typedef
  8321. NDIS_STATUS
  8322. (*W_CO_ACTIVATE_VC_HANDLER)(
  8323. IN NDIS_HANDLE MiniportVcContext,
  8324. IN OUT PCO_CALL_PARAMETERS CallParameters
  8325. );
  8326. typedef
  8327. NDIS_STATUS
  8328. (*W_CO_DEACTIVATE_VC_HANDLER)(
  8329. IN NDIS_HANDLE MiniportVcContext
  8330. );
  8331. typedef
  8332. VOID
  8333. (*W_CO_SEND_PACKETS_HANDLER)(
  8334. IN NDIS_HANDLE MiniportVcContext,
  8335. IN PPNDIS_PACKET PacketArray,
  8336. IN UINT NumberOfPackets
  8337. );
  8338. typedef
  8339. NDIS_STATUS
  8340. (*W_CO_REQUEST_HANDLER)(
  8341. IN NDIS_HANDLE MiniportAdapterContext,
  8342. IN NDIS_HANDLE MiniportVcContext OPTIONAL,
  8343. IN OUT PNDIS_REQUEST NdisRequest
  8344. );
  8345. typedef struct _NDIS50_MINIPORT_CHARACTERISTICS
  8346. {
  8347. #ifdef __cplusplus
  8348. NDIS40_MINIPORT_CHARACTERISTICS Ndis40Chars;
  8349. #else
  8350. NDIS40_MINIPORT_CHARACTERISTICS;
  8351. #endif
  8352. //
  8353. // Extensions for NDIS 5.0
  8354. //
  8355. W_CO_CREATE_VC_HANDLER CoCreateVcHandler;
  8356. W_CO_DELETE_VC_HANDLER CoDeleteVcHandler;
  8357. W_CO_ACTIVATE_VC_HANDLER CoActivateVcHandler;
  8358. W_CO_DEACTIVATE_VC_HANDLER CoDeactivateVcHandler;
  8359. W_CO_SEND_PACKETS_HANDLER CoSendPacketsHandler;
  8360. W_CO_REQUEST_HANDLER CoRequestHandler;
  8361. } NDIS50_MINIPORT_CHARACTERISTICS;
  8362. //
  8363. // Miniport extensions for NDIS 5.1
  8364. //
  8365. typedef VOID
  8366. (*W_CANCEL_SEND_PACKETS_HANDLER)(
  8367. IN NDIS_HANDLE MiniportAdapterContext,
  8368. IN PVOID CancelId
  8369. );
  8370. //
  8371. // power profiles
  8372. //
  8373. typedef enum _NDIS_POWER_PROFILE
  8374. {
  8375. NdisPowerProfileBattery,
  8376. NdisPowerProfileAcOnLine
  8377. } NDIS_POWER_PROFILE, *PNDIS_POWER_PROFILE;
  8378. typedef enum _NDIS_DEVICE_PNP_EVENT
  8379. {
  8380. NdisDevicePnPEventQueryRemoved,
  8381. NdisDevicePnPEventRemoved,
  8382. NdisDevicePnPEventSurpriseRemoved,
  8383. NdisDevicePnPEventQueryStopped,
  8384. NdisDevicePnPEventStopped,
  8385. NdisDevicePnPEventPowerProfileChanged,
  8386. NdisDevicePnPEventMaximum
  8387. } NDIS_DEVICE_PNP_EVENT, *PNDIS_DEVICE_PNP_EVENT;
  8388. typedef VOID
  8389. (*W_PNP_EVENT_NOTIFY_HANDLER)(
  8390. IN NDIS_HANDLE MiniportAdapterContext,
  8391. IN NDIS_DEVICE_PNP_EVENT DevicePnPEvent,
  8392. IN PVOID InformationBuffer,
  8393. IN ULONG InformationBufferLength
  8394. );
  8395. typedef VOID
  8396. (*W_MINIPORT_SHUTDOWN_HANDLER) (
  8397. IN NDIS_HANDLE MiniportAdapterContext
  8398. );
  8399. #if NDIS_RECV_SCALE
  8400. typedef
  8401. BOOLEAN
  8402. (*MINIPORT_ISR_HANDLER)(
  8403. IN NDIS_HANDLE MiniportInterruptContext,
  8404. OUT PBOOLEAN QueueDefaultInterruptDpc,
  8405. OUT PULONG TargetProcessors
  8406. );
  8407. typedef
  8408. VOID
  8409. (*MINIPORT_INTERRUPT_DPC_HANDLER)(
  8410. IN NDIS_HANDLE MiniportInterruptContext,
  8411. OUT PULONG TargetProcessors
  8412. );
  8413. typedef struct _NDIS_MINIPORT_INTERRUPT_EX
  8414. {
  8415. PKINTERRUPT InterruptObject;
  8416. KSPIN_LOCK DpcCountLock;
  8417. union
  8418. {
  8419. PVOID Reserved;
  8420. PVOID InterruptContext;
  8421. };
  8422. MINIPORT_ISR_HANDLER MiniportIsr;
  8423. MINIPORT_INTERRUPT_DPC_HANDLER MiniportDpc;
  8424. KDPC InterruptDpc;
  8425. PNDIS_MINIPORT_BLOCK Miniport;
  8426. UCHAR DpcCount;
  8427. BOOLEAN Filler1;
  8428. //
  8429. // This is used to tell when all the Dpcs for the adapter are completed.
  8430. //
  8431. KEVENT DpcsCompletedEvent;
  8432. BOOLEAN SharedInterrupt;
  8433. BOOLEAN IsrRequested;
  8434. struct _NDIS_MINIPORT_INTERRUPT_EX *NextInterrupt;
  8435. ULONG DpcQueued; // bitmap of processors for which a Dpc is already queud
  8436. KDPC Dpc[NDIS_MAX_PROCESSOR_COUNT];
  8437. } NDIS_MINIPORT_INTERRUPT_EX, *PNDIS_MINIPORT_INTERRUPT_EX;
  8438. EXPORT
  8439. NDIS_STATUS
  8440. NdisMRegisterInterruptEx(
  8441. OUT PNDIS_MINIPORT_INTERRUPT_EX Interrupt,
  8442. IN NDIS_HANDLE MiniportAdapterHandle,
  8443. IN UINT InterruptVector,
  8444. IN UINT InterruptLevel,
  8445. IN BOOLEAN RequestIsr,
  8446. IN BOOLEAN SharedInterrupt,
  8447. IN NDIS_INTERRUPT_MODE InterruptMode
  8448. );
  8449. EXPORT
  8450. VOID
  8451. NdisMDeregisterInterruptEx(
  8452. IN PNDIS_MINIPORT_INTERRUPT_EX MiniportInterrupt
  8453. );
  8454. //
  8455. // for interrupts registered with NdisMRegisterInterruptEx
  8456. // BOOLEAN
  8457. // NdisMSynchronizeWithInterruptEx(
  8458. // IN PNDIS_MINIPORT_INTERRUPT_EX Interrupt,
  8459. // IN PVOID SynchronizeFunction,
  8460. // IN PVOID SynchronizeContext
  8461. // );
  8462. #define NdisMSynchronizeWithInterruptEx(_Interrupt, _SynchronizeFunction, _SynchronizeContext) \
  8463. NdisMSynchronizeWithInterrupt((PNDIS_MINIPORT_INTERRUPT)(_Interrupt), _SynchronizeFunction, _SynchronizeContext)
  8464. #endif
  8465. typedef struct _NDIS51_MINIPORT_CHARACTERISTICS
  8466. {
  8467. #ifdef __cplusplus
  8468. NDIS50_MINIPORT_CHARACTERISTICS Ndis50Chars;
  8469. #else
  8470. NDIS50_MINIPORT_CHARACTERISTICS;
  8471. #endif
  8472. //
  8473. // Extensions for NDIS 5.1
  8474. //
  8475. W_CANCEL_SEND_PACKETS_HANDLER CancelSendPacketsHandler;
  8476. W_PNP_EVENT_NOTIFY_HANDLER PnPEventNotifyHandler;
  8477. W_MINIPORT_SHUTDOWN_HANDLER AdapterShutdownHandler;
  8478. #if NDIS_RECV_SCALE
  8479. MINIPORT_ISR_HANDLER MiniportISRHandler;
  8480. MINIPORT_INTERRUPT_DPC_HANDLER InterruptDpcHandler;
  8481. #else
  8482. PVOID Reserved1;
  8483. PVOID Reserved2;
  8484. #endif
  8485. PVOID Reserved3;
  8486. PVOID Reserved4;
  8487. } NDIS51_MINIPORT_CHARACTERISTICS;
  8488. #ifdef NDIS51_MINIPORT
  8489. typedef struct _NDIS51_MINIPORT_CHARACTERISTICS NDIS_MINIPORT_CHARACTERISTICS;
  8490. #else
  8491. #ifdef NDIS50_MINIPORT
  8492. typedef struct _NDIS50_MINIPORT_CHARACTERISTICS NDIS_MINIPORT_CHARACTERISTICS;
  8493. #else
  8494. #ifdef NDIS40_MINIPORT
  8495. typedef struct _NDIS40_MINIPORT_CHARACTERISTICS NDIS_MINIPORT_CHARACTERISTICS;
  8496. #else
  8497. typedef struct _NDIS30_MINIPORT_CHARACTERISTICS NDIS_MINIPORT_CHARACTERISTICS;
  8498. #endif
  8499. #endif
  8500. #endif
  8501. typedef NDIS_MINIPORT_CHARACTERISTICS * PNDIS_MINIPORT_CHARACTERISTICS;
  8502. typedef NDIS_MINIPORT_CHARACTERISTICS NDIS_WAN_MINIPORT_CHARACTERISTICS;
  8503. typedef NDIS_WAN_MINIPORT_CHARACTERISTICS * PNDIS_MINIPORT_CHARACTERISTICS;
  8504. typedef struct _NDIS_MINIPORT_INTERRUPT
  8505. {
  8506. PKINTERRUPT InterruptObject;
  8507. KSPIN_LOCK DpcCountLock;
  8508. PVOID Reserved;
  8509. W_ISR_HANDLER MiniportIsr;
  8510. W_HANDLE_INTERRUPT_HANDLER MiniportDpc;
  8511. KDPC InterruptDpc;
  8512. PNDIS_MINIPORT_BLOCK Miniport;
  8513. UCHAR DpcCount;
  8514. BOOLEAN Filler1;
  8515. //
  8516. // This is used to tell when all the Dpcs for the adapter are completed.
  8517. //
  8518. KEVENT DpcsCompletedEvent;
  8519. BOOLEAN SharedInterrupt;
  8520. BOOLEAN IsrRequested;
  8521. } NDIS_MINIPORT_INTERRUPT, *PNDIS_MINIPORT_INTERRUPT;
  8522. typedef struct _NDIS_MINIPORT_TIMER
  8523. {
  8524. KTIMER Timer;
  8525. KDPC Dpc;
  8526. PNDIS_TIMER_FUNCTION MiniportTimerFunction;
  8527. PVOID MiniportTimerContext;
  8528. PNDIS_MINIPORT_BLOCK Miniport;
  8529. struct _NDIS_MINIPORT_TIMER *NextTimer;
  8530. } NDIS_MINIPORT_TIMER, *PNDIS_MINIPORT_TIMER;
  8531. typedef
  8532. VOID
  8533. (*FILTER_PACKET_INDICATION_HANDLER)(
  8534. IN NDIS_HANDLE Miniport,
  8535. IN PPNDIS_PACKET PacketArray,
  8536. IN UINT NumberOfPackets
  8537. );
  8538. typedef
  8539. VOID
  8540. (*ETH_RCV_INDICATE_HANDLER)(
  8541. IN PETH_FILTER Filter,
  8542. IN NDIS_HANDLE MacReceiveContext,
  8543. IN PCHAR Address,
  8544. IN PVOID HeaderBuffer,
  8545. IN UINT HeaderBufferSize,
  8546. IN PVOID LookaheadBuffer,
  8547. IN UINT LookaheadBufferSize,
  8548. IN UINT PacketSize
  8549. );
  8550. typedef
  8551. VOID
  8552. (*ETH_RCV_COMPLETE_HANDLER)(
  8553. IN PETH_FILTER Filter
  8554. );
  8555. typedef
  8556. VOID
  8557. (*FDDI_RCV_INDICATE_HANDLER)(
  8558. IN PFDDI_FILTER Filter,
  8559. IN NDIS_HANDLE MacReceiveContext,
  8560. IN PCHAR Address,
  8561. IN UINT AddressLength,
  8562. IN PVOID HeaderBuffer,
  8563. IN UINT HeaderBufferSize,
  8564. IN PVOID LookaheadBuffer,
  8565. IN UINT LookaheadBufferSize,
  8566. IN UINT PacketSize
  8567. );
  8568. typedef
  8569. VOID
  8570. (*FDDI_RCV_COMPLETE_HANDLER)(
  8571. IN PFDDI_FILTER Filter
  8572. );
  8573. typedef
  8574. VOID
  8575. (*TR_RCV_INDICATE_HANDLER)(
  8576. IN PTR_FILTER Filter,
  8577. IN NDIS_HANDLE MacReceiveContext,
  8578. IN PVOID HeaderBuffer,
  8579. IN UINT HeaderBufferSize,
  8580. IN PVOID LookaheadBuffer,
  8581. IN UINT LookaheadBufferSize,
  8582. IN UINT PacketSize
  8583. );
  8584. typedef
  8585. VOID
  8586. (*TR_RCV_COMPLETE_HANDLER)(
  8587. IN PTR_FILTER Filter
  8588. );
  8589. typedef
  8590. VOID
  8591. (*WAN_RCV_HANDLER)(
  8592. OUT PNDIS_STATUS Status,
  8593. IN NDIS_HANDLE MiniportAdapterHandle,
  8594. IN NDIS_HANDLE NdisLinkContext,
  8595. IN PUCHAR Packet,
  8596. IN ULONG PacketSize
  8597. );
  8598. typedef
  8599. VOID
  8600. (*WAN_RCV_COMPLETE_HANDLER)(
  8601. IN NDIS_HANDLE MiniportAdapterHandle,
  8602. IN NDIS_HANDLE NdisLinkContext
  8603. );
  8604. typedef
  8605. VOID
  8606. (*NDIS_M_SEND_COMPLETE_HANDLER)(
  8607. IN NDIS_HANDLE MiniportAdapterHandle,
  8608. IN PNDIS_PACKET Packet,
  8609. IN NDIS_STATUS Status
  8610. );
  8611. typedef
  8612. VOID
  8613. (*NDIS_WM_SEND_COMPLETE_HANDLER)(
  8614. IN NDIS_HANDLE MiniportAdapterHandle,
  8615. IN PVOID Packet,
  8616. IN NDIS_STATUS Status
  8617. );
  8618. typedef
  8619. VOID
  8620. (*NDIS_M_TD_COMPLETE_HANDLER)(
  8621. IN NDIS_HANDLE MiniportAdapterHandle,
  8622. IN PNDIS_PACKET Packet,
  8623. IN NDIS_STATUS Status,
  8624. IN UINT BytesTransferred
  8625. );
  8626. typedef
  8627. VOID
  8628. (*NDIS_M_SEND_RESOURCES_HANDLER)(
  8629. IN NDIS_HANDLE MiniportAdapterHandle
  8630. );
  8631. typedef
  8632. VOID
  8633. (*NDIS_M_STATUS_HANDLER)(
  8634. IN NDIS_HANDLE MiniportHandle,
  8635. IN NDIS_STATUS GeneralStatus,
  8636. IN PVOID StatusBuffer,
  8637. IN UINT StatusBufferSize
  8638. );
  8639. typedef
  8640. VOID
  8641. (*NDIS_M_STS_COMPLETE_HANDLER)(
  8642. IN NDIS_HANDLE MiniportAdapterHandle
  8643. );
  8644. typedef
  8645. VOID
  8646. (*NDIS_M_REQ_COMPLETE_HANDLER)(
  8647. IN NDIS_HANDLE MiniportAdapterHandle,
  8648. IN NDIS_STATUS Status
  8649. );
  8650. typedef
  8651. VOID
  8652. (*NDIS_M_RESET_COMPLETE_HANDLER)(
  8653. IN NDIS_HANDLE MiniportAdapterHandle,
  8654. IN NDIS_STATUS Status,
  8655. IN BOOLEAN AddressingReset
  8656. );
  8657. typedef
  8658. BOOLEAN
  8659. (FASTCALL *NDIS_M_START_SENDS)(
  8660. IN PNDIS_MINIPORT_BLOCK Miniport
  8661. );
  8662. //
  8663. // Defines the type of work item.
  8664. //
  8665. typedef enum _NDIS_WORK_ITEM_TYPE
  8666. {
  8667. NdisWorkItemRequest,
  8668. NdisWorkItemSend,
  8669. NdisWorkItemReturnPackets,
  8670. NdisWorkItemResetRequested,
  8671. NdisWorkItemResetInProgress,
  8672. NdisWorkItemReserved,
  8673. NdisWorkItemMiniportCallback,
  8674. NdisMaxWorkItems
  8675. } NDIS_WORK_ITEM_TYPE, *PNDIS_WORK_ITEM_TYPE;
  8676. #define NUMBER_OF_WORK_ITEM_TYPES NdisMaxWorkItems
  8677. #define NUMBER_OF_SINGLE_WORK_ITEMS 6
  8678. //
  8679. // Work item structure
  8680. //
  8681. typedef struct _NDIS_MINIPORT_WORK_ITEM
  8682. {
  8683. //
  8684. // Link for the list of work items of this type.
  8685. //
  8686. SINGLE_LIST_ENTRY Link;
  8687. //
  8688. // type of work item and context information.
  8689. //
  8690. NDIS_WORK_ITEM_TYPE WorkItemType;
  8691. PVOID WorkItemContext;
  8692. } NDIS_MINIPORT_WORK_ITEM, *PNDIS_MINIPORT_WORK_ITEM;
  8693. typedef
  8694. NDIS_STATUS
  8695. (FASTCALL *NDIS_M_QUEUE_WORK_ITEM)(
  8696. IN PNDIS_MINIPORT_BLOCK Miniport,
  8697. IN NDIS_WORK_ITEM_TYPE WorkItemType,
  8698. IN PVOID WorkItemContext
  8699. );
  8700. typedef
  8701. NDIS_STATUS
  8702. (FASTCALL *NDIS_M_QUEUE_NEW_WORK_ITEM)(
  8703. IN PNDIS_MINIPORT_BLOCK Miniport,
  8704. IN NDIS_WORK_ITEM_TYPE WorkItemType,
  8705. IN PVOID WorkItemContext
  8706. );
  8707. typedef
  8708. VOID
  8709. (FASTCALL *NDIS_M_DEQUEUE_WORK_ITEM)(
  8710. IN PNDIS_MINIPORT_BLOCK Miniport,
  8711. IN NDIS_WORK_ITEM_TYPE WorkItemType,
  8712. OUT PVOID * WorkItemContext
  8713. );
  8714. #if defined(NDIS_WRAPPER)
  8715. //
  8716. // Structure used by the logging apis
  8717. //
  8718. typedef struct _NDIS_LOG
  8719. {
  8720. PNDIS_MINIPORT_BLOCK Miniport; // The owning miniport block
  8721. KSPIN_LOCK LogLock; // For serialization
  8722. PIRP Irp; // Pending Irp to consume this log
  8723. UINT TotalSize; // Size of the log buffer
  8724. UINT CurrentSize;// Size of the log buffer
  8725. UINT InPtr; // IN part of the circular buffer
  8726. UINT OutPtr; // OUT part of the circular buffer
  8727. UCHAR LogBuf[1]; // The circular buffer
  8728. } NDIS_LOG, *PNDIS_LOG;
  8729. #if ARCNET
  8730. //
  8731. // Arcnet specific stuff
  8732. //
  8733. #define ARC_SEND_BUFFERS 8
  8734. #define ARC_HEADER_SIZE 4
  8735. typedef struct _NDIS_ARC_BUF
  8736. {
  8737. NDIS_HANDLE ArcnetBufferPool;
  8738. PUCHAR ArcnetLookaheadBuffer;
  8739. UINT NumFree;
  8740. ARC_BUFFER_LIST ArcnetBuffers[ARC_SEND_BUFFERS];
  8741. } NDIS_ARC_BUF, *PNDIS_ARC_BUF;
  8742. #endif
  8743. #endif
  8744. typedef struct _NDIS_BIND_PATHS
  8745. {
  8746. UINT Number;
  8747. NDIS_STRING Paths[1];
  8748. } NDIS_BIND_PATHS, *PNDIS_BIND_PATHS;
  8749. //
  8750. // Do not change the structure below !!!
  8751. //
  8752. typedef struct
  8753. {
  8754. union
  8755. {
  8756. PETH_FILTER EthDB;
  8757. PNULL_FILTER NullDB; // Default Filter
  8758. };
  8759. PTR_FILTER TrDB;
  8760. PFDDI_FILTER FddiDB;
  8761. #if ARCNET
  8762. PARC_FILTER ArcDB;
  8763. #else
  8764. PVOID XXXDB;
  8765. #endif
  8766. } FILTERDBS, *PFILTERDBS;
  8767. //
  8768. // one of these per mini-port registered on a Driver
  8769. //
  8770. struct _NDIS_MINIPORT_BLOCK
  8771. {
  8772. PVOID Signature; // MINIPORT_DEVICE_MAGIC_VALUE
  8773. PNDIS_MINIPORT_BLOCK NextMiniport; // used by driver's MiniportQueue
  8774. PNDIS_M_DRIVER_BLOCK DriverHandle; // pointer to our Driver block
  8775. NDIS_HANDLE MiniportAdapterContext; // context when calling mini-port functions
  8776. UNICODE_STRING MiniportName; // how mini-port refers to us
  8777. PNDIS_BIND_PATHS BindPaths;
  8778. NDIS_HANDLE OpenQueue; // queue of opens for this mini-port
  8779. REFERENCE ShortRef; // contains spinlock for OpenQueue
  8780. NDIS_HANDLE DeviceContext; // Context associated with the intermediate driver
  8781. UCHAR Padding1; // DO NOT REMOVE OR NDIS WILL BREAK!!!
  8782. //
  8783. // Synchronization stuff.
  8784. //
  8785. // The boolean is used to lock out several DPCs from running at the same time.
  8786. //
  8787. UCHAR LockAcquired; // EXPOSED via macros. Do not move
  8788. UCHAR PmodeOpens; // Count of opens which turned on pmode/all_local
  8789. //
  8790. // This is the processor number that the miniport's
  8791. // interrupt DPC and timers are running on.
  8792. //
  8793. UCHAR AssignedProcessor;
  8794. KSPIN_LOCK Lock;
  8795. PNDIS_REQUEST MediaRequest;
  8796. PNDIS_MINIPORT_INTERRUPT Interrupt;
  8797. ULONG Flags; // Flags to keep track of the
  8798. // miniport's state.
  8799. ULONG PnPFlags;
  8800. //
  8801. // Send information
  8802. //
  8803. LIST_ENTRY PacketList;
  8804. PNDIS_PACKET FirstPendingPacket; // This is head of the queue of packets
  8805. // waiting to be sent to miniport.
  8806. PNDIS_PACKET ReturnPacketsQueue;
  8807. //
  8808. // Space used for temp. use during request processing
  8809. //
  8810. ULONG RequestBuffer;
  8811. PVOID SetMCastBuffer;
  8812. PNDIS_MINIPORT_BLOCK PrimaryMiniport;
  8813. PVOID WrapperContext;
  8814. //
  8815. // context to pass to bus driver when reading or writing config space
  8816. //
  8817. PVOID BusDataContext;
  8818. //
  8819. // flag to specify PnP capabilities of the device. we need this to fail query_stop
  8820. // query_remove or suspend request if the device can not handle it
  8821. //
  8822. ULONG PnPCapabilities;
  8823. //
  8824. // Resource information
  8825. //
  8826. PCM_RESOURCE_LIST Resources;
  8827. //
  8828. // Watch-dog timer
  8829. //
  8830. NDIS_TIMER WakeUpDpcTimer;
  8831. //
  8832. // Needed for PnP. Upcased version. The buffer is allocated as part of the
  8833. // NDIS_MINIPORT_BLOCK itself.
  8834. //
  8835. // Note:
  8836. // the following two fields should be explicitly UNICODE_STRING because
  8837. // under Win9x the NDIS_STRING is an ANSI_STRING
  8838. //
  8839. UNICODE_STRING BaseName;
  8840. UNICODE_STRING SymbolicLinkName;
  8841. //
  8842. // Check for hang stuff
  8843. //
  8844. ULONG CheckForHangSeconds;
  8845. USHORT CFHangTicks;
  8846. USHORT CFHangCurrentTick;
  8847. //
  8848. // Reset information
  8849. //
  8850. NDIS_STATUS ResetStatus;
  8851. NDIS_HANDLE ResetOpen;
  8852. //
  8853. // Holds media specific information.
  8854. //
  8855. #ifdef __cplusplus
  8856. FILTERDBS FilterDbs; // EXPOSED via macros. Do not move
  8857. #else
  8858. FILTERDBS; // EXPOSED via macros. Do not move
  8859. #endif
  8860. FILTER_PACKET_INDICATION_HANDLER PacketIndicateHandler;
  8861. NDIS_M_SEND_COMPLETE_HANDLER SendCompleteHandler;
  8862. NDIS_M_SEND_RESOURCES_HANDLER SendResourcesHandler;
  8863. NDIS_M_RESET_COMPLETE_HANDLER ResetCompleteHandler;
  8864. NDIS_MEDIUM MediaType;
  8865. //
  8866. // contains mini-port information
  8867. //
  8868. ULONG BusNumber;
  8869. NDIS_INTERFACE_TYPE BusType;
  8870. NDIS_INTERFACE_TYPE AdapterType;
  8871. PDEVICE_OBJECT DeviceObject;
  8872. PDEVICE_OBJECT PhysicalDeviceObject;
  8873. PDEVICE_OBJECT NextDeviceObject;
  8874. //
  8875. // Holds the map registers for this mini-port.
  8876. //
  8877. struct _MAP_REGISTER_ENTRY *MapRegisters; // EXPOSED via macros. Do not move
  8878. //
  8879. // List of registered address families. Valid for the call-manager, Null for the client
  8880. //
  8881. PNDIS_AF_LIST CallMgrAfList;
  8882. PVOID MiniportThread;
  8883. PVOID SetInfoBuf;
  8884. USHORT SetInfoBufLen;
  8885. USHORT MaxSendPackets;
  8886. //
  8887. // Status code that is returned from the fake handlers.
  8888. //
  8889. NDIS_STATUS FakeStatus;
  8890. PVOID LockHandler; // For the filter lock
  8891. //
  8892. // the following field should be explicitly UNICODE_STRING because
  8893. // under Win9x the NDIS_STRING is an ANSI_STRING
  8894. //
  8895. PUNICODE_STRING pAdapterInstanceName; // Instance specific name for the adapter.
  8896. PNDIS_MINIPORT_TIMER TimerQueue;
  8897. UINT MacOptions;
  8898. //
  8899. // RequestInformation
  8900. //
  8901. PNDIS_REQUEST PendingRequest;
  8902. UINT MaximumLongAddresses;
  8903. UINT MaximumShortAddresses;
  8904. UINT CurrentLookahead;
  8905. UINT MaximumLookahead;
  8906. //
  8907. // For efficiency
  8908. //
  8909. W_HANDLE_INTERRUPT_HANDLER HandleInterruptHandler;
  8910. W_DISABLE_INTERRUPT_HANDLER DisableInterruptHandler;
  8911. W_ENABLE_INTERRUPT_HANDLER EnableInterruptHandler;
  8912. W_SEND_PACKETS_HANDLER SendPacketsHandler;
  8913. NDIS_M_START_SENDS DeferredSendHandler;
  8914. //
  8915. // The following cannot be unionized.
  8916. //
  8917. ETH_RCV_INDICATE_HANDLER EthRxIndicateHandler; // EXPOSED via macros. Do not move
  8918. TR_RCV_INDICATE_HANDLER TrRxIndicateHandler; // EXPOSED via macros. Do not move
  8919. FDDI_RCV_INDICATE_HANDLER FddiRxIndicateHandler; // EXPOSED via macros. Do not move
  8920. ETH_RCV_COMPLETE_HANDLER EthRxCompleteHandler; // EXPOSED via macros. Do not move
  8921. TR_RCV_COMPLETE_HANDLER TrRxCompleteHandler; // EXPOSED via macros. Do not move
  8922. FDDI_RCV_COMPLETE_HANDLER FddiRxCompleteHandler; // EXPOSED via macros. Do not move
  8923. NDIS_M_STATUS_HANDLER StatusHandler; // EXPOSED via macros. Do not move
  8924. NDIS_M_STS_COMPLETE_HANDLER StatusCompleteHandler; // EXPOSED via macros. Do not move
  8925. NDIS_M_TD_COMPLETE_HANDLER TDCompleteHandler; // EXPOSED via macros. Do not move
  8926. NDIS_M_REQ_COMPLETE_HANDLER QueryCompleteHandler; // EXPOSED via macros. Do not move
  8927. NDIS_M_REQ_COMPLETE_HANDLER SetCompleteHandler; // EXPOSED via macros. Do not move
  8928. NDIS_WM_SEND_COMPLETE_HANDLER WanSendCompleteHandler;// EXPOSED via macros. Do not move
  8929. WAN_RCV_HANDLER WanRcvHandler; // EXPOSED via macros. Do not move
  8930. WAN_RCV_COMPLETE_HANDLER WanRcvCompleteHandler; // EXPOSED via macros. Do not move
  8931. /********************************************************************************************/
  8932. /**************** **********/
  8933. /**************** STUFF ABOVE IS POTENTIALLY ACCESSED BY MACROS. ADD STUFF BELOW **********/
  8934. /**************** SEVERE POSSIBILITY OF BREAKING SOMETHING IF STUFF ABOVE IS MOVED **********/
  8935. /**************** **********/
  8936. /********************************************************************************************/
  8937. #if defined(NDIS_WRAPPER)
  8938. PNDIS_MINIPORT_BLOCK NextGlobalMiniport; // used to queue miniport on global miniport queue
  8939. //
  8940. // Work that the miniport needs to do.
  8941. //
  8942. SINGLE_LIST_ENTRY WorkQueue[NUMBER_OF_WORK_ITEM_TYPES];
  8943. SINGLE_LIST_ENTRY SingleWorkItems[NUMBER_OF_SINGLE_WORK_ITEMS];
  8944. UCHAR SendFlags;
  8945. UCHAR TrResetRing;
  8946. UCHAR ArcnetAddress;
  8947. UCHAR XState; // flag to indicate why we have set the fake handlers
  8948. union
  8949. {
  8950. #if ARCNET
  8951. PNDIS_ARC_BUF ArcBuf;
  8952. #endif
  8953. //
  8954. // the following field has a different use under NT and Memphis
  8955. //
  8956. PVOID BusInterface;
  8957. };
  8958. PNDIS_LOG Log;
  8959. //
  8960. // Store information here to track adapters
  8961. //
  8962. ULONG SlotNumber;
  8963. PCM_RESOURCE_LIST AllocatedResources;
  8964. PCM_RESOURCE_LIST AllocatedResourcesTranslated;
  8965. //
  8966. // Contains a list of the packet patterns that have been added to the
  8967. // adapter.
  8968. //
  8969. SINGLE_LIST_ENTRY PatternList;
  8970. //
  8971. // The driver's power management capabilities.
  8972. //
  8973. NDIS_PNP_CAPABILITIES PMCapabilities;
  8974. //
  8975. // DeviceCapabilites as received from bus driver
  8976. //
  8977. DEVICE_CAPABILITIES DeviceCaps;
  8978. //
  8979. // Contains the wake-up events that are enabled for the miniport.
  8980. //
  8981. ULONG WakeUpEnable;
  8982. //
  8983. // The current device state that the adapter is in.
  8984. //
  8985. DEVICE_POWER_STATE CurrentDevicePowerState;
  8986. //
  8987. // The following IRP is created in response to a cable disconnect
  8988. // from the device. We keep a pointer around in case we need to cancel
  8989. // it.
  8990. //
  8991. PIRP pIrpWaitWake;
  8992. SYSTEM_POWER_STATE WaitWakeSystemState;
  8993. //
  8994. // The following is a pointer to a dynamically allocated array
  8995. // of GUID structs. This is used to map GUIDs to OIDs
  8996. // for custom GUIDs provided by the miniport.
  8997. //
  8998. LARGE_INTEGER VcIndex; // Index used to identify a VC.
  8999. KSPIN_LOCK VcCountLock; // Lock used to protect VC instance count.
  9000. LIST_ENTRY WmiEnabledVcs; // List of WMI enabled VCs
  9001. PNDIS_GUID pNdisGuidMap; // This is a list of all the GUIDs
  9002. // and OIDs supported including any
  9003. // customg GUIDs.
  9004. PNDIS_GUID pCustomGuidMap; // This is a pointer into
  9005. // the pGuidToOidMap to the
  9006. // first custom GUID.
  9007. USHORT VcCount; // Number of VC's that have instance names.
  9008. USHORT cNdisGuidMap; // This is the number of std. GUIDs
  9009. USHORT cCustomGuidMap; // This is the number of custom GUIDs
  9010. //
  9011. // These two are used temporarily while allocating the map registers.
  9012. //
  9013. USHORT CurrentMapRegister;
  9014. PKEVENT AllocationEvent;
  9015. USHORT BaseMapRegistersNeeded;
  9016. USHORT SGMapRegistersNeeded;
  9017. ULONG MaximumPhysicalMapping;
  9018. //
  9019. // This timer is used for media disconnect timouts.
  9020. //
  9021. NDIS_TIMER MediaDisconnectTimer;
  9022. //
  9023. // The timeout value for media disconnect timer to fire
  9024. // default is 20 seconds
  9025. //
  9026. USHORT MediaDisconnectTimeOut;
  9027. //
  9028. // Used for WMI support
  9029. //
  9030. USHORT InstanceNumber;
  9031. //
  9032. // this event will be set at the end of adapter initialization
  9033. //
  9034. NDIS_EVENT OpenReadyEvent;
  9035. //
  9036. // current PnP state of the device, ex. started, stopped, query_removed, etc.
  9037. //
  9038. NDIS_PNP_DEVICE_STATE PnPDeviceState;
  9039. //
  9040. // previous device state. to be used when we get a cancel_remove or a cancel_stop
  9041. //
  9042. NDIS_PNP_DEVICE_STATE OldPnPDeviceState;
  9043. //
  9044. // Handlers to Write/Read Bus data
  9045. //
  9046. PGET_SET_DEVICE_DATA SetBusData;
  9047. PGET_SET_DEVICE_DATA GetBusData;
  9048. KDPC DeferredDpc;
  9049. //
  9050. // Some NDIS gathered stats
  9051. //
  9052. NDIS_STATS NdisStats;
  9053. //
  9054. // Valid during Packet Indication
  9055. //
  9056. PNDIS_PACKET IndicatedPacket[MAXIMUM_PROCESSORS];
  9057. //
  9058. // this event is for protecting against returning from REMOVE IRP
  9059. // too early and while we still have pending workitems
  9060. //
  9061. PKEVENT RemoveReadyEvent;
  9062. //
  9063. // this event gets signaled when all opens on the miniport are closed
  9064. //
  9065. PKEVENT AllOpensClosedEvent;
  9066. //
  9067. // this event gets signaled when all requests on the miniport are gone
  9068. //
  9069. PKEVENT AllRequestsCompletedEvent;
  9070. //
  9071. // Init time for the miniport in milliseconds
  9072. //
  9073. ULONG InitTimeMs;
  9074. NDIS_MINIPORT_WORK_ITEM WorkItemBuffer[NUMBER_OF_SINGLE_WORK_ITEMS];
  9075. PDMA_ADAPTER SystemAdapterObject;
  9076. //
  9077. // flags to fail certain NDIS APIs to make sure the driver does the right things
  9078. //
  9079. ULONG DriverVerifyFlags;
  9080. POID_LIST OidList;
  9081. //
  9082. // InternalResetCount: The # of times NDIS decided a miniport was hung
  9083. // MiniportResetCount The # of times miniport decided it was hung
  9084. //
  9085. USHORT InternalResetCount;
  9086. USHORT MiniportResetCount;
  9087. USHORT MediaSenseConnectCount;
  9088. USHORT MediaSenseDisconnectCount;
  9089. PNDIS_PACKET * xPackets;
  9090. //
  9091. // track the user mode requests
  9092. //
  9093. ULONG UserModeOpenReferences;
  9094. //
  9095. // Saved handlers. The handlers in the NDIS_OPEN_BLOCK are saved here
  9096. // by ndisMSwapOpenHandlers and restored by ndisMRestoreOpenHandlers.
  9097. //
  9098. union
  9099. {
  9100. PVOID SavedSendHandler;
  9101. PVOID SavedWanSendHandler;
  9102. };
  9103. W_SEND_PACKETS_HANDLER SavedSendPacketsHandler;
  9104. W_CANCEL_SEND_PACKETS_HANDLER SavedCancelSendPacketsHandler;
  9105. //
  9106. // real SendPacketsHandler
  9107. //
  9108. W_SEND_PACKETS_HANDLER WSendPacketsHandler;
  9109. ULONG MiniportAttributes;
  9110. PDMA_ADAPTER SavedSystemAdapterObject;
  9111. USHORT NumOpens;
  9112. //
  9113. // extra check for hang ticks allowed for OID_GEN_MEDIA_CONNECT_STATUS and OID_GEN_LINK_SPEED
  9114. //
  9115. USHORT CFHangXTicks;
  9116. ULONG RequestCount;
  9117. ULONG IndicatedPacketsCount;
  9118. ULONG PhysicalMediumType;
  9119. //
  9120. // last request. needed for debugging purpose
  9121. //
  9122. PNDIS_REQUEST LastRequest;
  9123. LONG DmaAdapterRefCount;
  9124. PVOID FakeMac;
  9125. ULONG LockDbg;
  9126. ULONG LockDbgX;
  9127. PVOID LockThread;
  9128. ULONG InfoFlags;
  9129. KSPIN_LOCK TimerQueueLock;
  9130. PKEVENT ResetCompletedEvent;
  9131. PKEVENT QueuedBindingCompletedEvent;
  9132. PKEVENT DmaResourcesReleasedEvent;
  9133. FILTER_PACKET_INDICATION_HANDLER SavedPacketIndicateHandler;
  9134. ULONG RegisteredInterrupts;
  9135. PNPAGED_LOOKASIDE_LIST SGListLookasideList;
  9136. ULONG ScatterGatherListSize;
  9137. PKEVENT WakeUpTimerEvent;
  9138. PSECURITY_DESCRIPTOR SecurityDescriptor;
  9139. //
  9140. // both these variables are protected by Ref->SpinLock
  9141. //
  9142. ULONG NumUserOpens; // number of non-admin open handles
  9143. ULONG NumAdminOpens; // number of admin open handles
  9144. ULONG_REFERENCE Ref;
  9145. #if NDIS_RECV_SCALE
  9146. NDIS_RECEIVE_SCALE_CAPABILITIES RecvScaleCapabilities;
  9147. #endif
  9148. #if DBG
  9149. ULONG cDpcSendCompletes;
  9150. ULONG cDpcRcvIndications;
  9151. ULONG cDpcRcvIndicationCalls;
  9152. #endif
  9153. #endif // NDIS_WRAPPER defined
  9154. };
  9155. //
  9156. // Routines for intermediate miniport drivers.
  9157. //
  9158. typedef
  9159. VOID
  9160. (*W_MINIPORT_CALLBACK)(
  9161. IN NDIS_HANDLE MiniportAdapterContext,
  9162. IN PVOID CallbackContext
  9163. );
  9164. EXPORT
  9165. NDIS_STATUS
  9166. NdisIMRegisterLayeredMiniport(
  9167. IN NDIS_HANDLE NdisWrapperHandle,
  9168. IN PNDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics,
  9169. IN UINT CharacteristicsLength,
  9170. OUT PNDIS_HANDLE DriverHandle
  9171. );
  9172. EXPORT
  9173. VOID
  9174. NdisIMDeregisterLayeredMiniport(
  9175. IN NDIS_HANDLE DriverHandle
  9176. );
  9177. EXPORT
  9178. VOID
  9179. NdisIMAssociateMiniport(
  9180. IN NDIS_HANDLE DriverHandle,
  9181. IN NDIS_HANDLE ProtocolHandle
  9182. );
  9183. EXPORT
  9184. NDIS_STATUS
  9185. NdisMRegisterDevice(
  9186. IN NDIS_HANDLE NdisWrapperHandle,
  9187. IN PNDIS_STRING DeviceName,
  9188. IN PNDIS_STRING SymbolicName,
  9189. IN PDRIVER_DISPATCH MajorFunctions[],
  9190. OUT PDEVICE_OBJECT * pDeviceObject,
  9191. OUT NDIS_HANDLE * NdisDeviceHandle
  9192. );
  9193. EXPORT
  9194. NDIS_STATUS
  9195. NdisMDeregisterDevice(
  9196. IN NDIS_HANDLE NdisDeviceHandle
  9197. );
  9198. EXPORT
  9199. VOID
  9200. NdisMRegisterUnloadHandler(
  9201. IN NDIS_HANDLE NdisWrapperHandle,
  9202. IN PDRIVER_UNLOAD UnloadHandler
  9203. );
  9204. //
  9205. // Operating System Requests
  9206. //
  9207. typedef UCHAR NDIS_DMA_SIZE;
  9208. #define NDIS_DMA_24BITS ((NDIS_DMA_SIZE)0)
  9209. #define NDIS_DMA_32BITS ((NDIS_DMA_SIZE)1)
  9210. #define NDIS_DMA_64BITS ((NDIS_DMA_SIZE)2)
  9211. EXPORT
  9212. NDIS_STATUS
  9213. NdisMAllocateMapRegisters(
  9214. IN NDIS_HANDLE MiniportAdapterHandle,
  9215. IN UINT DmaChannel,
  9216. IN NDIS_DMA_SIZE DmaSize,
  9217. IN ULONG BaseMapRegistersNeeded,
  9218. IN ULONG MaximumPhysicalMapping
  9219. );
  9220. EXPORT
  9221. VOID
  9222. NdisMFreeMapRegisters(
  9223. IN NDIS_HANDLE MiniportAdapterHandle
  9224. );
  9225. EXPORT
  9226. NDIS_STATUS
  9227. NdisMInitializeScatterGatherDma(
  9228. IN NDIS_HANDLE MiniportAdapterHandle,
  9229. IN BOOLEAN Dma64BitAddresses,
  9230. IN ULONG MaximumPhysicalMapping
  9231. );
  9232. EXPORT
  9233. NDIS_STATUS
  9234. NdisMRegisterIoPortRange(
  9235. OUT PVOID * PortOffset,
  9236. IN NDIS_HANDLE MiniportAdapterHandle,
  9237. IN UINT InitialPort,
  9238. IN UINT NumberOfPorts
  9239. );
  9240. EXPORT
  9241. VOID
  9242. NdisMDeregisterIoPortRange(
  9243. IN NDIS_HANDLE MiniportAdapterHandle,
  9244. IN UINT InitialPort,
  9245. IN UINT NumberOfPorts,
  9246. IN PVOID PortOffset
  9247. );
  9248. EXPORT
  9249. NDIS_STATUS
  9250. NdisMMapIoSpace(
  9251. OUT PVOID * VirtualAddress,
  9252. IN NDIS_HANDLE MiniportAdapterHandle,
  9253. IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
  9254. IN UINT Length
  9255. );
  9256. EXPORT
  9257. VOID
  9258. NdisMUnmapIoSpace(
  9259. IN NDIS_HANDLE MiniportAdapterHandle,
  9260. IN PVOID VirtualAddress,
  9261. IN UINT Length
  9262. );
  9263. EXPORT
  9264. NDIS_STATUS
  9265. NdisMRegisterInterrupt(
  9266. OUT PNDIS_MINIPORT_INTERRUPT Interrupt,
  9267. IN NDIS_HANDLE MiniportAdapterHandle,
  9268. IN UINT InterruptVector,
  9269. IN UINT InterruptLevel,
  9270. IN BOOLEAN RequestIsr,
  9271. IN BOOLEAN SharedInterrupt,
  9272. IN NDIS_INTERRUPT_MODE InterruptMode
  9273. );
  9274. EXPORT
  9275. VOID
  9276. NdisMDeregisterInterrupt(
  9277. IN PNDIS_MINIPORT_INTERRUPT Interrupt
  9278. );
  9279. EXPORT
  9280. BOOLEAN
  9281. NdisMSynchronizeWithInterrupt(
  9282. IN PNDIS_MINIPORT_INTERRUPT Interrupt,
  9283. IN PVOID SynchronizeFunction,
  9284. IN PVOID SynchronizeContext
  9285. );
  9286. EXPORT
  9287. VOID
  9288. NdisMQueryAdapterResources(
  9289. OUT PNDIS_STATUS Status,
  9290. IN NDIS_HANDLE WrapperConfigurationContext,
  9291. OUT PNDIS_RESOURCE_LIST ResourceList,
  9292. IN OUT PUINT BufferSize
  9293. );
  9294. //
  9295. // Timers
  9296. //
  9297. // VOID
  9298. // NdisMSetTimer(
  9299. // IN PNDIS_MINIPORT_TIMER Timer,
  9300. // IN UINT MillisecondsToDelay
  9301. // );
  9302. #define NdisMSetTimer(_Timer, _Delay) NdisSetTimer((PNDIS_TIMER)_Timer, _Delay)
  9303. EXPORT
  9304. VOID
  9305. NdisMSetPeriodicTimer(
  9306. IN PNDIS_MINIPORT_TIMER Timer,
  9307. IN UINT MillisecondPeriod
  9308. );
  9309. EXPORT
  9310. VOID
  9311. NdisMInitializeTimer(
  9312. IN OUT PNDIS_MINIPORT_TIMER Timer,
  9313. IN NDIS_HANDLE MiniportAdapterHandle,
  9314. IN PNDIS_TIMER_FUNCTION TimerFunction,
  9315. IN PVOID FunctionContext
  9316. );
  9317. EXPORT
  9318. VOID
  9319. NdisMCancelTimer(
  9320. IN PNDIS_MINIPORT_TIMER Timer,
  9321. OUT PBOOLEAN TimerCancelled
  9322. );
  9323. EXPORT
  9324. VOID
  9325. NdisMSleep(
  9326. IN ULONG MicrosecondsToSleep
  9327. );
  9328. //
  9329. // Physical Mapping
  9330. //
  9331. EXPORT
  9332. VOID
  9333. NdisMStartBufferPhysicalMapping(
  9334. IN NDIS_HANDLE MiniportAdapterHandle,
  9335. IN PNDIS_BUFFER Buffer,
  9336. IN ULONG PhysicalMapRegister,
  9337. IN BOOLEAN WriteToDevice,
  9338. OUT PNDIS_PHYSICAL_ADDRESS_UNIT PhysicalAddressArray,
  9339. OUT PUINT ArraySize
  9340. );
  9341. EXPORT
  9342. VOID
  9343. NdisMCompleteBufferPhysicalMapping(
  9344. IN NDIS_HANDLE MiniportAdapterHandle,
  9345. IN PNDIS_BUFFER Buffer,
  9346. IN ULONG PhysicalMapRegister
  9347. );
  9348. EXPORT
  9349. ULONG
  9350. NdisMGetDmaAlignment(
  9351. IN NDIS_HANDLE MiniportAdapterHandle
  9352. );
  9353. //
  9354. // Shared memory
  9355. //
  9356. EXPORT
  9357. VOID
  9358. NdisMAllocateSharedMemory(
  9359. IN NDIS_HANDLE MiniportAdapterHandle,
  9360. IN ULONG Length,
  9361. IN BOOLEAN Cached,
  9362. OUT PVOID * VirtualAddress,
  9363. OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress
  9364. );
  9365. EXPORT
  9366. NDIS_STATUS
  9367. NdisMAllocateSharedMemoryAsync(
  9368. IN NDIS_HANDLE MiniportAdapterHandle,
  9369. IN ULONG Length,
  9370. IN BOOLEAN Cached,
  9371. IN PVOID Context
  9372. );
  9373. /*++
  9374. VOID
  9375. NdisMUpdateSharedMemory(
  9376. IN NDIS_HANDLE MiniportAdapterHandle,
  9377. IN ULONG Length,
  9378. IN PVOID VirtualAddress,
  9379. IN NDIS_PHYSICAL_ADDRESS PhysicalAddress
  9380. )
  9381. --*/
  9382. #define NdisMUpdateSharedMemory(_H, _L, _V, _P) NdisUpdateSharedMemory(_H, _L, _V, _P)
  9383. EXPORT
  9384. VOID
  9385. NdisMFreeSharedMemory(
  9386. IN NDIS_HANDLE MiniportAdapterHandle,
  9387. IN ULONG Length,
  9388. IN BOOLEAN Cached,
  9389. IN PVOID VirtualAddress,
  9390. IN NDIS_PHYSICAL_ADDRESS PhysicalAddress
  9391. );
  9392. //
  9393. // DMA operations.
  9394. //
  9395. EXPORT
  9396. NDIS_STATUS
  9397. NdisMRegisterDmaChannel(
  9398. OUT PNDIS_HANDLE MiniportDmaHandle,
  9399. IN NDIS_HANDLE MiniportAdapterHandle,
  9400. IN UINT DmaChannel,
  9401. IN BOOLEAN Dma32BitAddresses,
  9402. IN PNDIS_DMA_DESCRIPTION DmaDescription,
  9403. IN ULONG MaximumLength
  9404. );
  9405. EXPORT
  9406. VOID
  9407. NdisMDeregisterDmaChannel(
  9408. IN NDIS_HANDLE MiniportDmaHandle
  9409. );
  9410. /*++
  9411. VOID
  9412. NdisMSetupDmaTransfer(
  9413. OUT PNDIS_STATUS Status,
  9414. IN NDIS_HANDLE MiniportDmaHandle,
  9415. IN PNDIS_BUFFER Buffer,
  9416. IN ULONG Offset,
  9417. IN ULONG Length,
  9418. IN BOOLEAN WriteToDevice
  9419. )
  9420. --*/
  9421. #define NdisMSetupDmaTransfer(_S, _H, _B, _O, _L, _M_) \
  9422. NdisSetupDmaTransfer(_S, _H, _B, _O, _L, _M_)
  9423. /*++
  9424. VOID
  9425. NdisMCompleteDmaTransfer(
  9426. OUT PNDIS_STATUS Status,
  9427. IN NDIS_HANDLE MiniportDmaHandle,
  9428. IN PNDIS_BUFFER Buffer,
  9429. IN ULONG Offset,
  9430. IN ULONG Length,
  9431. IN BOOLEAN WriteToDevice
  9432. )
  9433. --*/
  9434. #define NdisMCompleteDmaTransfer(_S, _H, _B, _O, _L, _M_) \
  9435. NdisCompleteDmaTransfer(_S, _H, _B, _O, _L, _M_)
  9436. EXPORT
  9437. ULONG
  9438. NdisMReadDmaCounter(
  9439. IN NDIS_HANDLE MiniportDmaHandle
  9440. );
  9441. //
  9442. // Requests Used by Miniport Drivers
  9443. //
  9444. #define NdisMInitializeWrapper(_a,_b,_c,_d) NdisInitializeWrapper((_a),(_b),(_c),(_d))
  9445. EXPORT
  9446. NDIS_STATUS
  9447. NdisMRegisterMiniport(
  9448. IN NDIS_HANDLE NdisWrapperHandle,
  9449. IN PNDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics,
  9450. IN UINT CharacteristicsLength
  9451. );
  9452. // EXPORT
  9453. // NDIS_STATUS
  9454. // NdisIMInitializeDeviceInstance(
  9455. // IN NDIS_HANDLE DriverHandle,
  9456. // IN PNDIS_STRING DriverInstance
  9457. // );
  9458. #define NdisIMInitializeDeviceInstance(_H_, _I_) \
  9459. NdisIMInitializeDeviceInstanceEx(_H_, _I_, NULL)
  9460. EXPORT
  9461. NDIS_STATUS
  9462. NdisIMInitializeDeviceInstanceEx(
  9463. IN NDIS_HANDLE DriverHandle,
  9464. IN PNDIS_STRING DriverInstance,
  9465. IN NDIS_HANDLE DeviceContext OPTIONAL
  9466. );
  9467. EXPORT
  9468. NDIS_STATUS
  9469. NdisIMCancelInitializeDeviceInstance(
  9470. IN NDIS_HANDLE DriverHandle,
  9471. IN PNDIS_STRING DeviceInstance
  9472. );
  9473. EXPORT
  9474. NDIS_HANDLE
  9475. NdisIMGetDeviceContext(
  9476. IN NDIS_HANDLE MiniportAdapterHandle
  9477. );
  9478. EXPORT
  9479. NDIS_HANDLE
  9480. NdisIMGetBindingContext(
  9481. IN NDIS_HANDLE NdisBindingHandle
  9482. );
  9483. EXPORT
  9484. NDIS_STATUS
  9485. NdisIMDeInitializeDeviceInstance(
  9486. IN NDIS_HANDLE NdisMiniportHandle
  9487. );
  9488. EXPORT
  9489. VOID
  9490. NdisIMCopySendPerPacketInfo(
  9491. OUT PNDIS_PACKET DstPacket,
  9492. IN PNDIS_PACKET SrcPacket
  9493. );
  9494. EXPORT
  9495. VOID
  9496. NdisIMCopySendCompletePerPacketInfo(
  9497. OUT PNDIS_PACKET DstPacket,
  9498. IN PNDIS_PACKET SrcPacket
  9499. );
  9500. // EXPORT
  9501. // VOID
  9502. // NdisMSetAttributes(
  9503. // IN NDIS_HANDLE MiniportAdapterHandle,
  9504. // IN NDIS_HANDLE MiniportAdapterContext,
  9505. // IN BOOLEAN BusMaster,
  9506. // IN NDIS_INTERFACE_TYPE AdapterType
  9507. // );
  9508. #define NdisMSetAttributes(_H_, _C_, _M_, _T_) \
  9509. NdisMSetAttributesEx(_H_, \
  9510. _C_, \
  9511. 0, \
  9512. (_M_) ? NDIS_ATTRIBUTE_BUS_MASTER : 0, \
  9513. _T_) \
  9514. EXPORT
  9515. VOID
  9516. NdisMSetAttributesEx(
  9517. IN NDIS_HANDLE MiniportAdapterHandle,
  9518. IN NDIS_HANDLE MiniportAdapterContext,
  9519. IN UINT CheckForHangTimeInSeconds OPTIONAL,
  9520. IN ULONG AttributeFlags,
  9521. IN NDIS_INTERFACE_TYPE AdapterType OPTIONAL
  9522. );
  9523. #define NDIS_ATTRIBUTE_IGNORE_PACKET_TIMEOUT 0x00000001
  9524. #define NDIS_ATTRIBUTE_IGNORE_REQUEST_TIMEOUT 0x00000002
  9525. #define NDIS_ATTRIBUTE_IGNORE_TOKEN_RING_ERRORS 0x00000004
  9526. #define NDIS_ATTRIBUTE_BUS_MASTER 0x00000008
  9527. #define NDIS_ATTRIBUTE_INTERMEDIATE_DRIVER 0x00000010
  9528. #define NDIS_ATTRIBUTE_DESERIALIZE 0x00000020
  9529. #define NDIS_ATTRIBUTE_NO_HALT_ON_SUSPEND 0x00000040
  9530. #define NDIS_ATTRIBUTE_SURPRISE_REMOVE_OK 0x00000080
  9531. #define NDIS_ATTRIBUTE_NOT_CO_NDIS 0x00000100
  9532. #define NDIS_ATTRIBUTE_USES_SAFE_BUFFER_APIS 0x00000200
  9533. #define NDIS_ATTRIBUTE_DO_NOT_BIND_TO_ALL_CO 0x00000400
  9534. EXPORT
  9535. NDIS_STATUS
  9536. NdisMSetMiniportSecondary(
  9537. IN NDIS_HANDLE MiniportHandle,
  9538. IN NDIS_HANDLE PrimaryMiniportHandle
  9539. );
  9540. EXPORT
  9541. NDIS_STATUS
  9542. NdisMPromoteMiniport(
  9543. IN NDIS_HANDLE MiniportHandle
  9544. );
  9545. EXPORT
  9546. NDIS_STATUS
  9547. NdisMRemoveMiniport(
  9548. IN NDIS_HANDLE MiniportHandle
  9549. );
  9550. #define NdisMSendComplete(_M, _P, _S) (*((PNDIS_MINIPORT_BLOCK)(_M))->SendCompleteHandler)(_M, _P, _S)
  9551. #define NdisMSendResourcesAvailable(_M) (*((PNDIS_MINIPORT_BLOCK)(_M))->SendResourcesHandler)(_M)
  9552. #define NdisMResetComplete(_M, _S, _A) (*((PNDIS_MINIPORT_BLOCK)(_M))->ResetCompleteHandler)(_M, _S, _A)
  9553. #define NdisMTransferDataComplete(_M, _P, _S, _B) \
  9554. (*((PNDIS_MINIPORT_BLOCK)(_M))->TDCompleteHandler)(_M, _P, _S, _B)
  9555. /*++
  9556. VOID
  9557. NdisMWanSendComplete(
  9558. IN NDIS_HANDLE MiniportAdapterHandle,
  9559. IN PVOID Packet,
  9560. IN NDIS_STATUS Status
  9561. );
  9562. --*/
  9563. #define NdisMWanSendComplete(_M_, _P_, _S_) \
  9564. (*((PNDIS_MINIPORT_BLOCK)(_M_))->WanSendCompleteHandler)(_M_, _P_, _S_)
  9565. #define NdisMQueryInformationComplete(_M, _S) \
  9566. (*((PNDIS_MINIPORT_BLOCK)(_M))->QueryCompleteHandler)(_M, _S)
  9567. #define NdisMSetInformationComplete(_M, _S) \
  9568. (*((PNDIS_MINIPORT_BLOCK)(_M))->SetCompleteHandler)(_M, _S)
  9569. /*++
  9570. VOID
  9571. NdisMIndicateReceivePacket(
  9572. IN NDIS_HANDLE MiniportAdapterHandle,
  9573. IN PPNDIS_PACKET ReceivedPackets,
  9574. IN UINT NumberOfPackets
  9575. );
  9576. --*/
  9577. #define NdisMIndicateReceivePacket(_H, _P, _N) \
  9578. { \
  9579. (*((PNDIS_MINIPORT_BLOCK)(_H))->PacketIndicateHandler)( \
  9580. _H, \
  9581. _P, \
  9582. _N); \
  9583. }
  9584. /*++
  9585. VOID
  9586. NdisMWanIndicateReceive(
  9587. OUT PNDIS_STATUS Status,
  9588. IN NDIS_HANDLE MiniportAdapterHandle,
  9589. IN NDIS_HANDLE NdisLinkContext,
  9590. IN PUCHAR Packet,
  9591. IN ULONG PacketSize
  9592. );
  9593. --*/
  9594. #define NdisMWanIndicateReceive(_S_, _M_, _C_, _P_, _Z_) \
  9595. (*((PNDIS_MINIPORT_BLOCK)(_M_))->WanRcvHandler)(_S_, _M_, _C_, _P_, _Z_)
  9596. /*++
  9597. VOID
  9598. NdisMWanIndicateReceiveComplete(
  9599. IN NDIS_HANDLE MiniportAdapterHandle,
  9600. IN NDIS_HANDLE NdisLinkContext
  9601. );
  9602. --*/
  9603. #define NdisMWanIndicateReceiveComplete(_M_, _C_) \
  9604. (*((PNDIS_MINIPORT_BLOCK)(_M_))->WanRcvCompleteHandler)(_M_, _C_)
  9605. /*++
  9606. VOID
  9607. NdisMEthIndicateReceive(
  9608. IN NDIS_HANDLE MiniportAdapterHandle,
  9609. IN NDIS_HANDLE MiniportReceiveContext,
  9610. IN PVOID HeaderBuffer,
  9611. IN UINT HeaderBufferSize,
  9612. IN PVOID LookaheadBuffer,
  9613. IN UINT LookaheadBufferSize,
  9614. IN UINT PacketSize
  9615. )
  9616. --*/
  9617. #define NdisMEthIndicateReceive( _H, _C, _B, _SZ, _L, _LSZ, _PSZ) \
  9618. { \
  9619. (*((PNDIS_MINIPORT_BLOCK)(_H))->EthRxIndicateHandler)( \
  9620. ((PNDIS_MINIPORT_BLOCK)(_H))->EthDB, \
  9621. _C, \
  9622. _B, \
  9623. _B, \
  9624. _SZ, \
  9625. _L, \
  9626. _LSZ, \
  9627. _PSZ \
  9628. ); \
  9629. }
  9630. /*++
  9631. VOID
  9632. NdisMTrIndicateReceive(
  9633. IN NDIS_HANDLE MiniportAdapterHandle,
  9634. IN NDIS_HANDLE MiniportReceiveContext,
  9635. IN PVOID HeaderBuffer,
  9636. IN UINT HeaderBufferSize,
  9637. IN PVOID LookaheadBuffer,
  9638. IN UINT LookaheadBufferSize,
  9639. IN UINT PacketSize
  9640. )
  9641. --*/
  9642. #define NdisMTrIndicateReceive( _H, _C, _B, _SZ, _L, _LSZ, _PSZ) \
  9643. { \
  9644. (*((PNDIS_MINIPORT_BLOCK)(_H))->TrRxIndicateHandler)( \
  9645. ((PNDIS_MINIPORT_BLOCK)(_H))->TrDB, \
  9646. _C, \
  9647. _B, \
  9648. _SZ, \
  9649. _L, \
  9650. _LSZ, \
  9651. _PSZ \
  9652. ); \
  9653. }
  9654. /*++
  9655. VOID
  9656. NdisMFddiIndicateReceive(
  9657. IN NDIS_HANDLE MiniportAdapterHandle,
  9658. IN NDIS_HANDLE MiniportReceiveContext,
  9659. IN PVOID HeaderBuffer,
  9660. IN UINT HeaderBufferSize,
  9661. IN PVOID LookaheadBuffer,
  9662. IN UINT LookaheadBufferSize,
  9663. IN UINT PacketSize
  9664. )
  9665. --*/
  9666. #define NdisMFddiIndicateReceive( _H, _C, _B, _SZ, _L, _LSZ, _PSZ) \
  9667. { \
  9668. (*((PNDIS_MINIPORT_BLOCK)(_H))->FddiRxIndicateHandler)( \
  9669. ((PNDIS_MINIPORT_BLOCK)(_H))->FddiDB, \
  9670. _C, \
  9671. (PUCHAR)_B + 1, \
  9672. ((((PUCHAR)_B)[0] & 0x40) ? FDDI_LENGTH_OF_LONG_ADDRESS \
  9673. : FDDI_LENGTH_OF_SHORT_ADDRESS), \
  9674. _B, \
  9675. _SZ, \
  9676. _L, \
  9677. _LSZ, \
  9678. _PSZ \
  9679. ); \
  9680. }
  9681. /*++
  9682. VOID
  9683. NdisMArcIndicateReceive(
  9684. IN NDIS_HANDLE MiniportHandle,
  9685. IN PUCHAR pRawHeader, // Pointer to Arcnet frame header
  9686. IN PUCHAR pData, // Pointer to data portion of Arcnet frame
  9687. IN UINT Length // Data Length
  9688. )
  9689. --*/
  9690. #define NdisMArcIndicateReceive( _H, _HD, _D, _SZ) \
  9691. { \
  9692. ArcFilterDprIndicateReceive(((PNDIS_MINIPORT_BLOCK)(_H))->ArcDB, \
  9693. _HD, \
  9694. _D, \
  9695. _SZ \
  9696. ); \
  9697. }
  9698. /*++
  9699. VOID
  9700. NdisMEthIndicateReceiveComplete(
  9701. IN NDIS_HANDLE MiniportHandle
  9702. );
  9703. --*/
  9704. #define NdisMEthIndicateReceiveComplete( _H ) \
  9705. { \
  9706. (*((PNDIS_MINIPORT_BLOCK)(_H))->EthRxCompleteHandler)( \
  9707. ((PNDIS_MINIPORT_BLOCK)_H)->EthDB); \
  9708. }
  9709. /*++
  9710. VOID
  9711. NdisMTrIndicateReceiveComplete(
  9712. IN NDIS_HANDLE MiniportHandle
  9713. );
  9714. --*/
  9715. #define NdisMTrIndicateReceiveComplete( _H ) \
  9716. { \
  9717. (*((PNDIS_MINIPORT_BLOCK)(_H))->TrRxCompleteHandler)( \
  9718. ((PNDIS_MINIPORT_BLOCK)_H)->TrDB); \
  9719. }
  9720. /*++
  9721. VOID
  9722. NdisMFddiIndicateReceiveComplete(
  9723. IN NDIS_HANDLE MiniportHandle
  9724. );
  9725. --*/
  9726. #define NdisMFddiIndicateReceiveComplete( _H ) \
  9727. { \
  9728. (*((PNDIS_MINIPORT_BLOCK)(_H))->FddiRxCompleteHandler)( \
  9729. ((PNDIS_MINIPORT_BLOCK)_H)->FddiDB); \
  9730. }
  9731. /*++
  9732. VOID
  9733. NdisMArcIndicateReceiveComplete(
  9734. IN NDIS_HANDLE MiniportHandle
  9735. );
  9736. --*/
  9737. #define NdisMArcIndicateReceiveComplete( _H ) \
  9738. { \
  9739. if (((PNDIS_MINIPORT_BLOCK)_H)->EthDB) \
  9740. { \
  9741. NdisMEthIndicateReceiveComplete(_H); \
  9742. } \
  9743. \
  9744. ArcFilterDprIndicateReceiveComplete(((PNDIS_MINIPORT_BLOCK)_H)->ArcDB); \
  9745. }
  9746. /*++
  9747. EXPORT
  9748. VOID
  9749. NdisMIndicateStatus(
  9750. IN NDIS_HANDLE MiniportHandle,
  9751. IN NDIS_STATUS GeneralStatus,
  9752. IN PVOID StatusBuffer,
  9753. IN UINT StatusBufferSize
  9754. );
  9755. --*/
  9756. #define NdisMIndicateStatus(_M, _G, _SB, _BS) (*((PNDIS_MINIPORT_BLOCK)(_M))->StatusHandler)(_M, _G, _SB, _BS)
  9757. /*++
  9758. EXPORT
  9759. VOID
  9760. NdisMIndicateStatusComplete(
  9761. IN NDIS_HANDLE MiniportHandle
  9762. );
  9763. --*/
  9764. #define NdisMIndicateStatusComplete(_M) (*((PNDIS_MINIPORT_BLOCK)(_M))->StatusCompleteHandler)(_M)
  9765. EXPORT
  9766. VOID
  9767. NdisMRegisterAdapterShutdownHandler(
  9768. IN NDIS_HANDLE MiniportHandle,
  9769. IN PVOID ShutdownContext,
  9770. IN ADAPTER_SHUTDOWN_HANDLER ShutdownHandler
  9771. );
  9772. EXPORT
  9773. VOID
  9774. NdisMDeregisterAdapterShutdownHandler(
  9775. IN NDIS_HANDLE MiniportHandle
  9776. );
  9777. EXPORT
  9778. NDIS_STATUS
  9779. NdisMPciAssignResources(
  9780. IN NDIS_HANDLE MiniportHandle,
  9781. IN ULONG SlotNumber,
  9782. IN PNDIS_RESOURCE_LIST * AssignedResources
  9783. );
  9784. #ifdef NDIS51_MINIPORT
  9785. EXPORT
  9786. NDIS_STATUS
  9787. NdisIMNotifyPnPEvent(
  9788. IN NDIS_HANDLE MiniportHandle,
  9789. IN PNET_PNP_EVENT NetPnPEvent
  9790. );
  9791. #endif
  9792. //
  9793. // Logging support for miniports
  9794. //
  9795. EXPORT
  9796. NDIS_STATUS
  9797. NdisMCreateLog(
  9798. IN NDIS_HANDLE MiniportAdapterHandle,
  9799. IN UINT Size,
  9800. OUT PNDIS_HANDLE LogHandle
  9801. );
  9802. EXPORT
  9803. VOID
  9804. NdisMCloseLog(
  9805. IN NDIS_HANDLE LogHandle
  9806. );
  9807. EXPORT
  9808. NDIS_STATUS
  9809. NdisMWriteLogData(
  9810. IN NDIS_HANDLE LogHandle,
  9811. IN PVOID LogBuffer,
  9812. IN UINT LogBufferSize
  9813. );
  9814. EXPORT
  9815. VOID
  9816. NdisMFlushLog(
  9817. IN NDIS_HANDLE LogHandle
  9818. );
  9819. EXPORT
  9820. VOID
  9821. NdisMGetDeviceProperty(
  9822. IN NDIS_HANDLE MiniportAdapterHandle,
  9823. IN OUT PDEVICE_OBJECT * PhysicalDeviceObject OPTIONAL,
  9824. IN OUT PDEVICE_OBJECT * FunctionalDeviceObject OPTIONAL,
  9825. IN OUT PDEVICE_OBJECT * NextDeviceObject OPTIONAL,
  9826. IN OUT PCM_RESOURCE_LIST * AllocatedResources OPTIONAL,
  9827. IN OUT PCM_RESOURCE_LIST * AllocatedResourcesTranslated OPTIONAL
  9828. );
  9829. //
  9830. // Get a pointer to the adapter's localized instance name.
  9831. //
  9832. EXPORT
  9833. NDIS_STATUS
  9834. NdisMQueryAdapterInstanceName(
  9835. OUT PNDIS_STRING pAdapterInstanceName,
  9836. IN NDIS_HANDLE MiniportHandle
  9837. );
  9838. //
  9839. // NDIS 5.0 extensions for miniports
  9840. //
  9841. EXPORT
  9842. VOID
  9843. NdisMCoIndicateReceivePacket(
  9844. IN NDIS_HANDLE NdisVcHandle,
  9845. IN PPNDIS_PACKET PacketArray,
  9846. IN UINT NumberOfPackets
  9847. );
  9848. EXPORT
  9849. VOID
  9850. NdisMCoIndicateStatus(
  9851. IN NDIS_HANDLE MiniportAdapterHandle,
  9852. IN NDIS_HANDLE NdisVcHandle OPTIONAL,
  9853. IN NDIS_STATUS GeneralStatus,
  9854. IN PVOID StatusBuffer OPTIONAL,
  9855. IN ULONG StatusBufferSize
  9856. );
  9857. EXPORT
  9858. VOID
  9859. NdisMCoReceiveComplete(
  9860. IN NDIS_HANDLE MiniportAdapterHandle
  9861. );
  9862. EXPORT
  9863. VOID
  9864. NdisMCoSendComplete(
  9865. IN NDIS_STATUS Status,
  9866. IN NDIS_HANDLE NdisVcHandle,
  9867. IN PNDIS_PACKET Packet
  9868. );
  9869. EXPORT
  9870. VOID
  9871. NdisMCoActivateVcComplete(
  9872. IN NDIS_STATUS Status,
  9873. IN NDIS_HANDLE NdisVcHandle,
  9874. IN PCO_CALL_PARAMETERS CallParameters
  9875. );
  9876. EXPORT
  9877. VOID
  9878. NdisMCoDeactivateVcComplete(
  9879. IN NDIS_STATUS Status,
  9880. IN NDIS_HANDLE NdisVcHandle
  9881. );
  9882. EXPORT
  9883. VOID
  9884. NdisMCoRequestComplete(
  9885. IN NDIS_STATUS Status,
  9886. IN NDIS_HANDLE MiniportAdapterHandle,
  9887. IN PNDIS_REQUEST Request
  9888. );
  9889. EXPORT
  9890. NDIS_STATUS
  9891. NdisMCmRegisterAddressFamily(
  9892. IN NDIS_HANDLE MiniportAdapterHandle,
  9893. IN PCO_ADDRESS_FAMILY AddressFamily,
  9894. IN PNDIS_CALL_MANAGER_CHARACTERISTICS CmCharacteristics,
  9895. IN UINT SizeOfCmCharacteristics
  9896. );
  9897. EXPORT
  9898. NDIS_STATUS
  9899. NdisMCmCreateVc(
  9900. IN NDIS_HANDLE MiniportAdapterHandle,
  9901. IN NDIS_HANDLE NdisAfHandle,
  9902. IN NDIS_HANDLE MiniportVcContext,
  9903. OUT PNDIS_HANDLE NdisVcHandle
  9904. );
  9905. EXPORT
  9906. NDIS_STATUS
  9907. NdisMCmDeleteVc(
  9908. IN NDIS_HANDLE NdisVcHandle
  9909. );
  9910. EXPORT
  9911. NDIS_STATUS
  9912. NdisMCmActivateVc(
  9913. IN NDIS_HANDLE NdisVcHandle,
  9914. IN PCO_CALL_PARAMETERS CallParameters
  9915. );
  9916. EXPORT
  9917. NDIS_STATUS
  9918. NdisMCmDeactivateVc(
  9919. IN NDIS_HANDLE NdisVcHandle
  9920. );
  9921. EXPORT
  9922. NDIS_STATUS
  9923. NdisMCmRequest(
  9924. IN NDIS_HANDLE NdisAfHandle,
  9925. IN NDIS_HANDLE NdisVcHandle OPTIONAL,
  9926. IN NDIS_HANDLE NdisPartyHandle OPTIONAL,
  9927. IN OUT PNDIS_REQUEST NdisRequest
  9928. );
  9929. // EXPORT
  9930. // VOID
  9931. // NdisMCmRequestComplete(
  9932. // IN NDIS_STATUS Status,
  9933. // IN NDIS_HANDLE NdisAfHandle,
  9934. // IN NDIS_HANDLE NdisVcHandle OPTIONAL,
  9935. // IN NDIS_HANDLE NdisPartyHandle OPTIONAL,
  9936. // IN PNDIS_REQUEST NdisRequest
  9937. // );
  9938. #define NdisMCmRequestComplete(_S_, _AH_, _VH_, _PH_, _R_) \
  9939. NdisCoRequestComplete(_S_, _AH_, _VH_, _PH_, _R_)
  9940. // EXPORT
  9941. // VOID
  9942. // NdisMCmOpenAddressFamilyComplete(
  9943. // IN NDIS_STATUS Status,
  9944. // IN NDIS_HANDLE NdisAfHandle,
  9945. // IN NDIS_HANDLE CallMgrAfContext
  9946. // );
  9947. #define NdisMCmOpenAddressFamilyComplete(_S_, _H_, _C_) \
  9948. NdisCmOpenAddressFamilyComplete(_S_, _H_, _C_)
  9949. // EXPORT
  9950. // VOID
  9951. // NdisMCmCloseAddressFamilyComplete(
  9952. // IN NDIS_STATUS Status,
  9953. // IN NDIS_HANDLE NdisAfHandle
  9954. // );
  9955. #define NdisMCmCloseAddressFamilyComplete(_S_, _H_) \
  9956. NdisCmCloseAddressFamilyComplete(_S_, _H_)
  9957. // EXPORT
  9958. // VOID
  9959. // NdisMCmRegisterSapComplete(
  9960. // IN NDIS_STATUS Status,
  9961. // IN NDIS_HANDLE NdisSapHandle,
  9962. // IN NDIS_HANDLE CallMgrSapContext
  9963. // );
  9964. #define NdisMCmRegisterSapComplete(_S_, _H_, _C_) \
  9965. NdisCmRegisterSapComplete(_S_, _H_, _C_)
  9966. // EXPORT
  9967. // VOID
  9968. // NdisMCmDeregisterSapComplete(
  9969. // IN NDIS_STATUS Status,
  9970. // IN NDIS_HANDLE NdisSapHandle
  9971. // );
  9972. #define NdisMCmDeregisterSapComplete(_S_, _H_) \
  9973. NdisCmDeregisterSapComplete(_S_, _H_)
  9974. // EXPORT
  9975. // VOID
  9976. // NdisMCmMakeCallComplete(
  9977. // IN NDIS_STATUS Status,
  9978. // IN NDIS_HANDLE NdisVcHandle,
  9979. // IN NDIS_HANDLE NdisPartyHandle OPTIONAL,
  9980. // IN NDIS_HANDLE CallMgrPartyContext OPTIONAL,
  9981. // IN PCO_CALL_PARAMETERS CallParameters
  9982. // );
  9983. #define NdisMCmMakeCallComplete(_S_, _VH_, _PH_, _CC_, _CP_) \
  9984. NdisCmMakeCallComplete(_S_, _VH_, _PH_, _CC_, _CP_)
  9985. // EXPORT
  9986. // VOID
  9987. // NdisMCmCloseCallComplete(
  9988. // IN NDIS_STATUS Status,
  9989. // IN NDIS_HANDLE NdisVcHandle,
  9990. // IN NDIS_HANDLE NdisPartyHandle OPTIONAL
  9991. // );
  9992. #define NdisMCmCloseCallComplete(_S_, _VH_, _PH_) \
  9993. NdisCmCloseCallComplete(_S_, _VH_, _PH_)
  9994. // EXPORT
  9995. // VOID
  9996. // NdisMCmAddPartyComplete(
  9997. // IN NDIS_STATUS Status,
  9998. // IN NDIS_HANDLE NdisPartyHandle,
  9999. // IN NDIS_HANDLE CallMgrPartyContext OPTIONAL,
  10000. // IN PCO_CALL_PARAMETERS CallParameters
  10001. // );
  10002. #define NdisMCmAddPartyComplete(_S_, _H_, _C_, _P_) \
  10003. NdisCmAddPartyComplete(_S_, _H_, _C_, _P_)
  10004. // EXPORT
  10005. // VOID
  10006. // NdisMCmDropPartyComplete(
  10007. // IN NDIS_STATUS Status,
  10008. // IN NDIS_HANDLE NdisPartyHandle
  10009. // );
  10010. #define NdisMCmDropPartyComplete(_S_, _H_) \
  10011. NdisCmDropPartyComplete(_S_, _H_)
  10012. // EXPORT
  10013. // NDIS_STATUS
  10014. // NdisMCmDispatchIncomingCall(
  10015. // IN NDIS_HANDLE NdisSapHandle,
  10016. // IN NDIS_HANDLE NdisVcHandle,
  10017. // IN PCO_CALL_PARAMETERS CallParameters
  10018. // );
  10019. #define NdisMCmDispatchIncomingCall(_SH_, _VH_, _CP_) \
  10020. NdisCmDispatchIncomingCall(_SH_, _VH_, _CP_)
  10021. // EXPORT
  10022. // VOID
  10023. // NdisMCmDispatchCallConnected(
  10024. // IN NDIS_HANDLE NdisVcHandle
  10025. // );
  10026. #define NdisMCmDispatchCallConnected(_H_) \
  10027. NdisCmDispatchCallConnected(_H_)
  10028. // EXPORT
  10029. // NdisMCmModifyCallQoSComplete(
  10030. // IN NDIS_STATUS Status,
  10031. // IN NDIS_HANDLE NdisVcHandle,
  10032. // IN PCO_CALL_PARAMETERS CallParameters
  10033. // );
  10034. #define NdisMCmModifyCallQoSComplete(_S_, _H_, _P_) \
  10035. NdisCmModifyCallQoSComplete(_S_, _H_, _P_)
  10036. // EXPORT
  10037. // VOID
  10038. // VOID
  10039. // NdisMCmDispatchIncomingCallQoSChange(
  10040. // IN NDIS_HANDLE NdisVcHandle,
  10041. // IN PCO_CALL_PARAMETERS CallParameters
  10042. // );
  10043. #define NdisMCmDispatchIncomingCallQoSChange(_H_, _P_) \
  10044. NdisCmDispatchIncomingCallQoSChange(_H_, _P_)
  10045. // EXPORT
  10046. // VOID
  10047. // NdisMCmDispatchIncomingCloseCall(
  10048. // IN NDIS_STATUS CloseStatus,
  10049. // IN NDIS_HANDLE NdisVcHandle,
  10050. // IN PVOID Buffer OPTIONAL,
  10051. // IN UINT Size
  10052. // );
  10053. #define NdisMCmDispatchIncomingCloseCall(_S_, _H_, _B_, _Z_) \
  10054. NdisCmDispatchIncomingCloseCall(_S_, _H_, _B_, _Z_)
  10055. // EXPORT
  10056. // VOID
  10057. // NdisMCmDispatchIncomingDropParty(
  10058. // IN NDIS_STATUS DropStatus,
  10059. // IN NDIS_HANDLE NdisPartyHandle,
  10060. // IN PVOID Buffer OPTIONAL,
  10061. // IN UINT Size
  10062. // );
  10063. #define NdisMCmDispatchIncomingDropParty(_S_, _H_, _B_, _Z_) \
  10064. NdisCmDispatchIncomingDropParty(_S_, _H_, _B_, _Z_)
  10065. #endif // defined(NDIS_MINIPORT_DRIVER) || defined(NDIS_WRAPPER)
  10066. #if defined(NDIS50) || defined(NDIS50_MINIPORT) || defined(NDIS51_MINIPORT)
  10067. typedef struct _CO_CALL_PARAMETERS CO_CALL_PARAMETERS, *PCO_CALL_PARAMETERS;
  10068. typedef struct _CO_MEDIA_PARAMETERS CO_MEDIA_PARAMETERS, *PCO_MEDIA_PARAMETERS;
  10069. //
  10070. // CoNdis client only handler proto-types - used by clients of call managers
  10071. //
  10072. typedef
  10073. VOID
  10074. (*CL_OPEN_AF_COMPLETE_HANDLER)(
  10075. IN NDIS_STATUS Status,
  10076. IN NDIS_HANDLE ProtocolAfContext,
  10077. IN NDIS_HANDLE NdisAfHandle
  10078. );
  10079. typedef
  10080. VOID
  10081. (*CL_CLOSE_AF_COMPLETE_HANDLER)(
  10082. IN NDIS_STATUS Status,
  10083. IN NDIS_HANDLE ProtocolAfContext
  10084. );
  10085. typedef
  10086. VOID
  10087. (*CL_REG_SAP_COMPLETE_HANDLER)(
  10088. IN NDIS_STATUS Status,
  10089. IN NDIS_HANDLE ProtocolSapContext,
  10090. IN PCO_SAP Sap,
  10091. IN NDIS_HANDLE NdisSapHandle
  10092. );
  10093. typedef
  10094. VOID
  10095. (*CL_DEREG_SAP_COMPLETE_HANDLER)(
  10096. IN NDIS_STATUS Status,
  10097. IN NDIS_HANDLE ProtocolSapContext
  10098. );
  10099. typedef
  10100. VOID
  10101. (*CL_MAKE_CALL_COMPLETE_HANDLER)(
  10102. IN NDIS_STATUS Status,
  10103. IN NDIS_HANDLE ProtocolVcContext,
  10104. IN NDIS_HANDLE NdisPartyHandle OPTIONAL,
  10105. IN PCO_CALL_PARAMETERS CallParameters
  10106. );
  10107. typedef
  10108. VOID
  10109. (*CL_CLOSE_CALL_COMPLETE_HANDLER)(
  10110. IN NDIS_STATUS Status,
  10111. IN NDIS_HANDLE ProtocolVcContext,
  10112. IN NDIS_HANDLE ProtocolPartyContext OPTIONAL
  10113. );
  10114. typedef
  10115. VOID
  10116. (*CL_ADD_PARTY_COMPLETE_HANDLER)(
  10117. IN NDIS_STATUS Status,
  10118. IN NDIS_HANDLE ProtocolPartyContext,
  10119. IN NDIS_HANDLE NdisPartyHandle,
  10120. IN PCO_CALL_PARAMETERS CallParameters
  10121. );
  10122. typedef
  10123. VOID
  10124. (*CL_DROP_PARTY_COMPLETE_HANDLER)(
  10125. IN NDIS_STATUS Status,
  10126. IN NDIS_HANDLE ProtocolPartyContext
  10127. );
  10128. typedef
  10129. NDIS_STATUS
  10130. (*CL_INCOMING_CALL_HANDLER)(
  10131. IN NDIS_HANDLE ProtocolSapContext,
  10132. IN NDIS_HANDLE ProtocolVcContext,
  10133. IN OUT PCO_CALL_PARAMETERS CallParameters
  10134. );
  10135. typedef
  10136. VOID
  10137. (*CL_CALL_CONNECTED_HANDLER)(
  10138. IN NDIS_HANDLE ProtocolVcContext
  10139. );
  10140. typedef
  10141. VOID
  10142. (*CL_INCOMING_CLOSE_CALL_HANDLER)(
  10143. IN NDIS_STATUS CloseStatus,
  10144. IN NDIS_HANDLE ProtocolVcContext,
  10145. IN PVOID CloseData OPTIONAL,
  10146. IN UINT Size OPTIONAL
  10147. );
  10148. typedef
  10149. VOID
  10150. (*CL_INCOMING_DROP_PARTY_HANDLER)(
  10151. IN NDIS_STATUS DropStatus,
  10152. IN NDIS_HANDLE ProtocolPartyContext,
  10153. IN PVOID CloseData OPTIONAL,
  10154. IN UINT Size OPTIONAL
  10155. );
  10156. typedef
  10157. VOID
  10158. (*CL_MODIFY_CALL_QOS_COMPLETE_HANDLER)(
  10159. IN NDIS_STATUS Status,
  10160. IN NDIS_HANDLE ProtocolVcContext,
  10161. IN PCO_CALL_PARAMETERS CallParameters
  10162. );
  10163. typedef
  10164. VOID
  10165. (*CL_INCOMING_CALL_QOS_CHANGE_HANDLER)(
  10166. IN NDIS_HANDLE ProtocolVcContext,
  10167. IN PCO_CALL_PARAMETERS CallParameters
  10168. );
  10169. typedef struct _NDIS_CLIENT_CHARACTERISTICS
  10170. {
  10171. UCHAR MajorVersion;
  10172. UCHAR MinorVersion;
  10173. USHORT Filler;
  10174. UINT Reserved;
  10175. CO_CREATE_VC_HANDLER ClCreateVcHandler;
  10176. CO_DELETE_VC_HANDLER ClDeleteVcHandler;
  10177. CO_REQUEST_HANDLER ClRequestHandler;
  10178. CO_REQUEST_COMPLETE_HANDLER ClRequestCompleteHandler;
  10179. CL_OPEN_AF_COMPLETE_HANDLER ClOpenAfCompleteHandler;
  10180. CL_CLOSE_AF_COMPLETE_HANDLER ClCloseAfCompleteHandler;
  10181. CL_REG_SAP_COMPLETE_HANDLER ClRegisterSapCompleteHandler;
  10182. CL_DEREG_SAP_COMPLETE_HANDLER ClDeregisterSapCompleteHandler;
  10183. CL_MAKE_CALL_COMPLETE_HANDLER ClMakeCallCompleteHandler;
  10184. CL_MODIFY_CALL_QOS_COMPLETE_HANDLER ClModifyCallQoSCompleteHandler;
  10185. CL_CLOSE_CALL_COMPLETE_HANDLER ClCloseCallCompleteHandler;
  10186. CL_ADD_PARTY_COMPLETE_HANDLER ClAddPartyCompleteHandler;
  10187. CL_DROP_PARTY_COMPLETE_HANDLER ClDropPartyCompleteHandler;
  10188. CL_INCOMING_CALL_HANDLER ClIncomingCallHandler;
  10189. CL_INCOMING_CALL_QOS_CHANGE_HANDLER ClIncomingCallQoSChangeHandler;
  10190. CL_INCOMING_CLOSE_CALL_HANDLER ClIncomingCloseCallHandler;
  10191. CL_INCOMING_DROP_PARTY_HANDLER ClIncomingDropPartyHandler;
  10192. CL_CALL_CONNECTED_HANDLER ClCallConnectedHandler;
  10193. } NDIS_CLIENT_CHARACTERISTICS, *PNDIS_CLIENT_CHARACTERISTICS;
  10194. //
  10195. // CoNdis call-manager only handler proto-types - used by call managers only
  10196. //
  10197. typedef
  10198. NDIS_STATUS
  10199. (*CM_OPEN_AF_HANDLER)(
  10200. IN NDIS_HANDLE CallMgrBindingContext,
  10201. IN PCO_ADDRESS_FAMILY AddressFamily,
  10202. IN NDIS_HANDLE NdisAfHandle,
  10203. OUT PNDIS_HANDLE CallMgrAfContext
  10204. );
  10205. typedef
  10206. NDIS_STATUS
  10207. (*CM_CLOSE_AF_HANDLER)(
  10208. IN NDIS_HANDLE CallMgrAfContext
  10209. );
  10210. typedef
  10211. NDIS_STATUS
  10212. (*CM_REG_SAP_HANDLER)(
  10213. IN NDIS_HANDLE CallMgrAfContext,
  10214. IN PCO_SAP Sap,
  10215. IN NDIS_HANDLE NdisSapHandle,
  10216. OUT PNDIS_HANDLE CallMgrSapContext
  10217. );
  10218. typedef
  10219. NDIS_STATUS
  10220. (*CM_DEREG_SAP_HANDLER)(
  10221. IN NDIS_HANDLE CallMgrSapContext
  10222. );
  10223. typedef
  10224. NDIS_STATUS
  10225. (*CM_MAKE_CALL_HANDLER)(
  10226. IN NDIS_HANDLE CallMgrVcContext,
  10227. IN OUT PCO_CALL_PARAMETERS CallParameters,
  10228. IN NDIS_HANDLE NdisPartyHandle OPTIONAL,
  10229. OUT PNDIS_HANDLE CallMgrPartyContext OPTIONAL
  10230. );
  10231. typedef
  10232. NDIS_STATUS
  10233. (*CM_CLOSE_CALL_HANDLER)(
  10234. IN NDIS_HANDLE CallMgrVcContext,
  10235. IN NDIS_HANDLE CallMgrPartyContext OPTIONAL,
  10236. IN PVOID CloseData OPTIONAL,
  10237. IN UINT Size OPTIONAL
  10238. );
  10239. typedef
  10240. NDIS_STATUS
  10241. (*CM_MODIFY_CALL_QOS_HANDLER)(
  10242. IN NDIS_HANDLE CallMgrVcContext,
  10243. IN PCO_CALL_PARAMETERS CallParameters
  10244. );
  10245. typedef
  10246. VOID
  10247. (*CM_INCOMING_CALL_COMPLETE_HANDLER)(
  10248. IN NDIS_STATUS Status,
  10249. IN NDIS_HANDLE CallMgrVcContext,
  10250. IN PCO_CALL_PARAMETERS CallParameters
  10251. );
  10252. typedef
  10253. VOID
  10254. (*CM_ACTIVATE_VC_COMPLETE_HANDLER)(
  10255. IN NDIS_STATUS Status,
  10256. IN NDIS_HANDLE CallMgrVcContext,
  10257. IN PCO_CALL_PARAMETERS CallParameters
  10258. );
  10259. typedef
  10260. VOID
  10261. (*CM_DEACTIVATE_VC_COMPLETE_HANDLER)(
  10262. IN NDIS_STATUS Status,
  10263. IN NDIS_HANDLE CallMgrVcContext
  10264. );
  10265. typedef
  10266. NDIS_STATUS
  10267. (*CM_ADD_PARTY_HANDLER)(
  10268. IN NDIS_HANDLE CallMgrVcContext,
  10269. IN OUT PCO_CALL_PARAMETERS CallParameters,
  10270. IN NDIS_HANDLE NdisPartyHandle,
  10271. OUT PNDIS_HANDLE CallMgrPartyContext
  10272. );
  10273. typedef
  10274. NDIS_STATUS
  10275. (*CM_DROP_PARTY_HANDLER)(
  10276. IN NDIS_HANDLE CallMgrPartyContext,
  10277. IN PVOID CloseData OPTIONAL,
  10278. IN UINT Size OPTIONAL
  10279. );
  10280. typedef struct _NDIS_CALL_MANAGER_CHARACTERISTICS
  10281. {
  10282. UCHAR MajorVersion;
  10283. UCHAR MinorVersion;
  10284. USHORT Filler;
  10285. UINT Reserved;
  10286. CO_CREATE_VC_HANDLER CmCreateVcHandler;
  10287. CO_DELETE_VC_HANDLER CmDeleteVcHandler;
  10288. CM_OPEN_AF_HANDLER CmOpenAfHandler;
  10289. CM_CLOSE_AF_HANDLER CmCloseAfHandler;
  10290. CM_REG_SAP_HANDLER CmRegisterSapHandler;
  10291. CM_DEREG_SAP_HANDLER CmDeregisterSapHandler;
  10292. CM_MAKE_CALL_HANDLER CmMakeCallHandler;
  10293. CM_CLOSE_CALL_HANDLER CmCloseCallHandler;
  10294. CM_INCOMING_CALL_COMPLETE_HANDLER CmIncomingCallCompleteHandler;
  10295. CM_ADD_PARTY_HANDLER CmAddPartyHandler;
  10296. CM_DROP_PARTY_HANDLER CmDropPartyHandler;
  10297. CM_ACTIVATE_VC_COMPLETE_HANDLER CmActivateVcCompleteHandler;
  10298. CM_DEACTIVATE_VC_COMPLETE_HANDLER CmDeactivateVcCompleteHandler;
  10299. CM_MODIFY_CALL_QOS_HANDLER CmModifyCallQoSHandler;
  10300. CO_REQUEST_HANDLER CmRequestHandler;
  10301. CO_REQUEST_COMPLETE_HANDLER CmRequestCompleteHandler;
  10302. } NDIS_CALL_MANAGER_CHARACTERISTICS, *PNDIS_CALL_MANAGER_CHARACTERISTICS;
  10303. //
  10304. // this send flag is used on ATM net cards to set ( turn on ) the CLP bit
  10305. // (Cell Loss Priority) bit
  10306. //
  10307. #define CO_SEND_FLAG_SET_DISCARD_ELIBILITY 0x00000001
  10308. //
  10309. // the Address structure used on NDIS_CO_ADD_ADDRESS or NDIS_CO_DELETE_ADDRESS
  10310. //
  10311. typedef struct _CO_ADDRESS
  10312. {
  10313. ULONG AddressSize;
  10314. UCHAR Address[1];
  10315. } CO_ADDRESS, *PCO_ADDRESS;
  10316. //
  10317. // the list of addresses returned from the CallMgr on a NDIS_CO_GET_ADDRESSES
  10318. //
  10319. typedef struct _CO_ADDRESS_LIST
  10320. {
  10321. ULONG NumberOfAddressesAvailable;
  10322. ULONG NumberOfAddresses;
  10323. CO_ADDRESS AddressList;
  10324. } CO_ADDRESS_LIST, *PCO_ADDRESS_LIST;
  10325. #ifndef FAR
  10326. #define FAR
  10327. #endif
  10328. #include <qos.h>
  10329. typedef struct _CO_SPECIFIC_PARAMETERS
  10330. {
  10331. ULONG ParamType;
  10332. ULONG Length;
  10333. UCHAR Parameters[1];
  10334. } CO_SPECIFIC_PARAMETERS, *PCO_SPECIFIC_PARAMETERS;
  10335. typedef struct _CO_CALL_MANAGER_PARAMETERS
  10336. {
  10337. FLOWSPEC Transmit;
  10338. FLOWSPEC Receive;
  10339. CO_SPECIFIC_PARAMETERS CallMgrSpecific;
  10340. } CO_CALL_MANAGER_PARAMETERS, *PCO_CALL_MANAGER_PARAMETERS;
  10341. //
  10342. // this is the generic portion of the media parameters, including the media
  10343. // specific component too.
  10344. //
  10345. typedef struct _CO_MEDIA_PARAMETERS
  10346. {
  10347. ULONG Flags;
  10348. ULONG ReceivePriority;
  10349. ULONG ReceiveSizeHint;
  10350. CO_SPECIFIC_PARAMETERS POINTER_ALIGNMENT MediaSpecific;
  10351. } CO_MEDIA_PARAMETERS, *PCO_MEDIA_PARAMETERS;
  10352. //
  10353. // definitions for the flags in CO_MEDIA_PARAMETERS
  10354. //
  10355. #define RECEIVE_TIME_INDICATION 0x00000001
  10356. #define USE_TIME_STAMPS 0x00000002
  10357. #define TRANSMIT_VC 0x00000004
  10358. #define RECEIVE_VC 0x00000008
  10359. #define INDICATE_ERRED_PACKETS 0x00000010
  10360. #define INDICATE_END_OF_TX 0x00000020
  10361. #define RESERVE_RESOURCES_VC 0x00000040
  10362. #define ROUND_DOWN_FLOW 0x00000080
  10363. #define ROUND_UP_FLOW 0x00000100
  10364. //
  10365. // define a flag to set in the flags of an Ndis packet when the miniport
  10366. // indicates a receive with an error in it
  10367. //
  10368. #define ERRED_PACKET_INDICATION 0x00000001
  10369. //
  10370. // this is the structure passed during call-setup
  10371. //
  10372. typedef struct _CO_CALL_PARAMETERS
  10373. {
  10374. ULONG Flags;
  10375. PCO_CALL_MANAGER_PARAMETERS CallMgrParameters;
  10376. PCO_MEDIA_PARAMETERS MediaParameters;
  10377. } CO_CALL_PARAMETERS, *PCO_CALL_PARAMETERS;
  10378. //
  10379. // Definitions for the Flags in CO_CALL_PARAMETERS
  10380. //
  10381. #define PERMANENT_VC 0x00000001
  10382. #define CALL_PARAMETERS_CHANGED 0x00000002
  10383. #define QUERY_CALL_PARAMETERS 0x00000004
  10384. #define BROADCAST_VC 0x00000008
  10385. #define MULTIPOINT_VC 0x00000010
  10386. //
  10387. // The format of the Request for adding/deleting a PVC
  10388. //
  10389. typedef struct _CO_PVC
  10390. {
  10391. NDIS_HANDLE NdisAfHandle;
  10392. CO_SPECIFIC_PARAMETERS PvcParameters;
  10393. } CO_PVC,*PCO_PVC;
  10394. typedef struct _ATM_ADDRESS ATM_ADDRESS, *PATM_ADDRESS;
  10395. EXPORT
  10396. VOID
  10397. NdisConvertStringToAtmAddress(
  10398. OUT PNDIS_STATUS Status,
  10399. IN PNDIS_STRING String,
  10400. OUT PATM_ADDRESS AtmAddress
  10401. );
  10402. //
  10403. // NDIS 5.0 Extensions for protocols
  10404. //
  10405. EXPORT
  10406. NDIS_STATUS
  10407. NdisCoAssignInstanceName(
  10408. IN NDIS_HANDLE NdisVcHandle,
  10409. IN PNDIS_STRING BaseInstanceName,
  10410. OUT PNDIS_STRING VcInstanceName
  10411. );
  10412. EXPORT
  10413. VOID
  10414. NdisCoSendPackets(
  10415. IN NDIS_HANDLE NdisVcHandle,
  10416. IN PPNDIS_PACKET PacketArray,
  10417. IN UINT NumberOfPackets
  10418. );
  10419. EXPORT
  10420. NDIS_STATUS
  10421. NdisCoCreateVc(
  10422. IN NDIS_HANDLE NdisBindingHandle,
  10423. IN NDIS_HANDLE NdisAfHandle OPTIONAL, // For CM signalling VCs
  10424. IN NDIS_HANDLE ProtocolVcContext,
  10425. IN OUT PNDIS_HANDLE NdisVcHandle
  10426. );
  10427. EXPORT
  10428. NDIS_STATUS
  10429. NdisCoDeleteVc(
  10430. IN NDIS_HANDLE NdisVcHandle
  10431. );
  10432. EXPORT
  10433. NDIS_STATUS
  10434. NdisCoRequest(
  10435. IN NDIS_HANDLE NdisBindingHandle,
  10436. IN NDIS_HANDLE NdisAfHandle OPTIONAL,
  10437. IN NDIS_HANDLE NdisVcHandle OPTIONAL,
  10438. IN NDIS_HANDLE NdisPartyHandle OPTIONAL,
  10439. IN OUT PNDIS_REQUEST NdisRequest
  10440. );
  10441. EXPORT
  10442. VOID
  10443. NdisCoRequestComplete(
  10444. IN NDIS_STATUS Status,
  10445. IN NDIS_HANDLE NdisAfHandle,
  10446. IN NDIS_HANDLE NdisVcHandle OPTIONAL,
  10447. IN NDIS_HANDLE NdisPartyHandle OPTIONAL,
  10448. IN PNDIS_REQUEST NdisRequest
  10449. );
  10450. #ifndef __NDISTAPI_VAR_STRING_DECLARED
  10451. #define __NDISTAPI_VAR_STRING_DECLARED
  10452. typedef struct _VAR_STRING
  10453. {
  10454. ULONG ulTotalSize;
  10455. ULONG ulNeededSize;
  10456. ULONG ulUsedSize;
  10457. ULONG ulStringFormat;
  10458. ULONG ulStringSize;
  10459. ULONG ulStringOffset;
  10460. } VAR_STRING, *PVAR_STRING;
  10461. #endif // __NDISTAPI_VAR_STRING_DECLARED
  10462. #ifndef __NDISTAPI_STRINGFORMATS_DEFINED
  10463. #define __NDISTAPI_STRINGFORMATS_DEFINED
  10464. #define STRINGFORMAT_ASCII 0x00000001
  10465. #define STRINGFORMAT_DBCS 0x00000002
  10466. #define STRINGFORMAT_UNICODE 0x00000003
  10467. #define STRINGFORMAT_BINARY 0x00000004
  10468. #endif // __NDISTAPI_STRINGFORMATS_DEFINED
  10469. EXPORT
  10470. NDIS_STATUS
  10471. NdisCoGetTapiCallId(
  10472. IN NDIS_HANDLE NdisVcHandle,
  10473. IN OUT PVAR_STRING TapiCallId
  10474. );
  10475. //
  10476. // Client Apis
  10477. //
  10478. EXPORT
  10479. NDIS_STATUS
  10480. NdisClOpenAddressFamily(
  10481. IN NDIS_HANDLE NdisBindingHandle,
  10482. IN PCO_ADDRESS_FAMILY AddressFamily,
  10483. IN NDIS_HANDLE ProtocolAfContext,
  10484. IN PNDIS_CLIENT_CHARACTERISTICS ClCharacteristics,
  10485. IN UINT SizeOfClCharacteristics,
  10486. OUT PNDIS_HANDLE NdisAfHandle
  10487. );
  10488. EXPORT
  10489. NDIS_STATUS
  10490. NdisClCloseAddressFamily(
  10491. IN NDIS_HANDLE NdisAfHandle
  10492. );
  10493. EXPORT
  10494. NDIS_STATUS
  10495. NdisClRegisterSap(
  10496. IN NDIS_HANDLE NdisAfHandle,
  10497. IN NDIS_HANDLE ProtocolSapContext,
  10498. IN PCO_SAP Sap,
  10499. OUT PNDIS_HANDLE NdisSapHandle
  10500. );
  10501. EXPORT
  10502. NDIS_STATUS
  10503. NdisClDeregisterSap(
  10504. IN NDIS_HANDLE NdisSapHandle
  10505. );
  10506. EXPORT
  10507. NDIS_STATUS
  10508. NdisClMakeCall(
  10509. IN NDIS_HANDLE NdisVcHandle,
  10510. IN OUT PCO_CALL_PARAMETERS CallParameters,
  10511. IN NDIS_HANDLE ProtocolPartyContext OPTIONAL,
  10512. OUT PNDIS_HANDLE NdisPartyHandle OPTIONAL
  10513. );
  10514. EXPORT
  10515. NDIS_STATUS
  10516. NdisClCloseCall(
  10517. IN NDIS_HANDLE NdisVcHandle,
  10518. IN NDIS_HANDLE NdisPartyHandle OPTIONAL,
  10519. IN PVOID Buffer OPTIONAL,
  10520. IN UINT Size OPTIONAL
  10521. );
  10522. EXPORT
  10523. NDIS_STATUS
  10524. NdisClModifyCallQoS(
  10525. IN NDIS_HANDLE NdisVcHandle,
  10526. IN PCO_CALL_PARAMETERS CallParameters
  10527. );
  10528. EXPORT
  10529. VOID
  10530. NdisClIncomingCallComplete(
  10531. IN NDIS_STATUS Status,
  10532. IN NDIS_HANDLE NdisVcHandle,
  10533. IN PCO_CALL_PARAMETERS CallParameters
  10534. );
  10535. EXPORT
  10536. NDIS_STATUS
  10537. NdisClAddParty(
  10538. IN NDIS_HANDLE NdisVcHandle,
  10539. IN NDIS_HANDLE ProtocolPartyContext,
  10540. IN OUT PCO_CALL_PARAMETERS CallParameters,
  10541. OUT PNDIS_HANDLE NdisPartyHandle
  10542. );
  10543. EXPORT
  10544. NDIS_STATUS
  10545. NdisClDropParty(
  10546. IN NDIS_HANDLE NdisPartyHandle,
  10547. IN PVOID Buffer OPTIONAL,
  10548. IN UINT Size OPTIONAL
  10549. );
  10550. EXPORT
  10551. NDIS_STATUS
  10552. NdisClGetProtocolVcContextFromTapiCallId(
  10553. IN UNICODE_STRING TapiCallId,
  10554. OUT PNDIS_HANDLE ProtocolVcContext
  10555. );
  10556. //
  10557. // Call Manager Apis
  10558. //
  10559. EXPORT
  10560. NDIS_STATUS
  10561. NdisCmRegisterAddressFamily(
  10562. IN NDIS_HANDLE NdisBindingHandle,
  10563. IN PCO_ADDRESS_FAMILY AddressFamily,
  10564. IN PNDIS_CALL_MANAGER_CHARACTERISTICS CmCharacteristics,
  10565. IN UINT SizeOfCmCharacteristics
  10566. );
  10567. EXPORT
  10568. VOID
  10569. NdisCmOpenAddressFamilyComplete(
  10570. IN NDIS_STATUS Status,
  10571. IN NDIS_HANDLE NdisAfHandle,
  10572. IN NDIS_HANDLE CallMgrAfContext
  10573. );
  10574. EXPORT
  10575. VOID
  10576. NdisCmCloseAddressFamilyComplete(
  10577. IN NDIS_STATUS Status,
  10578. IN NDIS_HANDLE NdisAfHandle
  10579. );
  10580. EXPORT
  10581. VOID
  10582. NdisCmRegisterSapComplete(
  10583. IN NDIS_STATUS Status,
  10584. IN NDIS_HANDLE NdisSapHandle,
  10585. IN NDIS_HANDLE CallMgrSapContext
  10586. );
  10587. EXPORT
  10588. VOID
  10589. NdisCmDeregisterSapComplete(
  10590. IN NDIS_STATUS Status,
  10591. IN NDIS_HANDLE NdisSapHandle
  10592. );
  10593. EXPORT
  10594. NDIS_STATUS
  10595. NdisCmActivateVc(
  10596. IN NDIS_HANDLE NdisVcHandle,
  10597. IN OUT PCO_CALL_PARAMETERS CallParameters
  10598. );
  10599. EXPORT
  10600. NDIS_STATUS
  10601. NdisCmDeactivateVc(
  10602. IN NDIS_HANDLE NdisVcHandle
  10603. );
  10604. EXPORT
  10605. VOID
  10606. NdisCmMakeCallComplete(
  10607. IN NDIS_STATUS Status,
  10608. IN NDIS_HANDLE NdisVcHandle,
  10609. IN NDIS_HANDLE NdisPartyHandle OPTIONAL,
  10610. IN NDIS_HANDLE CallMgrPartyContext OPTIONAL,
  10611. IN PCO_CALL_PARAMETERS CallParameters
  10612. );
  10613. EXPORT
  10614. VOID
  10615. NdisCmCloseCallComplete(
  10616. IN NDIS_STATUS Status,
  10617. IN NDIS_HANDLE NdisVcHandle,
  10618. IN NDIS_HANDLE NdisPartyHandle OPTIONAL
  10619. );
  10620. EXPORT
  10621. VOID
  10622. NdisCmAddPartyComplete(
  10623. IN NDIS_STATUS Status,
  10624. IN NDIS_HANDLE NdisPartyHandle,
  10625. IN NDIS_HANDLE CallMgrPartyContext OPTIONAL,
  10626. IN PCO_CALL_PARAMETERS CallParameters
  10627. );
  10628. EXPORT
  10629. VOID
  10630. NdisCmDropPartyComplete(
  10631. IN NDIS_STATUS Status,
  10632. IN NDIS_HANDLE NdisPartyHandle
  10633. );
  10634. EXPORT
  10635. NDIS_STATUS
  10636. NdisCmDispatchIncomingCall(
  10637. IN NDIS_HANDLE NdisSapHandle,
  10638. IN NDIS_HANDLE NdisVcHandle,
  10639. IN PCO_CALL_PARAMETERS CallParameters
  10640. );
  10641. EXPORT
  10642. VOID
  10643. NdisCmDispatchCallConnected(
  10644. IN NDIS_HANDLE NdisVcHandle
  10645. );
  10646. EXPORT
  10647. VOID
  10648. NdisCmModifyCallQoSComplete(
  10649. IN NDIS_STATUS Status,
  10650. IN NDIS_HANDLE NdisVcHandle,
  10651. IN PCO_CALL_PARAMETERS CallParameters
  10652. );
  10653. EXPORT
  10654. VOID
  10655. NdisCmDispatchIncomingCallQoSChange(
  10656. IN NDIS_HANDLE NdisVcHandle,
  10657. IN PCO_CALL_PARAMETERS CallParameters
  10658. );
  10659. EXPORT
  10660. VOID
  10661. NdisCmDispatchIncomingCloseCall(
  10662. IN NDIS_STATUS CloseStatus,
  10663. IN NDIS_HANDLE NdisVcHandle,
  10664. IN PVOID Buffer OPTIONAL,
  10665. IN UINT Size OPTIONAL
  10666. );
  10667. EXPORT
  10668. VOID
  10669. NdisCmDispatchIncomingDropParty(
  10670. IN NDIS_STATUS DropStatus,
  10671. IN NDIS_HANDLE NdisPartyHandle,
  10672. IN PVOID Buffer OPTIONAL,
  10673. IN UINT Size OPTIONAL
  10674. );
  10675. #endif // defined(NDIS50) || defined(NDIS50_MINIPORT) || defined(NDIS51_MINIPORT)
  10676. #endif // _NDIS_