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.

234 lines
5.3 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. NTSTATUS
  121. HalpAllocateMapRegisters(
  122. IN PADAPTER_OBJECT DmaAdapter,
  123. IN ULONG NumberOfMapRegisters,
  124. IN ULONG BaseAddressCount,
  125. OUT PMAP_REGISTER_ENTRY MapRegisterArray
  126. );
  127. PHYSICAL_ADDRESS
  128. __inline
  129. HalpGetAdapterMaximumPhysicalAddress(
  130. IN PADAPTER_OBJECT AdapterObject
  131. )
  132. /*++
  133. Routine Description:
  134. This routine determines and returns the maximum physical address that
  135. can be accessed by the given adapter.
  136. Arguments:
  137. AdapterObject - Supplies a pointer to the adapter object used by this
  138. device.
  139. Return Value:
  140. Returns the maximum physical address that can be accessed by this
  141. device.
  142. --*/
  143. {
  144. PHYSICAL_ADDRESS maximumAddress;
  145. //
  146. // Assume the device requires physical addresses 2GB.
  147. //
  148. maximumAddress.HighPart = 0;
  149. maximumAddress.LowPart = MAXIMUM_PHYSICAL_ADDRESS - 1;
  150. //
  151. // IoMapTransfer() is sometimes called with a NULL adapter object. In
  152. // this case, assume the adapter is 32 bit.
  153. //
  154. if (AdapterObject == NULL) {
  155. return maximumAddress;
  156. }
  157. if (AdapterObject->MasterDevice) {
  158. if (AdapterObject->Dma64BitAddresses) {
  159. //
  160. // This device is a master and can handle 64 bit addresses.
  161. //
  162. maximumAddress.QuadPart = (ULONGLONG)-1;
  163. } else if(AdapterObject->Dma32BitAddresses) {
  164. //
  165. // This device is a master and can handle 32 bit addresses.
  166. //
  167. maximumAddress.LowPart = (ULONG)-1;
  168. }
  169. }
  170. return maximumAddress;
  171. }
  172. #endif // _IXISA_