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.

365 lines
9.1 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: ssbits.c
  12. *
  13. * AUTHOR: Benny Ng
  14. *
  15. * DESCRIPTION:
  16. * This module implements the DrvSaveScreenBits() for
  17. * Laguna NT driver.
  18. *
  19. * MODULES:
  20. * DrvSaveScreenBits()
  21. *
  22. * REVISION HISTORY:
  23. * 6/20/95 Benny Ng Initial version
  24. *
  25. * $Log: X:/log/laguna/nt35/displays/cl546x/SSBITS.C $
  26. *
  27. * Rev 1.18 Apr 28 1998 12:51:44 frido
  28. * PDR#11389. I have disabled DrvSaveScreenBits on 2MB boards. We
  29. * seem to run out of memory and the memory manager moves the blocks
  30. * to a different place causing corruption.
  31. *
  32. * Rev 1.17 Mar 04 1998 15:34:18 frido
  33. * Added new shadow macros.
  34. *
  35. * Rev 1.16 Nov 03 1997 11:18:10 frido
  36. * Added REQUIRE macros.
  37. *
  38. * Rev 1.15 08 Aug 1997 17:24:22 FRIDO
  39. * Added support for new memory manager.
  40. *
  41. * Rev 1.14 09 Apr 1997 10:49:28 SueS
  42. * Changed sw_test_flag to pointer_switch.
  43. *
  44. * Rev 1.13 08 Apr 1997 12:27:40 einkauf
  45. *
  46. * add SYNC_W_3D to coordinate MCD/2D hw access
  47. *
  48. * Rev 1.12 26 Nov 1996 10:44:02 SueS
  49. * Changed WriteLogFile parameters for buffering.
  50. *
  51. * Rev 1.11 13 Nov 1996 17:08:46 SueS
  52. * Changed WriteFile calls to WriteLogFile.
  53. *
  54. * Rev 1.10 07 Nov 1996 16:09:08 bennyn
  55. *
  56. * Added no offscn allocation if DD enabled
  57. *
  58. * Rev 1.9 23 Aug 1996 09:10:38 noelv
  59. * Save unders are now discardable.
  60. *
  61. * Rev 1.2 22 Aug 1996 17:07:14 frido
  62. * #ss - Added validation of saved area before restoring or freeing it.
  63. *
  64. * Rev 1.1 15 Aug 1996 11:39:54 frido
  65. * Added precompiled header.
  66. *
  67. * Rev 1.0 14 Aug 1996 17:16:30 frido
  68. * Initial revision.
  69. *
  70. * Rev 1.7 18 Jun 1996 12:39:34 noelv
  71. * added debug information.
  72. *
  73. * Rev 1.6 28 May 1996 15:11:30 noelv
  74. * Updated data logging.
  75. *
  76. * Rev 1.5 16 May 1996 15:01:02 bennyn
  77. *
  78. * Add PIXEL_ALIGN to allocoffscnmen()
  79. *
  80. * Rev 1.4 20 Mar 1996 16:09:42 noelv
  81. *
  82. * Updated data logging
  83. *
  84. * Rev 1.3 05 Mar 1996 12:01:46 noelv
  85. * Frido version 19
  86. *
  87. * Rev 1.1 20 Jan 1996 01:16:48 frido
  88. *
  89. *
  90. * Rev 1.4 15 Jan 1996 17:00:08 NOELV
  91. * AB workaround reductions
  92. *
  93. * Rev 1.3 20 Oct 1995 11:21:50 NOELV
  94. *
  95. * Was leaking offscreen memory. Now it releases its memory after resoring.
  96. *
  97. * Rev 1.2 04 Oct 1995 10:17:36 NOELV
  98. *
  99. * Used updated write macros.
  100. *
  101. * Rev 1.1 21 Aug 1995 13:52:44 NOELV
  102. * Initial port to real hardware.
  103. * Converted all 32 bit register writes to 2 16 bit regiser writes.
  104. *
  105. * Rev 1.0 25 Jul 1995 11:23:20 NOELV
  106. * Initial revision.
  107. *
  108. * Rev 1.2 06 Jul 1995 09:59:10 BENNYN
  109. *
  110. *
  111. * Rev 1.1 05 Jul 1995 08:39:44 BENNYN
  112. * Initial version
  113. *
  114. * Rev 1.0 29 Jun 1995 14:20:44 BENNYN
  115. * Initial revision.
  116. *
  117. ****************************************************************************
  118. ****************************************************************************/
  119. /*----------------------------- INCLUDES ----------------------------------*/
  120. #include "precomp.h"
  121. #include "SWAT.h"
  122. #if MEMMGR
  123. POFMHDL FindHandle(PPDEV ppdev, POFMHDL hdl);
  124. #endif
  125. /*----------------------------- DEFINES -----------------------------------*/
  126. #define SSB_DBG_LEVEL 1
  127. /*--------------------- STATIC FUNCTION PROTOTYPES ------------------------*/
  128. /*--------------------------- ENUMERATIONS --------------------------------*/
  129. /*----------------------------- TYPEDEFS ----------------------------------*/
  130. /*-------------------------- STATIC VARIABLES -----------------------------*/
  131. /*-------------------------- GLOBAL FUNCTIONS -----------------------------*/
  132. //
  133. // If data logging is enabled, Prototype the logging files.
  134. //
  135. #if LOG_CALLS
  136. void LogSaveScreenBits(
  137. int acc,
  138. PPDEV ppdev);
  139. //
  140. // If data logging is not enabled, compile out the calls.
  141. //
  142. #else
  143. #define LogSaveScreenBits(acc, ppdev)
  144. #endif
  145. /****************************************************************************
  146. * FUNCTION NAME: DrvSaveScreenBits()
  147. *
  148. * DESCRIPTION: Do the save and restore of a given rectange of the
  149. * displayed image
  150. *
  151. * REVISION HISTORY:
  152. * 7/05/95 Benny Ng Initial version
  153. ****************************************************************************/
  154. ULONG DrvSaveScreenBits(
  155. SURFOBJ* pso,
  156. ULONG iMode,
  157. ULONG ident,
  158. RECTL* prcl)
  159. {
  160. POFMHDL Handle;
  161. SIZEL reqsz;
  162. LONG szx, szy;
  163. PPDEV ppdev = (PPDEV) pso->dhpdev;
  164. #if 1 //#ss
  165. POFMHDL pofm;
  166. #endif
  167. SYNC_W_3D(ppdev);
  168. DISPDBG((SSB_DBG_LEVEL, "DrvSaveScreenBits - (%d)\n", iMode));
  169. switch (iMode)
  170. {
  171. case SS_SAVE: // -----------------------------------------------------------
  172. #ifdef ALLOC_IN_CREATESURFACE
  173. if (ppdev->bDirectDrawInUse)
  174. return (0);
  175. #ifdef WINNT_VER40 // WINNT_VER40
  176. // MCD should be active only when DDraw is active, but after mode change,
  177. // it seems that DDraw is disabled and not re-enabled. Since MCD uses
  178. // off screen memory like DDraw, we should punt SS_SAVE as if DDraw was alive
  179. if (ppdev->NumMCDContexts > 0) \
  180. return (0);
  181. #endif
  182. #endif
  183. #if 1 // PDR#11389
  184. if (ppdev->lTotalMem < 4096 * 1024)
  185. {
  186. DISPDBG((SSB_DBG_LEVEL, "DrvSaveScreenBits - Not enough memory\n"));
  187. return (ULONG)NULL;
  188. }
  189. #endif
  190. ASSERTMSG((prcl != NULL),
  191. "NULL rectangle in SaveScreenBits. Mode=SS_SAVE.\n");
  192. szx = prcl->right - prcl->left;
  193. szy = prcl->bottom - prcl->top;
  194. reqsz.cx = szx;
  195. reqsz.cy = szy;
  196. Handle = AllocOffScnMem(ppdev, &reqsz, PIXEL_AlIGN, NULL);
  197. if (Handle != NULL)
  198. {
  199. // Save the image to offscreen memory
  200. REQUIRE(9);
  201. LL_DRAWBLTDEF(0x101000CC, 0);
  202. LL_OP1(prcl->left, prcl->top);
  203. LL_OP0(Handle->aligned_x / ppdev->iBytesPerPixel,
  204. Handle->aligned_y);
  205. LL_BLTEXT(szx, szy);
  206. LogSaveScreenBits(0, ppdev);
  207. #if 1 //#ss
  208. Handle->alignflag |= SAVESCREEN_FLAG;
  209. #endif
  210. }
  211. else
  212. {
  213. LogSaveScreenBits(9, ppdev);
  214. }
  215. DISPDBG((SSB_DBG_LEVEL, "DrvSaveScreenBits - Exit\n", iMode));
  216. return((ULONG) Handle);
  217. case SS_RESTORE: // --------------------------------------------------------
  218. ASSERTMSG((prcl != NULL),
  219. "NULL rectangle in SaveScreenBits. Mode=SS_RESTORE.\n");
  220. Handle = (POFMHDL) ident;
  221. #if 1 //#ss
  222. #if MEMMGR
  223. pofm = FindHandle(ppdev, Handle);
  224. #else
  225. for (pofm = ppdev->OFM_UsedQ; pofm; pofm = pofm->nexthdl)
  226. {
  227. if (Handle == pofm)
  228. {
  229. break;
  230. }
  231. }
  232. #endif
  233. if (pofm == NULL)
  234. {
  235. DISPDBG((SSB_DBG_LEVEL,
  236. "DrvSaveScreenBits - Unable to restore.\n"));
  237. return(FALSE);
  238. }
  239. #endif
  240. // Restore the image using the BLT operation
  241. REQUIRE(9);
  242. LL_DRAWBLTDEF(0x101000CC, 0);
  243. LL_OP1(Handle->aligned_x / ppdev->iBytesPerPixel, Handle->aligned_y);
  244. LL_OP0(prcl->left, prcl->top);
  245. LL_BLTEXT(prcl->right - prcl->left, prcl->bottom - prcl->top);
  246. //
  247. // After doing a restore we automatically do a free, So fall through to
  248. // SS_FREE.
  249. //
  250. LogSaveScreenBits(1, ppdev);
  251. case SS_FREE: // -----------------------------------------------------------
  252. Handle = (POFMHDL) ident;
  253. #if MEMMGR
  254. pofm = FindHandle(ppdev, Handle);
  255. #else
  256. for (pofm = ppdev->OFM_UsedQ; pofm; pofm = pofm->nexthdl)
  257. {
  258. if (Handle == pofm)
  259. {
  260. break;
  261. }
  262. }
  263. #endif
  264. if (pofm != NULL)
  265. {
  266. FreeOffScnMem(ppdev, Handle);
  267. LogSaveScreenBits(2, ppdev);
  268. }
  269. DISPDBG((SSB_DBG_LEVEL, "DrvSaveScreenBits - Exit\n", iMode));
  270. return(TRUE);
  271. } // end switch
  272. //
  273. // We shouldn't ever get here.
  274. //
  275. DISPDBG((SSB_DBG_LEVEL, "DrvSaveScreenBits - PANIC\n", iMode));
  276. RIP(("Panic! SaveScreenBits got an invalid command.\n"));
  277. LogSaveScreenBits(2, ppdev);
  278. return(FALSE);
  279. }
  280. #if LOG_CALLS
  281. void LogSaveScreenBits(
  282. int acc,
  283. PPDEV ppdev)
  284. {
  285. char buf[256];
  286. int i;
  287. #if ENABLE_LOG_SWITCH
  288. if (pointer_switch == 0) return;
  289. #endif
  290. i = sprintf(buf,"DrvSaveScreenBits: ");
  291. WriteLogFile(ppdev->pmfile, buf, i, ppdev->TxtBuff, &ppdev->TxtBuffIndex);
  292. switch(acc)
  293. {
  294. case 0:
  295. i = sprintf(buf, "SAVE (success)");
  296. break;
  297. case 1:
  298. i = sprintf(buf,"RESTORE ");
  299. break;
  300. case 2:
  301. i = sprintf(buf, "DELETE ");
  302. break;
  303. case 3:
  304. i = sprintf(buf, "INVALID ");
  305. break;
  306. case 9:
  307. i = sprintf(buf, "SAVE (fail) ");
  308. break;
  309. default:
  310. i = sprintf(buf, "PUNT unknown ");
  311. break;
  312. }
  313. WriteLogFile(ppdev->pmfile, buf, i, ppdev->TxtBuff, &ppdev->TxtBuffIndex);
  314. i = sprintf(buf,"\r\n");
  315. WriteLogFile(ppdev->pmfile, buf, i, ppdev->TxtBuff, &ppdev->TxtBuffIndex);
  316. }
  317. #endif
  318.