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

207 lines
4.3 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. D:\nt\private\ntos\tdi\rawwan\atm\macros.h
  5. Abstract:
  6. Macros for the ATM-Specific Raw WAN module.
  7. Revision History:
  8. Who When What
  9. -------- -------- ----
  10. arvindm 06-18-97 created
  11. Notes:
  12. --*/
  13. #ifndef __ATMSP_MACROS_H_INCLUDED
  14. #define __ATMSP_MACROS_H_INCLUDED
  15. #define ATMSP_SET_FLAG(Flags, Mask, Val) \
  16. (Flags) = ((Flags) & ~(Mask)) | (Val)
  17. #define ATMSP_IS_FLAG_SET(Flags, Mask, Val) \
  18. (((Flags) & (Mask)) == (Val))
  19. #define ATMSP_SET_BIT(_Flags, _Bit) \
  20. (_Flags) = (_Flags) | (_Bit);
  21. #define ATMSP_RESET_BIT(_Flags, _Bit) \
  22. (_Flags) &= ~(_Bit);
  23. #define ATMSP_IS_BIT_SET(_Flags, _Bit) \
  24. (((_Flags) & (_Bit)) != 0)
  25. /*++
  26. VOID
  27. ATMSP_INIT_EVENT_STRUCT(
  28. IN ATMSP_EVENT *pEvent
  29. )
  30. --*/
  31. #define ATMSP_INIT_EVENT_STRUCT(pEvent) NdisInitializeEvent(&((pEvent)->Event))
  32. /*++
  33. NDIS_STATUS
  34. ATMSP_WAIT_ON_EVENT_STRUCT(
  35. IN ATMSP_EVENT *pEvent
  36. )
  37. --*/
  38. #define ATMSP_WAIT_ON_EVENT_STRUCT(pEvent) \
  39. (NdisWaitEvent(&((pEvent)->Event), 0), (pEvent)->Status)
  40. /*++
  41. VOID
  42. ATMSP_SIGNAL_EVENT_STRUCT(
  43. IN ATMSP_EVENT *pEvent,
  44. IN UINT Status
  45. )
  46. --*/
  47. #define ATMSP_SIGNAL_EVENT_STRUCT(pEvent, _Status) \
  48. { (pEvent)->Status = _Status; NdisSetEvent(&((pEvent)->Event)); }
  49. /*++
  50. VOID
  51. ATMSP_ALLOC_MEM(
  52. IN POPAQUE pVar,
  53. IN OPAQUE StructureType,
  54. IN ULONG SizeOfStructure
  55. )
  56. --*/
  57. #if DBG
  58. extern
  59. PVOID
  60. RWanAuditAllocMem(
  61. PVOID pPointer,
  62. ULONG Size,
  63. ULONG FileNumber,
  64. ULONG LineNumber
  65. );
  66. #define ATMSP_ALLOC_MEM(pVar, StructureType, SizeOfStructure) \
  67. pVar = (StructureType *)RWanAuditAllocMem( \
  68. (PVOID)(&(pVar)), \
  69. (ULONG)(SizeOfStructure), \
  70. _FILENUMBER, \
  71. __LINE__ \
  72. );
  73. #else
  74. #define ATMSP_ALLOC_MEM(pVar, StructureType, SizeOfStructure) \
  75. NdisAllocateMemoryWithTag((PVOID *)(&pVar), (ULONG)(SizeOfStructure), (ULONG)'naWR');
  76. #endif // DBG
  77. /*++
  78. VOID
  79. ATMSP_FREE_MEM(
  80. IN POPAQUE pMem
  81. )
  82. --*/
  83. #if DBG
  84. extern VOID RWanAuditFreeMem(PVOID Pointer);
  85. #define ATMSP_FREE_MEM(pMem) RWanAuditFreeMem((PVOID)(pMem));
  86. #else
  87. #define ATMSP_FREE_MEM(pMem) NdisFreeMemory((PVOID)(pMem), 0, 0);
  88. #endif // DBG
  89. #define ATMSP_SET_MEM(pMem, bValue, NumberOfBytes) \
  90. RtlFillMemory((PVOID)(pMem), (ULONG)(NumberOfBytes), (UCHAR)(bValue));
  91. #define ATMSP_ZERO_MEM(pMem, NumberOfBytes) \
  92. RtlZeroMemory((PVOID)pMem, (ULONG)(NumberOfBytes));
  93. #define ATMSP_COPY_MEM(pDst, pSrc, NumberOfBytes) \
  94. NdisMoveMemory((PVOID)(pDst), (PVOID)(pSrc), NumberOfBytes);
  95. #define ATMSP_EQUAL_MEM(_pMem1, _pMem2, _Length) \
  96. (RtlCompareMemory((PVOID)(_pMem1), (PVOID)(_pMem2), (ULONG)(_Length)) == (_Length))
  97. //
  98. // Spinlock macros.
  99. //
  100. #define ATMSP_INIT_LOCK(_pLock) NdisAllocateSpinLock(_pLock)
  101. #define ATMSP_ACQUIRE_LOCK(_pLock) NdisAcquireSpinLock(_pLock)
  102. #define ATMSP_RELEASE_LOCK(_pLock) NdisReleaseSpinLock(_pLock)
  103. #define ATMSP_FREE_LOCK(_pLock) NdisFreeSpinLock(_pLock)
  104. //
  105. // Doubly linked list manipulation definitions and macros.
  106. //
  107. #define ATMSP_INIT_LIST(_pListHead) \
  108. InitializeListHead(_pListHead)
  109. #define ATMSP_IS_LIST_EMPTY(_pListHead) \
  110. IsListEmpty(_pListHead)
  111. #define ATMSP_INSERT_HEAD_LIST(_pListHead, _pEntry) \
  112. InsertHeadList((_pListHead), (_pEntry))
  113. #define ATMSP_INSERT_TAIL_LIST(_pListHead, _pEntry) \
  114. InsertTailList((_pListHead), (_pEntry))
  115. #define ATMSP_DELETE_FROM_LIST(_pEntry) \
  116. RemoveEntryList(_pEntry)
  117. #define ATMSP_BLLI_PRESENT(_pBlli) \
  118. ( (((_pBlli)->Layer2Protocol != SAP_FIELD_ABSENT) && \
  119. ((_pBlli)->Layer2Protocol != SAP_FIELD_ANY)) \
  120. || \
  121. (((_pBlli)->Layer3Protocol != SAP_FIELD_ABSENT) && \
  122. ((_pBlli)->Layer3Protocol != SAP_FIELD_ANY)) \
  123. )
  124. #define ATMSP_BHLI_PRESENT(_pBhli) \
  125. (((_pBhli)->HighLayerInfoType != SAP_FIELD_ABSENT) && \
  126. ((_pBhli)->HighLayerInfoType != SAP_FIELD_ANY))
  127. /*++
  128. ULONG
  129. ROUND_UP(
  130. IN ULONG Val
  131. )
  132. Round up a value so that it becomes a multiple of 4.
  133. --*/
  134. #define ROUND_UP(Val) (((Val) + 3) & ~0x3)
  135. #if DBG
  136. #define ATMSP_ASSERT(exp) \
  137. { \
  138. if (!(exp)) \
  139. { \
  140. DbgPrint("NulT: assert " #exp " failed in file %s, line %d\n", __FILE__, __LINE__); \
  141. DbgBreakPoint(); \
  142. } \
  143. }
  144. #else
  145. #define ATMSP_ASSERT(exp) // Nothing
  146. #endif // DBG
  147. #endif // __ATMSP_MACROS_H_INCLUDED