vgabios: Extend information in internal vgamode_s struct.
[seabios.git] / vgasrc / vgatables.h
1 #ifndef __VGATABLES_H
2 #define __VGATABLES_H
3
4 #include "types.h" // u8
5 #include "farptr.h" // struct segoff_s
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 */
48 #define SEG_GRAPH 0xA000
49 #define SEG_CTEXT 0xB800
50 #define SEG_MTEXT 0xB000
51
52 /*
53  * Tables of default values for each mode
54  */
55 #define TEXT       0x80
56
57 #define CTEXT      (0x00 | TEXT)
58 #define MTEXT      (0x01 | TEXT)
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
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))
72
73 // Standard Video Save Pointer Table
74 struct VideoSavePointer_s {
75     struct segoff_s videoparam;
76     struct segoff_s paramdynamicsave;
77     struct segoff_s textcharset;
78     struct segoff_s graphcharset;
79     struct segoff_s secsavepointer;
80     u8 reserved[8];
81 } PACKED;
82
83 /* standard BIOS Video Parameter Table */
84 struct VideoParam_s {
85     u8 twidth;
86     u8 theightm1;
87     u8 cheight;
88     u16 slength;
89     u8 sequ_regs[4];
90     u8 miscreg;
91     u8 crtc_regs[25];
92     u8 actl_regs[20];
93     u8 grdc_regs[9];
94 } PACKED;
95
96 struct vgamode_s {
97     u8 svgamode;
98     u8 memmodel;    /* CTEXT,MTEXT,CGA,PL1,PL2,PL4,P8,P15,P16,P24,P32 */
99     u8 twidth;
100     u8 theight;
101     u8 cheight;
102     u8 pixbits;
103     u16 sstart;
104     u16 slength;
105     struct VideoParam_s *vparam;
106
107     u8 pelmask;
108     u8 *dac;
109     u16 dacsize;
110     u8 *sequ_regs;
111     u8 miscreg;
112     u8 *crtc_regs;
113     u8 *actl_regs;
114     u8 *grdc_regs;
115 };
116
117 struct saveVideoHardware {
118     u8 sequ_index;
119     u8 crtc_index;
120     u8 grdc_index;
121     u8 actl_index;
122     u8 feature;
123     u8 sequ_regs[4];
124     u8 sequ0;
125     u8 crtc_regs[25];
126     u8 actl_regs[20];
127     u8 grdc_regs[9];
128     u16 crtc_addr;
129     u8 plane_latch[4];
130 };
131
132 struct saveBDAstate {
133     u8 video_mode;
134     u16 video_cols;
135     u16 video_pagesize;
136     u16 crtc_address;
137     u8 video_rows;
138     u16 char_height;
139     u8 video_ctl;
140     u8 video_switches;
141     u8 modeset_ctl;
142     u16 cursor_type;
143     u16 cursor_pos[8];
144     u16 video_pagestart;
145     u8 video_page;
146     /* current font */
147     struct segoff_s font0;
148     struct segoff_s font1;
149 };
150
151 struct saveDACcolors {
152     u8 rwmode;
153     u8 peladdr;
154     u8 pelmask;
155     u8 dac[768];
156     u8 color_select;
157 };
158
159 // vgatables.c
160 struct vgamode_s *find_vga_entry(u8 mode);
161 extern struct VideoSavePointer_s video_save_pointer_table;
162 extern struct VideoParam_s video_param_table[];
163 extern u8 static_functionality[];
164
165 // vgafonts.c
166 extern u8 vgafont8[];
167 extern u8 vgafont14[];
168 extern u8 vgafont16[];
169 extern u8 vgafont14alt[];
170 extern u8 vgafont16alt[];
171
172 // vga.c
173 struct carattr {
174     u8 car, attr, use_attr;
175 };
176 struct cursorpos {
177     u8 x, y, page;
178 };
179 void vga_set_mode(u8 mode, u8 noclearmem);
180
181 // vgafb.c
182 void clear_screen(struct vgamode_s *vmode_g);
183 void vgafb_scroll(int nblines, int attr
184                   , struct cursorpos ul, struct cursorpos lr);
185 void vgafb_write_char(struct cursorpos cp, struct carattr ca);
186 struct carattr vgafb_read_char(struct cursorpos cp);
187 void vgafb_write_pixel(u8 color, u16 x, u16 y);
188 u8 vgafb_read_pixel(u16 x, u16 y);
189 void vgafb_load_font(u16 seg, void *src_far, u16 count
190                      , u16 start, u8 destflags, u8 fontsize);
191
192 // vgaio.c
193 void vgahw_screen_disable(void);
194 void vgahw_screen_enable(void);
195 void vgahw_set_border_color(u8 color);
196 void vgahw_set_overscan_border_color(u8 color);
197 u8 vgahw_get_overscan_border_color(void);
198 void vgahw_set_palette(u8 palid);
199 void vgahw_set_single_palette_reg(u8 reg, u8 val);
200 u8 vgahw_get_single_palette_reg(u8 reg);
201 void vgahw_set_all_palette_reg(u16 seg, u8 *data_far);
202 void vgahw_get_all_palette_reg(u16 seg, u8 *data_far);
203 void vgahw_toggle_intensity(u8 flag);
204 void vgahw_select_video_dac_color_page(u8 flag, u8 data);
205 void vgahw_read_video_dac_state(u8 *pmode, u8 *curpage);
206 void vgahw_set_dac_regs(u16 seg, u8 *data_far, u8 start, int count);
207 void vgahw_get_dac_regs(u16 seg, u8 *data_far, u8 start, int count);
208 void vgahw_set_pel_mask(u8 val);
209 u8 vgahw_get_pel_mask(void);
210 void vgahw_save_dac_state(u16 seg, struct saveDACcolors *info);
211 void vgahw_restore_dac_state(u16 seg, struct saveDACcolors *info);
212 void vgahw_sequ_write(u8 index, u8 value);
213 void vgahw_grdc_write(u8 index, u8 value);
214 void vgahw_set_text_block_specifier(u8 spec);
215 void get_font_access(void);
216 void release_font_access(void);
217 void vgahw_set_cursor_shape(u8 start, u8 end);
218 void vgahw_set_active_page(u16 address);
219 void vgahw_set_cursor_pos(u16 address);
220 void vgahw_set_scan_lines(u8 lines);
221 u16 vgahw_get_vde(void);
222 void vgahw_save_state(u16 seg, struct saveVideoHardware *info);
223 void vgahw_restore_state(u16 seg, struct saveVideoHardware *info);
224 void vgahw_set_mode(struct VideoParam_s *vparam_g);
225 void vgahw_enable_video_addressing(u8 disable);
226 void vgahw_init(void);
227
228 // clext.c
229 int cirrus_set_video_mode(u8 mode, u8 noclearmem);
230 void cirrus_init(void);
231
232 // vbe.c
233 #define VBE_OEM_STRING "SeaBIOS VBE(C) 2011"
234 #define VBE_VENDOR_STRING "SeaBIOS Developers"
235 #define VBE_PRODUCT_STRING "SeaBIOS VBE Adapter"
236 #define VBE_REVISION_STRING "Rev. 1"
237
238 struct vbe_modeinfo
239 {
240     u16 width;
241     u16 height;
242     u8 depth;
243     u16 linesize;
244     u32 phys_base;
245     u32 vram_size;
246 };
247 int vbe_init(u8 bus, u8 devfn);
248 int vbe_enabled(void);
249 u16 vbe_total_mem(void);
250 int vbe_list_modes(u16 seg, u16 ptr);
251 int vbe_mode_info(u16 mode, struct vbe_modeinfo *info);
252 void vbe_hires_enable(int enable);
253 void vbe_set_mode(u16 mode, struct vbe_modeinfo *info);
254 void vbe_clear_scr(void);
255 int vbe_hires_enabled(void);
256 u16 vbe_curr_mode(void);
257
258 #endif // vgatables.h