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.

1110 lines
50 KiB

  1. /******************************Module*Header**********************************\
  2. *
  3. * *******************
  4. * * GDI SAMPLE CODE *
  5. * *******************
  6. *
  7. * Module Name: glntctxt.c
  8. *
  9. * Content:
  10. *
  11. * Context switching for GLINT. Used to create and swap contexts in and out.
  12. * The display driver has a context, the 3D extension has another
  13. *
  14. * Copyright (c) 1994-1999 3Dlabs Inc. Ltd. All rights reserved.
  15. * Copyright (c) 1995-2003 Microsoft Corporation. All rights reserved.
  16. \*****************************************************************************/
  17. #include "precomp.h"
  18. #include "glint.h"
  19. #include "glntctxt.h"
  20. DWORD readableRegistersP3[] = {
  21. __GlintTagStartXDom, // [0x000]
  22. __GlintTagdXDom, // [0x001]
  23. __GlintTagStartXSub, // [0x002]
  24. __GlintTagdXSub, // [0x003]
  25. __GlintTagStartY, // [0x004]
  26. __GlintTagdY, // [0x005]
  27. __GlintTagCount, // [0x006]
  28. __GlintTagPointTable0, // [0x010]
  29. __GlintTagPointTable1, // [0x011]
  30. __GlintTagPointTable2, // [0x012]
  31. __GlintTagPointTable3, // [0x013]
  32. __GlintTagRasterizerMode, // [0x014]
  33. __GlintTagYLimits, // [0x015]
  34. //__GlintTagScanlineOwnership, // [0x016]
  35. __GlintTagPixelSize, // [0x018]
  36. //__GlintTagFastBlockLimits, // [0x026]
  37. __GlintTagScissorMode, // [0x030]
  38. __GlintTagScissorMinXY, // [0x031]
  39. __GlintTagScissorMaxXY, // [0x032]
  40. //__GlintTagScreenSize, // [0x033]
  41. __GlintTagAreaStippleMode, // [0x034]
  42. __GlintTagLineStippleMode, // [0x035]
  43. __GlintTagLoadLineStippleCounters, // [0x036]
  44. __GlintTagWindowOrigin, // [0x039]
  45. __GlintTagAreaStipplePattern0, // [0x040]
  46. __GlintTagAreaStipplePattern1, // [0x041]
  47. __GlintTagAreaStipplePattern2, // [0x042]
  48. __GlintTagAreaStipplePattern3, // [0x043]
  49. __GlintTagAreaStipplePattern4, // [0x044]
  50. __GlintTagAreaStipplePattern5, // [0x045]
  51. __GlintTagAreaStipplePattern6, // [0x046]
  52. __GlintTagAreaStipplePattern7, // [0x047]
  53. __GlintTagAreaStipplePattern8, // [0x048]
  54. __GlintTagAreaStipplePattern9, // [0x049]
  55. __GlintTagAreaStipplePattern10, // [0x04A]
  56. __GlintTagAreaStipplePattern11, // [0x04B]
  57. __GlintTagAreaStipplePattern12, // [0x04C]
  58. __GlintTagAreaStipplePattern13, // [0x04D]
  59. __GlintTagAreaStipplePattern14, // [0x04E]
  60. __GlintTagAreaStipplePattern15, // [0x04F]
  61. __GlintTagAreaStipplePattern16, // [0x050]
  62. __GlintTagAreaStipplePattern17, // [0x051]
  63. __GlintTagAreaStipplePattern18, // [0x052]
  64. __GlintTagAreaStipplePattern19, // [0x053]
  65. __GlintTagAreaStipplePattern20, // [0x054]
  66. __GlintTagAreaStipplePattern21, // [0x055]
  67. __GlintTagAreaStipplePattern22, // [0x056]
  68. __GlintTagAreaStipplePattern23, // [0x057]
  69. __GlintTagAreaStipplePattern24, // [0x058]
  70. __GlintTagAreaStipplePattern25, // [0x059]
  71. __GlintTagAreaStipplePattern26, // [0x05A]
  72. __GlintTagAreaStipplePattern27, // [0x05B]
  73. __GlintTagAreaStipplePattern28, // [0x05C]
  74. __GlintTagAreaStipplePattern29, // [0x05D]
  75. __GlintTagAreaStipplePattern30, // [0x05E]
  76. __GlintTagAreaStipplePattern31, // [0x05F]
  77. __PXRXTagTextureCoordMode, // [0x070]
  78. __GlintTagSStart, // [0x071]
  79. __GlintTagdSdx, // [0x072]
  80. __GlintTagdSdyDom, // [0x073]
  81. __GlintTagTStart, // [0x074]
  82. __GlintTagdTdx, // [0x075]
  83. __GlintTagdTdyDom, // [0x076]
  84. __GlintTagQStart, // [0x077]
  85. __GlintTagdQdx, // [0x078]
  86. __GlintTagdQdyDom, // [0x079]
  87. __GlintTagLOD, // [0x07A]
  88. __GlintTagdSdy, // [0x07B]
  89. __GlintTagdTdy, // [0x07C]
  90. __GlintTagdQdy, // [0x07D]
  91. __PXRXTagS1Start, // [0x080]
  92. __PXRXTagdS1dx, // [0x081]
  93. __PXRXTagdS1dyDom, // [0x082]
  94. __PXRXTagT1Start, // [0x083]
  95. __PXRXTagdT1dx, // [0x084]
  96. __PXRXTagdT1dyDom, // [0x085]
  97. __PXRXTagQ1Start, // [0x086]
  98. __PXRXTagdQ1dx, // [0x087]
  99. __PXRXTagdQ1dyDom, // [0x088]
  100. __GlintTagLOD1, // [0x089]
  101. __GlintTagTextureLODBiasS, // [0x08A]
  102. __GlintTagTextureLODBiasT, // [0x08B]
  103. __GlintTagTextureReadMode, // [0x090]
  104. __GlintTagTextureFormat, // [0x091]
  105. __GlintTagTextureCacheControl, // [0x092]
  106. __GlintTagBorderColor, // [0x095]
  107. //__GlintTagLUTIndex, // [0x098]
  108. //__GlintTagLUTData, // [0x099]
  109. //__GlintTagLUTAddress, // [0x09A]
  110. //__GlintTagLUTTransfer, // [0x09B]
  111. __GlintTagTextureFilterMode, // [0x09C]
  112. __GlintTagTextureChromaUpper, // [0x09D]
  113. __GlintTagTextureChromaLower, // [0x09E]
  114. __GlintTagBorderColor1, // [0x09F]
  115. __GlintTagTextureBaseAddress, // [0x0A0]
  116. __GlintTagTextureBaseAddressLR, // [0x0A1]
  117. __GlintTagTextureBaseAddress2, // [0x0A2]
  118. __GlintTagTextureBaseAddress3, // [0x0A3]
  119. __GlintTagTextureBaseAddress4, // [0x0A4]
  120. __GlintTagTextureBaseAddress5, // [0x0A5]
  121. __GlintTagTextureBaseAddress6, // [0x0A6]
  122. __GlintTagTextureBaseAddress7, // [0x0A7]
  123. __GlintTagTextureBaseAddress8, // [0x0A8]
  124. __GlintTagTextureBaseAddress9, // [0x0A9]
  125. __GlintTagTextureBaseAddress10, // [0x0AA]
  126. __GlintTagTextureBaseAddress11, // [0x0AB]
  127. __GlintTagTextureBaseAddress12, // [0x0AC]
  128. __GlintTagTextureBaseAddress13, // [0x0AD]
  129. __GlintTagTextureBaseAddress14, // [0x0AE]
  130. __GlintTagTextureBaseAddress15, // [0x0AF]
  131. __PXRXTagTextureMapWidth0, // [0x0B0]
  132. __PXRXTagTextureMapWidth1, // [0x0B1]
  133. __PXRXTagTextureMapWidth2, // [0x0B2]
  134. __PXRXTagTextureMapWidth3, // [0x0B3]
  135. __PXRXTagTextureMapWidth4, // [0x0B4]
  136. __PXRXTagTextureMapWidth5, // [0x0B5]
  137. __PXRXTagTextureMapWidth6, // [0x0B6]
  138. __PXRXTagTextureMapWidth7, // [0x0B7]
  139. __PXRXTagTextureMapWidth8, // [0x0B8]
  140. __PXRXTagTextureMapWidth9, // [0x0B9]
  141. __PXRXTagTextureMapWidth10, // [0x0BA]
  142. __PXRXTagTextureMapWidth11, // [0x0BB]
  143. __PXRXTagTextureMapWidth12, // [0x0BC]
  144. __PXRXTagTextureMapWidth13, // [0x0BD]
  145. __PXRXTagTextureMapWidth14, // [0x0BE]
  146. __PXRXTagTextureMapWidth15, // [0x0BF]
  147. __PXRXTagTextureChromaUpper1, // [0x0C0]
  148. __PXRXTagTextureChromaLower1, // [0x0C1]
  149. __PXRXTagTextureApplicationMode, // [0x0D0]
  150. __GlintTagTextureEnvColor, // [0x0D1]
  151. __GlintTagFogMode, // [0x0D2]
  152. __GlintTagFogColor, // [0x0D3]
  153. __GlintTagFStart, // [0x0D4]
  154. __GlintTagdFdx, // [0x0D5]
  155. __GlintTagdFdyDom, // [0x0D6]
  156. __GlintTagZFogBias, // [0x0D7]
  157. __GlintTagRStart, // [0x0F0]
  158. __GlintTagdRdx, // [0x0F1]
  159. __GlintTagdRdyDom, // [0x0F2]
  160. __GlintTagGStart, // [0x0F3]
  161. __GlintTagdGdx, // [0x0F4]
  162. __GlintTagdGdyDom, // [0x0F5]
  163. __GlintTagBStart, // [0x0F6]
  164. __GlintTagdBdx, // [0x0F7]
  165. __GlintTagdBdyDom, // [0x0F8]
  166. __GlintTagAStart, // [0x0F9]
  167. __GlintTagdAdx, // [0x0FA]
  168. __GlintTagdAdyDom, // [0x0FB]
  169. __GlintTagColorDDAMode, // [0x0FC]
  170. __GlintTagConstantColor, // [0x0FD]
  171. __GlintTagColor, // [0x0FE]
  172. __GlintTagAlphaTestMode, // [0x100]
  173. __GlintTagAntialiasMode, // [0x101]
  174. __GlintTagDitherMode, // [0x103]
  175. __GlintTagFBSoftwareWriteMask, // [0x104]
  176. __GlintTagLogicalOpMode, // [0x105]
  177. __GlintTagRouterMode, // [0x108]
  178. __GlintTagLBReadFormat, // [0x111]
  179. __GlintTagLBSourceOffset, // [0x112]
  180. __GlintTagLBWriteMode, // [0x118]
  181. __GlintTagLBWriteFormat, // [0x119]
  182. //__GlintTagTextureDownloadOffset, // [0x11E]
  183. __GlintTagWindow, // [0x130]
  184. __GlintTagStencilMode, // [0x131]
  185. __GlintTagStencilData, // [0x132]
  186. __GlintTagStencil, // [0x133]
  187. __GlintTagDepthMode, // [0x134]
  188. __GlintTagDepth, // [0x135]
  189. __GlintTagZStartU, // [0x136]
  190. __GlintTagZStartL, // [0x137]
  191. __GlintTagdZdxU, // [0x138]
  192. __GlintTagdZdxL, // [0x139]
  193. __GlintTagdZdyDomU, // [0x13A]
  194. __GlintTagdZdyDomL, // [0x13B]
  195. __GlintTagFastClearDepth, // [0x13C]
  196. __GlintTagFBWriteMode, // [0x157]
  197. __GlintTagFBHardwareWriteMask, // [0x158]
  198. __GlintTagFBBlockColor, // [0x159]
  199. //__GlintTagFilterMode, // [0x180]
  200. __GlintTagStatisticMode, // [0x181]
  201. __GlintTagMinRegion, // [0x182]
  202. __GlintTagMaxRegion, // [0x183]
  203. __GlintTagRLEMask, // [0x189]
  204. __GlintTagFBBlockColorBackU, // [0x18B]
  205. __GlintTagFBBlockColorBackL, // [0x18C]
  206. //__GlintTagFBBlockColorU, // [0x18D]
  207. //__GlintTagFBBlockColorL, // [0x18E]
  208. __GlintTagKsRStart, // [0x190]
  209. __GlintTagdKsRdx, // [0x191]
  210. __GlintTagdKsRdyDom, // [0x192]
  211. __GlintTagKsGStart, // [0x193]
  212. __GlintTagdKsGdx, // [0x194]
  213. __GlintTagdKsGdyDom, // [0x195]
  214. __GlintTagKsBStart, // [0x196]
  215. __GlintTagdKsBdx, // [0x197]
  216. __GlintTagdKsBdyDom, // [0x198]
  217. __GlintTagKdRStart, // [0x1A0]
  218. __GlintTagdKdRdx, // [0x1A1]
  219. __GlintTagdKdRdyDom, // [0x1A2]
  220. __GlintTagKdGStart, // [0x1A3]
  221. __GlintTagdKdGdx, // [0x1A4]
  222. __GlintTagdKdGdyDom, // [0x1A5]
  223. __GlintTagKdBStart, // [0x1A6]
  224. __GlintTagdKdBdx, // [0x1A7]
  225. __GlintTagdKdBdyDom, // [0x1A8]
  226. //LUT0, // [0x1D0]
  227. //LUT1, // [0x1D1]
  228. //LUT2, // [0x1D2]
  229. //LUT3, // [0x1D3]
  230. //LUT4, // [0x1D4]
  231. //LUT5, // [0x1D5]
  232. //LUT6, // [0x1D6]
  233. //LUT7, // [0x1D7]
  234. //LUT8, // [0x1D8]
  235. //LUT9, // [0x1D9]
  236. //LUT10, // [0x1DA]
  237. //LUT11, // [0x1DB]
  238. //LUT12, // [0x1DC]
  239. //LUT13, // [0x1DD]
  240. //LUT14, // [0x1DE]
  241. //LUT15, // [0x1DF]
  242. __PXRXTagYUVMode, // [0x1E0]
  243. __PXRXTagChromaUpper, // [0x1E1]
  244. __PXRXTagChromaLower, // [0x1E2]
  245. __GlintTagChromaTestMode, // [0x1E3]
  246. __PXRXTagV0FloatS1, // [0x200]
  247. __PXRXTagV0FloatT1, // [0x201]
  248. __PXRXTagV0FloatQ1, // [0x202]
  249. __PXRXTagV0FloatKsR, // [0x20A]
  250. __PXRXTagV0FloatKsG, // [0x20B]
  251. __PXRXTagV0FloatKsB, // [0x20C]
  252. __PXRXTagV0FloatKdR, // [0x20D]
  253. __PXRXTagV0FloatKdG, // [0x20E]
  254. __PXRXTagV0FloatKdB, // [0x20F]
  255. __PXRXTagV1FloatS1, // [0x210]
  256. __PXRXTagV1FloatT1, // [0x211]
  257. __PXRXTagV1FloatQ1, // [0x212]
  258. __PXRXTagV1FloatKsR, // [0x21A]
  259. __PXRXTagV1FloatKsG, // [0x21B]
  260. __PXRXTagV1FloatKsB, // [0x21C]
  261. __PXRXTagV1FloatKdR, // [0x21D]
  262. __PXRXTagV1FloatKdG, // [0x21E]
  263. __PXRXTagV1FloatKdB, // [0x21F]
  264. __PXRXTagV2FloatS1, // [0x220]
  265. __PXRXTagV2FloatT1, // [0x221]
  266. __PXRXTagV2FloatQ1, // [0x222]
  267. __PXRXTagV2FloatKsR, // [0x22A]
  268. __PXRXTagV2FloatKsG, // [0x22B]
  269. __PXRXTagV2FloatKsB, // [0x22C]
  270. __PXRXTagV2FloatKdR, // [0x22D]
  271. __PXRXTagV2FloatKdG, // [0x22E]
  272. __PXRXTagV2FloatKdB, // [0x22F]
  273. __PXRXTagV0FloatS, // [0x230]
  274. __PXRXTagV0FloatT, // [0x231]
  275. __PXRXTagV0FloatQ, // [0x232]
  276. __PXRXTagV0FloatR, // [0x235]
  277. __PXRXTagV0FloatG, // [0x236]
  278. __PXRXTagV0FloatB, // [0x237]
  279. __PXRXTagV0FloatA, // [0x238]
  280. __PXRXTagV0FloatF, // [0x239]
  281. __PXRXTagV0FloatX, // [0x23A]
  282. __PXRXTagV0FloatY, // [0x23B]
  283. __PXRXTagV0FloatZ, // [0x23C]
  284. __PXRXTagV0FloatW, // [0x23D]
  285. __PXRXTagV0FloatPackedColour, // [0x23E]
  286. __PXRXTagV0FloatPackedSpecularFog, // [0x23F]
  287. __RXRXTagV1FloatS, // [0x240]
  288. __RXRXTagV1FloatT, // [0x241]
  289. __RXRXTagV1FloatQ, // [0x242]
  290. __RXRXTagV1FloatR, // [0x245]
  291. __RXRXTagV1FloatG, // [0x246]
  292. __RXRXTagV1FloatB, // [0x247]
  293. __RXRXTagV1FloatA, // [0x248]
  294. __RXRXTagV1FloatF, // [0x249]
  295. __RXRXTagV1FloatX, // [0x24A]
  296. __RXRXTagV1FloatY, // [0x24B]
  297. __RXRXTagV1FloatZ, // [0x24C]
  298. __RXRXTagV1FloatW, // [0x24D]
  299. __RXRXTagV1FloatPackedColour, // [0x24E]
  300. __RXRXTagV1FloatPackedSpecularFog, // [0x24F]
  301. __RXRXTagV2FloatS, // [0x250]
  302. __RXRXTagV2FloatT, // [0x251]
  303. __RXRXTagV2FloatQ, // [0x252]
  304. __RXRXTagV2FloatR, // [0x255]
  305. __RXRXTagV2FloatG, // [0x256]
  306. __RXRXTagV2FloatB, // [0x257]
  307. __RXRXTagV2FloatA, // [0x258]
  308. __RXRXTagV2FloatF, // [0x259]
  309. __RXRXTagV2FloatX, // [0x25A]
  310. __RXRXTagV2FloatY, // [0x25B]
  311. __RXRXTagV2FloatZ, // [0x25C]
  312. __RXRXTagV2FloatW, // [0x25D]
  313. __RXRXTagV2FloatPackedColour, // [0x25E]
  314. __RXRXTagV2FloatPackedSpecularFog, // [0x25F]
  315. __DeltaTagDeltaMode, // [0x260]
  316. __DeltaTagProvokingVertex, // [0x267]
  317. __DeltaTagTextureLODScale, // [0x268]
  318. __DeltaTagTextureLODScale1, // [0x269]
  319. __DeltaTagDeltaControl, // [0x26A]
  320. __DeltaTagProvokingVertexMask, // [0x26B]
  321. //__DeltaTagBroadcastMask, // [0x26F]
  322. //__DeltaTagDeltaTexture01, // [0x28B]
  323. //__DeltaTagDeltaTexture11, // [0x28C]
  324. //__DeltaTagDeltaTexture21, // [0x28D]
  325. //__DeltaTagDeltaTexture31, // [0x28E]
  326. __DeltaTagXBias, // [0x290]
  327. __DeltaTagYBias, // [0x291]
  328. __DeltaTagZBias, // [0x29F]
  329. //__GlintTagDMAAddr, // [0x530]
  330. //__GlintTagDMACount, // [0x531]
  331. //__GlintTagCommandInterrupt, // [0x532]
  332. //__GlintTagDMARectangleRead, // [0x535]
  333. //__GlintTagDMARectangleReadAddress, // [0x536]
  334. //__GlintTagDMARectangleReadLinePitch, // [0x537]
  335. //__GlintTagDMARectangleReadTarget, // [0x538]
  336. //__GlintTagDMARectangleWrite, // [0x539]
  337. //__GlintTagDMARectangleWriteAddress, // [0x53A]
  338. //__GlintTagDMARectangleWriteLinePitch, // [0x53B]
  339. //__GlintTagDMAOutputAddress, // [0x53C]
  340. //__GlintTagDMAOutputCount, // [0x53D]
  341. //__GlintTagDMAFeedback, // [0x542]
  342. __GlintTagFBDestReadBufferAddr0, // [0x5D0]
  343. __GlintTagFBDestReadBufferAddr1, // [0x5D1]
  344. __GlintTagFBDestReadBufferAddr2, // [0x5D2]
  345. __GlintTagFBDestReadBufferAddr3, // [0x5D3]
  346. __GlintTagFBDestReadBufferOffset0, // [0x5D4]
  347. __GlintTagFBDestReadBufferOffset1, // [0x5D5]
  348. __GlintTagFBDestReadBufferOffset2, // [0x5D6]
  349. __GlintTagFBDestReadBufferOffset3, // [0x5D7]
  350. __GlintTagFBDestReadBufferWidth0, // [0x5D8]
  351. __GlintTagFBDestReadBufferWidth1, // [0x5D9]
  352. __GlintTagFBDestReadBufferWidth2, // [0x5DA]
  353. __GlintTagFBDestReadBufferWidth3, // [0x5DB]
  354. __GlintTagFBDestReadMode, // [0x5DC]
  355. __GlintTagFBDestReadEnables, // [0x5DD]
  356. __GlintTagFBSourceReadMode, // [0x5E0]
  357. __GlintTagFBSourceReadBufferAddr, // [0x5E1]
  358. __GlintTagFBSourceReadBufferOffset, // [0x5E2]
  359. __GlintTagFBSourceReadBufferWidth, // [0x5E3]
  360. __GlintTagPCIWindowBase0, // [0x5E8]
  361. __GlintTagPCIWindowBase1, // [0x5E9]
  362. __GlintTagPCIWindowBase2, // [0x5EA]
  363. __GlintTagPCIWindowBase3, // [0x5EB]
  364. __GlintTagPCIWindowBase4, // [0x5EC]
  365. __GlintTagPCIWindowBase5, // [0x5ED]
  366. __GlintTagPCIWindowBase6, // [0x5EE]
  367. __GlintTagPCIWindowBase7, // [0x5EF]
  368. __GlintTagAlphaSourceColor, // [0x5F0]
  369. __GlintTagAlphaDestColor, // [0x5F1]
  370. __GlintTagChromaPassColor, // [0x5F2]
  371. __GlintTagChromaFailColor, // [0x5F3]
  372. __GlintTagAlphaBlendColorMode, // [0x5F4]
  373. __GlintTagAlphaBlendAlphaMode, // [0x5F5]
  374. //__GlintTagConstantColorDDA, // [0x5F6]
  375. //__GlintTagD3DAlphaTestMode, // [0x5F8]
  376. __GlintTagFBWriteBufferAddr0, // [0x600]
  377. __GlintTagFBWriteBufferAddr1, // [0x601]
  378. __GlintTagFBWriteBufferAddr2, // [0x602]
  379. __GlintTagFBWriteBufferAddr3, // [0x603]
  380. __GlintTagFBWriteBufferOffset0, // [0x604]
  381. __GlintTagFBWriteBufferOffset1, // [0x605]
  382. __GlintTagFBWriteBufferOffset2, // [0x606]
  383. __GlintTagFBWriteBufferOffset3, // [0x607]
  384. __GlintTagFBWriteBufferWidth0, // [0x608]
  385. __GlintTagFBWriteBufferWidth1, // [0x609]
  386. __GlintTagFBWriteBufferWidth2, // [0x60A]
  387. __GlintTagFBWriteBufferWidth3, // [0x60B]
  388. //__GlintTagFBBlockColor0, // [0x60C]
  389. //__GlintTagFBBlockColor1, // [0x60D]
  390. //__GlintTagFBBlockColor2, // [0x60E]
  391. //__GlintTagFBBlockColor3, // [0x60F]
  392. //__GlintTagFBBlockColorBack0, // [0x610]
  393. //__GlintTagFBBlockColorBack1, // [0x611]
  394. //__GlintTagFBBlockColorBack2, // [0x612]
  395. //__GlintTagFBBlockColorBack3, // [0x613]
  396. __GlintTagFBBlockColorBack, // [0x614]
  397. //__GlintTagSizeOfFramebuffer, // [0x615]
  398. //__GlintTagVTGAddress, // [0x616]
  399. //__GlintTagVTGData, // [0x617]
  400. //__GlintTagForegroundColor, // [0x618]
  401. //__GlintTagBackgroundColor, // [0x619]
  402. //__GlintTagDownloadAddress, // [0x61A]
  403. //__GlintTagFBBlockColorExt, // [0x61C]
  404. //__GlintTagFBBlockColorBackExt, // [0x61D]
  405. //__GlintTagFBWriteMaskExt, // [0x61E]
  406. //@@BEGIN_DDKSPLIT
  407. #if 0
  408. FogTable0, // [0x620]
  409. FogTable1, // [0x621]
  410. FogTable2, // [0x622]
  411. FogTable3, // [0x623]
  412. FogTable4, // [0x624]
  413. FogTable5, // [0x625]
  414. FogTable6, // [0x626]
  415. FogTable7, // [0x627]
  416. FogTable8, // [0x628]
  417. FogTable9, // [0x629]
  418. FogTable10, // [0x62A]
  419. FogTable11 // [0x62B]
  420. FogTable12, // [0x62C]
  421. FogTable13, // [0x62D]
  422. FogTable14, // [0x62E]
  423. FogTable15, // [0x62F]
  424. FogTable16, // [0x630]
  425. FogTable17, // [0x631]
  426. FogTable18, // [0x632]
  427. FogTable19, // [0x633]
  428. FogTable20, // [0x634]
  429. FogTable21, // [0x635]
  430. FogTable22, // [0x636]
  431. FogTable23, // [0x637]
  432. FogTable24, // [0x638]
  433. FogTable25, // [0x639]
  434. FogTable26, // [0x63A]
  435. FogTable27, // [0x63B]
  436. FogTable28, // [0x63C]
  437. FogTable29, // [0x63D]
  438. FogTable30, // [0x63E]
  439. FogTable31, // [0x63F]
  440. FogTable32, // [0x640]
  441. FogTable33, // [0x641]
  442. FogTable34, // [0x642]
  443. FogTable35, // [0x643]
  444. FogTable36, // [0x644]
  445. FogTable37, // [0x645]
  446. FogTable38, // [0x646]
  447. FogTable39, // [0x647]
  448. FogTable40, // [0x648]
  449. FogTable41, // [0x649]
  450. FogTable42, // [0x64A]
  451. FogTable43, // [0x64B]
  452. FogTable44, // [0x64C]
  453. FogTable45, // [0x64D]
  454. FogTable46, // [0x64E]
  455. FogTable47, // [0x64F]
  456. FogTable48, // [0x650]
  457. FogTable49, // [0x651]
  458. FogTable50, // [0x652]
  459. FogTable51, // [0x653]
  460. FogTable52, // [0x654]
  461. FogTable53, // [0x655]
  462. FogTable54, // [0x656]
  463. FogTable55, // [0x657]
  464. FogTable56, // [0x658]
  465. FogTable57, // [0x659]
  466. FogTable58, // [0x65A]
  467. FogTable59, // [0x65B]
  468. FogTable60, // [0x65C]
  469. FogTable61, // [0x65D]
  470. FogTable62, // [0x65E]
  471. FogTable63, // [0x65F]
  472. #endif
  473. //@@END_DDKSPLIT
  474. __GlintTagTextureCompositeMode, // [0x660]
  475. __GlintTagTextureCompositeColorMode0, // [0x661]
  476. __GlintTagTextureCompositeAlphaMode0, // [0x662]
  477. __GlintTagTextureCompositeColorMode1, // [0x663]
  478. __GlintTagTextureCompositeAlphaMode1, // [0x664]
  479. __GlintTagTextureCompositeFactor0, // [0x665]
  480. __GlintTagTextureCompositeFactor1, // [0x666]
  481. __GlintTagTextureIndexMode0, // [0x667]
  482. __GlintTagTextureIndexMode1, // [0x668]
  483. __GlintTagLodRange0, // [0x669]
  484. __GlintTagLodRange1, // [0x66A]
  485. //__GlintTagSetLogicalTexturePage, // [0x66C]
  486. __GlintTagLUTMode, // [0x66F]
  487. __GlintTagTextureReadMode0, // [0x680]
  488. __GlintTagTextureReadMode1, // [0x681]
  489. __GlintTagTextureMapSize, // [0x685]
  490. //HeadPhysicalPageAllocation0, // [0x690]
  491. //HeadPhysicalPageAllocation1, // [0x691]
  492. //HeadPhysicalPageAllocation2, // [0x692]
  493. //HeadPhysicalPageAllocation3, // [0x693]
  494. //TailPhysicalPageAllocation0, // [0x694]
  495. //TailPhysicalPageAllocation1, // [0x695]
  496. //TailPhysicalPageAllocation2, // [0x696]
  497. //TailPhysicalPageAllocation3, // [0x697]
  498. //PhysicalPageAllocationTableAddr, // [0x698]
  499. //BasePageOfWorkingSet, // [0x699]
  500. //LogicalTexturePageTableAddr, // [0x69A]
  501. //LogicalTexturePageTableLength, // [0x69B]
  502. __GlintTagLBDestReadMode, // [0x6A0]
  503. __GlintTagLBDestReadEnables, // [0x6A1]
  504. __GlintTagLBDestReadBufferAddr, // [0x6A2]
  505. __GlintTagLBDestReadBufferOffset, // [0x6A3]
  506. __GlintTagLBSourceReadMode, // [0x6A4]
  507. __GlintTagLBSourceReadBufferAddr, // [0x6A5]
  508. __GlintTagLBSourceReadBufferOffset, // [0x6A6]
  509. __GlintTagGIDMode, // [0x6A7]
  510. __GlintTagLBWriteBufferAddr, // [0x6A8]
  511. __GlintTagLBWriteBufferOffset, // [0x6A9]
  512. __GlintTagLBClearDataL, // [0x6AA]
  513. __GlintTagLBClearDataU, // [0x6AB]
  514. __GlintTagRectanglePosition, // [0x6C0]
  515. //__GlintTagGlyphPosition, // [0x6C1]
  516. __GlintTagRenderPatchOffset, // [0x6C2]
  517. //__GlintTagConfig2D, // [0x6C3]
  518. //__GlintTagRender2D, // [0x6C8]
  519. //__GlintTagRender2DGlyph, // [0x6C9]
  520. __GlintTagDownloadTarget, // [0x6CA]
  521. //__GlintTagDownloadGlyphWidth, // [0x6CB]
  522. //__GlintTagGlyphData, // [0x6CC]
  523. //__GlintTagPacked4Pixels, // [0x6CD]
  524. //__GlintTagRLData, // [0x6CE]
  525. //__GlintTagRLCount, // [0x6CF]
  526. //__GlintTagKClkProfileMask0, // [0x6D4]
  527. //__GlintTagKClkProfileMask1, // [0x6D5]
  528. //__GlintTagKClkProfileMask2, // [0x6D6]
  529. //__GlintTagKClkProfileMask3, // [0x6D7]
  530. //__GlintTagKClkProfileCount0, // [0x6D8]
  531. //__GlintTagKClkProfileCount1, // [0x6D9]
  532. //__GlintTagKClkProfileCount2, // [0x6DA]
  533. //__GlintTagKClkProfileCount3, // [0x6DB]
  534. };
  535. #define N_READABLE_TAGSP3 \
  536. (sizeof(readableRegistersP3) / sizeof(readableRegistersP3[0]))
  537. //@@BEGIN_DDKSPLIT
  538. //
  539. // the status flags are used to indicate whether DMA has completed, the
  540. // GLINT is synced etc. This has to be global for each board. The whole
  541. // idea is that we can do a quick check without having to read a chip
  542. // register. So for speed of access we'll make it visible everywhere
  543. //
  544. // !!! azn - we had to reintroduce this g_CC in order to fix the
  545. // regular recurrence of bug #158713 (pxrxFifoUpload stall)
  546. // we have to chk later how to rewrite it
  547. //@@END_DDKSPLIT
  548. /******************************************************************************
  549. * GlintAllocateNewContext:
  550. *
  551. * Allocate a new context. If all registers are to be saved in the context
  552. * then pTag is passed as null. The priv field is an opaque handle which the
  553. * caller passes in. It is saved as part of the context and used to disable
  554. * any context which causes the chip to lockup.
  555. *
  556. ******************************************************************************/
  557. LONG GlintAllocateNewContext(
  558. PPDEV ppdev,
  559. DWORD *pTag,
  560. LONG ntags,
  561. ULONG NumSubBuffers,
  562. PVOID priv,
  563. ContextType ctxtType)
  564. {
  565. GlintCtxtTable *pCtxtTable, *pNewCtxtTable;
  566. GlintCtxtRec **ppEntry;
  567. GlintCtxtRec *pEntry;
  568. CtxtData *pData;
  569. LONG nEntries, size, ctxtId;
  570. ULONG *pul;
  571. GLINT_DECL;
  572. // first time round allocate the context table of pointers. We will
  573. // grow this table as required.
  574. if (ppdev->pGContextTable == NULL)
  575. {
  576. DISPDBG((DBGLVL, "creating context table"));
  577. size = sizeof(GlintCtxtTable);
  578. pCtxtTable = (GlintCtxtTable*)ENGALLOCMEM(FL_ZERO_MEMORY,
  579. size,
  580. ALLOC_TAG_GDI(7));
  581. if (pCtxtTable == NULL)
  582. {
  583. DISPDBG((ERRLVL, "Failed to allocate GLINT context table. "
  584. "Out of memory"));
  585. return(-1);
  586. }
  587. pCtxtTable->nEntries = CTXT_CHUNK;
  588. pCtxtTable->size = size;
  589. ppdev->pGContextTable = pCtxtTable;
  590. }
  591. // Always update this. If a new PDEV comes along for this board we need
  592. // to initialize its current context. One way to do this would be to
  593. // provide an explicit function to do the job but why do that to update
  594. // one variable. Anyway context allocation is pretty rare so this extra
  595. // assign isn't too much of a overhead.
  596. //
  597. ppdev->currentCtxt = -1;
  598. // Find an empty entry in the table
  599. // I suppose if we have hundreds of contexts this could be a bit slow but
  600. // allocating the context isn't time critical, swapping in and out is.
  601. //
  602. pCtxtTable = ppdev->pGContextTable;
  603. nEntries = pCtxtTable->nEntries;
  604. ppEntry = &pCtxtTable->pEntry[0];
  605. for (ctxtId = 0; ctxtId < nEntries; ++ctxtId)
  606. {
  607. if (*ppEntry == 0)
  608. {
  609. DISPDBG((DBGLVL, "found free context id %d", ctxtId));
  610. break;
  611. }
  612. ++ppEntry;
  613. }
  614. DISPDBG((DBGLVL, "Got ppEntry = 0x%x", ppEntry));
  615. DISPDBG((DBGLVL, "Got *ppEntry = 0x%x", *ppEntry));
  616. // if we found no free entries try to grow the table
  617. if (ctxtId == nEntries)
  618. {
  619. DISPDBG((WRNLVL, "context table full so enlarging"));
  620. size = pCtxtTable->size + (CTXT_CHUNK * sizeof(GlintCtxtRec*));
  621. pNewCtxtTable = (GlintCtxtTable*)ENGALLOCMEM(FL_ZERO_MEMORY,
  622. size,
  623. ALLOC_TAG_GDI(8));
  624. if (pNewCtxtTable == NULL)
  625. {
  626. DISPDBG((ERRLVL, "failed to increase GLINT context table. "
  627. "Out of memory"));
  628. return(-1);
  629. }
  630. // copy the old table to the new one
  631. RtlCopyMemory(pNewCtxtTable, pCtxtTable, pCtxtTable->size);
  632. pNewCtxtTable->size = size;
  633. pNewCtxtTable->nEntries = nEntries + CTXT_CHUNK;
  634. ppdev->pGContextTable = pNewCtxtTable;
  635. // first of the newly allocated entries is next free one
  636. ctxtId = nEntries;
  637. ppEntry = &pNewCtxtTable->pEntry[ctxtId];
  638. // free the old context table and reassign some variables
  639. ENGFREEMEM(pCtxtTable);
  640. pCtxtTable = pNewCtxtTable;
  641. nEntries = pCtxtTable->nEntries;
  642. }
  643. size = sizeof(GlintCtxtRec) - sizeof(CtxtData);
  644. if( ctxtType == ContextType_RegisterList )
  645. {
  646. // if pTag is passed as null then we are to add all
  647. // readable registers to the context.
  648. if( pTag == NULL )
  649. {
  650. DISPDBG((DBGLVL, "adding all readable P3 registers to the context"));
  651. pTag = readableRegistersP3;
  652. ntags = N_READABLE_TAGSP3;
  653. }
  654. // now allocate space for the new entry. We are given the number of
  655. // tags to save when context switching. Allocate twice this much
  656. // memory as we have to hold the data values as well.
  657. DISPDBG((DBGLVL, "Allocating space for context. ntags = %d", ntags));
  658. size += ntags * sizeof(CtxtData);
  659. }
  660. *ppEntry = (GlintCtxtRec*)ENGALLOCMEM(FL_ZERO_MEMORY,
  661. size,
  662. ALLOC_TAG_GDI(9));
  663. if (*ppEntry == NULL)
  664. {
  665. DISPDBG((ERRLVL, "Out of memory "
  666. "trying to allocate space for new context"));
  667. return(-1);
  668. }
  669. pEntry = *ppEntry;
  670. DISPDBG((DBGLVL, "Got pEntry 0x%x", pEntry));
  671. pEntry->type = ctxtType;
  672. pEntry->ntags = ntags;
  673. pEntry->priv = priv;
  674. pData = pEntry->pData;
  675. DISPDBG((DBGLVL, "pEntry setup"));
  676. switch (pEntry->type)
  677. {
  678. case ContextType_None:
  679. DISPDBG((DBGLVL, "context is of type 'None'"));
  680. // doing nothing
  681. break;
  682. case ContextType_RegisterList:
  683. DISPDBG((DBGLVL, "context is of type 'RegisterList'"));
  684. while (--ntags >= 0)
  685. {
  686. pData->tag = *pTag++;
  687. READ_GLINT_FIFO_REG(pData->tag, pData->data);
  688. ++pData;
  689. }
  690. break;
  691. case ContextType_Fixed:
  692. DISPDBG((DBGLVL, "context is of type 'Fixed'"));
  693. pEntry->dumpFunc = (ContextFixedFunc) pTag;
  694. break;
  695. default:
  696. DISPDBG((DBGLVL, "context is of unknown type: %d", ctxtType));
  697. break;
  698. }
  699. // init the control registers that we save in the context.
  700. //
  701. pEntry->DoubleWrite = 0;
  702. //@@BEGIN_DDKSPLIT
  703. // TMM: Find out the current setting of DISCONNECT and use that one
  704. // this might seem a bit strange but we want to inherit the crrent
  705. // setting of Disconnect.
  706. //@@END_DDKSPLIT
  707. READ_GLINT_CTRL_REG (DisconnectControl, pEntry->inFifoDisc);
  708. READ_GLINT_CTRL_REG (VideoControl, pEntry->VideoControl);
  709. READ_GLINT_CTRL_REG (DMAControl, pEntry->DMAControl);
  710. // if no interrupt driven DMA or asked for less than 3 buffers then
  711. // configure no Q for this context
  712. if (!GLINT_INTERRUPT_DMA || (NumSubBuffers <= 2))
  713. {
  714. NumSubBuffers = 0;
  715. }
  716. // initialize the size of the Q for interrupt driven DMA. We must always
  717. // set the Q length to 2 less than the number of sub-buffers. This is so
  718. // that we block before allowing the application to write to a buffer that
  719. // has no yet been DMA'ed. Since the Q always has a blank entry to make
  720. // it circular the endIndex of the Q is one beyond the end
  721. // (i.e. the number of entries in the Q is endIndex-1) so subtract one
  722. // from the number of sub-buffers to get the endIndex.
  723. // If NumSubBuffers is zero then we are not using interrupt driven DMA
  724. // for this context.
  725. if (NumSubBuffers > 0)
  726. {
  727. pEntry->endIndex = NumSubBuffers-1;
  728. }
  729. else
  730. {
  731. pEntry->endIndex = 0;
  732. }
  733. DISPDBG((DBGLVL, "Allocated context %d", ctxtId));
  734. return(ctxtId);
  735. } //GlintAllocateNewContext
  736. /******************************************************************************
  737. * vGlintFreeContext:
  738. *
  739. * Free a previously allocated context
  740. *
  741. ******************************************************************************/
  742. VOID vGlintFreeContext(
  743. PPDEV ppdev,
  744. LONG ctxtId)
  745. {
  746. GlintCtxtTable *pCtxtTable;
  747. GlintCtxtRec **ppEntry;
  748. BOOL bAllCtxtsFreed;
  749. LONG i;
  750. pCtxtTable = ppdev->pGContextTable;
  751. if (pCtxtTable == NULL)
  752. {
  753. DISPDBG((ERRLVL,"vGlintFreeContext: no contexts have been created!"));
  754. return;
  755. }
  756. if ((ctxtId < 0) || (ctxtId >= pCtxtTable->nEntries))
  757. {
  758. DISPDBG((ERRLVL,
  759. "vGlintFreeContext: Trying to free out of range context"));
  760. return;
  761. }
  762. ppEntry = &pCtxtTable->pEntry[ctxtId];
  763. // If the entry is not yet free (it shouldn't) free it
  764. if (NULL != *ppEntry)
  765. {
  766. ENGFREEMEM(*ppEntry);
  767. *ppEntry = 0; // marks it as free
  768. }
  769. else
  770. {
  771. DISPDBG((WRNLVL, "vGlintFreeContext: ppEntry already freed "
  772. "ctxtId = %d", ctxtId));
  773. }
  774. // If there are no more valid contexts in the context table, lets
  775. // destroy it, otherwise it will leak memory. Whenever we get called
  776. // to allocate a new context, it will be created if necessary
  777. bAllCtxtsFreed = TRUE;
  778. for (i = 0; i < pCtxtTable->nEntries; i++)
  779. {
  780. bAllCtxtsFreed = bAllCtxtsFreed && (pCtxtTable->pEntry[i] == NULL);
  781. }
  782. if(bAllCtxtsFreed)
  783. {
  784. ENGFREEMEM(ppdev->pGContextTable);
  785. ppdev->pGContextTable = NULL;
  786. }
  787. // if this was the current context, mark the current context as invalid so
  788. // we force a reload next time. Guard against null pointers when exiting
  789. // from DrvEnableSurface with some error condition
  790. if (ppdev->currentCtxt == ctxtId)
  791. {
  792. if (ppdev->bEnabled)
  793. {
  794. // only sync if PDEV is enabled as we can be called from
  795. // DrvDisableSUrface after the PDEV was disabled by
  796. // DrvAssertMode(,FALSE)
  797. GLINT_DECL;
  798. SYNC_WITH_GLINT;
  799. }
  800. ppdev->currentCtxt = -1;
  801. ppdev->g_GlintBoardStatus &= ~(GLINT_INTR_CONTEXT | GLINT_DUAL_CONTEXT);
  802. }
  803. DISPDBG((DBGLVL, "Released context %d", ctxtId));
  804. } // vGlintFreeContext
  805. /******************************************************************************
  806. * vGlintSwitchContext
  807. *
  808. * Load a new context into the hardware. We assume that this call is protected
  809. * by a test that the given context is not the current one - hence the
  810. * assertion. The code would work but the driver should never try to load an
  811. * already loaded context so we trap it as an error.
  812. *
  813. * The NON_GLINT_CONTEXT_ID is used by 2D accelerators on combo boards. Effectively,
  814. * we use it to extend the context switching to allow syncing between the 2D and
  815. * the GLINT chips. As they are both talking to the same framebuffer, we cannot
  816. * allow both to be active at the same time. Of course, in the future we could
  817. * come up with some mutual exclusion scheme based on the bounding boxes of the
  818. * areas into which each chip is rendering, but that would require major surgery
  819. * to both the 2D driver and the 3D extension.
  820. *
  821. ******************************************************************************/
  822. VOID vGlintSwitchContext(
  823. PPDEV ppdev,
  824. LONG ctxtId)
  825. {
  826. GlintCtxtTable *pCtxtTable;
  827. GlintCtxtRec *pEntry;
  828. CtxtData *pData;
  829. LONG oldCtxtId;
  830. ULONG enableFlags;
  831. LONG ntags, n;
  832. LONG i;
  833. ULONG *pul;
  834. GLINT_DECL;
  835. pCtxtTable = ppdev->pGContextTable;
  836. if (pCtxtTable == NULL)
  837. {
  838. DISPDBG((ERRLVL,"vGlintSwitchContext: no contexts have been created!"));
  839. return;
  840. }
  841. oldCtxtId = ppdev->currentCtxt;
  842. DISPDBG((DBGLVL, "swapping from context %d to context %d",
  843. oldCtxtId, ctxtId));
  844. if ((ctxtId < -1) || (ctxtId >= pCtxtTable->nEntries))
  845. {
  846. DISPDBG((ERRLVL,
  847. "vGlintSwitchContext: Trying to free out of range context"));
  848. return;
  849. }
  850. // sync with the chip before reading back the current state. The flag
  851. // is used to control context manipulation on lockup recovery.
  852. //
  853. DISPDBG((DBGLVL, "SYNC_WITH_GLINT for context switch"));
  854. SYNC_WITH_GLINT;
  855. ASSERTDD(!(ppdev->g_GlintBoardStatus & GLINT_INTR_CONTEXT) ||
  856. ((ppdev->g_GlintBoardStatus & GLINT_INTR_CONTEXT) &&
  857. (glintInfo->pInterruptCommandBlock->frontIndex ==
  858. glintInfo->pInterruptCommandBlock->backIndex)),
  859. "Trying to context switch with outstanding DMA queue entries");
  860. if (oldCtxtId != -1)
  861. {
  862. pEntry = pCtxtTable->pEntry[oldCtxtId];
  863. if (pEntry != NULL)
  864. {
  865. pData = pEntry->pData;
  866. ntags = pEntry->ntags;
  867. switch (pEntry->type)
  868. {
  869. case ContextType_None:
  870. // nothing doing
  871. DISPDBG((DBGLVL, "Context is of type none - doing nothing"));
  872. break;
  873. case ContextType_Fixed:
  874. DISPDBG((DBGLVL, "Context is of type fixed, calling dumpFunc "
  875. "0x%08X with FALSE", pEntry->dumpFunc));
  876. pEntry->dumpFunc(ppdev, FALSE);
  877. break;
  878. case ContextType_RegisterList:
  879. while( --ntags >= 0 )
  880. {
  881. READ_GLINT_FIFO_REG(pData->tag, pData->data);
  882. DISPDBG((DBGLVL, "readback tag 0x%x, data 0x%x",
  883. pData->tag, pData->data));
  884. ++pData;
  885. }
  886. break;
  887. default:
  888. DISPDBG((ERRLVL, "Context is of unknown type!!!"));
  889. }
  890. // Save disconnect
  891. READ_GLINT_CTRL_REG (DisconnectControl, pEntry->inFifoDisc);
  892. READ_GLINT_CTRL_REG (VideoControl, pEntry->VideoControl);
  893. READ_GLINT_CTRL_REG (DMAControl, pEntry->DMAControl);
  894. // disable interrupt driven DMA. New context may re-enable it.
  895. // Clear dual TX status while we're at it.
  896. ppdev->g_GlintBoardStatus &= ~(GLINT_INTR_CONTEXT | GLINT_DUAL_CONTEXT);
  897. READ_GLINT_CTRL_REG (IntEnable, enableFlags);
  898. WRITE_GLINT_CTRL_REG(IntEnable, enableFlags & ~(INTR_ENABLE_DMA));
  899. if (GLINT_DELTA_PRESENT)
  900. {
  901. READ_GLINT_CTRL_REG (DeltaIntEnable, enableFlags);
  902. WRITE_GLINT_CTRL_REG(DeltaIntEnable,
  903. enableFlags & ~(INTR_ENABLE_DMA));
  904. }
  905. DISPDBG((DBGLVL, "DMA Interrupt disabled"));
  906. // record whether double writes are enabled or not
  907. if (glintInfo->flags & GLICAP_RACER_DOUBLE_WRITE)
  908. {
  909. GET_RACER_DOUBLEWRITE (pEntry->DoubleWrite);
  910. }
  911. }
  912. else
  913. {
  914. // nothing doing
  915. DISPDBG((ERRLVL, "Context pEntry is unexpectedly NULL! (2)"));
  916. }
  917. }
  918. // load the new context. We allow -1 to be passed so that we can force a
  919. // save of the current context and force the current context to be
  920. // undefined.
  921. //
  922. if (ctxtId != -1)
  923. {
  924. //@@BEGIN_DDKSPLIT
  925. // AZN Assert taken out since we now check below for (pEntry != NULL)
  926. //ASSERTDD(pCtxtTable->pEntry[ctxtId] != 0,
  927. // "Trying to load a freed context");
  928. //@@END_DDKSPLIT
  929. pEntry = pCtxtTable->pEntry[ctxtId];
  930. if (pEntry != NULL)
  931. {
  932. switch (pEntry->type)
  933. {
  934. case ContextType_None:
  935. // nothing doing
  936. DISPDBG((DBGLVL, "Context is of type none, doing nothing"));
  937. break;
  938. case ContextType_Fixed:
  939. DISPDBG((DBGLVL,"Context is of type fixed, "
  940. "calling dumpFunc 0x%08X with TRUE",
  941. pEntry->dumpFunc));
  942. pEntry->dumpFunc(ppdev, TRUE);
  943. break;
  944. case ContextType_RegisterList:
  945. ntags = pEntry->ntags;
  946. pData = pEntry->pData;
  947. while (ntags > 0)
  948. {
  949. n = 16;
  950. WAIT_GLINT_FIFO(n);
  951. ntags -= n;
  952. if (ntags < 0)
  953. {
  954. n += ntags;
  955. }
  956. while (--n >= 0)
  957. {
  958. LD_GLINT_FIFO(pData->tag, pData->data);
  959. DISPDBG((DBGLVL, "loading tag 0x%x, data 0x%x",
  960. pData->tag, pData->data));
  961. ++pData;
  962. }
  963. }
  964. break;
  965. default:
  966. DISPDBG((ERRLVL, "Context is of unknown type!!!"));
  967. }
  968. // load up the control registers
  969. //
  970. if (glintInfo->flags & GLICAP_RACER_DOUBLE_WRITE)
  971. {
  972. SET_RACER_DOUBLEWRITE (pEntry->DoubleWrite);
  973. }
  974. // Restore disconnect
  975. WRITE_GLINT_CTRL_REG (DisconnectControl, pEntry->inFifoDisc);
  976. WRITE_GLINT_CTRL_REG (VideoControl,
  977. ((pEntry->VideoControl & 0xFFFFFF87) | 0x29));
  978. WRITE_GLINT_CTRL_REG (DMAControl, pEntry->DMAControl);
  979. // if using interrupt driven DMA for this context (endIndex > 0) then
  980. // restore the size of the interrupt driven DMA queue for this context
  981. // and reset the queue.
  982. //
  983. if (pEntry->endIndex > 0)
  984. {
  985. ASSERTDD(GLINT_INTERRUPT_DMA,
  986. "trying to set up DMA Q "
  987. "but no interrupt driven DMA available");
  988. ASSERTDD(glintInfo->pInterruptCommandBlock->frontIndex ==
  989. glintInfo->pInterruptCommandBlock->backIndex,
  990. "Trying to context switch "
  991. "with outstanding DMA queue entries");
  992. glintInfo->pInterruptCommandBlock->frontIndex = 0;
  993. glintInfo->pInterruptCommandBlock->backIndex = 0;
  994. glintInfo->pInterruptCommandBlock->endIndex = pEntry->endIndex;
  995. ppdev->g_GlintBoardStatus |= GLINT_INTR_CONTEXT;
  996. READ_GLINT_CTRL_REG (IntEnable, enableFlags);
  997. DISPDBG((DBGLVL, "DMA Interrupt enabled. flags = 0x%x",
  998. enableFlags |
  999. (INTR_ENABLE_DMA|INTR_ENABLE_ERROR)));
  1000. WRITE_GLINT_CTRL_REG(IntEnable, enableFlags |
  1001. INTR_ENABLE_DMA |
  1002. INTR_ENABLE_ERROR );
  1003. if (GLINT_DELTA_PRESENT)
  1004. {
  1005. READ_GLINT_CTRL_REG (DeltaIntEnable, enableFlags);
  1006. WRITE_GLINT_CTRL_REG(DeltaIntEnable, enableFlags |
  1007. INTR_ENABLE_DMA |
  1008. INTR_ENABLE_ERROR );
  1009. }
  1010. }
  1011. }
  1012. else
  1013. {
  1014. // nothing doing
  1015. DISPDBG((ERRLVL, "Context pEntry is unexpectedly NULL! (1)"));
  1016. }
  1017. }
  1018. DISPDBG((DBGLVL, "vGlintSwitchContext: context %d now current", ctxtId));
  1019. ppdev->currentCtxt = ctxtId;
  1020. } // vGlintSwitchContext