/private/ntos/nthals/hal0jens/alpha/jxcache.c

https://github.com/ZoloZiak/WinNT4 · C · 521 lines · 149 code · 23 blank · 349 comment · 2 complexity · 6d1a8c87d474f5a1d5acd68403363eab MD5 · raw file

  1. /*++
  2. Copyright (c) 1992 Digital Equipment Corporation
  3. Module Name:
  4. jxcache.c
  5. Abstract:
  6. This file contains the routines for managing the caches on Jensen.
  7. Jensen is based on EV4, which has primary I and D caches, both
  8. write-through. Jensen has a single back-up cache. This cache is
  9. write-back, but it is also coherent with all DMA operations. The
  10. primary caches are shadowed by the backup, and on a write hit, the
  11. primary data (but not instruction) cache is invalidated.
  12. Consequently, the routines to flush,sweep,purge,etc the data
  13. stream are nops on Jensen, but the corresponding routines for the
  14. Istream must ensure that we cannot hit in the primary I cache
  15. after a DMA operation.
  16. Jensen has a write buffer which contains 4 32-byte entries, which
  17. must be flushable before DMA operations. The MB instruction is
  18. used to accomplish this.
  19. There is no coloring support on Jensen, so Color operations are
  20. null. Zero page is unsupported because it has no users. Copy
  21. page is not special because we lack coloring.
  22. We had to make a philosophical decision about what interfaces to
  23. support in this file. (Almost) none of the interfaces defined in
  24. the HAL spec are actually supported in either the i386 or MIPS
  25. code. The i386 stream has almost no cache support at all. The
  26. Mips stream has cache support, but most routines also refer to
  27. coloring. Should we use the Spec'ed interfaces, or the Mips
  28. interfaces? I have elected the Mips interfaces because they are
  29. in use, and we are stealing much of the Mips code which expects
  30. these interfaces. Besides, the only change we might make is to
  31. remove the coloring arguments, but they may be used on Alpha
  32. machines at some future date.
  33. Author:
  34. Miche Baker-Harvey (miche) 29-May-1992
  35. Revision History:
  36. 13-Jul-1992 Jeff McLeman (mcleman)
  37. use HalpMb to do a memory barrier. Also, alter code and use super
  38. pages to pass to rtl memory routines.
  39. 10-Jul-1992 Jeff McLeman (mcleman)
  40. use HalpImb to call pal.
  41. 06-Jul-1992 Jeff McLeman (mcleman)
  42. Move routine KeFlushDcache into this module.
  43. Use only one memory barrier in the KeFlushWriteBuffer
  44. routine. This is because the PAL for the EVx will
  45. make sure the proper write ordering is done in PAL mode.
  46. --*/
  47. // Include files
  48. #include "halp.h"
  49. VOID
  50. HalFlushDcache (
  51. IN BOOLEAN AllProcessors
  52. );
  53. //
  54. // Cache and write buffer flush functions.
  55. //
  56. VOID
  57. HalChangeColorPage (
  58. IN PVOID NewColor,
  59. IN PVOID OldColor,
  60. IN ULONG PageFrame
  61. )
  62. /*++
  63. Routine Description:
  64. This function changes the color of a page if the old and new colors
  65. do not match. Jensen machines do not have page coloring, and
  66. therefore, this function performs no operation.
  67. Arguments:
  68. NewColor - Supplies the page aligned virtual address of the
  69. new color of the page to change.
  70. OldColor - Supplies the page aligned virtual address of the
  71. old color of the page to change.
  72. pageFrame - Supplies the page frame number of the page that
  73. is changed.
  74. Return Value:
  75. None.
  76. --*/
  77. {
  78. return;
  79. }
  80. VOID
  81. HalFlushDcachePage (
  82. IN PVOID Color,
  83. IN ULONG PageFrame,
  84. IN ULONG Length
  85. )
  86. /*++
  87. Routine Description:
  88. This function flushes (invalidates) up to a page of data from the
  89. data cache.
  90. Arguments:
  91. Color - Supplies the starting virtual address and color of the
  92. data that is flushed.
  93. PageFrame - Supplies the page frame number of the page that
  94. is flushed.
  95. Length - Supplies the length of the region in the page that is
  96. flushed.
  97. Return Value:
  98. None.
  99. --*/
  100. {
  101. return;
  102. }
  103. VOID
  104. HalFlushIoBuffers (
  105. IN PMDL Mdl,
  106. IN BOOLEAN ReadOperation,
  107. IN BOOLEAN DmaOperation
  108. )
  109. /*++
  110. Routine Description:
  111. This function flushes the I/O buffer specified by the memory descriptor
  112. list from the data cache on the current processor.
  113. Arguments:
  114. Mdl - Supplies a pointer to a memory descriptor list that describes the
  115. I/O buffer location.
  116. ReadOperation - Supplies a boolean value that determines whether the I/O
  117. operation is a read into memory.
  118. DmaOperation - Supplies a boolean value that determines whether the I/O
  119. operation is a DMA operation.
  120. Return Value:
  121. None.
  122. --*/
  123. {
  124. if (ReadOperation) {
  125. HalpMb(); // force all previous writes off chip
  126. HalpMb(); // not issued until previous mb completes
  127. if (Mdl->MdlFlags & MDL_IO_PAGE_READ) {
  128. //
  129. // The operation is a page read, thus the istream must
  130. // be flushed.
  131. //
  132. HalpImb();
  133. }
  134. }
  135. }
  136. VOID
  137. HalPurgeDcachePage (
  138. IN PVOID Color,
  139. IN ULONG PageFrame,
  140. IN ULONG Length
  141. )
  142. /*++
  143. Routine Description:
  144. This function purges (invalidates) up to a page of data from the
  145. data cache.
  146. Arguments:
  147. Color - Supplies the starting virtual address and color of the
  148. data that is purged.
  149. PageFrame - Supplies the page frame number of the page that
  150. is purged.
  151. Length - Supplies the length of the region in the page that is
  152. purged.
  153. Return Value:
  154. None.
  155. --*/
  156. {
  157. return;
  158. }
  159. VOID
  160. HalPurgeIcachePage (
  161. IN PVOID Color,
  162. IN ULONG PageFrame,
  163. IN ULONG Length
  164. )
  165. /*++
  166. Routine Description:
  167. This function purges (invalidates) up to a page fo data from the
  168. instruction cache.
  169. Arguments:
  170. Color - Supplies the starting virtual address and color of the
  171. data that is purged.
  172. PageFrame - Supplies the page frame number of the page that
  173. is purged.
  174. Length - Supplies the length of the region in the page that is
  175. purged.
  176. Return Value:
  177. None.
  178. --*/
  179. {
  180. //
  181. // The call to HalpImb calls PAL to flush the Icache, which ensures that
  182. // any stale hits will be invalidated
  183. //
  184. HalpImb;
  185. }
  186. VOID
  187. HalSweepDcache (
  188. VOID
  189. )
  190. /*++
  191. Routine Description:
  192. This function sweeps (invalidates) the entire data cache.
  193. Arguments:
  194. None.
  195. Return Value:
  196. None.
  197. --*/
  198. {
  199. return;
  200. }
  201. VOID
  202. HalSweepDcacheRange (
  203. IN PVOID BaseAddress,
  204. IN ULONG Length
  205. )
  206. /*++
  207. Routine Description:
  208. This function flushes the specified range of addresses from the data
  209. cache on the current processor.
  210. Arguments:
  211. BaseAddress - Supplies the starting physical address of a range of
  212. physical addresses that are to be flushed from the data cache.
  213. Length - Supplies the length of the range of physical addresses
  214. that are to be flushed from the data cache.
  215. Return Value:
  216. None.
  217. --*/
  218. {
  219. return;
  220. }
  221. VOID
  222. HalSweepIcache (
  223. VOID
  224. )
  225. /*++
  226. Routine Description:
  227. This function sweeps (invalidates) the entire instruction cache.
  228. Arguments:
  229. None.
  230. Return Value:
  231. None.
  232. --*/
  233. {
  234. //
  235. // The call to HalpImb calls PAL to flush the Icache, which ensures that
  236. // any stale hits will be invalidated
  237. //
  238. HalpImb;
  239. return;
  240. }
  241. VOID
  242. HalSweepIcacheRange (
  243. IN PVOID BaseAddress,
  244. IN ULONG Length
  245. )
  246. /*++
  247. Routine Description:
  248. This function flushes the specified range of addresses from the
  249. instruction cache on the current processor.
  250. Arguments:
  251. BaseAddress - Supplies the starting physical address of a range of
  252. physical addresses that are to be flushed from the instruction cache.
  253. Length - Supplies the length of the range of physical addresses
  254. that are to be flushed from the instruction cache.
  255. Return Value:
  256. None.
  257. --*/
  258. {
  259. //
  260. // The call to HalpImb calls PAL to flush the Icache, which ensures that
  261. // any stale hits will be invalidated
  262. //
  263. HalpImb;
  264. }
  265. VOID
  266. HalZeroPage (
  267. IN PVOID NewColor,
  268. IN PVOID OldColor,
  269. IN ULONG PageFrame
  270. )
  271. /*++
  272. Routine Description:
  273. This function zeros a page of memory.
  274. Arguments:
  275. NewColor - Supplies the page aligned virtual address of the
  276. new color of the page that is zeroed.
  277. OldColor - Supplies the page aligned virtual address of the
  278. old color of the page that is zeroed.
  279. PageFrame - Supplies the page frame number of the page that
  280. is zeroed.
  281. Return Value:
  282. None.
  283. --*/
  284. {
  285. PVOID tmp;
  286. tmp = (PVOID)((PageFrame << PAGE_SHIFT) | KSEG0_BASE);
  287. RtlZeroMemory(tmp, PAGE_SIZE);
  288. }
  289. VOID
  290. KeFlushWriteBuffer (
  291. VOID
  292. )
  293. {
  294. //
  295. // We flush the write buffer by doing a series of memory
  296. // barrier operations. It still isn't clear if we need
  297. // to do two/four of them to flush the buffer, or if one
  298. // to order the writes is suffcient
  299. //
  300. HalpMb;
  301. return;
  302. }
  303. VOID
  304. KeFlushDcache (
  305. IN BOOLEAN AllProcessors,
  306. IN PVOID BaseAddress OPTIONAL,
  307. IN ULONG Length
  308. )
  309. /*++
  310. Routine Description:
  311. This function flushes the data cache on all processors that are currently
  312. running threads which are children of the current process or flushes the
  313. data cache on all processors in the host configuration.
  314. Arguments:
  315. AllProcessors - Supplies a boolean value that determines which data
  316. caches are flushed.
  317. Return Value:
  318. None.
  319. --*/
  320. {
  321. UNREFERENCED_PARAMETER(BaseAddress);
  322. UNREFERENCED_PARAMETER(Length);
  323. HalFlushDcache(AllProcessors);
  324. return;
  325. }
  326. VOID
  327. HalFlushDcache (
  328. IN BOOLEAN AllProcessors
  329. )
  330. /*++
  331. Routine Description:
  332. This function flushes the data cache on all processors that are currently
  333. running threads which are children of the current process or flushes the
  334. data cache on all processors in the host configuration.
  335. Arguments:
  336. AllProcessors - Supplies a boolean value that determines which data
  337. caches are flushed.
  338. Return Value:
  339. None.
  340. --*/
  341. {
  342. //
  343. // Sweep (index/writeback/invalidate) the data cache.
  344. //
  345. HalSweepDcache();
  346. return;
  347. }
  348. ULONG
  349. HalGetDmaAlignmentRequirement (
  350. VOID
  351. )
  352. /*++
  353. Routine Description:
  354. This function returns the alignment requirements for DMA transfers on
  355. host system.
  356. Arguments:
  357. None.
  358. Return Value:
  359. The DMA alignment requirement is returned as the fucntion value.
  360. --*/
  361. {
  362. return 8;
  363. }