|
|
1.1 root 1: /******************************Module*Header*******************************\
2: * Module Name: driver.h
3: *
4: * driver prototypes
5: *
6: * Copyright (c) 1992 Microsoft Corporation
7: \**************************************************************************/
8:
9: #include "stddef.h"
10: #include "windows.h"
11: #include "winddi.h"
12: #include <devioctl.h>
13: #include <ntddvdeo.h>
14:
15: #include "debug.h"
16:
17: #include "brush.h"
18: /* gflDrv */
19:
20: #define DRV_ENABLED_ONCE 0x00000001
21: #define DRV_ENABLED_PDEV 0x00000002
22:
23: // # of bytes at end of display memory required for the pointer work and save
24: // areas
25:
26: //BUGBUG not really sure about these
27: #define POINTER_WORK_AREA_SIZE 1024
28: #define POINTER_SAVE_AREA_SIZE 256
29:
30: #define MIN_TEMP_BUFFER_SIZE 0x4000 // Minimum size of buffer used to
31: // build text (may be bigger because
32: // it's shared with blt buffer)
33:
34: // Space required for working storage when working with banking on adapters
35: // that support only one window, with no independent read and write bank
36: // selection. The largest supported bank is 64K; this constant provides for
37: // storing four 64K planes.
38:
39: #define BANK_BUFFER_PLANE_SIZE 0x10000
40: #define BANK_BUFFER_SIZE_1RW (((ULONG)BANK_BUFFER_PLANE_SIZE)*4)
41: #define PLANE_0_OFFSET 0
42: #define PLANE_1_OFFSET BANK_BUFFER_PLANE_SIZE
43: #define PLANE_2_OFFSET (BANK_BUFFER_PLANE_SIZE*2)
44: #define PLANE_3_OFFSET (BANK_BUFFER_PLANE_SIZE*3)
45:
46: // Space required for working storage when working with banking on adapters
47: // that support one readable window and one writable window, but not two
48: // independently read/write addressable windows. This is space for storing
49: // one bank's worth of edge words for each of four planes, or for the text
50: // building buffer, whichever is larger.
51:
52: #define BANK_MAX_HEIGHT 512 // tallest supported bank
53: #define BANK_BUFFER_SIZE_1R1W (max((((ULONG)BANK_MAX_HEIGHT)*4*2), \
54: MIN_TEMP_BUFFER_SIZE))
55:
56: // On a 2RW or unbanked adapter, just make space for the text building buffer.
57: #define BANK_BUFFER_SIZE_UNBANKED MIN_TEMP_BUFFER_SIZE
58: #define BANK_BUFFER_SIZE_2RW MIN_TEMP_BUFFER_SIZE
59:
60: // Amount of space to reserve for saved screen bits buffer preallocated at
61: // EnablePDEV time, so we usually won't have to allocate and deallocate the
62: // memory. 36K should be big enough for most menus (not 32K because the big
63: // system menu on consoles is just slightly larger than 32K).
64: #define PREALLOC_SSB_SIZE 0x10000
65:
66: /* This device can have only one PDEV */
67:
68: #define DRV_ONE_PDEV 1
69:
70:
71: //
72: // Sizes assumed for 1-window and 2 RW-window banks.
73: //
74: #define BANK_SIZE_1_WINDOW 0x10000
75: #define BANK_SIZE_2RW_WINDOW 0x08000
76:
77: //
78: // The following value allows us to set rounding for cursor exclusion.
79: //
80:
81: #define POINTER_ROUNDING_SIZE 8
82:
83: #define POINTER_ROUND (POINTER_ROUNDING_SIZE - 1)
84: #define POINTER_MASK (-POINTER_ROUNDING_SIZE)
85:
86: //
87: // Determines the size of the DriverExtra information in the DEVMODE
88: // structure passed to and from the display driver.
89: //
90:
91: #define DRIVER_EXTRA_SIZE 0
92:
93: //
94: // Miscellaneous driver flags in pdev.fl
95: // Must be mirrored in i386\driver.inc
96: //
97:
98: #define DRIVER_USE_OFFSCREEN 0x02L // if not set, don't use offscreen memory
99:
100: //
101: // General Rectangle Enumeration structure
102: //
103:
104: #define ENUM_RECT_LIMIT 50
105:
106: typedef struct _RECT_ENUM
107: {
108: ULONG c;
109: RECTL arcl[ENUM_RECT_LIMIT];
110: } RECT_ENUM;
111:
112:
113: /**************************************************************************\
114: *
115: * Descriptor for a saved screen bits block
116: *
117: \**************************************************************************/
118:
119: typedef struct _SAVED_SCREEN_BITS
120: {
121: BOOL bFlags;
122: PBYTE pjBuffer; // pointer to save buffer start
123: ULONG ulSize; // size of save buffer (per plane; display memory only)
124: ULONG ulSaveWidthInBytes; // # of bytes across save area (including
125: // partial edge bytes, if any)
126: ULONG ulDelta; // # of bytes from end of one saved scan's saved bits to
127: // start of next (system memory only)
128: PVOID pvNextSSB; // pointer to next saved screen bits block
129: // for system memory blocks, saved bits start immediately
130: // after this structure
131: } SAVED_SCREEN_BITS, *PSAVED_SCREEN_BITS;
132: #define SSB_IN_ADAPTER_MEMORY 0x01 // true if block saved in adapter mem
133: #define SSB_IN_PREALLOC_BUFFER 0x02 // true if block saved in preallocated
134: // buffer
135:
136: /**************************************************************************\
137: *
138: * Bank clipping info
139: *
140: \**************************************************************************/
141:
142: typedef struct {
143: RECTL rclBankBounds; // describes pixels addressable in this bank
144: ULONG ulBankOffset; // offset of bank start from bitmap start, if
145: // the bitmap were linearly addressable
146: } BANK_INFO, *PBANK_INFO;
147:
148:
149: /**************************************************************************\
150: *
151: * Bank control function vector
152: *
153: \**************************************************************************/
154:
155: typedef VOID (*PFN_BankControl)(PDEVSURF, ULONG, BANK_JUST);
156:
157:
158: /**************************************************************************\
159: *
160: * Physical device description block
161: *
162: \**************************************************************************/
163:
164: #define CURSOR_DOWN 0x00000001
165: #define CURSOR_COLOR 0x00000004
166: #define CURSOR_HW 0x00000010
167: #define CURSOR_HW_ACTIVE 0x00000020
168: #define CURSOR_ANIMATE 0x00000040
169:
170: // The XYPAIR structure is used to allow ATOMIC read/write of the cursor
171: // position. NEVER, NEVER, NEVER get or set the cursor position without
172: // doing this. There is no semaphore protection of this data structure,
173: // nor will there ever be any. [donalds]
174:
175: typedef struct _XYPAIR
176: {
177: USHORT x;
178: USHORT y;
179: } XYPAIR;
180:
181: // Must be mirrored in i386\strucs.inc
182:
183: typedef struct _PDEV
184: {
185: FLONG fl; // Driver flags (DRIVER_xxx)
186: IDENT ident; // Identifier
187: HANDLE hDriver; // Handle to the miniport
188: HDEV hdevEng; // Engine's handle to PDEV
189: HSURF hsurfEng; // Engine's handle to surface
190: PVOID pdsurf; // Associated surface
191: SIZEL sizlSurf; // Displayed size of the surface
192: DWORD ulIs386; // 1 if 386, 0 if 486 or higher
193: PBYTE pjScreen; // Pointer to the frame buffer base
194: XYPAIR xyCursor; // Where the cursor should be
195: POINTL ptlExtent; // Cursor extent
196: ULONG cExtent; // Effective cursor extent.
197: XYPAIR xyHotSpot; // Cursor hot spot
198: FLONG flCursor; // Cursor status
199: DEVINFO devinfo; // Device info
200: HBITMAP ahbmPat[HS_DDI_MAX]; // Engine handles to standard patterns
201: GDIINFO GdiInfo; // Device capabilities
202: ULONG ulModeNum; // Mode index for current VGA mode
203: PVIDEO_POINTER_ATTRIBUTES pPointerAttributes; // HW Pointer Attributes
204: ULONG XorMaskStartOffset; // Start offset of hardware pointer
205: // XOR mask relative to AND mask for
206: // passing to HW pointer
207: DWORD cjPointerAttributes; // Size of buffer allocated
208: DWORD flPreallocSSBBufferInUse; // True if preallocated saved screen
209: // bits buffer is in use
210: PUCHAR pjPreallocSSBBuffer; // Pointer to preallocated saved screen
211: // bits buffer, if there is one
212: ULONG ulPreallocSSBSize; // Size of preallocated saved screen
213: // bits buffer
214: VIDEO_POINTER_CAPABILITIES PointerCapabilities; // HW pointer abilities
215: PUCHAR pucDIB4ToVGAConvBuffer; // Pointer to DIB4->VGA conversion
216: // table buffer
217: PUCHAR pucDIB4ToVGAConvTables; // Pointer to DIB4->VGA conversion
218: // table start in buffer (must be on a
219: // 256-byte boundary)
220: } PDEV, *PPDEV;
221:
222:
223: /**************************************************************************\
224: *
225: * Specifies desired justification for requestion scan line within bank window
226: *
227: \**************************************************************************/
228:
229: typedef enum {
230: JustifyTop = 0,
231: JustifyBottom,
232: } BANK_JUST;
233:
234:
235: /**************************************************************************\
236: *
237: * Specifies which window is to be mapped by two-window bank handler.
238: *
239: \**************************************************************************/
240:
241: typedef enum {
242: MapSourceBank = 0,
243: MapDestBank,
244: } BANK_JUST;
245:
246:
247: /**************************************************************************\
248: *
249: * Definition of a surface as seen and used by the various VGA drivers
250: *
251: \**************************************************************************/
252:
253: // Must be mirrored in i386\strucs.inc
254:
255: typedef struct _DEVSURF /* dsurf */
256: {
257: IDENT ident; // Identifier for debugging ease
258: ULONG flSurf; // DS_ flags as defined below
259: BYTE iColor; // Solid color surface if DS_SOLIDBRUSH
260:
261: // If DS_SOLIDBRUSH, the following fields are undefined and not guaranteed to
262: // have been allocated!
263:
264: BYTE iFormat; // BMF_*, BMF_PHYSDEVICE
265: BYTE jReserved1; // Reserved
266: BYTE jReserved2; // Reserved
267: PPDEV ppdev; // Pointer to associated PDEV
268: SIZEL sizlSurf; // Size of the surface
269: SIZE_T lNextScan; // Offset from scan "n" to "n+1"
270: SIZE_T lNextPlane; // Offset from plane "n" to "n+1"
271: PVOID pvScan0; // Pointer to scan 0 of bitmap
272: // (actual address of start of bank,
273: // for banked VGA surface)
274: PVOID pvStart; // Pointer to start of bitmap
275: PVOID pvConv; // Pointer to DIB/Planer conversion buffer
276: // Banking variables; used only for
277: // banked VGA surfaces
278: PVIDEO_BANK_SELECT pBankSelectInfo; // Pointer to bank select info
279: // returned by miniport
280: ULONG ulBank2RWSkip; // Offset from one bank index to next
281: // to make two 32K banks appear to be
282: // one seamless 64K bank
283: PFN pfnBankSwitchCode; // Pointer to bank switch code
284: VIDEO_BANK_TYPE vbtBankingType; // Type of banking
285: ULONG ulBitmapSize; // Length of bitmap if there were no
286: // banking, in CPU addressable bytes
287: ULONG ulPtrBankScan; // Last scan line in pointer work bank
288: RECTL rcl1WindowClip; // Single-window banking clip rect
289: RECTL rcl2WindowClip[2]; // Double-window banking clip rects for
290: // windows 0 & 1
291: ULONG ulWindowBank[2]; // Current banks mapped into windows
292: // 0 & 1 (used in 2 window mode only)
293: PBANK_INFO pbiBankInfo; // Pointer to array of bank clip info
294: ULONG ulBankInfoLength; // Length of pbiBankInfo, in entries
295: PBANK_INFO pbiBankInfo2RW; // Same as above, but for 2RW window
296: ULONG ulBankInfo2RWLength; // case
297: PFN_BankControl pfnBankControl; // Pointer to bank control function
298: PFN_BankControl pfnBankControl2Window; // Pointer to double-window bank
299: // control function
300: PVOID pvBitmapStart; // Single-window bitmap start pointer
301: // (adjusted as necessary to make
302: // window map in at proper offset)
303: PVOID pvBitmapStart2Window[2]; // Double-window window 0 and 1 bitmap
304: // start
305: PVOID pvBankBufferPlane0; // Pointer to temp buffer capable of
306: // storing one full bank for plane 0
307: // for 1 R/W case; capable of storing
308: // one full bank height of edge bytes
309: // for all four planes for the 1R/1W
310: // case. Also used to point to text
311: // building buffer in all cases
312: // This is the pointer used to dealloc
313: // bank working storage for all four
314: // planes
315: // The following 3 pointers used by
316: // 1 R/W banked devices
317: PVOID pvBankBufferPlane1; // Like above, but for plane 1
318: PVOID pvBankBufferPlane2; // Like above, but for plane 2
319: PVOID pvBankBufferPlane3; // Like above, but for plane 3
320: ULONG ulTempBufferSize; // Full size of temp buffer pointed to
321: // by pvBankBufferPlane0
322:
323: ULONG ajBits[1]; // Bits will start here for device bitmaps
324: PSAVED_SCREEN_BITS ssbList; // Pointer to start of linked list of
325: // saved screen bit blocks
326: PBYTE pjAdapterHeapStart; // First byte of display memory
327: // available for temporary storage
328: PBYTE pjAdapterHeapEnd; // Last byte of display memory
329: // available for temporary storage
330: PBYTE pjAdapterHeapTop; // Last byte of display memory
331: // currently available for temporary
332: // storage
333: } DEVSURF, * PDEVSURF;
334:
335:
336: // Identifier stored in ds.ident for debugging
337:
338: #define PDEV_IDENT ('V' + ('P' << 8) + ('D' << 16) + ('V' << 24))
339: #define DEVSURF_IDENT ('V' + ('S' << 8) + ('R' << 16) + ('F' << 24))
340:
341:
342: // Definition of the BMF_PHYSDEVICE format type
343:
344: #define BMF_PHYSDEVICE 0xFF
345:
346:
347: // Flags for flSurf
348:
349: #define DS_SOLIDBRUSH 0x00000001 // Surface is a solid color representing a brush
350: #define DS_GREYBRUSH 0x00000002 // Surface is a grey color representing a brush
351: #define DS_BRUSH 0x00000004 // Surface is a brush
352: #define DS_DIB 0x00000008 // Surface is supporting an Engine DIB
353:
354: /**************************************************************************\
355: *
356: * Function prototypes shared by all C files.
357: *
358: \**************************************************************************/
359:
360:
361: VOID vInitRegs(void);
362: BOOL bInitVGA(PPDEV, BOOL);
363: BOOL bInitPDEV(PPDEV, DEVMODEW *, GDIINFO *, DEVINFO *);
364:
365: DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION *, DWORD *);
366: typedef VOID (*PFN_ScreenToScreenBlt)(PDEVSURF, PRECTL, PPOINTL, INT);
367:
368: VOID vDIB2VGA( DEVSURF * pdsurfDst, DEVSURF * pdsurfSrc,
369: RECTL * prclDst, POINTL * pptlSrc, UCHAR * pucConv);
370: BOOL DrvIntersectRect(PRECTL prcDst, PRECTL prcSrc1, PRECTL prcSrc2);
371: FLONG flClipRect(PRECTL,PRECTL,PRECTL);
372: VOID vMonoPatBlt(PDEVSURF,ULONG,PRECTL,MIX, BRUSHINST *,PPOINTL);
373: VOID vClrPatBlt(PDEVSURF,ULONG,PRECTL,MIX, BRUSHINST *,PPOINTL);
374: VOID vTrgBlt(PDEVSURF,ULONG,PRECTL,MIX,ULONG);
375: VOID vAlignedSrcCopy(PDEVSURF,PRECTL,PPOINTL,INT);
376: VOID vNonAlignedSrcCopy(PDEVSURF,PRECTL,PPOINTL,INT);
377: VOID vDibToDev(PDEVSURF pdsurf, SURFOBJ *pso, PVOID pvConv);
378: VOID vConvertVGA2DIB(PDEVSURF, LONG, LONG, VOID *, LONG, LONG, ULONG, ULONG,
379: LONG, ULONG, ULONG *);
380: BOOL SimCopyBits(SURFOBJ *psoTrg, SURFOBJ *psoSrc, CLIPOBJ *pco,
381: XLATEOBJ *pxlo, PRECTL prclTrg, PPOINTL pptlSrc);
382: VOID vConvertVGA2DIB(PDEVSURF, LONG, LONG, VOID *, LONG, LONG, ULONG, ULONG, LONG,
383: ULONG, ULONG *);
384: BOOL bRleBlt(SURFOBJ *,SURFOBJ *, CLIPOBJ *, XLATEOBJ *, RECTL *, POINTL *);
385: VOID vSetDIB4ToVGATables(UCHAR *);
386: BOOL DrvFillPath (SURFOBJ *pso, PATHOBJ *ppo, CLIPOBJ *pco, BRUSHOBJ *pbo,
387: POINTL *pptlBrush, MIX mix, FLONG flOptions);
388: VOID vClearMemDword(ULONG * pulBuffer, ULONG ulDwordCount);
389: VOID vForceBank0(PPDEV ppdev);
390:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.