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)
49 if(detect_vgainfo() == 0) {
52 if(detect_egainfo() == 0) {
58 static int detect_vgainfo(void)
63 int86(0x10, ®s, ®s);
64 if(regs.h.al != 0x1a) {
107 static int detect_egainfo(void)
113 int86(0x10, ®s, ®s);
114 if(regs.h.bh == 0xff) {
123 static void detect_eqlist(void)
127 int86(0x11, ®s, ®s);
128 switch(regs.w.ax & 0x30) {
151 fmemset(vmem, 0, 80 * 25 * 2);
154 void vid_clearline(int row)
161 ptr = vmem + row * 80;
162 for(i=0; i<80; i++) {
167 /* write a copy to wrap-around future scrolling */
169 for(i=0; i<80; i++) {
178 for(i=0; i<25; i++) {
183 void vid_scroll(int line)
186 cur_scroll = line & 0x1f;
187 offs = cur_scroll * 80;
188 crtc_write(CRTC_START_H, offs >> 8);
189 crtc_write(CRTC_START_L, offs);
192 void vid_setcursor(int x, int y)
194 int loc = (y + cur_scroll) * 80 + x;
197 crtc_write(CRTC_CURPOS_H, loc >> 8);
198 crtc_write(CRTC_CURPOS_L, loc);
201 void vid_fgcolor(int color)
203 cur_attr = (cur_attr & 0xf0) | color;
206 void vid_bgcolor(int color)
208 cur_attr = (cur_attr & 0x0f) | (color << 4);
211 void vid_glyph(int x, int y, int c, int attr)
214 uint16_t val = (c & 0xff) | attr;
218 ptr = vmem + y * 80 + x;
222 /* write a copy to wrap-around future scrolling */
228 void vid_text(int x, int y, const char *s, int attr)
235 ptr = vmem + y * 80 + x;
237 *ptr++ = (*s++ & 0xff) | attr;
242 /* write a copy to wrap-around future scrolling */
243 ptr -= 80 * 32 + len;
246 *ptr++ = (*s++ & 0xff) | attr;
251 static void crtc_write(int reg, unsigned char val)
253 outp(CRTC_ADDR_PORT, reg);
254 outp(CRTC_DATA_PORT, val);