Kevin O'Connor | 05c32dc | 2009-05-14 19:29:37 -0400 | [diff] [blame] | 1 | #ifndef __VGATABLES_H |
| 2 | #define __VGATABLES_H |
Kevin O'Connor | 1f2c307 | 2009-05-06 23:35:59 -0400 | [diff] [blame] | 3 | |
| 4 | #include "types.h" // u8 |
| 5 | |
| 6 | /* |
| 7 | * |
| 8 | * VGA registers |
| 9 | * |
| 10 | */ |
| 11 | #define VGAREG_ACTL_ADDRESS 0x3c0 |
| 12 | #define VGAREG_ACTL_WRITE_DATA 0x3c0 |
| 13 | #define VGAREG_ACTL_READ_DATA 0x3c1 |
| 14 | |
| 15 | #define VGAREG_INPUT_STATUS 0x3c2 |
| 16 | #define VGAREG_WRITE_MISC_OUTPUT 0x3c2 |
| 17 | #define VGAREG_VIDEO_ENABLE 0x3c3 |
| 18 | #define VGAREG_SEQU_ADDRESS 0x3c4 |
| 19 | #define VGAREG_SEQU_DATA 0x3c5 |
| 20 | |
| 21 | #define VGAREG_PEL_MASK 0x3c6 |
| 22 | #define VGAREG_DAC_STATE 0x3c7 |
| 23 | #define VGAREG_DAC_READ_ADDRESS 0x3c7 |
| 24 | #define VGAREG_DAC_WRITE_ADDRESS 0x3c8 |
| 25 | #define VGAREG_DAC_DATA 0x3c9 |
| 26 | |
| 27 | #define VGAREG_READ_FEATURE_CTL 0x3ca |
| 28 | #define VGAREG_READ_MISC_OUTPUT 0x3cc |
| 29 | |
| 30 | #define VGAREG_GRDC_ADDRESS 0x3ce |
| 31 | #define VGAREG_GRDC_DATA 0x3cf |
| 32 | |
| 33 | #define VGAREG_MDA_CRTC_ADDRESS 0x3b4 |
| 34 | #define VGAREG_MDA_CRTC_DATA 0x3b5 |
| 35 | #define VGAREG_VGA_CRTC_ADDRESS 0x3d4 |
| 36 | #define VGAREG_VGA_CRTC_DATA 0x3d5 |
| 37 | |
| 38 | #define VGAREG_MDA_WRITE_FEATURE_CTL 0x3ba |
| 39 | #define VGAREG_VGA_WRITE_FEATURE_CTL 0x3da |
| 40 | #define VGAREG_ACTL_RESET 0x3da |
| 41 | |
| 42 | #define VGAREG_MDA_MODECTL 0x3b8 |
| 43 | #define VGAREG_CGA_MODECTL 0x3d8 |
| 44 | #define VGAREG_CGA_PALETTE 0x3d9 |
| 45 | |
| 46 | /* Video memory */ |
Kevin O'Connor | d113a99 | 2009-05-16 21:05:02 -0400 | [diff] [blame] | 47 | #define SEG_GRAPH 0xA000 |
| 48 | #define SEG_CTEXT 0xB800 |
| 49 | #define SEG_MTEXT 0xB000 |
Kevin O'Connor | 1f2c307 | 2009-05-06 23:35:59 -0400 | [diff] [blame] | 50 | |
| 51 | /* |
| 52 | * |
| 53 | * Tables of default values for each mode |
| 54 | * |
| 55 | */ |
Kevin O'Connor | 1f2c307 | 2009-05-06 23:35:59 -0400 | [diff] [blame] | 56 | #define TEXT 0x00 |
| 57 | #define GRAPH 0x01 |
| 58 | |
| 59 | #define CTEXT 0x00 |
| 60 | #define MTEXT 0x01 |
| 61 | #define CGA 0x02 |
| 62 | #define PLANAR1 0x03 |
| 63 | #define PLANAR4 0x04 |
| 64 | #define LINEAR8 0x05 |
| 65 | |
| 66 | // for SVGA |
| 67 | #define LINEAR15 0x10 |
| 68 | #define LINEAR16 0x11 |
| 69 | #define LINEAR24 0x12 |
| 70 | #define LINEAR32 0x13 |
| 71 | |
| 72 | #define SCROLL_DOWN 0 |
| 73 | #define SCROLL_UP 1 |
| 74 | #define NO_ATTR 2 |
| 75 | #define WITH_ATTR 3 |
| 76 | |
| 77 | #define SCREEN_SIZE(x,y) (((x*y*2)|0x00ff)+1) |
| 78 | #define SCREEN_MEM_START(x,y,p) ((((x*y*2)|0x00ff)+1)*p) |
| 79 | #define SCREEN_IO_START(x,y,p) ((((x*y)|0x00ff)+1)*p) |
| 80 | |
Kevin O'Connor | 1f2c307 | 2009-05-06 23:35:59 -0400 | [diff] [blame] | 81 | /* standard BIOS Video Parameter Table */ |
Kevin O'Connor | 5727c29 | 2009-05-16 17:29:32 -0400 | [diff] [blame] | 82 | struct VideoParam_s { |
Kevin O'Connor | 1f2c307 | 2009-05-06 23:35:59 -0400 | [diff] [blame] | 83 | u8 twidth; |
| 84 | u8 theightm1; |
| 85 | u8 cheight; |
| 86 | u16 slength; |
| 87 | u8 sequ_regs[4]; |
| 88 | u8 miscreg; |
| 89 | u8 crtc_regs[25]; |
| 90 | u8 actl_regs[20]; |
| 91 | u8 grdc_regs[9]; |
| 92 | } PACKED; |
| 93 | |
Kevin O'Connor | 5727c29 | 2009-05-16 17:29:32 -0400 | [diff] [blame] | 94 | struct vgamode_s { |
| 95 | u8 svgamode; |
| 96 | struct VideoParam_s *vparam; |
| 97 | u8 class; /* TEXT, GRAPH */ |
| 98 | u8 memmodel; /* CTEXT,MTEXT,CGA,PL1,PL2,PL4,P8,P15,P16,P24,P32 */ |
| 99 | u8 pixbits; |
| 100 | u16 sstart; |
| 101 | u8 pelmask; |
| 102 | u8 *dac; |
| 103 | u16 dacsize; |
| 104 | }; |
| 105 | |
Kevin O'Connor | ca66864 | 2009-05-21 23:06:08 -0400 | [diff] [blame] | 106 | struct saveVideoHardware { |
| 107 | u8 sequ_index; |
| 108 | u8 crtc_index; |
| 109 | u8 grdc_index; |
| 110 | u8 actl_index; |
| 111 | u8 feature; |
| 112 | u8 sequ_regs[4]; |
| 113 | u8 sequ0; |
| 114 | u8 crtc_regs[25]; |
| 115 | u8 actl_regs[20]; |
| 116 | u8 grdc_regs[9]; |
| 117 | u16 crtc_addr; |
| 118 | u8 plane_latch[4]; |
| 119 | }; |
| 120 | |
| 121 | struct saveBDAstate { |
| 122 | u8 video_mode; |
| 123 | u16 video_cols; |
| 124 | u16 video_pagesize; |
| 125 | u16 crtc_address; |
| 126 | u8 video_rows; |
| 127 | u16 char_height; |
| 128 | u8 video_ctl; |
| 129 | u8 video_switches; |
| 130 | u8 modeset_ctl; |
| 131 | u16 cursor_type; |
| 132 | u16 cursor_pos[8]; |
| 133 | u16 video_pagestart; |
| 134 | u8 video_page; |
| 135 | /* current font */ |
| 136 | u16 font0_off; |
| 137 | u16 font0_seg; |
| 138 | u16 font1_off; |
| 139 | u16 font1_seg; |
| 140 | }; |
| 141 | |
| 142 | struct saveDACcolors { |
| 143 | u8 rwmode; |
| 144 | u8 peladdr; |
| 145 | u8 pelmask; |
| 146 | u8 dac[768]; |
| 147 | u8 color_select; |
| 148 | }; |
| 149 | |
Kevin O'Connor | 5727c29 | 2009-05-16 17:29:32 -0400 | [diff] [blame] | 150 | // vgatables.c |
| 151 | struct vgamode_s *find_vga_entry(u8 mode); |
| 152 | extern u16 video_save_pointer_table[]; |
| 153 | extern struct VideoParam_s video_param_table[]; |
Kevin O'Connor | 1f2c307 | 2009-05-06 23:35:59 -0400 | [diff] [blame] | 154 | extern u8 static_functionality[]; |
| 155 | |
| 156 | // vgafonts.c |
| 157 | extern u8 vgafont8[]; |
| 158 | extern u8 vgafont14[]; |
| 159 | extern u8 vgafont16[]; |
| 160 | extern u8 vgafont14alt[]; |
| 161 | extern u8 vgafont16alt[]; |
| 162 | |
| 163 | // vga.c |
Kevin O'Connor | c0c7df6 | 2009-05-17 18:11:33 -0400 | [diff] [blame] | 164 | u16 biosfn_get_cursor_pos(u8 page); |
| 165 | |
| 166 | // vgafb.c |
| 167 | void biosfn_scroll(u8 nblines, u8 attr, u8 rul, u8 cul, u8 rlr, u8 clr |
| 168 | , u8 page, u8 dir); |
| 169 | void biosfn_write_char_attr(u8 car, u8 page, u8 attr, u16 count); |
| 170 | void biosfn_write_char_only(u8 car, u8 page, u8 attr, u16 count); |
| 171 | void biosfn_read_char_attr(u8 page, u16 *car); |
| 172 | void biosfn_write_pixel(u8 BH, u8 AL, u16 CX, u16 DX); |
| 173 | void biosfn_read_pixel(u8 BH, u16 CX, u16 DX, u16 *AX); |
| 174 | void biosfn_load_text_user_pat(u16 ES, u16 BP, u16 CX, u16 DX, u8 BL, u8 BH); |
| 175 | void biosfn_load_text_8_14_pat(u8 BL); |
| 176 | void biosfn_load_text_8_8_pat(u8 BL); |
| 177 | void biosfn_load_text_8_16_pat(u8 BL); |
| 178 | |
| 179 | // vgaio.c |
Kevin O'Connor | a0ecb05 | 2009-05-18 23:34:00 -0400 | [diff] [blame] | 180 | void vgahw_screen_disable(); |
| 181 | void vgahw_screen_enable(); |
Kevin O'Connor | 8bc059e | 2009-05-17 21:19:36 -0400 | [diff] [blame] | 182 | void vgahw_set_border_color(u8 color); |
| 183 | void vgahw_set_overscan_border_color(u8 color); |
| 184 | u8 vgahw_get_overscan_border_color(); |
| 185 | void vgahw_set_palette(u8 palid); |
| 186 | void vgahw_set_single_palette_reg(u8 reg, u8 val); |
| 187 | u8 vgahw_get_single_palette_reg(u8 reg); |
| 188 | void vgahw_set_all_palette_reg(u16 seg, u8 *data_far); |
| 189 | void vgahw_get_all_palette_reg(u16 seg, u8 *data_far); |
| 190 | void vgahw_toggle_intensity(u8 flag); |
| 191 | void vgahw_select_video_dac_color_page(u8 flag, u8 data); |
| 192 | void vgahw_read_video_dac_state(u8 *pmode, u8 *curpage); |
| 193 | void vgahw_set_dac_regs(u16 seg, u8 *data_far, u8 start, int count); |
| 194 | void vgahw_get_dac_regs(u16 seg, u8 *data_far, u8 start, int count); |
| 195 | void vgahw_set_pel_mask(u8 val); |
| 196 | u8 vgahw_get_pel_mask(); |
Kevin O'Connor | ca66864 | 2009-05-21 23:06:08 -0400 | [diff] [blame] | 197 | void vgahw_save_dac_state(u16 seg, struct saveDACcolors *info); |
| 198 | void vgahw_restore_dac_state(u16 seg, struct saveDACcolors *info); |
Kevin O'Connor | 8bc059e | 2009-05-17 21:19:36 -0400 | [diff] [blame] | 199 | void vgahw_set_text_block_specifier(u8 spec); |
Kevin O'Connor | c0c7df6 | 2009-05-17 18:11:33 -0400 | [diff] [blame] | 200 | void get_font_access(); |
| 201 | void release_font_access(); |
Kevin O'Connor | a0ecb05 | 2009-05-18 23:34:00 -0400 | [diff] [blame] | 202 | void vgahw_set_cursor_shape(u8 start, u8 end); |
| 203 | void vgahw_set_active_page(u16 address); |
| 204 | void vgahw_set_cursor_pos(u16 address); |
| 205 | void vgahw_set_scan_lines(u8 lines); |
| 206 | u16 vgahw_get_vde(); |
Kevin O'Connor | 8bc059e | 2009-05-17 21:19:36 -0400 | [diff] [blame] | 207 | void vgahw_enable_video_addressing(u8 disable); |
| 208 | void vgahw_init(); |
Kevin O'Connor | ca66864 | 2009-05-21 23:06:08 -0400 | [diff] [blame] | 209 | void vgahw_save_state(u16 seg, struct saveVideoHardware *info); |
| 210 | void vgahw_restore_state(u16 seg, struct saveVideoHardware *info); |
Kevin O'Connor | 1f2c307 | 2009-05-06 23:35:59 -0400 | [diff] [blame] | 211 | |
| 212 | // clext.c |
| 213 | void cirrus_set_video_mode(u8 mode); |
| 214 | void cirrus_init(); |
Kevin O'Connor | 05c32dc | 2009-05-14 19:29:37 -0400 | [diff] [blame] | 215 | |
Kevin O'Connor | 21079f4 | 2009-05-16 21:30:10 -0400 | [diff] [blame] | 216 | // vbe.c -- not implemented yet. |
| 217 | #define VBE_DISPI_DISABLED 0x00 |
| 218 | void dispi_set_enable(int enable); |
| 219 | void vbe_init(); |
| 220 | int vbe_has_vbe_display(); |
| 221 | |
Kevin O'Connor | 05c32dc | 2009-05-14 19:29:37 -0400 | [diff] [blame] | 222 | #endif // vgatables.h |