ReactOS  0.4.14-dev-384-g5b37caa
vgaddi.h
Go to the documentation of this file.
1 #ifndef _VGADDI_PCH_
2 #define _VGADDI_PCH_
3 
4 #define _WINBASE_
5 #define _WINDOWS_H
6 #include <stdarg.h>
7 #include <windef.h>
8 #include <wingdi.h>
9 #include <winddi.h>
10 #include <winioctl.h>
11 #include <ntddvdeo.h>
12 #include <ioaccess.h>
13 
14 #include "vgavideo/vgavideo.h"
15 
16 #ifndef NDEBUG
17 #define DPRINT DbgPrint
18 #else
19 #define DPRINT
20 #endif
21 #define DPRINT1 DbgPrint
22 
23 /* FIXME - what a headers mess.... */
24 
25 #define DDKFASTAPI __fastcall
26 #define FASTCALL __fastcall
27 
29 
30 static __inline BOOLEAN
33 {
34  PLIST_ENTRY OldFlink;
35  PLIST_ENTRY OldBlink;
36 
37  OldFlink = Entry->Flink;
38  OldBlink = Entry->Blink;
39  OldFlink->Blink = OldBlink;
40  OldBlink->Flink = OldFlink;
41  return (OldFlink == OldBlink);
42 }
43 
44 static __inline VOID
46  IN PLIST_ENTRY ListHead,
48 {
49  PLIST_ENTRY OldFlink;
50  OldFlink = ListHead->Flink;
51  Entry->Flink = OldFlink;
52  Entry->Blink = ListHead;
53  OldFlink->Blink = Entry;
54  ListHead->Flink = Entry;
55 }
56 
57 static __inline VOID
59  IN PLIST_ENTRY ListHead)
60 {
61  ListHead->Flink = ListHead->Blink = ListHead;
62 }
63 
64 /***********************************************************/
65 
66 #define DS_SOLIDBRUSH 0x00000001
67 #define DS_GREYBRUSH 0x00000002
68 #define DS_BRUSH 0x00000004
69 #define DS_DIB 0x00000008
70 
71 #define POW2(stride) (!((stride) & ((stride)-1))) // TRUE if stride is power of 2
72 #define BROKEN_RASTERS(stride,cy) ((!(POW2(stride))) && ((stride*cy) > 0x10000))
73 
74 #define ENUM_RECT_LIMIT 50
75 
76 typedef struct _RECT_ENUM
77 {
80 } RECT_ENUM;
81 
82 // Cursor coordinates
83 typedef struct _XYPAIR
84 {
87 } XYPAIR;
88 
89 typedef struct _SAVED_SCREEN_BITS
90 {
96 
97 // Cursor states
98 #define CURSOR_COLOR 0x00000004
99 #define CURSOR_HW 0x00000010
100 #define CURSOR_HW_ACTIVE 0x00000020
101 #define CURSOR_ANIMATE 0x00000040
102 
103 typedef struct _PDEV
104 {
105  ULONG fl; // driver flags
106 
107  // Handles
109  HDEV GDIDevHandle; // engine's handle to PDEV
110  HSURF SurfHandle; // engine's handle to surface
111  PVOID AssociatedSurf; // associated surface
112 
113  // Cursor
114  XYPAIR xyHotSpot; // cursor hotspot
115 
116  // Pointer
117  PVIDEO_POINTER_ATTRIBUTES pPointerAttributes; // HW Pointer Attributes
119  ULONG XorMaskStartOffset; // Start offset of hardware pointer
120  // XOR mask relative to AND mask for
121  // passing to HW pointer
122  DWORD PointerAttributes; // Size of buffer allocated
123  DWORD flPreallocSSBBufferInUse; // True if preallocated saved screen
124  // bits buffer is in use
125  PUCHAR pjPreallocSSBBuffer; // Pointer to preallocated saved screen
126  // bits buffer, if there is one
127  ULONG ulPreallocSSBSize; // Size of preallocated saved screen
128  // bits buffer
129  VIDEO_POINTER_CAPABILITIES PointerCapabilities; // HW pointer abilities
130  PUCHAR pucDIB4ToVGAConvBuffer; // DIB4->VGA conversion table buffer
131  PUCHAR pucDIB4ToVGAConvTables; // Pointer to DIB4->VGA conversion
132 
133  // Misc
134  ULONG ModeNum; // mode index for current VGA mode
135 
136  SIZEL sizeSurf; // displayed size of the surface
137  PBYTE fbScreen; // pointer to the frame buffer
138  RECTL SavedBitsRight; // invisible part right of screen
139  RECTL SavedBitsBottom; // invisible part at the bottom of the screen
140  BOOL BitsSaved; // TRUE if bits are currently saved
141  SIZEL sizeMem; // actual size (in pixels) of video memory
142  LONG NumScansUsedByPointer; // # scans of offscreen memory used by
143 
144 } PDEV, *PPDEV;
145 
146 typedef struct {
147  RECTL BankBounds; // Pixels addressable in this bank
148  ULONG BankOffset; // Offset of bank start from bitmap start if linearly addressable
150 
151 typedef enum {
154 } BANK_JUST;
155 
156 // bank control function vector
157 //typedef VOID (*PFN_BankControl)(PDEVSURF, ULONG, BANK_JUST);
159 
160 // DEVSURF -- definition of a surface as seen and used by the various VGA
161 // drivers
162 
163 typedef struct _DEVSURF
164 {
165  IDENT ident; // Identifier for debugging ease
166  ULONG flSurf; // DS_ flags as defined below
167  BYTE Color; // Solid color surface if DS_SOLIDBRUSH
168 
169 // If DS_SOLIDBRUSH, the following fields are undefined and not guaranteed to
170 // have been allocated!
171 
172  BYTE Format; // BMF_*, BMF_PHYSDEVICE
173  BYTE jReserved1; // Reserved
174  BYTE jReserved2; // Reserved
175  PPDEV ppdev; // Pointer to associated PDEV
176  SIZEL sizeSurf; // Size of the surface
177  ULONG NextScan; // Offset from scan "n" to "n+1"
178  ULONG NextPlane; // Offset from plane "n" to "n+1"
179  PVOID Scan0; // Pointer to scan 0 of bitmap
180  // (actual address of start of bank, for banked VGA surface)
181  PVOID StartBmp; // Pointer to start of bitmap
182  PVOID Conv; // Pointer to DIB/Planer conversion buffer
183 
184 // Banking variables; used only for banked VGA surfaces
185 
187  ULONG Bank2RWSkip; // Offset from one bank index to next to make two 32K banks appear to be
188  // one seamless 64K bank
191  ULONG BitmapSize; // Length of bitmap if there were no banking, in CPU addressable bytes
192  ULONG PtrBankScan; // Last scan line in pointer work bank
193  RECTL WindowClip1; // Single-window banking clip rect
194  RECTL WindowClip2[2]; // Double-window banking clip rects for
195  // windows 0 & 1
196  ULONG WindowBank[2]; // Current banks mapped into windows
197  // 0 & 1 (used in 2 window mode only)
198  PBANK_INFO BankInfo; // Pointer to array of bank clip info
199  ULONG BankInfoLength; // Length of pbiBankInfo, in entries
200  PBANK_INFO BankInfo2RW; // Same as above, but for 2RW window
202  PFN_BankControl pfnBankControl; // Pointer to bank control function
203  PFN_BankControl pfnBankControl2Window; // Pointer to double-window bank
204  // control function
205  PVOID BitmapStart; // Single-window bitmap start pointer (adjusted as
206  // necessary to make window map in at proper offset)
207  PVOID BitmapStart2Window[2]; // Double-window window 0 and 1 bitmap start
208  PVOID BankBufferPlane0; // Pointer to temp buffer capable of
209  // storing one full bank for plane 0 for 1
210  // R/W case; capable of storing one full
211  // bank height of edge bytes for all four
212  // planes for the 1R/1W case. Also used to
213  // point to text building buffer in all
214  // cases. This is the pointer used to
215  // dealloc bank working storage for all
216  // four planes
217 
218  // The following 3 pointers used by 1 R/W banked devices
219  PVOID BankBufferPlane1; // Like above, but for plane 1
220  PVOID BankBufferPlane2; // Like above, but for plane 2
221  PVOID BankBufferPlane3; // Like above, but for plane 3
222  ULONG TempBufferSize; // Full size of temp buffer pointed to
223  // by pvBankBufferPlane0
224 
225  ULONG ajBits[1]; // Bits will start here for device bitmaps
226  PSAVED_SCREEN_BITS ssbList; // Pointer to start of linked list of
227  // saved screen bit blocks
228 } DEVSURF, *PDEVSURF;
229 
231 
232 // BMF_PHYSDEVICE format type
233 
234 #define BMF_PHYSDEVICE 0xFF
235 #define BMF_DFB 0xFE
236 
237 // Identifiers used in debugging (DEVSURF.ident)
238 
239 #define PDEV_IDENT ('V' + ('P' << 8) + ('D' << 16) + ('V' << 24))
240 #define DEVSURF_IDENT ('V' + ('S' << 8) + ('R' << 16) + ('F' << 24))
241 
242 BOOL InitVGA(PPDEV ppdev, BOOL bFirst); // screen.c: initialize VGA mode
243 BOOL DeinitVGA(PPDEV ppdev); // screen.c: Free resources allocated in InitVGA
244 
245 #define DRIVER_EXTRA_SIZE 0
246 #define ALLOC_TAG 'agvD' // Dvga tag
247 #define DLL_NAME L"vga" // DLL name in Unicode
248 
249 #define MAX_SCAN_WIDTH 2048 // pixels
250 #define DRIVER_OFFSCREEN_REFRESHED 0x04L // if not set, don't use offscreen memory
251 #define PLANAR_PELS_PER_CPU_ADDRESS 8
252 #define PACKED_PELS_PER_CPU_ADDRESS 2
253 
254 BOOL VGAtoGDI(
255  SURFOBJ *Dest, SURFOBJ *Source, SURFOBJ *Mask, XLATEOBJ *ColorTranslation,
256  RECTL *DestRect, POINTL *SourcePoint);
257 
258 VOID
260  ULONG DestY,
261  PSAVED_SCREEN_BITS Src,
262  ULONG SizeX,
263  ULONG SizeY);
264 VOID
266  ULONG SourceX,
267  ULONG SourceY,
268  ULONG SizeX,
269  ULONG SizeY);
270 VOID
274 VOID
276 
277 BOOL InitPointer(PPDEV ppdev);
279  PVIDEO_MODE_INFORMATION *modeInformation,
280  DWORD *ModeSize);
281 
283 vgaReadScan(int x, int y, int w, void *b);
284 
286 vgaWriteScan(int x, int y, int w, void *b);
287 
288 #endif /* _VGADDI_PCH_ */
ULONG XorMaskStartOffset
Definition: vgaddi.h:119
ULONG TempBufferSize
Definition: vgaddi.h:222
PVOID StartBmp
Definition: vgaddi.h:181
#define IN
Definition: typedefs.h:38
HSURF SurfHandle
Definition: vgaddi.h:110
VIDEO_POINTER_CAPABILITIES PointerCapabilities
Definition: driver.h:44
struct _POINTL * PPOINTL
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
struct _SAVED_SCREEN_BITS * PSAVED_SCREEN_BITS
struct _SAVED_SCREEN_BITS SAVED_SCREEN_BITS
BOOL VGAtoGDI(SURFOBJ *Dest, SURFOBJ *Source, SURFOBJ *Mask, XLATEOBJ *ColorTranslation, RECTL *DestRect, POINTL *SourcePoint)
struct RECTL * PRECTL
PFN pfnBankSwitchCode
Definition: vgaddi.h:189
BOOL InitPointer(PPDEV ppdev)
Definition: pointer.c:143
struct _Entry Entry
Definition: kefuncs.h:640
DWORD PointerAttributes
Definition: vgaddi.h:122
PVOID Scan0
Definition: vgaddi.h:179
struct _LIST_ENTRY * Blink
Definition: typedefs.h:120
SIZEL sizeMem
Definition: vgaddi.h:141
unsigned char * PUCHAR
Definition: retypes.h:3
BYTE jReserved2
Definition: vgaddi.h:174
VOID VGADDI_FreeSavedScreenBits(PSAVED_SCREEN_BITS SavedBits)
Definition: offscreen.c:87
ULONG WindowBank[2]
Definition: vgaddi.h:196
#define INT
Definition: polytest.cpp:20
VOID VGADDI_InitializeOffScreenMem(ULONG Start, ULONG Length)
VOID FASTCALL vgaReadScan(int x, int y, int w, void *b)
Definition: vgavideo.c:579
PVOID Conv
Definition: vgaddi.h:182
PUCHAR pucDIB4ToVGAConvBuffer
Definition: vgaddi.h:130
PVIDEO_BANK_SELECT BankSelectInfo
Definition: vgaddi.h:186
PSAVED_SCREEN_BITS ImageBehindCursor
Definition: vgaddi.h:118
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
BOOL InitVGA(PPDEV ppdev, BOOL bFirst)
Definition: screen.c:134
PSAVED_SCREEN_BITS VGADDI_AllocSavedScreenBits(ULONG Size)
Definition: offscreen.c:121
PSAVED_SCREEN_BITS ssbList
Definition: vgaddi.h:226
static ULONG SizeX
Definition: display.c:138
PFN_BankControl pfnBankControl
Definition: vgaddi.h:202
struct _PDEV * PPDEV
PVOID AssociatedSurf
Definition: vgaddi.h:111
ULONG c
Definition: vgaddi.h:78
static __inline VOID InitializeListHead(IN PLIST_ENTRY ListHead)
Definition: vgaddi.h:58
PVOID BankBufferPlane2
Definition: vgaddi.h:220
ULONG Bank2RWSkip
Definition: vgaddi.h:187
PVOID BitmapStart2Window[2]
Definition: vgaddi.h:207
LONG NumScansUsedByPointer
Definition: vgaddi.h:142
PBANK_INFO BankInfo
Definition: vgaddi.h:198
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
RECTL WindowClip2[2]
Definition: vgaddi.h:194
ULONG DbgPrint(PCCH Format,...)
Definition: debug.c:416
Definition: vgaddi.h:83
SIZEL sizeSurf
Definition: vgaddi.h:136
PUCHAR pucDIB4ToVGAConvTables
Definition: vgaddi.h:131
unsigned char BOOLEAN
USHORT y
Definition: vgaddi.h:86
BANK_JUST
Definition: vgaddi.h:151
static __inline BOOLEAN RemoveEntryList(IN PLIST_ENTRY Entry)
Definition: vgaddi.h:31
void * PVOID
Definition: retypes.h:9
PBYTE fbScreen
Definition: vgaddi.h:137
struct _PDEV PDEV
_In_ PCUNICODE_STRING _In_ PVOID Driver
Definition: cmfuncs.h:32
USHORT x
Definition: vgaddi.h:85
typedef HSURF(APIENTRY FN_DrvEnableSurface)(_In_ DHPDEV dhpdev)
PFN_BankControl pfnBankControl2Window
Definition: vgaddi.h:203
BYTE Color
Definition: vgaddi.h:167
static __inline VOID InsertHeadList(IN PLIST_ENTRY ListHead, IN PLIST_ENTRY Entry)
Definition: vgaddi.h:45
VOID(* PFN_BankControl)(PVOID, ULONG, BANK_JUST)
Definition: vgaddi.h:158
VOID VGADDI_BltFromSavedScreenBits(ULONG DestX, ULONG DestY, PSAVED_SCREEN_BITS Src, ULONG SizeX, ULONG SizeY)
ULONG BankOffset
Definition: vgaddi.h:148
struct _RECT_ENUM RECT_ENUM
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
PUCHAR pjPreallocSSBBuffer
Definition: vgaddi.h:125
CONST CHAR * PCCH
Definition: ntbasedef.h:399
HANDLE KMDriver
Definition: vgaddi.h:108
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
BOOL DeinitVGA(PPDEV ppdev)
Definition: screen.c:112
DWORD flPreallocSSBBufferInUse
Definition: vgaddi.h:123
RECTL WindowClip1
Definition: vgaddi.h:193
BOOL BitsSaved
Definition: vgaddi.h:140
unsigned long DWORD
Definition: ntddk_ex.h:95
PVOID BitmapStart
Definition: vgaddi.h:205
ULONG NextScan
Definition: vgaddi.h:177
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
struct BANK_INFO * PBANK_INFO
PVOID BankBufferPlane1
Definition: vgaddi.h:219
IDENT ident
Definition: vgaddi.h:165
Definition: partlist.h:33
ULONG ajBits[1]
Definition: vgaddi.h:225
Definition: framebuf.h:33
struct _DEVSURF * PDEVSURF
BYTE Format
Definition: vgaddi.h:172
#define VOID
Definition: acefi.h:82
#define FASTCALL
Definition: vgaddi.h:26
ULONG fl
Definition: vgaddi.h:105
unsigned char BYTE
Definition: mem.h:68
VIDEO_BANK_TYPE BankingType
Definition: vgaddi.h:190
ULONG ulPreallocSSBSize
Definition: vgaddi.h:127
PPDEV ppdev
Definition: vgaddi.h:175
struct _XYPAIR XYPAIR
Definition: typedefs.h:117
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
ULONG NextPlane
Definition: vgaddi.h:178
#define ENUM_RECT_LIMIT
Definition: vgaddi.h:74
PVOID BankBufferPlane3
Definition: vgaddi.h:221
ULONG BitmapSize
Definition: vgaddi.h:191
RECTL arcl[ENUM_RECT_LIMIT]
Definition: vgaddi.h:79
ULONG PtrBankScan
Definition: vgaddi.h:192
BOOLEAN(* PFN)(PARGS)
Definition: parse.h:47
RECTL BankBounds
Definition: vgaddi.h:147
DWORD getAvailableModes(HANDLE Driver, PVIDEO_MODE_INFORMATION *modeInformation, DWORD *ModeSize)
Definition: screen.c:507
RECTL SavedBitsBottom
Definition: vgaddi.h:139
PVIDEO_POINTER_ATTRIBUTES pPointerAttributes
Definition: driver.h:45
HDEV GDIDevHandle
Definition: vgaddi.h:109
unsigned short USHORT
Definition: pedump.c:61
SIZEL sizeSurf
Definition: vgaddi.h:176
ULONG ModeNum
Definition: vgaddi.h:134
LIST_ENTRY ListEntry
Definition: vgaddi.h:94
ULONG flSurf
Definition: vgaddi.h:166
ULONG IDENT
Definition: winddi.h:119
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
VOID VGADDI_BltToSavedScreenBits(PSAVED_SCREEN_BITS Dest, ULONG SourceX, ULONG SourceY, ULONG SizeX, ULONG SizeY)
PVOID BankBufferPlane0
Definition: vgaddi.h:208
ULONG BankInfo2RWLength
Definition: vgaddi.h:201
struct _DEVSURF DEVSURF
unsigned int ULONG
Definition: retypes.h:1
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
VOID FASTCALL vgaWriteScan(int x, int y, int w, void *b)
Definition: vgavideo.c:655
BYTE jReserved1
Definition: vgaddi.h:173
XYPAIR xyHotSpot
Definition: vgaddi.h:114
ULONG BankInfoLength
Definition: vgaddi.h:199
VOID(* PFN_ScreenToScreenBlt)(PDEVSURF, PRECTL, PPOINTL, INT)
Definition: vgaddi.h:230
BYTE * PBYTE
Definition: pedump.c:66
base of all file and directory entries
Definition: entries.h:82
RECTL SavedBitsRight
Definition: vgaddi.h:138
static ULONG SizeY
Definition: display.c:139
enum _VIDEO_BANK_TYPE VIDEO_BANK_TYPE
PBANK_INFO BankInfo2RW
Definition: vgaddi.h:200