2243
|
1 /*
|
|
2 VESA VBE 2.0 compatible structures and definitions.
|
|
3 You can redistribute this file under terms and conditions
|
|
4 GNU General Public licence v2.
|
|
5 Written by Nick Kurshev <nickols_k@mail.ru>
|
|
6 */
|
|
7 #ifndef __VESA_VBELIB_INCLUDED__
|
|
8 #define __VESA_VBELIB_INCLUDED__ 1
|
|
9
|
|
10 /* Note: every pointer within structures is 32-bit protected mode pointer.
|
|
11 So you don't need to convert it from real mode. */
|
|
12
|
|
13 typedef struct tagFarPtr
|
|
14 {
|
|
15 unsigned short off;
|
|
16 unsigned short seg;
|
|
17 }FarPtr;
|
|
18
|
|
19 struct VbeInfoBlock {
|
|
20 char VESASignature[4]; /* 'VESA' 4 byte signature */
|
|
21 short VESAVersion; /* VBE version number */
|
|
22 char * OemStringPtr; /* Pointer to OEM string */
|
|
23 long Capabilities; /* Capabilities of video card */
|
|
24 unsigned short* VideoModePtr; /* Pointer to supported modes */
|
|
25 short TotalMemory; /* Number of 64kb memory blocks */
|
|
26 /* VBE 3.0 and above */
|
|
27 short OemSoftwareRev;
|
|
28 char * OemVendorNamePtr;
|
|
29 char * OemProductNamePtr;
|
|
30 char * OemProductRevPtr;
|
|
31 char reserved[222];
|
|
32 char OemData[256]; /* Pad to 512 byte block size */
|
|
33 }__attribute__ ((packed));
|
|
34
|
|
35 static inline FarPtr VirtToPhys(void *ptr)
|
|
36 {
|
|
37 FarPtr retval;
|
|
38 retval.seg = ((unsigned long)ptr) >> 4;
|
|
39 retval.off = ((unsigned long)ptr) & 0x0f;
|
|
40 return retval;
|
|
41 }
|
|
42
|
|
43 static inline unsigned short VirtToPhysSeg(void *ptr)
|
|
44 {
|
|
45 return ((unsigned long)ptr) >> 4;
|
|
46 }
|
|
47
|
|
48 static inline unsigned short VirtToPhysOff(void *ptr)
|
|
49 {
|
|
50 return ((unsigned long)ptr) & 0x0f;
|
|
51 }
|
|
52
|
|
53 static inline void * PhysToVirt(FarPtr ptr)
|
|
54 {
|
|
55 return (void *)((ptr.seg << 4) | ptr.off);
|
|
56 }
|
|
57
|
|
58 static inline void * PhysToVirtSO(unsigned short seg,unsigned short off)
|
|
59 {
|
|
60 return (void *)((seg << 4) | off);
|
|
61 }
|
|
62
|
|
63 #define MODE_ATTR_MODE_SUPPORTED (1 << 0)
|
|
64 #define MODE_ATTR_TTY (1 << 2)
|
|
65 #define MODE_ATTR_COLOR (1 << 3)
|
|
66 #define MODE_ATTR_GRAPHICS (1 << 4)
|
|
67 #define MODE_ATTR_NOT_VGA (1 << 5)
|
|
68 #define MODE_ATTR_NOT_WINDOWED (1 << 6)
|
|
69 #define MODE_ATTR_LINEAR (1 << 7)
|
|
70 #define MODE_ATTR_DOUBLESCAN (1 << 8)
|
|
71 #define MODE_ATTR_INTERLACE (1 << 9)
|
|
72 #define MODE_ATTR_TRIPLEBUFFER (1 << 10)
|
|
73 #define MODE_ATTR_STEREOSCOPIC (1 << 11)
|
|
74 #define MODE_ATTR_DUALDISPLAY (1 << 12)
|
|
75
|
|
76 #define MODE_WIN_RELOCATABLE (1 << 0)
|
|
77 #define MODE_WIN_READABLE (1 << 1)
|
|
78 #define MODE_WIN_WRITEABLE (1 << 2)
|
|
79
|
|
80 /* SuperVGA mode information block */
|
|
81 struct VesaModeInfoBlock {
|
|
82 unsigned short ModeAttributes; /* Mode attributes */
|
|
83 unsigned char WinAAttributes; /* Window A attributes */
|
|
84 unsigned char WinBAttributes; /* Window B attributes */
|
|
85 unsigned short WinGranularity; /* Window granularity in k */
|
|
86 unsigned short WinSize; /* Window size in k */
|
|
87 unsigned short WinASegment; /* Window A segment */
|
|
88 unsigned short WinBSegment; /* Window B segment */
|
|
89 FarPtr WinFuncPtr; /* 16-bit far pointer to window function */
|
|
90 unsigned short BytesPerScanLine; /* Bytes per scanline */
|
|
91 /* VBE 1.2 and above */
|
|
92 unsigned short XResolution; /* Horizontal resolution */
|
|
93 unsigned short YResolution; /* Vertical resolution */
|
|
94 unsigned char XCharSize; /* Character cell width */
|
|
95 unsigned char YCharSize; /* Character cell height */
|
|
96 unsigned char NumberOfPlanes; /* Number of memory planes */
|
|
97 unsigned char BitsPerPixel; /* Bits per pixel */
|
|
98 unsigned char NumberOfBanks; /* Number of CGA style banks */
|
|
99 unsigned char MemoryModel; /* Memory model type */
|
|
100 unsigned char BankSize; /* Size of CGA style banks */
|
|
101 unsigned char NumberOfImagePages; /* Number of images pages */
|
|
102 unsigned char res1; /* Reserved */
|
|
103 /* Direct Color fields (required for direct/6 and YUV/7 memory models) */
|
|
104 unsigned char RedMaskSize; /* Size of direct color red mask */
|
|
105 unsigned char RedFieldPosition; /* Bit posn of lsb of red mask */
|
|
106 unsigned char GreenMaskSize; /* Size of direct color green mask */
|
|
107 unsigned char GreenFieldPosition; /* Bit posn of lsb of green mask */
|
|
108 unsigned char BlueMaskSize; /* Size of direct color blue mask */
|
|
109 unsigned char BlueFieldPosition; /* Bit posn of lsb of blue mask */
|
|
110 unsigned char RsvdMaskSize; /* Size of direct color res mask */
|
|
111 unsigned char RsvdFieldPosition; /* Bit posn of lsb of res mask */
|
|
112 unsigned char DirectColorModeInfo; /* Direct color mode attributes */
|
|
113 unsigned char res2[216]; /* Pad to 256 byte block size */
|
|
114 /* VBE 2.0 and above */
|
|
115 unsigned long PhysBasePtr; /* physical address for flat memory frame buffer. (Should be converted to linear before using) */
|
|
116 unsigned short res3[3]; /* Reserved - always set to 0 */
|
|
117 /* VBE 3.0 and above */
|
|
118 unsigned short LinBytesPerScanLine; /* bytes per scan line for linear modes */
|
|
119 unsigned char BnkNumberOfImagePages;/* number of images for banked modes */
|
|
120 unsigned char LinNumberOfImagePages;/* number of images for linear modes */
|
|
121 unsigned char LinRedMaskSize; /* size of direct color red mask (linear modes) */
|
|
122 unsigned char LinRedFieldPosition; /* bit position of lsb of red mask (linear modes) */
|
|
123 unsigned char LinGreenMaskSize; /* size of direct color green mask (linear modes) */
|
|
124 unsigned char LinGreenFieldPosition;/* bit position of lsb of green mask (linear modes) */
|
|
125 unsigned char LinBlueMaskSize; /* size of direct color blue mask (linear modes) */
|
|
126 unsigned char LinBlueFieldPosition;/* bit position of lsb of blue mask (linear modes) */
|
|
127 unsigned char LinRsvdMaskSize; /* size of direct color reserved mask (linear modes) */
|
|
128 unsigned char LinRsvdFieldPosition;/* bit position of lsb of reserved mask (linear modes) */
|
|
129 unsigned long MaxPixelClock; /* maximum pixel clock (in Hz) for graphics mode */
|
|
130 char res4[189]; /* remainder of ModeInfoBlock */
|
|
131 }__attribute__ ((packed));
|
|
132
|
|
133 typedef enum {
|
|
134 memText= 0,
|
|
135 memCGA = 1,
|
|
136 memHercules = 2,
|
|
137 memPL = 3, /* Planar memory model */
|
|
138 memPK = 4, /* Packed pixel memory model */
|
|
139 mem256 = 5,
|
|
140 memRGB = 6, /* Direct color RGB memory model */
|
|
141 memYUV = 7, /* Direct color YUV memory model */
|
|
142 } memModels;
|
|
143
|
|
144 struct VesaCRTCInfoBlock {
|
|
145 unsigned short hTotal; /* Horizontal total in pixels */
|
|
146 unsigned short hSyncStart; /* Horizontal sync start in pixels */
|
|
147 unsigned short hSyncEnd; /* Horizontal sync end in pixels */
|
|
148 unsigned short vTotal; /* Vertical total in lines */
|
|
149 unsigned short vSyncStart; /* Vertical sync start in lines */
|
|
150 unsigned short vSyncEnd; /* Vertical sync end in lines */
|
|
151 unsigned char Flags; /* Flags (Interlaced, Double Scan etc) */
|
|
152 unsigned long PixelClock; /* Pixel clock in units of Hz */
|
|
153 unsigned short RefreshRate;/* Refresh rate in units of 0.01 Hz*/
|
|
154 unsigned char Reserved[40];/* remainder of CRTCInfoBlock*/
|
|
155 }__attribute__ ((packed));
|
|
156
|
|
157 #define VESA_CRTC_DOUBLESCAN 0x01
|
|
158 #define VESA_CRTC_INTERLACED 0x02
|
|
159 #define VESA_CRTC_HSYNC_NEG 0x04
|
|
160 #define VESA_CRTC_VSYNC_NEG 0x08
|
|
161
|
|
162 #define VESA_MODE_CRTC_REFRESH (1 << 11)
|
|
163 #define VESA_MODE_USE_LINEAR (1 << 14)
|
|
164 #define VESA_MODE_NOT_CLEAR (1 << 15)
|
|
165
|
|
166 /* This will contain accesible 32-bit protmode pointers */
|
|
167 struct VesaProtModeInterface
|
|
168 {
|
|
169 void (*SetWindowCall)(void);
|
|
170 void (*SetDisplayStart)(void);
|
|
171 void (*SetPaletteData)(void);
|
|
172 unsigned short * iopl_ports;
|
|
173 }__attribute__ ((packed));
|
|
174
|
|
175 /*
|
|
176 All functions below return:
|
|
177 0 if succesful
|
|
178 0xffff if vm86 syscall error occurs
|
|
179 0x4fxx if VESA error occurs
|
|
180 */
|
|
181
|
|
182 #define VBE_OK 0
|
|
183 #define VBE_VM86_FAIL -1
|
|
184 #define VBE_OUT_OF_DOS_MEM -2
|
|
185 #define VBE_OUT_OF_MEM -3
|
|
186 #define VBE_VESA_ERROR_MASK 0x4f00
|
|
187 #define VBE_VESA_ERRCODE_MASK 0xff
|
|
188
|
|
189 extern int vbeInit( void );
|
|
190 extern int vbeDetroy( void );
|
|
191
|
|
192 extern int vbeGetControllerInfo(struct VbeInfoBlock *);
|
|
193 extern int vbeGetModeInfo(unsigned mode,struct VesaModeInfoBlock *);
|
|
194 extern int vbeSetMode(unsigned mode,struct VesaCRTCInfoBlock *);
|
|
195 extern int vbeGetMode(unsigned *mode);
|
|
196 extern int vbeSaveState(void **data); /* note never copy this data */
|
|
197 extern int vbeRestoreState(void *data);
|
|
198 extern int vbeGetWindow(unsigned *win_num); /* win_A=0 or win_B=1 */
|
|
199 extern int vbeSetWindow(unsigned win_num,unsigned win_gran);
|
|
200 /*
|
|
201 Func 0x06:
|
|
202 Support of logical scan line length is not implemented.
|
|
203 We assume that logical scan line length == physical scan line length.
|
|
204 (Logical display memory == displayed area).
|
|
205 */
|
|
206 /*
|
|
207 Func 0x07:
|
|
208 Support of disply start is not implemented.
|
|
209 We assume that display start always == 0, 0.
|
|
210 */
|
|
211 /*
|
|
212 Func 0x08-0x09:
|
|
213 Support of palette currently is not implemented.
|
|
214 */
|
|
215 extern int vbeGetProtModeInfo(struct VesaProtModeInterface *);
|
|
216 #endif |