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.

226 lines
4.9 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. ixisa.h
  5. Abstract:
  6. This header file defines the private Hardware Architecture Layer (HAL)
  7. EISA/ISA specific interfaces, defines and structures.
  8. Author:
  9. Jeff Havens (jhavens) 20-Jun-91
  10. Revision History:
  11. --*/
  12. #ifndef _IXISA_
  13. #define _IXISA_
  14. //
  15. // The MAXIMUM_MAP_BUFFER_SIZE defines the maximum map buffers which the system
  16. // will allocate for devices which require phyically contigous buffers.
  17. //
  18. #define MAXIMUM_ISA_MAP_BUFFER_SIZE 0x40000
  19. #define MAXIMUM_MAP_BUFFER_SIZE MAXIMUM_ISA_MAP_BUFFER_SIZE
  20. //
  21. // MAXIMUM_PCI_MAP_BUFFER_SIZE defines the maximum map buffers which the system
  22. // will allocate for 32-bit PCI devices on a 64-bit system.
  23. //
  24. #define MAXIMUM_PCI_MAP_BUFFER_SIZE (64 * 1024 * 1024)
  25. //
  26. // Define the initial buffer allocation size for a map buffers for systems with
  27. // no memory which has a physical address greater than MAXIMUM_PHYSICAL_ADDRESS.
  28. //
  29. #define INITIAL_MAP_BUFFER_SMALL_SIZE 0x10000
  30. //
  31. // Define the initial buffer allocation size for a map buffers for systems with
  32. // no memory which has a physical address greater than MAXIMUM_PHYSICAL_ADDRESS.
  33. //
  34. #define INITIAL_MAP_BUFFER_LARGE_SIZE 0x30000
  35. //
  36. // Define the incremental buffer allocation for a map buffers.
  37. //
  38. #define INCREMENT_MAP_BUFFER_SIZE 0x10000
  39. //
  40. // Define the maximum number of map registers that can be requested at one time
  41. // if actual map registers are required for the transfer.
  42. //
  43. #define MAXIMUM_ISA_MAP_REGISTER 16
  44. #define MAXIMUM_PCI_MAP_REGISTER 16
  45. //
  46. // Define the maximum physical address which can be handled by an Isa card
  47. //
  48. #define MAXIMUM_PHYSICAL_ADDRESS 0xffffffff
  49. //
  50. // Define the scatter/gather flag for the Map Register Base.
  51. //
  52. #define NO_SCATTER_GATHER 0x00000001
  53. //
  54. // Define the copy buffer flag for the index.
  55. //
  56. #define COPY_BUFFER 0XFFFFFFFF
  57. //
  58. // Define adapter object structure.
  59. //
  60. typedef struct _ADAPTER_OBJECT {
  61. DMA_ADAPTER DmaHeader;
  62. struct _ADAPTER_OBJECT *MasterAdapter;
  63. ULONG MapRegistersPerChannel;
  64. PVOID AdapterBaseVa;
  65. PVOID MapRegisterBase;
  66. ULONG NumberOfMapRegisters;
  67. ULONG CommittedMapRegisters;
  68. struct _WAIT_CONTEXT_BLOCK *CurrentWcb;
  69. KDEVICE_QUEUE ChannelWaitQueue;
  70. PKDEVICE_QUEUE RegisterWaitQueue;
  71. LIST_ENTRY AdapterQueue;
  72. KSPIN_LOCK SpinLock;
  73. PRTL_BITMAP MapRegisters;
  74. PUCHAR PagePort;
  75. UCHAR ChannelNumber;
  76. UCHAR AdapterNumber;
  77. USHORT DmaPortAddress;
  78. UCHAR AdapterMode;
  79. BOOLEAN NeedsMapRegisters;
  80. BOOLEAN MasterDevice;
  81. BOOLEAN Width16Bits;
  82. BOOLEAN ScatterGather;
  83. BOOLEAN IgnoreCount;
  84. BOOLEAN Dma32BitAddresses;
  85. BOOLEAN Dma64BitAddresses;
  86. } ADAPTER_OBJECT;
  87. ULONG
  88. HalGetDmaAlignment (
  89. PVOID Conext
  90. );
  91. NTSTATUS
  92. HalCalculateScatterGatherListSize(
  93. IN PADAPTER_OBJECT AdapterObject,
  94. IN OPTIONAL PMDL Mdl,
  95. IN PVOID CurrentVa,
  96. IN ULONG Length,
  97. OUT PULONG ScatterGatherListSize,
  98. OUT OPTIONAL PULONG pNumberOfMapRegisters
  99. );
  100. NTSTATUS
  101. HalBuildScatterGatherList (
  102. IN PADAPTER_OBJECT AdapterObject,
  103. IN PDEVICE_OBJECT DeviceObject,
  104. IN PMDL Mdl,
  105. IN PVOID CurrentVa,
  106. IN ULONG Length,
  107. IN PDRIVER_LIST_CONTROL ExecutionRoutine,
  108. IN PVOID Context,
  109. IN BOOLEAN WriteToDevice,
  110. IN PVOID ScatterGatherBuffer,
  111. IN ULONG ScatterGatherBufferLength
  112. );
  113. NTSTATUS
  114. HalBuildMdlFromScatterGatherList(
  115. IN PADAPTER_OBJECT AdapaterObject,
  116. IN PSCATTER_GATHER_LIST ScatterGather,
  117. IN PMDL OriginalMdl,
  118. OUT PMDL *TargetMdl
  119. );
  120. PHYSICAL_ADDRESS
  121. __inline
  122. HalpGetAdapterMaximumPhysicalAddress(
  123. IN PADAPTER_OBJECT AdapterObject
  124. )
  125. /*++
  126. Routine Description:
  127. This routine determines and returns the maximum physical address that
  128. can be accessed by the given adapter.
  129. Arguments:
  130. AdapterObject - Supplies a pointer to the adapter object used by this
  131. device.
  132. Return Value:
  133. Returns the maximum physical address that can be accessed by this
  134. device.
  135. --*/
  136. {
  137. PHYSICAL_ADDRESS maximumAddress;
  138. //
  139. // Assume the device requires physical addresses 2GB.
  140. //
  141. maximumAddress.HighPart = 0;
  142. maximumAddress.LowPart = MAXIMUM_PHYSICAL_ADDRESS - 1;
  143. //
  144. // IoMapTransfer() is sometimes called with a NULL adapter object. In
  145. // this case, assume the adapter is 32 bit.
  146. //
  147. if (AdapterObject == NULL) {
  148. return maximumAddress;
  149. }
  150. if (AdapterObject->MasterDevice) {
  151. if (AdapterObject->Dma64BitAddresses) {
  152. //
  153. // This device is a master and can handle 64 bit addresses.
  154. //
  155. maximumAddress.QuadPart = (ULONGLONG)-1;
  156. } else if(AdapterObject->Dma32BitAddresses) {
  157. //
  158. // This device is a master and can handle 32 bit addresses.
  159. //
  160. maximumAddress.LowPart = (ULONG)-1;
  161. }
  162. }
  163. return maximumAddress;
  164. }
  165. #endif // _IXISA_