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.

86 lines
4.7 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. //1 put some protection in this macro to guard against the cases that we can not
  16. //1 map the entire mdl because we don't have enough map registers.
  17. #define NdisMStartBufferPhysicalMappingMacro( \
  18. _MiniportAdapterHandle, \
  19. _Buffer, \
  20. _PhysicalMapRegister, \
  21. _Write, \
  22. _PhysicalAddressArray, \
  23. _ArraySize) \
  24. { \
  25. PNDIS_MINIPORT_BLOCK _Miniport = (PNDIS_MINIPORT_BLOCK)(_MiniportAdapterHandle);\
  26. PMAP_TRANSFER mapTransfer = *_Miniport->SystemAdapterObject->DmaOperations->MapTransfer;\
  27. PHYSICAL_ADDRESS _LogicalAddress; \
  28. PUCHAR _VirtualAddress; \
  29. ULONG _LengthRemaining; \
  30. ULONG _LengthMapped; \
  31. UINT _CurrentArrayLocation; \
  32. \
  33. _VirtualAddress = (PUCHAR)MmGetMdlVirtualAddress(_Buffer); \
  34. _LengthRemaining = MmGetMdlByteCount(_Buffer); \
  35. _CurrentArrayLocation = 0; \
  36. \
  37. while (_LengthRemaining > 0) \
  38. { \
  39. _LengthMapped = _LengthRemaining; \
  40. _LogicalAddress = \
  41. mapTransfer(_Miniport->SystemAdapterObject, \
  42. (_Buffer), \
  43. _Miniport->MapRegisters[_PhysicalMapRegister].MapRegister,\
  44. _VirtualAddress, \
  45. &_LengthMapped, \
  46. (_Write)); \
  47. (_PhysicalAddressArray)[_CurrentArrayLocation].PhysicalAddress = _LogicalAddress;\
  48. (_PhysicalAddressArray)[_CurrentArrayLocation].Length = _LengthMapped; \
  49. _LengthRemaining -= _LengthMapped; \
  50. _VirtualAddress += _LengthMapped; \
  51. ++_CurrentArrayLocation; \
  52. } \
  53. _Miniport->MapRegisters[_PhysicalMapRegister].WriteToDevice = (_Write); \
  54. *(_ArraySize) = _CurrentArrayLocation; \
  55. }
  56. #define NdisMCompleteBufferPhysicalMappingMacro(_MiniportAdapterHandle, \
  57. _Buffer, \
  58. _PhysicalMapRegister) \
  59. { \
  60. PNDIS_MINIPORT_BLOCK _Miniport = (PNDIS_MINIPORT_BLOCK)(_MiniportAdapterHandle);\
  61. PFLUSH_ADAPTER_BUFFERS flushAdapterBuffers = *_Miniport->SystemAdapterObject->DmaOperations->FlushAdapterBuffers;\
  62. \
  63. flushAdapterBuffers(_Miniport->SystemAdapterObject, \
  64. _Buffer, \
  65. (_Miniport)->MapRegisters[_PhysicalMapRegister].MapRegister,\
  66. MmGetMdlVirtualAddress(_Buffer), \
  67. MmGetMdlByteCount(_Buffer), \
  68. (_Miniport)->MapRegisters[_PhysicalMapRegister].WriteToDevice);\
  69. }
  70. #endif //_MACROS_H