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.

273 lines
6.1 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. #if !defined(_HALPAE_)
  20. #define MAXIMUM_MAP_BUFFER_SIZE MAXIMUM_ISA_MAP_BUFFER_SIZE
  21. #endif
  22. //
  23. // MAXIMUM_PCI_MAP_BUFFER_SIZE defines the maximum map buffers which the system
  24. // will allocate for 32-bit PCI devices on a 64-bit system.
  25. //
  26. #define MAXIMUM_PCI_MAP_BUFFER_SIZE (64 * 1024 * 1024)
  27. //
  28. // Define the initial buffer allocation size for a map buffers for systems with
  29. // no memory which has a physical address greater than MAXIMUM_PHYSICAL_ADDRESS.
  30. //
  31. #define INITIAL_MAP_BUFFER_SMALL_SIZE 0x10000
  32. //
  33. // Define the initial buffer allocation size for a map buffers for systems with
  34. // no memory which has a physical address greater than MAXIMUM_PHYSICAL_ADDRESS.
  35. //
  36. #define INITIAL_MAP_BUFFER_LARGE_SIZE 0x30000
  37. //
  38. // Define the incremental buffer allocation for a map buffers.
  39. //
  40. #define INCREMENT_MAP_BUFFER_SIZE 0x10000
  41. //
  42. // Define the maximum number of map registers that can be requested at one time
  43. // if actual map registers are required for the transfer.
  44. //
  45. #define MAXIMUM_ISA_MAP_REGISTER 16
  46. #define MAXIMUM_PCI_MAP_REGISTER 16
  47. //
  48. // Define the maximum physical address which can be handled by an Isa card.
  49. //
  50. #define MAXIMUM_PHYSICAL_ADDRESS 0x01000000
  51. //
  52. // Define the scatter/gather flag for the Map Register Base.
  53. //
  54. #define NO_SCATTER_GATHER 0x00000001
  55. //
  56. // Define the copy buffer flag for the index.
  57. //
  58. #define COPY_BUFFER 0XFFFFFFFF
  59. //
  60. // Define adapter object structure.
  61. //
  62. typedef struct _ADAPTER_OBJECT {
  63. DMA_ADAPTER DmaHeader;
  64. struct _ADAPTER_OBJECT *MasterAdapter;
  65. ULONG MapRegistersPerChannel;
  66. PVOID AdapterBaseVa;
  67. PVOID MapRegisterBase;
  68. ULONG NumberOfMapRegisters;
  69. ULONG CommittedMapRegisters;
  70. struct _WAIT_CONTEXT_BLOCK *CurrentWcb;
  71. KDEVICE_QUEUE ChannelWaitQueue;
  72. PKDEVICE_QUEUE RegisterWaitQueue;
  73. LIST_ENTRY AdapterQueue;
  74. KSPIN_LOCK SpinLock;
  75. PRTL_BITMAP MapRegisters;
  76. PUCHAR PagePort;
  77. UCHAR ChannelNumber;
  78. UCHAR AdapterNumber;
  79. USHORT DmaPortAddress;
  80. UCHAR AdapterMode;
  81. BOOLEAN NeedsMapRegisters;
  82. BOOLEAN MasterDevice;
  83. BOOLEAN Width16Bits;
  84. BOOLEAN ScatterGather;
  85. BOOLEAN IgnoreCount;
  86. BOOLEAN Dma32BitAddresses;
  87. BOOLEAN Dma64BitAddresses;
  88. BOOLEAN LegacyAdapter;
  89. LIST_ENTRY AdapterList;
  90. } ADAPTER_OBJECT;
  91. typedef struct _MASTER_ADAPTER_OBJECT {
  92. PADAPTER_OBJECT AdapterObject;
  93. //
  94. // Maximum number of buffers to allocate for this master adapter.
  95. //
  96. ULONG MaxBufferPages;
  97. //
  98. // Number of map buffers allocated
  99. //
  100. ULONG MapBufferSize;
  101. PHYSICAL_ADDRESS MapBufferPhysicalAddress;
  102. } MASTER_ADAPTER_OBJECT, *PMASTER_ADAPTER_OBJECT;
  103. ULONG
  104. HalGetDmaAlignment (
  105. PVOID Conext
  106. );
  107. NTSTATUS
  108. HalCalculateScatterGatherListSize(
  109. IN PADAPTER_OBJECT AdapterObject,
  110. IN OPTIONAL PMDL Mdl,
  111. IN PVOID CurrentVa,
  112. IN ULONG Length,
  113. OUT PULONG ScatterGatherListSize,
  114. OUT OPTIONAL PULONG pNumberOfMapRegisters
  115. );
  116. NTSTATUS
  117. HalBuildScatterGatherList (
  118. IN PADAPTER_OBJECT AdapterObject,
  119. IN PDEVICE_OBJECT DeviceObject,
  120. IN PMDL Mdl,
  121. IN PVOID CurrentVa,
  122. IN ULONG Length,
  123. IN PDRIVER_LIST_CONTROL ExecutionRoutine,
  124. IN PVOID Context,
  125. IN BOOLEAN WriteToDevice,
  126. IN PVOID ScatterGatherBuffer,
  127. IN ULONG ScatterGatherBufferLength
  128. );
  129. NTSTATUS
  130. HalBuildMdlFromScatterGatherList(
  131. IN PADAPTER_OBJECT AdapaterObject,
  132. IN PSCATTER_GATHER_LIST ScatterGather,
  133. IN PMDL OriginalMdl,
  134. OUT PMDL *TargetMdl
  135. );
  136. NTSTATUS
  137. HalpAllocateMapRegisters(
  138. IN PADAPTER_OBJECT DmaAdapter,
  139. IN ULONG NumberOfMapRegisters,
  140. IN ULONG BaseAddressCount,
  141. OUT PMAP_REGISTER_ENTRY MapRegisterArray
  142. );
  143. PHYSICAL_ADDRESS
  144. __inline
  145. HalpGetAdapterMaximumPhysicalAddress(
  146. IN PADAPTER_OBJECT AdapterObject
  147. )
  148. /*++
  149. Routine Description:
  150. This routine determines and returns the maximum physical address that
  151. can be accessed by the given adapter.
  152. Arguments:
  153. AdapterObject - Supplies a pointer to the adapter object used by this
  154. device.
  155. Return Value:
  156. Returns the maximum physical address that can be accessed by this
  157. device.
  158. --*/
  159. {
  160. PHYSICAL_ADDRESS maximumAddress;
  161. //
  162. // Assume the device requires physical addresses < 16M.
  163. //
  164. maximumAddress.HighPart = 0;
  165. maximumAddress.LowPart = MAXIMUM_PHYSICAL_ADDRESS - 1;
  166. //
  167. // IoMapTransfer() is sometimes called with a NULL adapter object. In
  168. // this case, assume the adapter is 24 bit.
  169. //
  170. if (AdapterObject == NULL) {
  171. return maximumAddress;
  172. }
  173. if (AdapterObject->MasterDevice) {
  174. if (AdapterObject->Dma64BitAddresses) {
  175. //
  176. // This device is a master and can handle 64 bit addresses.
  177. //
  178. maximumAddress.QuadPart = (ULONGLONG)-1;
  179. } else if(AdapterObject->Dma32BitAddresses) {
  180. //
  181. // This device is a master and can handle 32 bit addresses.
  182. //
  183. maximumAddress.LowPart = (ULONG)-1;
  184. }
  185. }
  186. return maximumAddress;
  187. }
  188. #if defined(_WIN64)
  189. NTSTATUS
  190. HalRealAllocateAdapterChannel(
  191. IN PADAPTER_OBJECT AdapterObject,
  192. IN PDEVICE_OBJECT DeviceObject,
  193. IN ULONG NumberOfMapRegisters,
  194. IN PDRIVER_CONTROL ExecutionRoutine,
  195. IN PVOID Context
  196. );
  197. #endif
  198. #endif // _IXISA_