blob: 87b8043403d9b506703b27771d17f32cf75e89f8 [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
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'Connord113a992009-05-16 21:05:02 -040047#define SEG_GRAPH 0xA000
48#define SEG_CTEXT 0xB800
49#define SEG_MTEXT 0xB000
Kevin O'Connor1f2c3072009-05-06 23:35:59 -040050
51/*
Kevin O'Connor1f2c3072009-05-06 23:35:59 -040052 * Tables of default values for each mode
Kevin O'Connor1f2c3072009-05-06 23:35:59 -040053 */
Kevin O'Connore4f220f2009-05-25 23:37:13 -040054#define TEXT 0x80
Kevin O'Connor1f2c3072009-05-06 23:35:59 -040055
Kevin O'Connore4f220f2009-05-25 23:37:13 -040056#define CTEXT (0x00 | TEXT)
57#define MTEXT (0x01 | TEXT)
Kevin O'Connor1f2c3072009-05-06 23:35:59 -040058#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
Kevin O'Connor2c34f412009-05-31 15:25:14 -040069#define SCREEN_IO_START(x,y,p) (((((x)*(y)) | 0x00ff) + 1) * (p))
70#define SCREEN_MEM_START(x,y,p) SCREEN_IO_START(((x)*2),(y),(p))
Kevin O'Connor1f2c3072009-05-06 23:35:59 -040071
Kevin O'Connor1f2c3072009-05-06 23:35:59 -040072/* standard BIOS Video Parameter Table */
Kevin O'Connor5727c292009-05-16 17:29:32 -040073struct VideoParam_s {
Kevin O'Connor1f2c3072009-05-06 23:35:59 -040074 u8 twidth;
75 u8 theightm1;
76 u8 cheight;
77 u16 slength;
78 u8 sequ_regs[4];
79 u8 miscreg;
80 u8 crtc_regs[25];
81 u8 actl_regs[20];
82 u8 grdc_regs[9];
83} PACKED;
84
Kevin O'Connor5727c292009-05-16 17:29:32 -040085struct vgamode_s {
86 u8 svgamode;
87 struct VideoParam_s *vparam;
Kevin O'Connor5727c292009-05-16 17:29:32 -040088 u8 memmodel; /* CTEXT,MTEXT,CGA,PL1,PL2,PL4,P8,P15,P16,P24,P32 */
89 u8 pixbits;
90 u16 sstart;
91 u8 pelmask;
92 u8 *dac;
93 u16 dacsize;
94};
95
Kevin O'Connorca668642009-05-21 23:06:08 -040096struct saveVideoHardware {
97 u8 sequ_index;
98 u8 crtc_index;
99 u8 grdc_index;
100 u8 actl_index;
101 u8 feature;
102 u8 sequ_regs[4];
103 u8 sequ0;
104 u8 crtc_regs[25];
105 u8 actl_regs[20];
106 u8 grdc_regs[9];
107 u16 crtc_addr;
108 u8 plane_latch[4];
109};
110
111struct saveBDAstate {
112 u8 video_mode;
113 u16 video_cols;
114 u16 video_pagesize;
115 u16 crtc_address;
116 u8 video_rows;
117 u16 char_height;
118 u8 video_ctl;
119 u8 video_switches;
120 u8 modeset_ctl;
121 u16 cursor_type;
122 u16 cursor_pos[8];
123 u16 video_pagestart;
124 u8 video_page;
125 /* current font */
126 u16 font0_off;
127 u16 font0_seg;
128 u16 font1_off;
129 u16 font1_seg;
130};
131
132struct saveDACcolors {
133 u8 rwmode;
134 u8 peladdr;
135 u8 pelmask;
136 u8 dac[768];
137 u8 color_select;
138};
139
Kevin O'Connor5727c292009-05-16 17:29:32 -0400140// vgatables.c
141struct vgamode_s *find_vga_entry(u8 mode);
142extern u16 video_save_pointer_table[];
143extern struct VideoParam_s video_param_table[];
Kevin O'Connor1f2c3072009-05-06 23:35:59 -0400144extern u8 static_functionality[];
145
146// vgafonts.c
147extern u8 vgafont8[];
148extern u8 vgafont14[];
149extern u8 vgafont16[];
150extern u8 vgafont14alt[];
151extern u8 vgafont16alt[];
152
153// vga.c
Kevin O'Connor09262412009-05-25 11:44:11 -0400154struct carattr {
Kevin O'Connor0ad77f02009-05-31 20:46:43 -0400155 u8 car, attr, use_attr;
Kevin O'Connor09262412009-05-25 11:44:11 -0400156};
Kevin O'Connor918b1562009-05-25 11:05:18 -0400157struct cursorpos {
158 u8 x, y, page;
159};
Kevin O'Connorc0c7df62009-05-17 18:11:33 -0400160
161// vgafb.c
Kevin O'Connor124b6f72009-05-25 00:44:29 -0400162void clear_screen(struct vgamode_s *vmode_g);
Kevin O'Connor217f2bc2009-05-31 00:46:47 -0400163void vgafb_scroll(int nblines, int attr
164 , struct cursorpos ul, struct cursorpos lr);
Kevin O'Connord3b38152009-05-26 00:05:37 -0400165void vgafb_write_char(struct cursorpos cp, struct carattr ca);
166struct carattr vgafb_read_char(struct cursorpos cp);
Kevin O'Connor227a2bb2009-05-31 22:00:20 -0400167void vgafb_write_pixel(u8 color, u16 x, u16 y);
168u8 vgafb_read_pixel(u16 x, u16 y);
Kevin O'Connordeb9cb92009-05-25 09:06:50 -0400169void vgafb_load_font(u16 seg, void *src_far, u16 count
170 , u16 start, u8 destflags, u8 fontsize);
Kevin O'Connorc0c7df62009-05-17 18:11:33 -0400171
172// vgaio.c
Kevin O'Connora0ecb052009-05-18 23:34:00 -0400173void vgahw_screen_disable();
174void vgahw_screen_enable();
Kevin O'Connor8bc059e2009-05-17 21:19:36 -0400175void vgahw_set_border_color(u8 color);
176void vgahw_set_overscan_border_color(u8 color);
177u8 vgahw_get_overscan_border_color();
178void vgahw_set_palette(u8 palid);
179void vgahw_set_single_palette_reg(u8 reg, u8 val);
180u8 vgahw_get_single_palette_reg(u8 reg);
181void vgahw_set_all_palette_reg(u16 seg, u8 *data_far);
182void vgahw_get_all_palette_reg(u16 seg, u8 *data_far);
183void vgahw_toggle_intensity(u8 flag);
184void vgahw_select_video_dac_color_page(u8 flag, u8 data);
185void vgahw_read_video_dac_state(u8 *pmode, u8 *curpage);
186void vgahw_set_dac_regs(u16 seg, u8 *data_far, u8 start, int count);
187void vgahw_get_dac_regs(u16 seg, u8 *data_far, u8 start, int count);
188void vgahw_set_pel_mask(u8 val);
189u8 vgahw_get_pel_mask();
Kevin O'Connorca668642009-05-21 23:06:08 -0400190void vgahw_save_dac_state(u16 seg, struct saveDACcolors *info);
191void vgahw_restore_dac_state(u16 seg, struct saveDACcolors *info);
Kevin O'Connor414d0732009-05-31 22:42:04 -0400192void vgahw_sequ_write(u8 index, u8 value);
193void vgahw_grdc_write(u8 index, u8 value);
Kevin O'Connor8bc059e2009-05-17 21:19:36 -0400194void vgahw_set_text_block_specifier(u8 spec);
Kevin O'Connorc0c7df62009-05-17 18:11:33 -0400195void get_font_access();
196void release_font_access();
Kevin O'Connora0ecb052009-05-18 23:34:00 -0400197void vgahw_set_cursor_shape(u8 start, u8 end);
198void vgahw_set_active_page(u16 address);
199void vgahw_set_cursor_pos(u16 address);
200void vgahw_set_scan_lines(u8 lines);
201u16 vgahw_get_vde();
Kevin O'Connorca668642009-05-21 23:06:08 -0400202void vgahw_save_state(u16 seg, struct saveVideoHardware *info);
203void vgahw_restore_state(u16 seg, struct saveVideoHardware *info);
Kevin O'Connor124b6f72009-05-25 00:44:29 -0400204void vgahw_set_mode(struct VideoParam_s *vparam_g);
205void vgahw_enable_video_addressing(u8 disable);
206void vgahw_init();
Kevin O'Connor1f2c3072009-05-06 23:35:59 -0400207
208// clext.c
209void cirrus_set_video_mode(u8 mode);
210void cirrus_init();
Kevin O'Connor05c32dc2009-05-14 19:29:37 -0400211
Kevin O'Connor21079f42009-05-16 21:30:10 -0400212// vbe.c -- not implemented yet.
213#define VBE_DISPI_DISABLED 0x00
214void dispi_set_enable(int enable);
215void vbe_init();
216int vbe_has_vbe_display();
217
Kevin O'Connor05c32dc2009-05-14 19:29:37 -0400218#endif // vgatables.h