1 | #ifndef vbe_h_included
|
---|
2 | #define vbe_h_included
|
---|
3 |
|
---|
4 | #include "vgabios.h"
|
---|
5 |
|
---|
6 | // DISPI helper function
|
---|
7 | void dispi_set_enable(enable);
|
---|
8 |
|
---|
9 | /** VBE int10 API
|
---|
10 | *
|
---|
11 | * See the function descriptions in vbe.c for more information
|
---|
12 | */
|
---|
13 | Boolean vbe_has_vbe_display();
|
---|
14 | void vbe_biosfn_return_controller_information(AX, ES, DI);
|
---|
15 | void vbe_biosfn_return_mode_information(AX, CX, ES, DI);
|
---|
16 | void vbe_biosfn_set_mode(AX, BX, ES, DI);
|
---|
17 | void vbe_biosfn_save_restore_state(AX, DL, CX, ES, BX);
|
---|
18 | void vbe_biosfn_set_get_palette_data(AX);
|
---|
19 | void vbe_biosfn_return_protected_mode_interface(AX);
|
---|
20 |
|
---|
21 | // The official VBE Information Block
|
---|
22 | typedef struct VbeInfoBlock
|
---|
23 | {
|
---|
24 | Bit8u VbeSignature[4];
|
---|
25 | Bit16u VbeVersion;
|
---|
26 | Bit16u OemStringPtr_Off;
|
---|
27 | Bit16u OemStringPtr_Seg;
|
---|
28 | Bit8u Capabilities[4];
|
---|
29 | Bit16u VideoModePtr_Off;
|
---|
30 | Bit16u VideoModePtr_Seg;
|
---|
31 | Bit16u TotalMemory;
|
---|
32 | Bit16u OemSoftwareRev;
|
---|
33 | Bit16u OemVendorNamePtr_Off;
|
---|
34 | Bit16u OemVendorNamePtr_Seg;
|
---|
35 | Bit16u OemProductNamePtr_Off;
|
---|
36 | Bit16u OemProductNamePtr_Seg;
|
---|
37 | Bit16u OemProductRevPtr_Off;
|
---|
38 | Bit16u OemProductRevPtr_Seg;
|
---|
39 | Bit16u Reserved[111]; // used for dynamicly generated mode list
|
---|
40 | Bit8u OemData[256];
|
---|
41 | } VbeInfoBlock;
|
---|
42 |
|
---|
43 |
|
---|
44 | // This one is for compactly storing a static list of mode info blocks
|
---|
45 | // this saves us 189 bytes per block
|
---|
46 | typedef struct ModeInfoBlockCompact
|
---|
47 | {
|
---|
48 | // Mandatory information for all VBE revisions
|
---|
49 | Bit16u ModeAttributes;
|
---|
50 | Bit8u WinAAttributes;
|
---|
51 | Bit8u WinBAttributes;
|
---|
52 | Bit16u WinGranularity;
|
---|
53 | Bit16u WinSize;
|
---|
54 | Bit16u WinASegment;
|
---|
55 | Bit16u WinBSegment;
|
---|
56 | Bit32u WinFuncPtr;
|
---|
57 | Bit16u BytesPerScanLine;
|
---|
58 | // Mandatory information for VBE 1.2 and above
|
---|
59 | Bit16u XResolution;
|
---|
60 | Bit16u YResolution;
|
---|
61 | Bit8u XCharSize;
|
---|
62 | Bit8u YCharSize;
|
---|
63 | Bit8u NumberOfPlanes;
|
---|
64 | Bit8u BitsPerPixel;
|
---|
65 | Bit8u NumberOfBanks;
|
---|
66 | Bit8u MemoryModel;
|
---|
67 | Bit8u BankSize;
|
---|
68 | Bit8u NumberOfImagePages;
|
---|
69 | Bit8u Reserved_page;
|
---|
70 | // Direct Color fields (required for direct/6 and YUV/7 memory models)
|
---|
71 | Bit8u RedMaskSize;
|
---|
72 | Bit8u RedFieldPosition;
|
---|
73 | Bit8u GreenMaskSize;
|
---|
74 | Bit8u GreenFieldPosition;
|
---|
75 | Bit8u BlueMaskSize;
|
---|
76 | Bit8u BlueFieldPosition;
|
---|
77 | Bit8u RsvdMaskSize;
|
---|
78 | Bit8u RsvdFieldPosition;
|
---|
79 | Bit8u DirectColorModeInfo;
|
---|
80 | // Mandatory information for VBE 2.0 and above
|
---|
81 | Bit32u PhysBasePtr;
|
---|
82 | Bit32u OffScreenMemOffset;
|
---|
83 | Bit16u OffScreenMemSize;
|
---|
84 | // Mandatory information for VBE 3.0 and above
|
---|
85 | Bit16u LinBytesPerScanLine;
|
---|
86 | Bit8u BnkNumberOfPages;
|
---|
87 | Bit8u LinNumberOfPages;
|
---|
88 | Bit8u LinRedMaskSize;
|
---|
89 | Bit8u LinRedFieldPosition;
|
---|
90 | Bit8u LinGreenMaskSize;
|
---|
91 | Bit8u LinGreenFieldPosition;
|
---|
92 | Bit8u LinBlueMaskSize;
|
---|
93 | Bit8u LinBlueFieldPosition;
|
---|
94 | Bit8u LinRsvdMaskSize;
|
---|
95 | Bit8u LinRsvdFieldPosition;
|
---|
96 | Bit32u MaxPixelClock;
|
---|
97 | // Bit8u Reserved[189]; // DO NOT PUT THIS IN HERE because of Compact Mode Info storage in bios
|
---|
98 | } ModeInfoBlockCompact;
|
---|
99 |
|
---|
100 | typedef struct ModeInfoBlock
|
---|
101 | {
|
---|
102 | // Mandatory information for all VBE revisions
|
---|
103 | Bit16u ModeAttributes;
|
---|
104 | Bit8u WinAAttributes;
|
---|
105 | Bit8u WinBAttributes;
|
---|
106 | Bit16u WinGranularity;
|
---|
107 | Bit16u WinSize;
|
---|
108 | Bit16u WinASegment;
|
---|
109 | Bit16u WinBSegment;
|
---|
110 | Bit32u WinFuncPtr;
|
---|
111 | Bit16u BytesPerScanLine;
|
---|
112 | // Mandatory information for VBE 1.2 and above
|
---|
113 | Bit16u XResolution;
|
---|
114 | Bit16u YResolution;
|
---|
115 | Bit8u XCharSize;
|
---|
116 | Bit8u YCharSize;
|
---|
117 | Bit8u NumberOfPlanes;
|
---|
118 | Bit8u BitsPerPixel;
|
---|
119 | Bit8u NumberOfBanks;
|
---|
120 | Bit8u MemoryModel;
|
---|
121 | Bit8u BankSize;
|
---|
122 | Bit8u NumberOfImagePages;
|
---|
123 | Bit8u Reserved_page;
|
---|
124 | // Direct Color fields (required for direct/6 and YUV/7 memory models)
|
---|
125 | Bit8u RedMaskSize;
|
---|
126 | Bit8u RedFieldPosition;
|
---|
127 | Bit8u GreenMaskSize;
|
---|
128 | Bit8u GreenFieldPosition;
|
---|
129 | Bit8u BlueMaskSize;
|
---|
130 | Bit8u BlueFieldPosition;
|
---|
131 | Bit8u RsvdMaskSize;
|
---|
132 | Bit8u RsvdFieldPosition;
|
---|
133 | Bit8u DirectColorModeInfo;
|
---|
134 | // Mandatory information for VBE 2.0 and above
|
---|
135 | Bit32u PhysBasePtr;
|
---|
136 | Bit32u OffScreenMemOffset;
|
---|
137 | Bit16u OffScreenMemSize;
|
---|
138 | // Mandatory information for VBE 3.0 and above
|
---|
139 | Bit16u LinBytesPerScanLine;
|
---|
140 | Bit8u BnkNumberOfPages;
|
---|
141 | Bit8u LinNumberOfPages;
|
---|
142 | Bit8u LinRedMaskSize;
|
---|
143 | Bit8u LinRedFieldPosition;
|
---|
144 | Bit8u LinGreenMaskSize;
|
---|
145 | Bit8u LinGreenFieldPosition;
|
---|
146 | Bit8u LinBlueMaskSize;
|
---|
147 | Bit8u LinBlueFieldPosition;
|
---|
148 | Bit8u LinRsvdMaskSize;
|
---|
149 | Bit8u LinRsvdFieldPosition;
|
---|
150 | Bit32u MaxPixelClock;
|
---|
151 | Bit8u Reserved[189];
|
---|
152 | } ModeInfoBlock;
|
---|
153 |
|
---|
154 | // VBE Return Status Info
|
---|
155 | // AL
|
---|
156 | #define VBE_RETURN_STATUS_SUPPORTED 0x4F
|
---|
157 | #define VBE_RETURN_STATUS_UNSUPPORTED 0x00
|
---|
158 | // AH
|
---|
159 | #define VBE_RETURN_STATUS_SUCCESSFULL 0x00
|
---|
160 | #define VBE_RETURN_STATUS_FAILED 0x01
|
---|
161 | #define VBE_RETURN_STATUS_NOT_SUPPORTED 0x02
|
---|
162 | #define VBE_RETURN_STATUS_INVALID 0x03
|
---|
163 |
|
---|
164 | // VBE Mode Numbers
|
---|
165 |
|
---|
166 | #define VBE_MODE_VESA_DEFINED 0x0100
|
---|
167 | #define VBE_MODE_REFRESH_RATE_USE_CRTC 0x0800
|
---|
168 | #define VBE_MODE_LINEAR_FRAME_BUFFER 0x4000
|
---|
169 | #define VBE_MODE_PRESERVE_DISPLAY_MEMORY 0x8000
|
---|
170 |
|
---|
171 | // VBE GFX Mode Number
|
---|
172 |
|
---|
173 | #define VBE_VESA_MODE_640X400X8 0x100
|
---|
174 | #define VBE_VESA_MODE_640X480X8 0x101
|
---|
175 | #define VBE_VESA_MODE_800X600X4 0x102
|
---|
176 | #define VBE_VESA_MODE_800X600X8 0x103
|
---|
177 | #define VBE_VESA_MODE_1024X768X4 0x104
|
---|
178 | #define VBE_VESA_MODE_1024X768X8 0x105
|
---|
179 | #define VBE_VESA_MODE_1280X1024X4 0x106
|
---|
180 | #define VBE_VESA_MODE_1280X1024X8 0x107
|
---|
181 | #define VBE_VESA_MODE_320X200X1555 0x10D
|
---|
182 | #define VBE_VESA_MODE_320X200X565 0x10E
|
---|
183 | #define VBE_VESA_MODE_320X200X888 0x10F
|
---|
184 | #define VBE_VESA_MODE_640X480X1555 0x110
|
---|
185 | #define VBE_VESA_MODE_640X480X565 0x111
|
---|
186 | #define VBE_VESA_MODE_640X480X888 0x112
|
---|
187 | #define VBE_VESA_MODE_800X600X1555 0x113
|
---|
188 | #define VBE_VESA_MODE_800X600X565 0x114
|
---|
189 | #define VBE_VESA_MODE_800X600X888 0x115
|
---|
190 | #define VBE_VESA_MODE_1024X768X1555 0x116
|
---|
191 | #define VBE_VESA_MODE_1024X768X565 0x117
|
---|
192 | #define VBE_VESA_MODE_1024X768X888 0x118
|
---|
193 | #define VBE_VESA_MODE_1280X1024X1555 0x119
|
---|
194 | #define VBE_VESA_MODE_1280X1024X565 0x11A
|
---|
195 | #define VBE_VESA_MODE_1280X1024X888 0x11B
|
---|
196 |
|
---|
197 | // BOCHS/PLEX86 'own' mode numbers
|
---|
198 | #define VBE_OWN_MODE_320X200X8888 0x140
|
---|
199 | #define VBE_OWN_MODE_640X400X8888 0x141
|
---|
200 | #define VBE_OWN_MODE_640X480X8888 0x142
|
---|
201 | #define VBE_OWN_MODE_800X600X8888 0x143
|
---|
202 | #define VBE_OWN_MODE_1024X768X8888 0x144
|
---|
203 | #define VBE_OWN_MODE_1280X1024X8888 0x145
|
---|
204 | #define VBE_OWN_MODE_320X200X8 0x146
|
---|
205 |
|
---|
206 | #define VBE_VESA_MODE_END_OF_LIST 0xFFFF
|
---|
207 |
|
---|
208 | // Capabilities
|
---|
209 |
|
---|
210 | #define VBE_CAPABILITY_8BIT_DAC 0x0001
|
---|
211 | #define VBE_CAPABILITY_NOT_VGA_COMPATIBLE 0x0002
|
---|
212 | #define VBE_CAPABILITY_RAMDAC_USE_BLANK_BIT 0x0004
|
---|
213 | #define VBE_CAPABILITY_STEREOSCOPIC_SUPPORT 0x0008
|
---|
214 | #define VBE_CAPABILITY_STEREO_VIA_VESA_EVC 0x0010
|
---|
215 |
|
---|
216 | // Mode Attributes
|
---|
217 |
|
---|
218 | #define VBE_MODE_ATTRIBUTE_SUPPORTED 0x0001
|
---|
219 | #define VBE_MODE_ATTRIBUTE_EXTENDED_INFORMATION_AVAILABLE 0x0002
|
---|
220 | #define VBE_MODE_ATTRIBUTE_TTY_BIOS_SUPPORT 0x0004
|
---|
221 | #define VBE_MODE_ATTRIBUTE_COLOR_MODE 0x0008
|
---|
222 | #define VBE_MODE_ATTRIBUTE_GRAPHICS_MODE 0x0010
|
---|
223 | #define VBE_MODE_ATTRIBUTE_NOT_VGA_COMPATIBLE 0x0020
|
---|
224 | #define VBE_MODE_ATTRIBUTE_NO_VGA_COMPATIBLE_WINDOW 0x0040
|
---|
225 | #define VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE 0x0080
|
---|
226 | #define VBE_MODE_ATTRIBUTE_DOUBLE_SCAN_MODE 0x0100
|
---|
227 | #define VBE_MODE_ATTRIBUTE_INTERLACE_MODE 0x0200
|
---|
228 | #define VBE_MODE_ATTRIBUTE_HARDWARE_TRIPLE_BUFFER 0x0400
|
---|
229 | #define VBE_MODE_ATTRIBUTE_HARDWARE_STEREOSCOPIC_DISPLAY 0x0800
|
---|
230 | #define VBE_MODE_ATTRIBUTE_DUAL_DISPLAY_START_ADDRESS 0x1000
|
---|
231 |
|
---|
232 | #define VBE_MODE_ATTTRIBUTE_LFB_ONLY ( VBE_MODE_ATTRIBUTE_NO_VGA_COMPATIBLE_WINDOW | VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE )
|
---|
233 |
|
---|
234 | // Window attributes
|
---|
235 |
|
---|
236 | #define VBE_WINDOW_ATTRIBUTE_RELOCATABLE 0x01
|
---|
237 | #define VBE_WINDOW_ATTRIBUTE_READABLE 0x02
|
---|
238 | #define VBE_WINDOW_ATTRIBUTE_WRITEABLE 0x04
|
---|
239 |
|
---|
240 | // Memory model
|
---|
241 |
|
---|
242 | #define VBE_MEMORYMODEL_TEXT_MODE 0x00
|
---|
243 | #define VBE_MEMORYMODEL_CGA_GRAPHICS 0x01
|
---|
244 | #define VBE_MEMORYMODEL_HERCULES_GRAPHICS 0x02
|
---|
245 | #define VBE_MEMORYMODEL_PLANAR 0x03
|
---|
246 | #define VBE_MEMORYMODEL_PACKED_PIXEL 0x04
|
---|
247 | #define VBE_MEMORYMODEL_NON_CHAIN_4_256 0x05
|
---|
248 | #define VBE_MEMORYMODEL_DIRECT_COLOR 0x06
|
---|
249 | #define VBE_MEMORYMODEL_YUV 0x07
|
---|
250 |
|
---|
251 | // DirectColorModeInfo
|
---|
252 |
|
---|
253 | #define VBE_DIRECTCOLOR_COLOR_RAMP_PROGRAMMABLE 0x01
|
---|
254 | #define VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE 0x02
|
---|
255 |
|
---|
256 | // GUEST <-> HOST Communication API
|
---|
257 |
|
---|
258 | // FIXME: either dynamicly ask host for this or put somewhere high in physical memory
|
---|
259 | // like 0xE0000000
|
---|
260 |
|
---|
261 |
|
---|
262 | #define VBE_DISPI_BANK_ADDRESS 0xA0000
|
---|
263 | #define VBE_DISPI_BANK_SIZE_KB 64
|
---|
264 |
|
---|
265 | #define VBE_DISPI_MAX_XRES 1024
|
---|
266 | #define VBE_DISPI_MAX_YRES 768
|
---|
267 |
|
---|
268 | #define VBE_DISPI_IOPORT_INDEX 0x01CE
|
---|
269 | #define VBE_DISPI_IOPORT_DATA 0x01CF
|
---|
270 |
|
---|
271 | #define VBE_DISPI_INDEX_ID 0x0
|
---|
272 | #define VBE_DISPI_INDEX_XRES 0x1
|
---|
273 | #define VBE_DISPI_INDEX_YRES 0x2
|
---|
274 | #define VBE_DISPI_INDEX_BPP 0x3
|
---|
275 | #define VBE_DISPI_INDEX_ENABLE 0x4
|
---|
276 | #define VBE_DISPI_INDEX_BANK 0x5
|
---|
277 | #define VBE_DISPI_INDEX_VIRT_WIDTH 0x6
|
---|
278 | #define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7
|
---|
279 | #define VBE_DISPI_INDEX_X_OFFSET 0x8
|
---|
280 | #define VBE_DISPI_INDEX_Y_OFFSET 0x9
|
---|
281 |
|
---|
282 | #define VBE_DISPI_ID0 0xB0C0
|
---|
283 | #define VBE_DISPI_ID1 0xB0C1
|
---|
284 | #define VBE_DISPI_ID2 0xB0C2
|
---|
285 | #define VBE_DISPI_ID3 0xB0C3
|
---|
286 |
|
---|
287 | #define VBE_DISPI_DISABLED 0x00
|
---|
288 | #define VBE_DISPI_ENABLED 0x01
|
---|
289 | #define VBE_DISPI_GETCAPS 0x02
|
---|
290 | #define VBE_DISPI_8BIT_DAC 0x20
|
---|
291 | #define VBE_DISPI_LFB_ENABLED 0x40
|
---|
292 | #define VBE_DISPI_NOCLEARMEM 0x80
|
---|
293 |
|
---|
294 | #define VBE_DISPI_LFB_PHYSICAL_ADDRESS 0xE0000000
|
---|
295 |
|
---|
296 | /**
|
---|
297 | * VBE Bios Extra Data structure.
|
---|
298 | * @remark duplicated in vga_int.h.
|
---|
299 | */
|
---|
300 | typedef struct VBEHeader
|
---|
301 | {
|
---|
302 | /** Signature (VBEHEADER_MAGIC). */
|
---|
303 | Bit16u u16Signature;
|
---|
304 | /** Data size. */
|
---|
305 | Bit16u cbData;
|
---|
306 | } VBEHeader;
|
---|
307 |
|
---|
308 | /** The value of the VBEHEADER::u16Signature field.
|
---|
309 | * @remark duplicated in vga_int.h. */
|
---|
310 | #define VBEHEADER_MAGIC 0x77CC
|
---|
311 |
|
---|
312 | /** The extra port which is used to read the mode list.
|
---|
313 | * @remark duplicated in vga_int.h. */
|
---|
314 | #define VBE_EXTRA_PORT 0x3b6
|
---|
315 |
|
---|
316 | /** The extra port which is used for debug printf.
|
---|
317 | * @remark duplicated in vga_int.h. */
|
---|
318 | #define VBE_PRINTF_PORT 0x3b7
|
---|
319 |
|
---|
320 |
|
---|
321 | #endif
|
---|