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, CX, DX, 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 typedef struct ModeInfoListItem 155 { 156 Bit16u mode; 157 ModeInfoBlockCompact info; 158 } ModeInfoListItem; 159 160 // VBE Return Status Info 161 // AL 162 #define VBE_RETURN_STATUS_SUPPORTED 0x4F 163 #define VBE_RETURN_STATUS_UNSUPPORTED 0x00 164 // AH 165 #define VBE_RETURN_STATUS_SUCCESSFULL 0x00 166 #define VBE_RETURN_STATUS_FAILED 0x01 167 #define VBE_RETURN_STATUS_NOT_SUPPORTED 0x02 168 #define VBE_RETURN_STATUS_INVALID 0x03 169 170 // VBE Mode Numbers 171 172 #define VBE_MODE_VESA_DEFINED 0x0100 173 #define VBE_MODE_REFRESH_RATE_USE_CRTC 0x0800 174 #define VBE_MODE_LINEAR_FRAME_BUFFER 0x4000 175 #define VBE_MODE_PRESERVE_DISPLAY_MEMORY 0x8000 176 177 // VBE GFX Mode Number 178 179 #define VBE_VESA_MODE_640X400X8 0x100 180 #define VBE_VESA_MODE_640X480X8 0x101 181 #define VBE_VESA_MODE_800X600X4 0x102 182 #define VBE_VESA_MODE_800X600X8 0x103 183 #define VBE_VESA_MODE_1024X768X4 0x104 184 #define VBE_VESA_MODE_1024X768X8 0x105 185 #define VBE_VESA_MODE_1280X1024X4 0x106 186 #define VBE_VESA_MODE_1280X1024X8 0x107 187 #define VBE_VESA_MODE_320X200X1555 0x10D 188 #define VBE_VESA_MODE_320X200X565 0x10E 189 #define VBE_VESA_MODE_320X200X888 0x10F 190 #define VBE_VESA_MODE_640X480X1555 0x110 191 #define VBE_VESA_MODE_640X480X565 0x111 192 #define VBE_VESA_MODE_640X480X888 0x112 193 #define VBE_VESA_MODE_800X600X1555 0x113 194 #define VBE_VESA_MODE_800X600X565 0x114 195 #define VBE_VESA_MODE_800X600X888 0x115 196 #define VBE_VESA_MODE_1024X768X1555 0x116 197 #define VBE_VESA_MODE_1024X768X565 0x117 198 #define VBE_VESA_MODE_1024X768X888 0x118 199 #define VBE_VESA_MODE_1280X1024X1555 0x119 200 #define VBE_VESA_MODE_1280X1024X565 0x11A 201 #define VBE_VESA_MODE_1280X1024X888 0x11B 202 #define VBE_VESA_MODE_1600X1200X8 0x11C 203 #define VBE_VESA_MODE_1600X1200X1555 0x11D 204 #define VBE_VESA_MODE_1600X1200X565 0x11E 205 #define VBE_VESA_MODE_1600X1200X888 0x11F 206 207 // BOCHS/PLEX86 'own' mode numbers 208 #define VBE_OWN_MODE_320X200X8888 0x140 209 #define VBE_OWN_MODE_640X400X8888 0x141 210 #define VBE_OWN_MODE_640X480X8888 0x142 211 #define VBE_OWN_MODE_800X600X8888 0x143 212 #define VBE_OWN_MODE_1024X768X8888 0x144 213 #define VBE_OWN_MODE_1280X1024X8888 0x145 214 #define VBE_OWN_MODE_320X200X8 0x146 215 #define VBE_OWN_MODE_1600X1200X8888 0x147 216 #define VBE_OWN_MODE_1152X864X8 0x148 217 #define VBE_OWN_MODE_1152X864X1555 0x149 218 #define VBE_OWN_MODE_1152X864X565 0x14a 219 #define VBE_OWN_MODE_1152X864X888 0x14b 220 #define VBE_OWN_MODE_1152X864X8888 0x14c 221 222 #define VBE_VESA_MODE_END_OF_LIST 0xFFFF 223 224 // Capabilities 225 226 #define VBE_CAPABILITY_8BIT_DAC 0x0001 227 #define VBE_CAPABILITY_NOT_VGA_COMPATIBLE 0x0002 228 #define VBE_CAPABILITY_RAMDAC_USE_BLANK_BIT 0x0004 229 #define VBE_CAPABILITY_STEREOSCOPIC_SUPPORT 0x0008 230 #define VBE_CAPABILITY_STEREO_VIA_VESA_EVC 0x0010 231 232 // Mode Attributes 233 234 #define VBE_MODE_ATTRIBUTE_SUPPORTED 0x0001 235 #define VBE_MODE_ATTRIBUTE_EXTENDED_INFORMATION_AVAILABLE 0x0002 236 #define VBE_MODE_ATTRIBUTE_TTY_BIOS_SUPPORT 0x0004 237 #define VBE_MODE_ATTRIBUTE_COLOR_MODE 0x0008 238 #define VBE_MODE_ATTRIBUTE_GRAPHICS_MODE 0x0010 239 #define VBE_MODE_ATTRIBUTE_NOT_VGA_COMPATIBLE 0x0020 240 #define VBE_MODE_ATTRIBUTE_NO_VGA_COMPATIBLE_WINDOW 0x0040 241 #define VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE 0x0080 242 #define VBE_MODE_ATTRIBUTE_DOUBLE_SCAN_MODE 0x0100 243 #define VBE_MODE_ATTRIBUTE_INTERLACE_MODE 0x0200 244 #define VBE_MODE_ATTRIBUTE_HARDWARE_TRIPLE_BUFFER 0x0400 245 #define VBE_MODE_ATTRIBUTE_HARDWARE_STEREOSCOPIC_DISPLAY 0x0800 246 #define VBE_MODE_ATTRIBUTE_DUAL_DISPLAY_START_ADDRESS 0x1000 247 248 #define VBE_MODE_ATTTRIBUTE_LFB_ONLY ( VBE_MODE_ATTRIBUTE_NO_VGA_COMPATIBLE_WINDOW | VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE ) 249 250 // Window attributes 251 252 #define VBE_WINDOW_ATTRIBUTE_RELOCATABLE 0x01 253 #define VBE_WINDOW_ATTRIBUTE_READABLE 0x02 254 #define VBE_WINDOW_ATTRIBUTE_WRITEABLE 0x04 255 256 // Memory model 257 258 #define VBE_MEMORYMODEL_TEXT_MODE 0x00 259 #define VBE_MEMORYMODEL_CGA_GRAPHICS 0x01 260 #define VBE_MEMORYMODEL_HERCULES_GRAPHICS 0x02 261 #define VBE_MEMORYMODEL_PLANAR 0x03 262 #define VBE_MEMORYMODEL_PACKED_PIXEL 0x04 263 #define VBE_MEMORYMODEL_NON_CHAIN_4_256 0x05 264 #define VBE_MEMORYMODEL_DIRECT_COLOR 0x06 265 #define VBE_MEMORYMODEL_YUV 0x07 266 267 // DirectColorModeInfo 268 269 #define VBE_DIRECTCOLOR_COLOR_RAMP_PROGRAMMABLE 0x01 270 #define VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE 0x02 271 272 // GUEST <-> HOST Communication API 273 274 // FIXME: either dynamicly ask host for this or put somewhere high in physical memory 275 // like 0xE0000000 276 277 278 #define VBE_DISPI_BANK_ADDRESS 0xA0000 279 #define VBE_DISPI_BANK_SIZE_KB 64 280 281 #define VBE_DISPI_MAX_XRES 2560 282 #define VBE_DISPI_MAX_YRES 1600 283 284 #define VBE_DISPI_IOPORT_INDEX 0x01CE 285 #define VBE_DISPI_IOPORT_DATA 0x01CF 286 287 #define VBE_DISPI_INDEX_ID 0x0 288 #define VBE_DISPI_INDEX_XRES 0x1 289 #define VBE_DISPI_INDEX_YRES 0x2 290 #define VBE_DISPI_INDEX_BPP 0x3 291 #define VBE_DISPI_INDEX_ENABLE 0x4 292 #define VBE_DISPI_INDEX_BANK 0x5 293 #define VBE_DISPI_INDEX_VIRT_WIDTH 0x6 294 #define VBE_DISPI_INDEX_VIRT_HEIGHT 0x7 295 #define VBE_DISPI_INDEX_X_OFFSET 0x8 296 #define VBE_DISPI_INDEX_Y_OFFSET 0x9 297 #define VBE_DISPI_INDEX_VIDEO_MEMORY_64K 0xa 298 #define VBE_DISPI_INDEX_LFB_ADDRESS_H 0xb 299 #define VBE_DISPI_INDEX_LFB_ADDRESS_L 0xc 300 301 #define VBE_DISPI_LFB_PHYSICAL_ADDRESS 0xE0000000 302 #define VBE_DISPI_ID0 0xB0C0 303 #define VBE_DISPI_ID1 0xB0C1 304 #define VBE_DISPI_ID2 0xB0C2 305 #define VBE_DISPI_ID3 0xB0C3 306 #define VBE_DISPI_ID4 0xB0C4 307 308 #define VBE_DISPI_DISABLED 0x00 309 #define VBE_DISPI_ENABLED 0x01 310 #define VBE_DISPI_GETCAPS 0x02 311 #define VBE_DISPI_8BIT_DAC 0x20 312 #define VBE_DISPI_LFB_ENABLED 0x40 313 #define VBE_DISPI_NOCLEARMEM 0x80 314 315 #endif 316