5 #define CRTC_ADDR_PORT (iobase | 4)
6 #define CRTC_DATA_PORT (iobase | 5)
9 #define CRTC_START_H 0x0c
10 #define CRTC_START_L 0x0d
11 #define CRTC_CURPOS_H 0x0e
12 #define CRTC_CURPOS_L 0x0f
14 static void detect_video(void);
15 static int detect_vgainfo(void);
16 static int detect_egainfo(void);
17 static void detect_eqlist(void);
18 static void crtc_write(int reg, unsigned char val);
20 //struct console con_vid = { con_clear, con_putc, 0 };
22 static uint16_t __far *vmem;
25 static uint16_t cur_attr;
26 static int cur_x, cur_y;
27 static int cur_scroll;
34 vmem = MK_FP(0xb000, 0);
37 vmem = MK_FP(0xb800, 0);
44 static void detect_video(void)
50 if(detect_vgainfo() == 0) {
53 if(detect_egainfo() == 0) {
59 static int detect_vgainfo(void)
64 int86(0x10, ®s, ®s);
65 if(regs.h.al != 0x1a) {
108 static int detect_egainfo(void)
114 int86(0x10, ®s, ®s);
115 if(regs.h.bh == 0xff) {
124 static void detect_eqlist(void)
128 int86(0x11, ®s, ®s);
129 switch(regs.w.ax & 0x30) {
152 fmemset(vmem, 0, 80 * 25 * 2);
155 void vid_clearline(int row)
162 ptr = vmem + row * 80;
163 for(i=0; i<80; i++) {
168 /* write a copy to wrap-around future scrolling */
170 for(i=0; i<80; i++) {
179 for(i=0; i<25; i++) {
184 void vid_scroll(int line)
187 cur_scroll = line & 0x1f;
188 offs = cur_scroll * 80;
189 crtc_write(CRTC_START_H, offs >> 8);
190 crtc_write(CRTC_START_L, offs);
193 void vid_setcursor(int x, int y)
195 int loc = (y + cur_scroll) * 80 + x;
198 crtc_write(CRTC_CURPOS_H, loc >> 8);
199 crtc_write(CRTC_CURPOS_L, loc);
202 void vid_fgcolor(int color)
204 cur_attr = (cur_attr & 0xf0) | color;
207 void vid_bgcolor(int color)
209 cur_attr = (cur_attr & 0x0f) | (color << 4);
212 void vid_glyph(int x, int y, int c, int attr)
215 uint16_t val = c | (attr << 8);
219 ptr = vmem + y * 80 + x;
223 /* write a copy to wrap-around future scrolling */
229 void vid_text(int x, int y, const char *s, int attr)
236 ptr = vmem + y * 80 + x;
238 *ptr++ = *s++ | (attr << 8);
243 /* write a copy to wrap-around future scrolling */
244 ptr -= 80 * 32 + len;
247 *ptr++ = *s++ | (attr << 8);
252 static void crtc_write(int reg, unsigned char val)
254 outp(CRTC_ADDR_PORT, reg);
255 outp(CRTC_DATA_PORT, val);