blob: ef15b1d9c9b3d693b0f6d0434c8dc3ddda5f9214 [file] [log] [blame]
Kevin O'Connor05c32dc2009-05-14 19:29:37 -04001#ifndef __VGATABLES_H
2#define __VGATABLES_H
Kevin O'Connor1f2c3072009-05-06 23:35:59 -04003
4#include "types.h" // u8
Kevin O'Connor9f985422009-09-09 11:34:39 -04005#include "farptr.h" // struct segoff_s
Kevin O'Connor1f2c3072009-05-06 23:35:59 -04006
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'Connord113a992009-05-16 21:05:02 -040048#define SEG_GRAPH 0xA000
49#define SEG_CTEXT 0xB800
50#define SEG_MTEXT 0xB000
Kevin O'Connor1f2c3072009-05-06 23:35:59 -040051
52/*
Kevin O'Connor1f2c3072009-05-06 23:35:59 -040053 * Tables of default values for each mode
Kevin O'Connor1f2c3072009-05-06 23:35:59 -040054 */
Kevin O'Connore4f220f2009-05-25 23:37:13 -040055#define TEXT 0x80
Kevin O'Connor1f2c3072009-05-06 23:35:59 -040056
Kevin O'Connore4f220f2009-05-25 23:37:13 -040057#define CTEXT (0x00 | TEXT)
58#define MTEXT (0x01 | TEXT)
Kevin O'Connor1f2c3072009-05-06 23:35:59 -040059#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'Connor2c34f412009-05-31 15:25:14 -040070#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'Connor1f2c3072009-05-06 23:35:59 -040072
Kevin O'Connor815e4472011-12-21 09:05:32 -050073// Standard Video Save Pointer Table
74struct 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
Kevin O'Connor1f2c3072009-05-06 23:35:59 -040083/* standard BIOS Video Parameter Table */
Kevin O'Connor5727c292009-05-16 17:29:32 -040084struct VideoParam_s {
Kevin O'Connor1f2c3072009-05-06 23:35:59 -040085 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
Kevin O'Connor5727c292009-05-16 17:29:32 -040096struct vgamode_s {
97 u8 svgamode;
98 struct VideoParam_s *vparam;
Kevin O'Connor5727c292009-05-16 17:29:32 -040099 u8 memmodel; /* CTEXT,MTEXT,CGA,PL1,PL2,PL4,P8,P15,P16,P24,P32 */
100 u8 pixbits;
101 u16 sstart;
102 u8 pelmask;
103 u8 *dac;
104 u16 dacsize;
105};
106
Kevin O'Connorca668642009-05-21 23:06:08 -0400107struct saveVideoHardware {
108 u8 sequ_index;
109 u8 crtc_index;
110 u8 grdc_index;
111 u8 actl_index;
112 u8 feature;
113 u8 sequ_regs[4];
114 u8 sequ0;
115 u8 crtc_regs[25];
116 u8 actl_regs[20];
117 u8 grdc_regs[9];
118 u16 crtc_addr;
119 u8 plane_latch[4];
120};
121
122struct saveBDAstate {
123 u8 video_mode;
124 u16 video_cols;
125 u16 video_pagesize;
126 u16 crtc_address;
127 u8 video_rows;
128 u16 char_height;
129 u8 video_ctl;
130 u8 video_switches;
131 u8 modeset_ctl;
132 u16 cursor_type;
133 u16 cursor_pos[8];
134 u16 video_pagestart;
135 u8 video_page;
136 /* current font */
Kevin O'Connor9f985422009-09-09 11:34:39 -0400137 struct segoff_s font0;
138 struct segoff_s font1;
Kevin O'Connorca668642009-05-21 23:06:08 -0400139};
140
141struct saveDACcolors {
142 u8 rwmode;
143 u8 peladdr;
144 u8 pelmask;
145 u8 dac[768];
146 u8 color_select;
147};
148
Kevin O'Connor5727c292009-05-16 17:29:32 -0400149// vgatables.c
150struct vgamode_s *find_vga_entry(u8 mode);
Kevin O'Connor815e4472011-12-21 09:05:32 -0500151extern struct VideoSavePointer_s video_save_pointer_table;
Kevin O'Connor5727c292009-05-16 17:29:32 -0400152extern struct VideoParam_s video_param_table[];
Kevin O'Connor1f2c3072009-05-06 23:35:59 -0400153extern u8 static_functionality[];
154
155// vgafonts.c
156extern u8 vgafont8[];
157extern u8 vgafont14[];
158extern u8 vgafont16[];
159extern u8 vgafont14alt[];
160extern u8 vgafont16alt[];
161
162// vga.c
Kevin O'Connor09262412009-05-25 11:44:11 -0400163struct carattr {
Kevin O'Connor0ad77f02009-05-31 20:46:43 -0400164 u8 car, attr, use_attr;
Kevin O'Connor09262412009-05-25 11:44:11 -0400165};
Kevin O'Connor918b1562009-05-25 11:05:18 -0400166struct cursorpos {
167 u8 x, y, page;
168};
Julian Pidancet87879e22011-12-19 05:08:00 +0000169void vga_set_mode(u8 mode, u8 noclearmem);
Kevin O'Connorc0c7df62009-05-17 18:11:33 -0400170
171// vgafb.c
Kevin O'Connor124b6f72009-05-25 00:44:29 -0400172void clear_screen(struct vgamode_s *vmode_g);
Kevin O'Connor217f2bc2009-05-31 00:46:47 -0400173void vgafb_scroll(int nblines, int attr
174 , struct cursorpos ul, struct cursorpos lr);
Kevin O'Connord3b38152009-05-26 00:05:37 -0400175void vgafb_write_char(struct cursorpos cp, struct carattr ca);
176struct carattr vgafb_read_char(struct cursorpos cp);
Kevin O'Connor227a2bb2009-05-31 22:00:20 -0400177void vgafb_write_pixel(u8 color, u16 x, u16 y);
178u8 vgafb_read_pixel(u16 x, u16 y);
Kevin O'Connordeb9cb92009-05-25 09:06:50 -0400179void vgafb_load_font(u16 seg, void *src_far, u16 count
180 , u16 start, u8 destflags, u8 fontsize);
Kevin O'Connorc0c7df62009-05-17 18:11:33 -0400181
182// vgaio.c
Kevin O'Connor1ca05b02010-01-03 17:43:37 -0500183void vgahw_screen_disable(void);
184void vgahw_screen_enable(void);
Kevin O'Connor8bc059e2009-05-17 21:19:36 -0400185void vgahw_set_border_color(u8 color);
186void vgahw_set_overscan_border_color(u8 color);
Kevin O'Connor1ca05b02010-01-03 17:43:37 -0500187u8 vgahw_get_overscan_border_color(void);
Kevin O'Connor8bc059e2009-05-17 21:19:36 -0400188void vgahw_set_palette(u8 palid);
189void vgahw_set_single_palette_reg(u8 reg, u8 val);
190u8 vgahw_get_single_palette_reg(u8 reg);
191void vgahw_set_all_palette_reg(u16 seg, u8 *data_far);
192void vgahw_get_all_palette_reg(u16 seg, u8 *data_far);
193void vgahw_toggle_intensity(u8 flag);
194void vgahw_select_video_dac_color_page(u8 flag, u8 data);
195void vgahw_read_video_dac_state(u8 *pmode, u8 *curpage);
196void vgahw_set_dac_regs(u16 seg, u8 *data_far, u8 start, int count);
197void vgahw_get_dac_regs(u16 seg, u8 *data_far, u8 start, int count);
198void vgahw_set_pel_mask(u8 val);
Kevin O'Connor1ca05b02010-01-03 17:43:37 -0500199u8 vgahw_get_pel_mask(void);
Kevin O'Connorca668642009-05-21 23:06:08 -0400200void vgahw_save_dac_state(u16 seg, struct saveDACcolors *info);
201void vgahw_restore_dac_state(u16 seg, struct saveDACcolors *info);
Kevin O'Connor414d0732009-05-31 22:42:04 -0400202void vgahw_sequ_write(u8 index, u8 value);
203void vgahw_grdc_write(u8 index, u8 value);
Kevin O'Connor8bc059e2009-05-17 21:19:36 -0400204void vgahw_set_text_block_specifier(u8 spec);
Kevin O'Connor1ca05b02010-01-03 17:43:37 -0500205void get_font_access(void);
206void release_font_access(void);
Kevin O'Connora0ecb052009-05-18 23:34:00 -0400207void vgahw_set_cursor_shape(u8 start, u8 end);
208void vgahw_set_active_page(u16 address);
209void vgahw_set_cursor_pos(u16 address);
210void vgahw_set_scan_lines(u8 lines);
Kevin O'Connor1ca05b02010-01-03 17:43:37 -0500211u16 vgahw_get_vde(void);
Kevin O'Connorca668642009-05-21 23:06:08 -0400212void vgahw_save_state(u16 seg, struct saveVideoHardware *info);
213void vgahw_restore_state(u16 seg, struct saveVideoHardware *info);
Kevin O'Connor124b6f72009-05-25 00:44:29 -0400214void vgahw_set_mode(struct VideoParam_s *vparam_g);
215void vgahw_enable_video_addressing(u8 disable);
Kevin O'Connor1ca05b02010-01-03 17:43:37 -0500216void vgahw_init(void);
Kevin O'Connor1f2c3072009-05-06 23:35:59 -0400217
218// clext.c
Kevin O'Connore48a5372011-12-20 23:56:14 -0500219int cirrus_set_video_mode(u8 mode, u8 noclearmem);
Kevin O'Connor1ca05b02010-01-03 17:43:37 -0500220void cirrus_init(void);
Kevin O'Connor05c32dc2009-05-14 19:29:37 -0400221
Julian Pidancet87879e22011-12-19 05:08:00 +0000222// vbe.c
223#define VBE_OEM_STRING "SeaBIOS VBE(C) 2011"
224#define VBE_VENDOR_STRING "SeaBIOS Developers"
225#define VBE_PRODUCT_STRING "SeaBIOS VBE Adapter"
226#define VBE_REVISION_STRING "Rev. 1"
227
228struct vbe_modeinfo
229{
230 u16 width;
231 u16 height;
232 u8 depth;
233 u16 linesize;
234 u32 phys_base;
235 u32 vram_size;
236};
237int vbe_init(u8 bus, u8 devfn);
238int vbe_enabled(void);
239u16 vbe_total_mem(void);
240int vbe_list_modes(u16 seg, u16 ptr);
241int vbe_mode_info(u16 mode, struct vbe_modeinfo *info);
242void vbe_hires_enable(int enable);
243void vbe_set_mode(u16 mode, struct vbe_modeinfo *info);
244void vbe_clear_scr(void);
245int vbe_hires_enabled(void);
246u16 vbe_curr_mode(void);
Kevin O'Connor21079f42009-05-16 21:30:10 -0400247
Kevin O'Connor05c32dc2009-05-14 19:29:37 -0400248#endif // vgatables.h