1/* 2 * Copyright 2004-2009, Axel D��rfler, axeld@pinc-software.de. 3 * Distributed under the terms of the MIT License. 4 */ 5#ifndef VESA_H 6#define VESA_H 7 8 9#include <SupportDefs.h> 10 11 12/* VBE info block structure */ 13 14#define VESA_SIGNATURE 'ASEV' 15#define VBE2_SIGNATURE '2EBV' 16 17struct vbe_info_block { 18 // VBE 1.x fields 19 uint32 signature; 20 struct { 21 uint8 minor; 22 uint8 major; 23 } version; 24 uint32 oem_string; 25 uint32 capabilities; 26 uint32 mode_list; 27 uint16 total_memory; // in 64k blocks 28 // VBE 2.0+ fields only 29 // Note, the block is 256 bytes in size for VBE 1.x as well, 30 // but doesn't define these fields. VBE 3 doesn't define 31 // any additional fields. 32 uint16 oem_software_revision; 33 uint32 oem_vendor_name_string; 34 uint32 oem_product_name_string; 35 uint32 oem_product_revision_string; 36 uint8 reserved[222]; 37 uint8 oem_data[256]; 38} _PACKED; 39 40// capabilities 41#define CAPABILITY_DAC_WIDTH 0x01 42#define CAPABILITY_NOT_VGA_COMPATIBLE 0x02 43 44 45/* VBE mode info structure */ 46 47struct vbe_mode_info { 48 uint16 attributes; 49 uint8 window_a_attributes; 50 uint8 window_b_attributes; 51 uint16 window_granularity; 52 uint16 window_size; 53 uint16 window_a_segment; 54 uint16 window_b_segment; 55 uint32 window_function; // real mode pointer 56 uint16 bytes_per_row; 57 58 // VBE 1.2 and above 59 uint16 width; 60 uint16 height; 61 uint8 char_width; 62 uint8 char_height; 63 uint8 num_planes; 64 uint8 bits_per_pixel; 65 uint8 num_banks; 66 uint8 memory_model; 67 uint8 bank_size; 68 uint8 num_image_pages; 69 uint8 _reserved0; 70 71 // direct color fields 72 uint8 red_mask_size; 73 uint8 red_field_position; 74 uint8 green_mask_size; 75 uint8 green_field_position; 76 uint8 blue_mask_size; 77 uint8 blue_field_position; 78 uint8 reserved_mask_size; 79 uint8 reserved_field_position; 80 uint8 direct_color_mode_info; 81 82 // VBE 2.0 and above 83 uint32 physical_base; 84 uint32 _reserved1; 85 uint16 _reserved2; 86 87 // VBE 3.0 and above 88 uint16 linear_bytes_per_row; 89 uint8 banked_num_image_pages; 90 uint8 linear_num_image_pages; 91 92 uint8 linear_red_mask_size; 93 uint8 linear_red_field_position; 94 uint8 linear_green_mask_size; 95 uint8 linear_green_field_position; 96 uint8 linear_blue_mask_size; 97 uint8 linear_blue_field_position; 98 uint8 linear_reserved_mask_size; 99 uint8 linear_reserved_field_position; 100 101 uint32 max_pixel_clock; // in Hz 102 103 uint8 _reserved[189]; 104} _PACKED; 105 106// definitions of mode info attributes 107#define MODE_ATTR_AVAILABLE 1 108#define MODE_ATTR_COLOR_MODE 8 109#define MODE_ATTR_GRAPHICS_MODE 16 110#define MODE_ATTR_LINEAR_BUFFER 128 111 112// memory models 113#define MODE_MEMORY_TEXT 0 114#define MODE_MEMORY_PLANAR 3 115#define MODE_MEMORY_PACKED_PIXEL 4 116#define MODE_MEMORY_DIRECT_COLOR 6 117#define MODE_MEMORY_YUV 7 118 119// set mode flags 120#define SET_MODE_MASK 0x01ff 121#define SET_MODE_SPECIFY_CRTC (1 << 11) 122#define SET_MODE_LINEAR_BUFFER (1 << 14) 123#define SET_MODE_DONT_CLEAR_MEMORY (1 << 15) 124 125 126/* CRTC info block structure */ 127 128struct crtc_info_block { 129 uint16 horizontal_total; 130 uint16 horizontal_sync_start; 131 uint16 horizontal_sync_end; 132 uint16 vertical_total; 133 uint16 vertical_sync_start; 134 uint16 vertical_sync_end; 135 uint8 flags; 136 uint32 pixel_clock; // in Hz 137 uint16 refresh_rate; // in 0.01 Hz 138 139 uint8 _reserved[40]; 140} _PACKED; 141 142#define CRTC_DOUBLE_SCAN 0x01 143#define CRTC_INTERLACED 0x02 144#define CRTC_NEGATIVE_HSYNC 0x04 145#define CRTC_NEGATIVE_VSYNC 0x08 146 147 148/* Power Management */ 149 150#define DPMS_ON 0x00 151#define DPMS_STANDBY 0x01 152#define DPMS_SUSPEND 0x02 153#define DPMS_OFF 0x04 154#define DPMS_REDUCED_ON 0x08 155 156 157/* VBE 3.0 protected mode interface 158 * The BIOS area can be scanned for the protected mode 159 * signature that identifies the structure below. 160 */ 161 162#define VBE_PM_SIGNATURE 'DIMP' 163 164struct vbe_protected_mode_info { 165 uint32 signature; 166 int16 entry_offset; 167 int16 init_offset; 168 uint16 data_selector; 169 uint16 a000_selector; 170 uint16 b000_selector; 171 uint16 b800_selector; 172 uint16 c000_selector; 173 uint8 in_protected_mode; 174 uint8 checksum; 175} _PACKED; 176 177#endif /* VESA_H */ 178