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.

84 lines
4.5 KiB

  1. /*++
  2. Copyright (c) 1990-1995 Microsoft Corporation
  3. Module Name:
  4. macros.h
  5. Abstract:
  6. NDIS wrapper definitions
  7. Author:
  8. Environment:
  9. Kernel mode, FSD
  10. Revision History:
  11. Jun-95 Jameel Hyder Split up from a monolithic file
  12. --*/
  13. #ifndef _MACROS_H
  14. #define _MACROS_H
  15. #define NdisMStartBufferPhysicalMappingMacro( \
  16. _MiniportAdapterHandle, \
  17. _Buffer, \
  18. _PhysicalMapRegister, \
  19. _Write, \
  20. _PhysicalAddressArray, \
  21. _ArraySize) \
  22. { \
  23. PNDIS_MINIPORT_BLOCK _Miniport = (PNDIS_MINIPORT_BLOCK)(_MiniportAdapterHandle);\
  24. PMAP_TRANSFER mapTransfer = *_Miniport->SystemAdapterObject->DmaOperations->MapTransfer;\
  25. PHYSICAL_ADDRESS _LogicalAddress; \
  26. PUCHAR _VirtualAddress; \
  27. ULONG _LengthRemaining; \
  28. ULONG _LengthMapped; \
  29. UINT _CurrentArrayLocation; \
  30. \
  31. _VirtualAddress = (PUCHAR)MmGetMdlVirtualAddress(_Buffer); \
  32. _LengthRemaining = MmGetMdlByteCount(_Buffer); \
  33. _CurrentArrayLocation = 0; \
  34. \
  35. while (_LengthRemaining > 0) \
  36. { \
  37. _LengthMapped = _LengthRemaining; \
  38. _LogicalAddress = \
  39. mapTransfer(_Miniport->SystemAdapterObject, \
  40. (_Buffer), \
  41. _Miniport->MapRegisters[_PhysicalMapRegister].MapRegister,\
  42. _VirtualAddress, \
  43. &_LengthMapped, \
  44. (_Write)); \
  45. (_PhysicalAddressArray)[_CurrentArrayLocation].PhysicalAddress = _LogicalAddress;\
  46. (_PhysicalAddressArray)[_CurrentArrayLocation].Length = _LengthMapped; \
  47. _LengthRemaining -= _LengthMapped; \
  48. _VirtualAddress += _LengthMapped; \
  49. ++_CurrentArrayLocation; \
  50. } \
  51. _Miniport->MapRegisters[_PhysicalMapRegister].WriteToDevice = (_Write); \
  52. *(_ArraySize) = _CurrentArrayLocation; \
  53. }
  54. #define NdisMCompleteBufferPhysicalMappingMacro(_MiniportAdapterHandle, \
  55. _Buffer, \
  56. _PhysicalMapRegister) \
  57. { \
  58. PNDIS_MINIPORT_BLOCK _Miniport = (PNDIS_MINIPORT_BLOCK)(_MiniportAdapterHandle);\
  59. PFLUSH_ADAPTER_BUFFERS flushAdapterBuffers = *_Miniport->SystemAdapterObject->DmaOperations->FlushAdapterBuffers;\
  60. \
  61. flushAdapterBuffers(_Miniport->SystemAdapterObject, \
  62. _Buffer, \
  63. (_Miniport)->MapRegisters[_PhysicalMapRegister].MapRegister,\
  64. MmGetMdlVirtualAddress(_Buffer), \
  65. MmGetMdlByteCount(_Buffer), \
  66. (_Miniport)->MapRegisters[_PhysicalMapRegister].WriteToDevice);\
  67. }
  68. #endif //_MACROS_H