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.

368 lines
15 KiB

  1. /******************************Module*Header**********************************\
  2. *
  3. * *******************
  4. * * GDI SAMPLE CODE *
  5. * *******************
  6. *
  7. * Module Name: driver.h
  8. *
  9. * Contains definitions and typedefs common to all driver
  10. * components.
  11. *
  12. * Copyright (c) 1994-1998 3Dlabs Inc. Ltd. All rights reserved.
  13. * Copyright (c) 1995-1999 Microsoft Corporation. All rights reserved.
  14. \*****************************************************************************/
  15. #ifndef __DRIVER__H__
  16. #define __DRIVER__H__
  17. typedef struct _PDev PDev; // Handy forward declaration
  18. typedef struct _Surf Surf; // Handy forward declaration
  19. typedef struct _GFNPB GFNPB; // Handy forward declaration
  20. typedef VOID (GFN)(GFNPB*);
  21. typedef BOOL (GFNLINE)(PDev*, LONG, LONG, LONG, LONG);
  22. typedef BOOL (GFNINIS)(PDev*, ULONG, DWORD, RECTL*);
  23. typedef VOID (GFNRSTS)(PDev*);
  24. typedef struct _P2DMA P2DMA;
  25. typedef struct tagP2CtxtRec *P2CtxtPtr;
  26. typedef struct _hw_data *HwDataPtr;
  27. // Four byte tag used for tracking memory allocations on a per source
  28. // file basis. (characters are in reverse order). Note if you add any
  29. // new files which call ENGALLOCMEM remember to update this list. This also
  30. // applies if you want to make the allocation tagging more granular than
  31. // file level.
  32. #define ALLOC_TAG_3D2P '3d2p' // Allocations from d3d.c
  33. #define ALLOC_TAG_6D2P '6d2p' // Allocations from d3ddx6.c
  34. #define ALLOC_TAG_SD2P 'sd2p' // Allocations from d3dstate.c
  35. #define ALLOC_TAG_TD2P 'td2p' // Allocations from d3dtxman.c
  36. #define ALLOC_TAG_US2P 'us2p' // Allocations from ddsurf.c
  37. #define ALLOC_TAG_ED2P 'ed2p' // Allocations from debug.c
  38. #define ALLOC_TAG_NE2P 'ne2p' // Allocations from enable.c
  39. #define ALLOC_TAG_IF2P 'if2p' // Allocations from fillpath.c
  40. #define ALLOC_TAG_EH2P 'eh2p' // Alloactions from heap.c
  41. #define ALLOC_TAG_WH2P 'wh2p' // Allocations from hwinit.c
  42. #define ALLOC_TAG_XC2P 'xc2p' // Allocations from p2ctxt.c
  43. #define ALLOC_TAG_AP2P 'ap2p' // Allocations from palette.c
  44. #define ALLOC_TAG_EP2P 'ep2p' // Allocations from permedia.c
  45. #define ALLOC_TAG_XT2P 'xt2p' // Allocations from textout.c
  46. //
  47. // Miscellaneous shared stuff
  48. //
  49. #define DLL_NAME L"perm2dll" // Name of the DLL in UNICODE
  50. #define STANDARD_DEBUG_PREFIX "PERM2DLL: "// All debug output is prefixed
  51. // by this string
  52. #define DRIVER_EXTRA_SIZE 0 // Size of the DriverExtra information in
  53. // the DEVMODE structure
  54. #define TMP_BUFFER_SIZE 8192 // Size in bytes of 'pvTmpBuffer'.
  55. // Has to be at least enough to store an
  56. // entire scan line (i.e., 6400 for
  57. // 1600x1200x32).
  58. #define MAX_CLUT_SIZE (sizeof(VIDEO_CLUT) + (sizeof(ULONG) * 256))
  59. #define INPUT_BUFFER_SIZE (1024 * 64) // Size in bytes
  60. //@@BEGIN_DDKSPLIT
  61. #define MULTITHREADED 0
  62. #define MT_LOG_LEVEL 6
  63. #if MULTITHREADED && DBG
  64. #define ASSERTLOCK(xppdev, func) \
  65. { \
  66. EngAcquireSemaphore((xppdev)->hsemLock); \
  67. if ((xppdev)->ulLockCount < 1) \
  68. { \
  69. DebugPrint(-1000, __FILE__ ":%d:" #func ": bad lock count", __LINE__); \
  70. EngDebugBreak(); \
  71. } \
  72. EngReleaseSemaphore((xppdev)->hsemLock); \
  73. }
  74. #else
  75. #define ASSERTLOCK(xppdev, func)
  76. #endif
  77. //@@END_DDKSPLIT
  78. //
  79. // Status flags
  80. //
  81. typedef enum
  82. {
  83. // STAT_* indicates that the resource actually exists
  84. STAT_BRUSH_CACHE = 0x0002, // Brush cache successfully allocated
  85. STAT_DEV_BITMAPS = 0x0004, // Device Bitmaps are allowed
  86. // ENABLE_* indicates whether resource is currently available
  87. ENABLE_BRUSH_CACHE = 0x0020, // Brush cache disabled
  88. ENABLE_DEV_BITMAPS = 0x0040, // Device Bitmaps disabled
  89. } /*STATUS*/;
  90. typedef int Status;
  91. //
  92. // The Physical Device data structure
  93. //
  94. typedef struct _PDev
  95. {
  96. BYTE* pjScreen; // Points to base screen address
  97. ULONG iBitmapFormat; // BMF_8BPP or BMF_16BPP or BMF_32BPP
  98. // (our current colour depth)
  99. CAPS flCaps; // Capabilities flags
  100. Status flStatus; // Status flags
  101. BOOL bEnabled; // In graphics mode (not full-screen)
  102. HANDLE hDriver; // Handle to \Device\Screen
  103. HDEV hdevEng; // Engine's handle to PDev
  104. HSURF hsurfScreen; // Engine's handle to screen surface
  105. Surf* pdsurfScreen; // Our private DSURF for the screen
  106. Surf* pdsurfOffScreen; // Our private DSURF for the back buffer
  107. LONG cxScreen; // Visible screen width
  108. LONG cyScreen; // Visible screen height
  109. LONG cxMemory; // Width of Video RAM
  110. LONG cyMemory; // Height of Video RAM
  111. ULONG ulMode; // Mode the mini-port driver is in.
  112. LONG lDelta; // Distance from one scan to the next.
  113. FLONG flHooks; // What we're hooking from GDI
  114. LONG cjPelSize; // 4/2/1 for 32/16/8 bpp
  115. LONG cPelSize; // 2/1/0 for 32/16/8 bpp
  116. DWORD bPixShift; // 2/1/0 for 32/16/8 bpp
  117. DWORD bBppShift; // 0/1/2 for 32/16/8 bpp
  118. DWORD dwBppMask; // 0/1/3 for 32/16/8 bpp
  119. ULONG ulWhite; // 0xff if 8bpp, 0xffff if 16bpp,
  120. // 0xffffffff if 32bpp
  121. ULONG* pulCtrlBase[2]; // Mapped control registers for this PDEV
  122. // 2 entries to support Dual-TX
  123. ULONG* pulDenseCtrlBase; // Dense mapping for direct draw
  124. ULONG* pulRamdacBase; // Mapped control registers for the RAMDAC
  125. VOID* pvTmpBuffer; // General purpose temporary buffer,
  126. // TMP_BUFFER_SIZE bytes in size
  127. // (Remember to synchronize if you use this
  128. // for device bitmaps or async pointers)
  129. LONG lVidMemHeight; // Height of Video RAM available to
  130. // DirectDraw heap (cyScreen <= cyHeap
  131. // <= cyMemory), including primary surface
  132. LONG lVidMemWidth; // Width, in pixel, of Video RAM available
  133. // to DDraw heap, including primary surface
  134. LONG cBitsPerPel; // Bits per pel (8, 15, 16, 24 or 32)
  135. UCHAR* pjIoBase; // Mapped IO port base for this PDEV
  136. ULONG ulPermFormat; // permedia format type of primary
  137. ULONG ulPermFormatEx; // permedia extended format bit of primary
  138. DWORD dwAccelLevel; // Acceleration level setting
  139. POINTL ptlOrigin; // Origin of desktop in multi-mon dev space
  140. //
  141. // Palette stuff:
  142. //
  143. PALETTEENTRY* pPal; // The palette if palette managed
  144. HPALETTE hpalDefault; // GDI handle to the default palette.
  145. FLONG flRed; // Red mask for 16/32bpp bitfields
  146. FLONG flGreen; // Green mask for 16/32bpp bitfields
  147. FLONG flBlue; // Blue mask for 16/32bpp bitfields
  148. //
  149. // Heap stuff for DDRAW managed off-screen memory
  150. //
  151. VIDEOMEMORY* pvmList; // Points to the video-memory heap list
  152. // as supplied by DirectDraw, needed
  153. // for heap allocations
  154. ULONG cHeaps; // Count of video-memory heaps
  155. ULONG iHeapUniq; // Incremented every time room is freed
  156. // in the off-screen heap
  157. Surf* psurfListHead; // Dbl Linked list of discardable bitmaps,
  158. Surf* psurfListTail; // in order of oldest to newest
  159. //
  160. // Pointer stuff
  161. //
  162. LONG xPointerHot; // xHot of current hardware pointer
  163. LONG yPointerHot; // yHot of current hardware pointer
  164. ULONG ulHwGraphicsCursorModeRegister_45;
  165. // Default value for index 45
  166. PtrFlags flPointer; // Pointer state flags
  167. VOID* pvPointerData; // Points to ajPointerData[0]
  168. BYTE ajPointerData[POINTER_DATA_SIZE];
  169. // Private work area for downloaded
  170. // miniport pointer code
  171. BOOL bPointerInitialized;// Flag to indicate if HW pointer has been
  172. // initizlized
  173. // Brush stuff:
  174. BOOL bRealizeTransparent;// Hint to DrvRealizeBrush for whether
  175. // the brush should be realized as
  176. // transparent or not
  177. LONG cPatterns; // Count of bitmap patterns created
  178. LONG lNextCachedBrush; // Index for next brush to be allocated
  179. LONG cBrushCache; // Total number of brushes cached
  180. BrushEntry abeMono; // Keeps track of area stipple brush
  181. BrushEntry abe[TOTAL_BRUSH_COUNT]; // Keeps track of brush cache
  182. HBITMAP ahbmPat[HS_DDI_MAX];// Engine handles to standard patterns
  183. ULONG ulBrushPackedPP; // Stride of brush as partial products
  184. VIDEOMEMORY*pvmBrushHeap; // Heap from which brush cached was alloced
  185. ULONG ulBrushVidMem; // Poitner to start of brush cache
  186. // Hardware pointer cache stuff:
  187. HWPointerCache HWPtrCache; // The cache data structure itself
  188. LONG HWPtrLastCursor; // The index of the last cursor that we drew
  189. LONG HWPtrPos_X; // The last X position of the cursor
  190. LONG HWPtrPos_Y; // The last Y position of the cursor
  191. HwDataPtr permediaInfo; // info about the interface to permedia2
  192. LONG FrameBufferLength; // Length of framebuffer in bytes
  193. // rendering routines
  194. GFN* pgfnAlphaBlend;
  195. GFN* pgfnConstantAlphaBlend;
  196. GFN* pgfnCopyBlt;
  197. GFN* pgfnCopyBltWithRop;
  198. GFN* pgfnGradientFillTri;
  199. GFN* pgfnGradientFillRect;
  200. GFN* pgfnMonoOffset;
  201. GFN* pgfnMonoPatFill;
  202. GFN* pgfnPatFill;
  203. GFN* pgfnPatRealize;
  204. GFN* pgfnSolidFill;
  205. GFN* pgfnSolidFillWithRop;
  206. GFN* pgfnSourceFillRect;
  207. GFN* pgfnTransparentBlt;
  208. GFN* pgfnXferImage;
  209. GFN* pgfnInvert;
  210. // support for DrvStroke
  211. // TODO: remove use of this implicit parameter passing
  212. Surf* psurf; // this is an implicit parameter passed to various
  213. // calls ... this needs to be removed.
  214. // Direct draw stuff
  215. P2CtxtPtr pDDContext; // DDRAW context
  216. // Virtual address of start of screen
  217. UINT_PTR dwScreenStart;
  218. // DDraw/D3D DMA shared memory block
  219. P2DMA *pP2dma;
  220. // Current pixel format of display
  221. DDPIXELFORMAT ddpfDisplay;
  222. // Some P2 specific information
  223. DWORD dwChipConfig; // image of P2 chip configuration
  224. // some virtual addresses of the P2
  225. // registers
  226. ULONG *pCtrlBase; //
  227. ULONG *pCoreBase; //
  228. ULONG *pGPFifo; //
  229. // DirectDraw callbacks
  230. DDHAL_DDCALLBACKS DDHALCallbacks;
  231. DDHAL_DDSURFACECALLBACKS DDSurfCallbacks;
  232. DWORD dwNewDDSurfaceOffset;
  233. BOOL bDdExclusiveMode; // TRUE if DDraw is in ExclusiveMode
  234. BOOL bDdStereoMode; // TRUE if flip has switched us
  235. // to stereo mode
  236. BOOL bCanDoStereo; // This mode can do stereo
  237. // These have to live here, as we could be running on 2 different cards
  238. // on two different displays...!
  239. UINT_PTR pD3DDriverData32;
  240. UINT_PTR pD3DHALCallbacks32;
  241. // Linear allocator defines
  242. UINT_PTR dwGARTLin; // Linear address of Base of AGP Memory
  243. UINT_PTR dwGARTDev; // High Linear address of Base of AGP Memory
  244. UINT_PTR dwGARTLinBase; // The Linear base address passed into
  245. // UpdateNonLocalVidMem
  246. UINT_PTR dwGARTDevBase; // The High Linear base address passed into
  247. // UpdateNonLocalVidMem
  248. // HAL info structure.
  249. DDHALINFO ddhi32;
  250. PFND3DPARSEUNKNOWNCOMMAND pD3DParseUnknownCommand;
  251. // New Input FIFO cached information
  252. PULONG pulInFifoPtr;
  253. PULONG pulInFifoStart;
  254. PULONG pulInFifoEnd;
  255. ULONG* dmaBufferVirtualAddress;
  256. LARGE_INTEGER dmaBufferPhysicalAddress;
  257. ULONG dmaCurrentBufferOffset;
  258. ULONG dmaActiveBufferOffset;
  259. ULONG* pulInputDmaCount;
  260. ULONG* pulInputDmaAddress;
  261. ULONG* pulFifo;
  262. ULONG* pulOutputFifoCount;
  263. ULONG* pulInputFifoCount;
  264. BOOL bGdiContext;
  265. BOOL bNeedSync;
  266. BOOL bForceSwap;
  267. #if DBG
  268. ULONG ulReserved;
  269. #endif
  270. //
  271. // On NT4.0 The psoScreen is the locked screen Surf we EngLockSurface
  272. // on to in DrvEnableSurface which we EngUnlockSurface in
  273. // DrvDisableSurface. On NT5.0 this should be NULL.
  274. //
  275. SURFOBJ *psoScreen;
  276. //@@BEGIN_DDKSPLIT
  277. #if MULTITHREADED
  278. HSEMAPHORE hsemLock;
  279. ULONG ulLockCount;
  280. #endif
  281. //@@END_DDKSPLIT
  282. } PDev, *PPDev;
  283. /*****************************************************************************\
  284. * *
  285. * NT 5.0 -> NT 4.0 single binary support: *
  286. * *
  287. \*****************************************************************************/
  288. // Are we running on NT40 system
  289. extern BOOL g_bOnNT40;
  290. // Function to load thunks for new NT5.0 functionality. Called in
  291. // DrvEnableDriver and implemented in thunks.c
  292. extern BOOL bEnableThunks();
  293. #endif // __DRIVER__