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.

317 lines
13 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: driver.h
  3. *
  4. * Contains prototypes for the 64k color VGA driver.
  5. *
  6. * NOTE: Must mirror driver.inc!
  7. *
  8. * Copyright (c) 1992 Microsoft Corporation
  9. \**************************************************************************/
  10. #ifndef _DRIVER_
  11. #define _DRIVER_
  12. #include "stdlib.h"
  13. #include "stddef.h"
  14. #include "windows.h"
  15. #include "winddi.h"
  16. #include "devioctl.h"
  17. #include "ntddvdeo.h"
  18. #include "debug.h"
  19. typedef struct _PDEV PDEV, *PPDEV;
  20. //
  21. // A mode requires broken rasters if the stride is a power of 2 and the video ram
  22. // accessed is greater than 64K.
  23. //
  24. #define POW2(stride) (!((stride) & ((stride)-1))) // TRUE if stride is power of 2
  25. #define BROKEN_RASTERS(stride,cy) ((!(POW2(stride))) && ((stride*cy) > 0x10000))
  26. //
  27. // Sizes assumed for 1-window and 2 RW-window banks.
  28. //
  29. #define BANK_SIZE_1_WINDOW 0x10000L
  30. #define BANK_SIZE_2RW_WINDOW 0x08000L
  31. //
  32. // Temporary buffer must be at least as large as a bank.
  33. // Must also be a multiple of 4.
  34. //
  35. #define TMP_BUFFER_SIZE (BANK_SIZE_1_WINDOW)
  36. /**************************************************************************\
  37. *
  38. * Specifies desired justification for requested scan line within bank window
  39. *
  40. \**************************************************************************/
  41. typedef enum {
  42. JustifyTop = 0,
  43. JustifyBottom,
  44. } BANK_JUST;
  45. /**************************************************************************\
  46. *
  47. * Specifies which window is to be mapped by two-window bank handler.
  48. *
  49. \**************************************************************************/
  50. typedef enum {
  51. MapSourceBank = 0,
  52. MapDestBank,
  53. } BANK_JUST;
  54. /**************************************************************************\
  55. *
  56. * Bank clipping info
  57. *
  58. \**************************************************************************/
  59. typedef struct {
  60. RECTL rclBankBounds; // describes pixels addressable in this bank
  61. ULONG ulBankOffset; // offset of bank start from bitmap start, if
  62. // the bitmap were linearly addressable
  63. } BANK_INFO, *PBANK_INFO;
  64. /**************************************************************************\
  65. *
  66. * Bank control function vector
  67. *
  68. \**************************************************************************/
  69. typedef VOID (*PFN_PlanarEnable)();
  70. typedef VOID (*PFN_PlanarDisable)();
  71. typedef VOID (*PFN_PlanarControl)(PPDEV, ULONG, BANK_JUST);
  72. typedef VOID (*PFN_PlanarControl2)(PPDEV, ULONG, BANK_JUST, ULONG);
  73. typedef VOID (*PFN_PlanarNext)(PPDEV);
  74. typedef VOID (*PFN_PlanarNext2)(PPDEV, ULONG);
  75. typedef VOID (*PFN_BankControl)(PPDEV, ULONG, BANK_JUST);
  76. typedef VOID (*PFN_BankControl2)(PPDEV, ULONG, BANK_JUST, ULONG);
  77. typedef VOID (*PFN_BankNext)(PPDEV);
  78. typedef VOID (*PFN_BankNext2)(PPDEV, ULONG);
  79. /**************************************************************************\
  80. *
  81. * Miscellaneous driver flags
  82. *
  83. \**************************************************************************/
  84. #define DRIVER_PLANAR_CAPABLE 0x01L
  85. #define DRIVER_USE_OFFSCREEN 0x02L // if not set, don't use offscreen memory
  86. // for long operations (because the
  87. // memory won't be refreshed)
  88. #define DRIVER_HAS_OFFSCREEN 0x04L // if not set, can't use any offscreen
  89. // memory
  90. /**************************************************************************\
  91. *
  92. * Bank status flags
  93. *
  94. \**************************************************************************/
  95. #define BANK_BROKEN_RASTER1 0x01L // If bank1 or read bank has broken raster
  96. #define BANK_BROKEN_RASTER2 0x02L // If bank2 or write bank has broken raster
  97. #define BANK_BROKEN_RASTERS (BANK_BROKEN_RASTER1 | BANK_BROKEN_RASTER2)
  98. #define BANK_PLANAR 0x04L // If in planar mode
  99. /**************************************************************************\
  100. *
  101. * Physical device data structure
  102. *
  103. \**************************************************************************/
  104. // ***********************************************************
  105. // *** MUST match the assembler version in i386\driver.inc ***
  106. // ***********************************************************
  107. typedef struct _PDEV
  108. {
  109. FLONG fl; // Driver flags (DRIVER_xxx)
  110. HANDLE hDriver; // Handle to \Device\Screen
  111. HDEV hdevEng; // Engine's handle to PDEV
  112. HSURF hsurfEng; // Engine's handle to surface
  113. HANDLE hsurfBm; // Handle to the "punt" surface
  114. SURFOBJ* pSurfObj; // pointer to the locked "punt" surface
  115. HPALETTE hpalDefault; // Handle to the default palette for device.
  116. PBYTE pjScreen; // This is pointer to base screen address
  117. ULONG cxScreen; // Visible screen width
  118. ULONG cyScreen; // Visible screen height
  119. ULONG ulMode; // Mode the mini-port driver is in.
  120. LONG lDeltaScreen; // Distance from one scan to the next.
  121. FLONG flRed; // For bitfields device, Red Mask
  122. FLONG flGreen; // For bitfields device, Green Mask
  123. FLONG flBlue; // For bitfields device, Blue Mask
  124. ULONG ulBitCount; // # of bits per pel -- can be only 16
  125. GDIINFO* pGdiInfo; // Pointer to temporary buffer for GDIINFO struct
  126. DEVINFO* pDevInfo; // Pointer to temporary buffer for DEVINFO struct
  127. ULONG ulrm0_wmX; // Four values (one per byte) to set
  128. // GC5 to to select read mode 0
  129. // together with write modes 0-3
  130. // Off screen save stuff:
  131. HBITMAP hbmTmp; // Handle to temporary buffer
  132. SURFOBJ* psoTmp; // Temporary surface
  133. PVOID pvTmp; // Pointer to temporary buffer
  134. ULONG cyTmp; // # of scans in temporary surface
  135. // DCI stuff:
  136. BOOL bSupportDCI; // True if miniport supports DCI
  137. // Bank manager stuff common between planar and non-planar modes:
  138. LONG cTotalScans; // Number of usable on and off-screen
  139. // scans
  140. PVIDEO_BANK_SELECT pBankInfo; // Bank info for current mode returned
  141. // by miniport
  142. FLONG flBank; // Flags for current bank state
  143. ULONG ulBitmapSize; // Length of bitmap if there were no
  144. // banking, in CPU addressable bytes
  145. ULONG ulWindowBank[2]; // Current banks mapped into windows
  146. // 0 & 1
  147. PVOID pvBitmapStart; // Single-window bitmap start pointer
  148. // (adjusted as necessary to make
  149. // window map in at proper offset)
  150. PVOID pvBitmapStart2Window[2];// Double-window window 0 and 1 bitmap
  151. // start
  152. // Non-planar mode specific bank management control stuff:
  153. VIDEO_BANK_TYPE vbtBankingType; // Type of banking
  154. PFN pfnBankSwitchCode; // Pointer to bank switch code
  155. LONG lNextScan; // Offset to next bank in bytes
  156. BYTE* pjJustifyTopBank; // Pointer to lookup table for
  157. // converting scans to banks
  158. BANK_INFO* pbiBankInfo; // Array of bank clip info
  159. ULONG ulJustifyBottomOffset; // # of scans from top to bottom
  160. // of bank, for bottom justifying
  161. ULONG iLastBank; // Index of last valid bank in
  162. // pbiBankInfo table
  163. ULONG ulBank2RWSkip; // Offset from one bank index to next
  164. // to make two 32K banks appear to be
  165. // one seamless 64K bank
  166. PFN_BankControl pfnBankControl; // Pointer to bank control function
  167. PFN_BankControl2 pfnBankControl2Window; // Pointer to double-window bank
  168. // control function
  169. PFN_BankNext pfnBankNext; // Pointer to next bank function
  170. PFN_BankNext2 pfnBankNext2Window; // Pointer to double-window next
  171. // bank function
  172. RECTL rcl1WindowClip; // Single-window banking clip rect
  173. RECTL rcl2WindowClip[2]; // Double-window banking clip rects for
  174. // windows 0 & 1
  175. // Planar mode specific bank management control stuff:
  176. VIDEO_BANK_TYPE vbtPlanarType; // Type of planar banking
  177. PFN pfnPlanarSwitchCode; // Pointer to planar bank switch
  178. // code
  179. LONG lPlanarNextScan; // Offset to next planar bank in
  180. // bytes
  181. BYTE* pjJustifyTopPlanar; // Pointer to lookup table for
  182. // converting scans to banks
  183. BANK_INFO* pbiPlanarInfo; // Array of bank clip info
  184. ULONG ulPlanarBottomOffset;// # of scans from top to bottom
  185. // of bank, for bottom justifying
  186. ULONG iLastPlanar; // Index of last valid bank in
  187. // pbiPlanarInfo table
  188. ULONG ulPlanar2RWSkip; // Offset from one bank index to next
  189. // to make two 32K banks appear to be
  190. // one seamless 64K bank
  191. PFN_PlanarControl pfnPlanarControl; // Planar one window bank control
  192. PFN_PlanarControl2 pfnPlanarControl2; // Planar two window bank control
  193. PFN_PlanarNext pfnPlanarNext; // Planar one window next bank
  194. PFN_PlanarNext2 pfnPlanarNext2; // Planar two window next bank
  195. RECTL rcl1PlanarClip; // Single-window banking clip rect
  196. RECTL rcl2PlanarClip[2]; // Double-window banking clip rects for
  197. // windows 0 & 1
  198. PFN_PlanarEnable pfnPlanarEnable; // Function to enable planar mode
  199. PFN_PlanarDisable pfnPlanarDisable; // Function to disable planar mode
  200. // Smart bank manager stuff:
  201. LONG iLastScan; // Last scan we want to enumerate
  202. PVOID pvSaveScan0; // Surface's original pvScan0
  203. RECTL rclSaveBounds; // Clip Object's original bounds
  204. CLIPOBJ* pcoNull; // Points to an empty clip object
  205. // we can use when we're given a
  206. // NULL CLIPOBJ pointer
  207. BYTE iSaveDComplexity; // Clip Object's original complexity
  208. BYTE fjSaveOptions; // Clip Object's original flags
  209. BYTE ajFiller[2]; // Pack dword alignment
  210. BOOLEAN BankIoctlSupported; // does the miniport support ioctl
  211. // based banking?
  212. }; /* pdev */
  213. // Size of the driver extra information in the DEVMODe structure passed
  214. // to and from the display driver
  215. #define DRIVER_EXTRA_SIZE 0
  216. #define DLL_NAME L"vga64k" // Name of the DLL in UNICODE
  217. #define STANDARD_DEBUG_PREFIX "VGA64K: " // All debug output is prefixed
  218. #define ALLOC_TAG '6gvD' // 4 byte TAG for memory allocations
  219. // When calling vEnumStart, make sure you set bAll to FALSE. This will tell
  220. // the Engine to only enumerate rectangles in rclBounds.
  221. // Hooks and Driver function table.
  222. #define HOOKS_BMF16BPP (HOOK_BITBLT | HOOK_TEXTOUT | HOOK_COPYBITS | \
  223. HOOK_STROKEPATH | HOOK_PAINT)
  224. #define BB_RECT_LIMIT 50
  225. typedef struct _BBENUM
  226. {
  227. ULONG c;
  228. RECTL arcl[BB_RECT_LIMIT];
  229. } BBENUM;
  230. // Initialization stuff:
  231. BOOL bEnableBanking(PPDEV);
  232. VOID vDisableBanking(PPDEV);
  233. BOOL bInitPDEV(PPDEV,PDEVMODEW);
  234. BOOL bInitSURF(PPDEV,BOOL);
  235. VOID vDisableSURF(PPDEV);
  236. VOID vInitRegs(PPDEV);
  237. DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION *, DWORD *);
  238. // Smart bank manager stuff:
  239. CLIPOBJ* pcoBankStart(PPDEV, RECTL*, SURFOBJ*, CLIPOBJ*);
  240. BOOL bBankEnum(PPDEV, SURFOBJ*, CLIPOBJ*);
  241. VOID vBankStartBltSrc(PPDEV, SURFOBJ*, POINTL*, RECTL*, POINTL*, RECTL*);
  242. BOOL bBankEnumBltSrc(PPDEV, SURFOBJ*, POINTL*, RECTL*, POINTL*, RECTL*);
  243. VOID vBankStartBltDest(PPDEV, SURFOBJ*, POINTL*, RECTL*, POINTL*, RECTL*);
  244. BOOL bBankEnumBltDest(PPDEV, SURFOBJ*, POINTL*, RECTL*, POINTL*, RECTL*);
  245. // Other prototypes:
  246. VOID vPlanarCopyBits(PPDEV, RECTL*, POINTL*);
  247. BOOL bIntersectRect(RECTL*, RECTL*, RECTL*);
  248. VOID vSetWriteModes(ULONG *);
  249. #endif // _DRIVER_