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