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.

283 lines
7.2 KiB

  1. /****************************************************************************
  2. *****************************************************************************
  3. *
  4. * ******************************************
  5. * * Copyright (c) 1995, Cirrus Logic, Inc. *
  6. * * All Rights Reserved *
  7. * ******************************************
  8. *
  9. * PROJECT: Laguna I (CL-GD5462) -
  10. *
  11. * FILE: sync.c
  12. *
  13. * Initial AUTHOR: Benny Ng
  14. * Major re-write: Noel VanHook
  15. *
  16. * DESCRIPTION:
  17. * This module contains the implementation of DrvSynchronize()
  18. * routine.
  19. *
  20. * MODULES:
  21. * DrvSynchronize()
  22. *
  23. * REVISION HISTORY:
  24. * 7/06/95 Benny Ng Initial version
  25. *
  26. * $Log: X:/log/laguna/nt35/displays/cl546x/sync.c $
  27. *
  28. * Rev 1.13 22 Apr 1997 11:06:36 noelv
  29. * Removed frame buffer cache invalidate since FB cache is disabled.
  30. *
  31. * Rev 1.12 09 Apr 1997 10:50:06 SueS
  32. * Changed sw_test_flag to pointer_switch.
  33. *
  34. * Rev 1.11 08 Apr 1997 12:32:00 einkauf
  35. *
  36. * add SYNC_W_3D to coordinate MCD/2D hw access
  37. *
  38. * Rev 1.10 04 Feb 1997 13:52:36 noelv
  39. * Fixed typo.
  40. *
  41. * Rev 1.9 04 Feb 1997 10:50:56 noelv
  42. * Added workaround for 5465 direct frame buffer readback bug.
  43. *
  44. * Rev 1.8 26 Nov 1996 10:45:48 SueS
  45. * Changed WriteLogFile parameters for buffering.
  46. *
  47. * Rev 1.7 13 Nov 1996 17:05:34 SueS
  48. * Changed WriteFile calls to WriteLogFile.
  49. *
  50. * Rev 1.6 20 Aug 1996 11:04:32 noelv
  51. * Bugfix release from Frido 8-19-96
  52. *
  53. * Rev 1.1 15 Aug 1996 11:39:20 frido
  54. * Added precompiled header.
  55. *
  56. * Rev 1.0 14 Aug 1996 17:16:32 frido
  57. * Initial revision.
  58. *
  59. * Rev 1.5 07 Aug 1996 08:30:56 noelv
  60. * added comments
  61. *
  62. * Rev 1.4 20 Mar 1996 16:09:44 noelv
  63. *
  64. * Updated data logging
  65. *
  66. * Rev 1.3 05 Mar 1996 11:59:18 noelv
  67. * Frido version 19
  68. *
  69. * Rev 1.1 20 Jan 1996 01:11:38 frido
  70. *
  71. * Rev 1.6 15 Jan 1996 17:01:34 NOELV
  72. *
  73. * Rev 1.5 12 Jan 1996 10:54:30 NOELV
  74. * Totally re-written.
  75. *
  76. * Rev 1.4 22 Sep 1995 10:24:58 NOELV
  77. * Re-aranged the order of the tests.
  78. *
  79. * Rev 1.1 19 Sep 1995 16:31:02 NOELV
  80. * Ported to rev AB.
  81. *
  82. * Rev 1.0 25 Jul 1995 11:23:22 NOELV
  83. * Initial revision.
  84. *
  85. * Rev 1.1 07 Jul 1995 10:37:22 BENNYN
  86. * Initial version
  87. *
  88. * Rev 1.0 06 Jul 1995 14:55:48 BENNYN
  89. * Initial revision.
  90. *
  91. ****************************************************************************
  92. ****************************************************************************/
  93. /*----------------------------- INCLUDES ----------------------------------*/
  94. #include "precomp.h"
  95. /*----------------------------- DEFINES -----------------------------------*/
  96. #define DBGDISP
  97. #define MAX_CNT 0x7FFFFF
  98. #define BLT_RDY_BIT 0x1L
  99. #define BLT_FLAG_BIT 0x2L
  100. #define WF_EMPTY_BIT 0x4L
  101. #define BITS_CHK (BLT_RDY_BIT | BLT_FLAG_BIT | WF_EMPTY_BIT)
  102. #define ENGINE_IDLE 0
  103. #define SYNC_DBG_LEVEL 0
  104. //
  105. // If data logging is enabled, Prototype the logging files.
  106. //
  107. #if LOG_CALLS
  108. void LogSync(
  109. int acc,
  110. PPDEV ppdev,
  111. int count);
  112. //
  113. // If data logging is not enabled, compile out the calls.
  114. //
  115. #else
  116. #define LogSync(acc, ppdev, count)
  117. #endif
  118. /****************************************************************************
  119. * FUNCTION NAME: DrvSynchronize()
  120. *
  121. * REVISION HISTORY:
  122. * 7/06/95 Benny Ng Initial version
  123. ****************************************************************************/
  124. VOID DrvSynchronize(DHPDEV dhpdev,
  125. RECTL *prcl)
  126. {
  127. PPDEV ppdev = (PPDEV) dhpdev;
  128. SYNC_W_3D(ppdev);
  129. //
  130. // NOTE: We also call this function from within the driver.
  131. // When we do, we don't bother to set prcl. If you need to use
  132. // prcl here, you need to find where we call DrvSynchronize, and
  133. // set prcl to a real value.
  134. //
  135. //
  136. // Make the first chip test as fast as possible. If the chip
  137. // is already idle, we want to return to NT as fast as possible.
  138. //
  139. if ( LLDR_SZ (grSTATUS) == ENGINE_IDLE)
  140. {
  141. LogSync(0, ppdev, 0);
  142. }
  143. //
  144. // Alright, the chip isn't idle yet.
  145. // Go into a wait loop.
  146. //
  147. else
  148. {
  149. ULONG ultmp;
  150. LONG delaycnt = 1;
  151. while (1)
  152. {
  153. ultmp = LLDR_SZ (grSTATUS);
  154. if ((ultmp & BITS_CHK) == ENGINE_IDLE)
  155. {
  156. LogSync(0, ppdev, delaycnt);
  157. break;
  158. }
  159. if (delaycnt++ >= MAX_CNT)
  160. {
  161. //
  162. // The chip never went idle. This most likely means the chip
  163. // is totally dead. In a checked build we will halt with a
  164. // debug message.
  165. // In a free build we will return to NT and hope for the best.
  166. //
  167. LogSync(1, ppdev, 0);
  168. RIP("Chip failed to go idle in DrvSynchronize!\n");
  169. break;
  170. }
  171. }
  172. }
  173. //
  174. // We can skp this 'cause frame buffer caching is broken.
  175. //
  176. #if 0
  177. #if DRIVER_5465
  178. {
  179. //
  180. // The 5465 Rev AA and Rev AB have a bug.
  181. // We must invalidate the frame buffer cache before direct
  182. // frame buffer accesses will work correctly.
  183. // We do this with two DWORD reads of the frame buffer,
  184. // 8 QWORDS apart.
  185. //
  186. DWORD temp;
  187. temp = * ((volatile DWORD *) (ppdev->pjScreen));
  188. temp = * ((volatile DWORD *) (ppdev->pjScreen+64));
  189. }
  190. #endif
  191. #endif
  192. return;
  193. }
  194. // meant to be called only from .asm routines - .c routines use SYNC_W_3D macro
  195. VOID Sync_w_3d_proc(PPDEV ppdev)
  196. {
  197. SYNC_W_3D(ppdev);
  198. }
  199. #if LOG_CALLS
  200. // ============================================================================
  201. //
  202. // Everything from here down is for data logging and is not used in the
  203. // production driver.
  204. //
  205. // ============================================================================
  206. // ****************************************************************************
  207. //
  208. // LogPaint()
  209. // This routine is called only from DrvPaint()
  210. // Dump information to a file about what is going on in DrvPaint land.
  211. //
  212. // ****************************************************************************
  213. void LogSync(
  214. int acc,
  215. PPDEV ppdev,
  216. int count)
  217. {
  218. char buf[256];
  219. int i;
  220. #if ENABLE_LOG_SWITCH
  221. if (pointer_switch == 0) return;
  222. #endif
  223. i = sprintf(buf,"DrvSync: ");
  224. WriteLogFile(ppdev->pmfile, buf, i, ppdev->TxtBuff, &ppdev->TxtBuffIndex);
  225. switch(acc)
  226. {
  227. case 0: // Accelerated
  228. i = sprintf(buf,"Wait %d Idle ",count);
  229. break;
  230. case 1: // Punted
  231. i = sprintf(buf, "Never idle ");
  232. break;
  233. default:
  234. i = sprintf(buf, "PUNT unknown ");
  235. break;
  236. }
  237. WriteLogFile(ppdev->pmfile, buf, i, ppdev->TxtBuff, &ppdev->TxtBuffIndex);
  238. i = sprintf(buf,"\r\n");
  239. WriteLogFile(ppdev->pmfile, buf, i, ppdev->TxtBuff, &ppdev->TxtBuffIndex);
  240. }
  241. #endif