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.

526 lines
11 KiB

  1. //
  2. // No Check-in Source Code.
  3. //
  4. // Do not make this code available to non-Microsoft personnel
  5. // without Intel's express permission
  6. //
  7. /**
  8. *** Copyright (C) 1996-97 Intel Corporation. All rights reserved.
  9. ***
  10. *** The information and source code contained herein is the exclusive
  11. *** property of Intel Corporation and may not be disclosed, examined
  12. *** or reproduced in whole or in part without explicit written authorization
  13. *** from the company.
  14. **/
  15. /*++
  16. Copyright (c) 1995 Intel Corporation
  17. Module Name:
  18. simdma.c
  19. Abstract:
  20. This module implements the DMA support routines for the HAL DLL.
  21. Author:
  22. 14-Apr-1995
  23. Environment:
  24. Kernel mode
  25. Revision History:
  26. --*/
  27. #include "halp.h"
  28. PADAPTER_OBJECT
  29. HalGetAdapter(
  30. IN PDEVICE_DESCRIPTION DeviceDescriptor,
  31. OUT PULONG NumberOfMapRegisters
  32. )
  33. /*++
  34. Routine Description:
  35. This function returns the appropriate adapter object for the DMA
  36. device. However, there is no DMA device in the simulation
  37. environment. Therefore, the function returns NULL to indicate
  38. failure.
  39. Arguments:
  40. DeviceDescriptor - Supplies a description of the deivce.
  41. NumberOfMapRegisters - Returns the maximum number of map registers which
  42. may be allocated by the device driver.
  43. Return Value:
  44. NULL
  45. --*/
  46. {
  47. return NULL;
  48. }
  49. NTSTATUS
  50. HalAllocateAdapterChannel(
  51. IN PADAPTER_OBJECT AdapterObject,
  52. IN PWAIT_CONTEXT_BLOCK Wcb,
  53. IN ULONG NumberOfMapRegisters,
  54. IN PDRIVER_CONTROL ExecutionRoutine
  55. )
  56. /*++
  57. Routine Description:
  58. As there is no DMA device in the simulation environment, this function
  59. is not supported.
  60. Arguments:
  61. AdapterObject - Pointer to the adapter control object to allocate to the
  62. driver.
  63. Wcb - Supplies a wait context block for saving the allocation parameters.
  64. The DeviceObject, CurrentIrp and DeviceContext should be initalized.
  65. NumberOfMapRegisters - The number of map registers that are to be allocated
  66. from the channel, if any.
  67. ExecutionRoutine - The address of the driver's execution routine that is
  68. invoked once the adapter channel (and possibly map registers) have been
  69. allocated.
  70. Return Value:
  71. Returns STATUS_NOT_SUPPORTED
  72. Notes:
  73. Note that this routine MUST be invoked at DISPATCH_LEVEL or above.
  74. --*/
  75. {
  76. return STATUS_NOT_SUPPORTED;
  77. }
  78. ULONG
  79. HalReadDmaCounter(
  80. IN PADAPTER_OBJECT AdapterObject
  81. )
  82. /*++
  83. Routine Description:
  84. This function reads the DMA counter and returns the number of bytes left
  85. to be transfered. As there is no DMA device, a value of zero is always
  86. returned.
  87. Arguments:
  88. AdapterObject - Supplies a pointer to the adapter object to be read.
  89. Return Value:
  90. Returns the number of bytes still be be transfered.
  91. --*/
  92. {
  93. return 0;
  94. }
  95. PVOID
  96. HalAllocateCommonBuffer(
  97. IN PADAPTER_OBJECT AdapterObject,
  98. IN ULONG Length,
  99. OUT PPHYSICAL_ADDRESS LogicalAddress,
  100. IN BOOLEAN CacheEnabled
  101. )
  102. /*++
  103. Routine Description:
  104. This function allocates the memory for a common buffer and maps so
  105. that it can be accessed by a master device and the CPU. As there
  106. is no DMA support, a value of NULL is always returned.
  107. Arguments:
  108. AdapterObject - Supplies a pointer to the adapter object used by this
  109. device.
  110. Length - Supplies the length of the common buffer to be allocated.
  111. LogicalAddress - Returns the logical address of the common buffer.
  112. CacheEnable - Indicates whether the memeory is cached or not.
  113. Return Value:
  114. Returns the virtual address of the common buffer. If the buffer cannot
  115. be allocated then NULL is returned.
  116. --*/
  117. {
  118. return NULL;
  119. }
  120. BOOLEAN
  121. HalFlushCommonBuffer(
  122. IN PADAPTER_OBJECT AdapterObject,
  123. IN ULONG Length,
  124. IN PHYSICAL_ADDRESS LogicalAddress,
  125. IN PVOID VirtualAddress
  126. )
  127. /*++
  128. Routine Description:
  129. This function is called to flush any hardware adapter buffers when the
  130. driver needs to read data written by an I/O master device to a common
  131. buffer. As there is no DMA support, that implies no buffers to flush
  132. and TRUE is always returned.
  133. Arguments:
  134. AdapterObject - Supplies a pointer to the adapter object used by this
  135. device.
  136. Length - Supplies the length of the common buffer. This should be the same
  137. value used for the allocation of the buffer.
  138. LogicalAddress - Supplies the logical address of the common buffer. This
  139. must be the same value return by HalAllocateCommonBuffer.
  140. VirtualAddress - Supplies the virtual address of the common buffer. This
  141. must be the same value return by HalAllocateCommonBuffer.
  142. Return Value:
  143. Returns TRUE if no errors were detected; otherwise, FALSE is return.
  144. --*/
  145. {
  146. return TRUE;
  147. }
  148. VOID
  149. HalFreeCommonBuffer(
  150. IN PADAPTER_OBJECT AdapterObject,
  151. IN ULONG Length,
  152. IN PHYSICAL_ADDRESS LogicalAddress,
  153. IN PVOID VirtualAddress,
  154. IN BOOLEAN CacheEnabled
  155. )
  156. /*++
  157. Routine Description:
  158. This function frees a common buffer and all of the resouces it uses.
  159. There is no buffer to be freed in the simulation environment. The
  160. function simply returns.
  161. Arguments:
  162. AdapterObject - Supplies a pointer to the adapter object used by this
  163. device.
  164. Length - Supplies the length of the common buffer. This should be the same
  165. value used for the allocation of the buffer.
  166. LogicalAddress - Supplies the logical address of the common buffer. This
  167. must be the same value return by HalAllocateCommonBuffer.
  168. VirtualAddress - Supplies the virtual address of the common buffer. This
  169. must be the same value return by HalAllocateCommonBuffer.
  170. CacheEnable - Indicates whether the memeory is cached or not.
  171. Return Value:
  172. None
  173. --*/
  174. {
  175. return;
  176. }
  177. PVOID
  178. HalAllocateCrashDumpRegisters(
  179. IN PADAPTER_OBJECT AdapterObject,
  180. IN PULONG NumberOfMapRegisters
  181. )
  182. /*++
  183. Routine Description:
  184. This routine is called during the crash dump disk driver's initialization
  185. to allocate a number map registers permanently. It is not supported and
  186. NULL is always returned to indicate allocation failure. The lack of this
  187. capability implies that the crash dump disk driver is not supported.
  188. Arguments:
  189. AdapterObject - Pointer to the adapter control object to allocate to the
  190. driver.
  191. NumberOfMapRegisters - Number of map registers requested. This field
  192. will be updated to reflect the actual number of registers allocated
  193. when the number is less than what was requested.
  194. Return Value:
  195. Returns NULL.
  196. --*/
  197. {
  198. return NULL;
  199. }
  200. BOOLEAN
  201. IoFlushAdapterBuffers(
  202. IN PADAPTER_OBJECT AdapterObject,
  203. IN PMDL Mdl,
  204. IN PVOID MapRegisterBase,
  205. IN PVOID CurrentVa,
  206. IN ULONG Length,
  207. IN BOOLEAN WriteToDevice
  208. )
  209. /*++
  210. Routine Description:
  211. This routine flushes the DMA adapter object buffers. In the simulation
  212. environment, nothing needs to be done and TRUE is always returned.
  213. Arguments:
  214. AdapterObject - Pointer to the adapter object representing the DMA
  215. controller channel.
  216. Mdl - A pointer to a Memory Descriptor List (MDL) that maps the locked-down
  217. buffer to/from which the I/O occured.
  218. MapRegisterBase - A pointer to the base of the map registers in the adapter
  219. or DMA controller.
  220. CurrentVa - The current virtual address in the buffer described the the Mdl
  221. where the I/O operation occurred.
  222. Length - Supplies the length of the transfer.
  223. WriteToDevice - Supplies a BOOLEAN value that indicates the direction of
  224. the data transfer was to the device.
  225. Return Value:
  226. TRUE - No errors are detected so the transfer must succeed.
  227. --*/
  228. {
  229. return TRUE;
  230. }
  231. VOID
  232. IoFreeAdapterChannel(
  233. IN PADAPTER_OBJECT AdapterObject
  234. )
  235. /*++
  236. Routine Description:
  237. This routine is invoked to deallocate the specified adapter object.
  238. Any map registers that were allocated are also automatically deallocated.
  239. No checks are made to ensure that the adapter is really allocated to
  240. a device object. However, if it is not, then kernel will bugcheck.
  241. If another device is waiting in the queue to allocate the adapter object
  242. it will be pulled from the queue and its execution routine will be
  243. invoked.
  244. In the simulation environment, this routine does nothing and returns.
  245. Arguments:
  246. AdapterObject - Pointer to the adapter object to be deallocated.
  247. Return Value:
  248. None.
  249. --*/
  250. {
  251. return;
  252. }
  253. VOID
  254. IoFreeMapRegisters(
  255. PADAPTER_OBJECT AdapterObject,
  256. PVOID MapRegisterBase,
  257. ULONG NumberOfMapRegisters
  258. )
  259. /*++
  260. Routine Description:
  261. This routine deallocates the map registers for the adapter. If there are
  262. any queued adapter waiting for an attempt is made to allocate the next
  263. entry.
  264. In the simulation environment, the routine does nothing and returns.
  265. Arguments:
  266. AdapterObject - The adapter object to where the map register should be
  267. returned.
  268. MapRegisterBase - The map register base of the registers to be deallocated.
  269. NumberOfMapRegisters - The number of registers to be deallocated.
  270. Return Value:
  271. None
  272. --+*/
  273. {
  274. return;
  275. }
  276. PHYSICAL_ADDRESS
  277. IoMapTransfer(
  278. IN PADAPTER_OBJECT AdapterObject,
  279. IN PMDL Mdl,
  280. IN PVOID MapRegisterBase,
  281. IN PVOID CurrentVa,
  282. IN OUT PULONG Length,
  283. IN BOOLEAN WriteToDevice
  284. )
  285. /*++
  286. Routine Description:
  287. This routine is invoked to set up the map registers in the DMA controller
  288. to allow a transfer to or from a device.
  289. In the simulation environment, no map register is supported and a
  290. logical address of zero is always returned.
  291. Arguments:
  292. AdapterObject - Pointer to the adapter object representing the DMA
  293. controller channel that has been allocated.
  294. Mdl - Pointer to the MDL that describes the pages of memory that are
  295. being read or written.
  296. MapRegisterBase - The address of the base map register that has been
  297. allocated to the device driver for use in mapping the transfer.
  298. CurrentVa - Current virtual address in the buffer described by the MDL
  299. that the transfer is being done to or from.
  300. Length - Supplies the length of the transfer. This determines the
  301. number of map registers that need to be written to map the transfer.
  302. Returns the length of the transfer which was actually mapped.
  303. WriteToDevice - Boolean value that indicates whether this is a write
  304. to the device from memory (TRUE), or vice versa.
  305. Return Value:
  306. Returns the logical address that should be used bus master controllers.
  307. --*/
  308. {
  309. PHYSICAL_ADDRESS result;
  310. result.HighPart = 0;
  311. result.LowPart = 0;
  312. return (result);
  313. }
  314. ULONG
  315. HalGetDmaAlignmentRequirement (
  316. VOID
  317. )
  318. /*++
  319. Routine Description:
  320. This function returns the alignment requirements for DMA transfers on
  321. host system.
  322. Arguments:
  323. None.
  324. Return Value:
  325. The DMA alignment requirement is returned as the fucntion value.
  326. --*/
  327. {
  328. return 8;
  329. }
  330. VOID
  331. HalFlushIoBuffers (
  332. IN PMDL Mdl,
  333. IN BOOLEAN ReadOperation,
  334. IN BOOLEAN DmaOperation
  335. )
  336. /*++
  337. Routine Description:
  338. This function flushes the I/O buffer specified by the memory descriptor
  339. list from the data cache on the current processor.
  340. Arguments:
  341. Mdl - Supplies a pointer to a memory descriptor list that describes the
  342. I/O buffer location.
  343. ReadOperation - Supplies a boolean value that determines whether the I/O
  344. operation is a read into memory.
  345. DmaOperation - Supplies a boolean value that determines whether the I/O
  346. operation is a DMA operation.
  347. Return Value:
  348. None.
  349. --*/
  350. {
  351. //
  352. // BUGBUG: This still needs to be done
  353. //
  354. }