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