VGA: Simplify vgafb_write/read_char.
[seabios.git] / vgasrc / vgatables.h
1 #ifndef __VGATABLES_H
2 #define __VGATABLES_H
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 */
47 #define SEG_GRAPH 0xA000
48 #define SEG_CTEXT 0xB800
49 #define SEG_MTEXT 0xB000
50
51 /*
52  * Tables of default values for each mode
53  */
54 #define TEXT       0x80
55
56 #define CTEXT      (0x00 | TEXT)
57 #define MTEXT      (0x01 | TEXT)
58 #define CGA        0x02
59 #define PLANAR1    0x03
60 #define PLANAR4    0x04
61 #define LINEAR8    0x05
62
63 // for SVGA
64 #define LINEAR15   0x10
65 #define LINEAR16   0x11
66 #define LINEAR24   0x12
67 #define LINEAR32   0x13
68
69 #define SCROLL_DOWN 0
70 #define SCROLL_UP   1
71
72 #define SCREEN_SIZE(x,y) (((x*y*2)|0x00ff)+1)
73 #define SCREEN_MEM_START(x,y,p) ((((x*y*2)|0x00ff)+1)*p)
74 #define SCREEN_IO_START(x,y,p) ((((x*y)|0x00ff)+1)*p)
75
76 /* standard BIOS Video Parameter Table */
77 struct VideoParam_s {
78     u8 twidth;
79     u8 theightm1;
80     u8 cheight;
81     u16 slength;
82     u8 sequ_regs[4];
83     u8 miscreg;
84     u8 crtc_regs[25];
85     u8 actl_regs[20];
86     u8 grdc_regs[9];
87 } PACKED;
88
89 struct vgamode_s {
90     u8 svgamode;
91     struct VideoParam_s *vparam;
92     u8 memmodel;    /* CTEXT,MTEXT,CGA,PL1,PL2,PL4,P8,P15,P16,P24,P32 */
93     u8 pixbits;
94     u16 sstart;
95     u8 pelmask;
96     u8 *dac;
97     u16 dacsize;
98 };
99
100 struct saveVideoHardware {
101     u8 sequ_index;
102     u8 crtc_index;
103     u8 grdc_index;
104     u8 actl_index;
105     u8 feature;
106     u8 sequ_regs[4];
107     u8 sequ0;
108     u8 crtc_regs[25];
109     u8 actl_regs[20];
110     u8 grdc_regs[9];
111     u16 crtc_addr;
112     u8 plane_latch[4];
113 };
114
115 struct saveBDAstate {
116     u8 video_mode;
117     u16 video_cols;
118     u16 video_pagesize;
119     u16 crtc_address;
120     u8 video_rows;
121     u16 char_height;
122     u8 video_ctl;
123     u8 video_switches;
124     u8 modeset_ctl;
125     u16 cursor_type;
126     u16 cursor_pos[8];
127     u16 video_pagestart;
128     u8 video_page;
129     /* current font */
130     u16 font0_off;
131     u16 font0_seg;
132     u16 font1_off;
133     u16 font1_seg;
134 };
135
136 struct saveDACcolors {
137     u8 rwmode;
138     u8 peladdr;
139     u8 pelmask;
140     u8 dac[768];
141     u8 color_select;
142 };
143
144 // vgatables.c
145 struct vgamode_s *find_vga_entry(u8 mode);
146 extern u16 video_save_pointer_table[];
147 extern struct VideoParam_s video_param_table[];
148 extern u8 static_functionality[];
149
150 // vgafonts.c
151 extern u8 vgafont8[];
152 extern u8 vgafont14[];
153 extern u8 vgafont16[];
154 extern u8 vgafont14alt[];
155 extern u8 vgafont16alt[];
156
157 // vga.c
158 struct carattr {
159     u8 car, attr;
160     u16 use_attr;
161 };
162 struct cursorpos {
163     u8 x, y, page;
164 };
165 struct cursorpos get_cursor_pos(u8 page);
166
167 // vgafb.c
168 void clear_screen(struct vgamode_s *vmode_g);
169 void biosfn_scroll(u8 nblines, u8 attr, u8 rul, u8 cul, u8 rlr, u8 clr
170                    , u8 page, u8 dir);
171 void vgafb_write_char(struct cursorpos cp, struct carattr ca);
172 struct carattr vgafb_read_char(struct cursorpos cp);
173 void biosfn_write_pixel(u8 BH, u8 AL, u16 CX, u16 DX);
174 void biosfn_read_pixel(u8 BH, u16 CX, u16 DX, u16 *AX);
175 void vgafb_load_font(u16 seg, void *src_far, u16 count
176                      , u16 start, u8 destflags, u8 fontsize);
177
178 // vgaio.c
179 void vgahw_screen_disable();
180 void vgahw_screen_enable();
181 void vgahw_set_border_color(u8 color);
182 void vgahw_set_overscan_border_color(u8 color);
183 u8 vgahw_get_overscan_border_color();
184 void vgahw_set_palette(u8 palid);
185 void vgahw_set_single_palette_reg(u8 reg, u8 val);
186 u8 vgahw_get_single_palette_reg(u8 reg);
187 void vgahw_set_all_palette_reg(u16 seg, u8 *data_far);
188 void vgahw_get_all_palette_reg(u16 seg, u8 *data_far);
189 void vgahw_toggle_intensity(u8 flag);
190 void vgahw_select_video_dac_color_page(u8 flag, u8 data);
191 void vgahw_read_video_dac_state(u8 *pmode, u8 *curpage);
192 void vgahw_set_dac_regs(u16 seg, u8 *data_far, u8 start, int count);
193 void vgahw_get_dac_regs(u16 seg, u8 *data_far, u8 start, int count);
194 void vgahw_set_pel_mask(u8 val);
195 u8 vgahw_get_pel_mask();
196 void vgahw_save_dac_state(u16 seg, struct saveDACcolors *info);
197 void vgahw_restore_dac_state(u16 seg, struct saveDACcolors *info);
198 void vgahw_set_text_block_specifier(u8 spec);
199 void get_font_access();
200 void release_font_access();
201 void vgahw_set_cursor_shape(u8 start, u8 end);
202 void vgahw_set_active_page(u16 address);
203 void vgahw_set_cursor_pos(u16 address);
204 void vgahw_set_scan_lines(u8 lines);
205 u16 vgahw_get_vde();
206 void vgahw_save_state(u16 seg, struct saveVideoHardware *info);
207 void vgahw_restore_state(u16 seg, struct saveVideoHardware *info);
208 void vgahw_set_mode(struct VideoParam_s *vparam_g);
209 void vgahw_enable_video_addressing(u8 disable);
210 void vgahw_init();
211
212 // clext.c
213 void cirrus_set_video_mode(u8 mode);
214 void cirrus_init();
215
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
222 #endif // vgatables.h