10 static void cleanup(void);
11 static int setmode(int mode);
12 static int curmode(void);
14 static void setpal4(int idx, int count, const struct vid_color *col);
15 static void getpal4(int idx, int count, struct vid_color *col);
16 static void clear4(uint32_t color);
17 static void blitfb4(void *fb, int pitch);
18 static void fill4(int x, int y, int w, int h, uint32_t color);
20 static void clear8(uint32_t color);
21 static void blitfb8(void *fb, int pitch);
22 static void fill8(int x, int y, int w, int h, uint32_t color);
25 static struct vid_driver drv;
26 static struct vid_drvops drvops = {init, cleanup, setmode, curmode};
27 static struct vid_modeinfo modes[] = {
33 static struct vid_gfxops gfxops_mode12h = {
34 0, 0, setpal4, getpal4, vid_vsync, clear4, blitfb4, 0, fill4 };
35 static struct vid_gfxops gfxops_mode13h = {
36 0, 0, vga_setpal, vga_getpal, vid_vsync, clear8, blitfb8, 0, fill8 };
38 void vid_register_vga(void)
46 drv.num_modes = sizeof modes / sizeof *modes;
48 for(i=0; i<drv.num_modes; i++) {
50 modes[i].vmem_addr = 0xa0000;
52 switch(modes[i].modeno) {
54 modes[i].vmem_addr = 0xb8000;
58 modes[i].ops = gfxops_mode13h;
62 modes[i].ops = gfxops_mode12h;
67 vid_drvlist[vid_numdrv++] = &drv;
72 while(inp(VGA_STAT1_PORT) & 8);
73 while((inp(VGA_STAT1_PORT) & 8) == 0);
76 void vga_setpal(int idx, int count, const struct vid_color *col)
79 outp(VGA_DAC_WADDR_PORT, idx);
80 for(i=0; i<count; i++) {
81 outp(VGA_DAC_DATA_PORT, col->r >> 2);
82 outp(VGA_DAC_DATA_PORT, col->g >> 2);
83 outp(VGA_DAC_DATA_PORT, col->b >> 2);
88 void vga_getpal(int idx, int count, struct vid_color *col)
91 outp(VGA_DAC_RADDR_PORT, idx);
92 for(i=0; i<count; i++) {
93 col->r = inp(VGA_DAC_DATA_PORT) << 2;
94 col->g = inp(VGA_DAC_DATA_PORT) << 2;
95 col->b = inp(VGA_DAC_DATA_PORT) << 2;
101 static int init(void)
106 static void cleanup(void)
110 static int setmode(int mode)
112 union REGS regs = {0};
114 int386(0x10, ®s, ®s);
118 static int curmode(void)
120 union REGS regs = {0};
122 int386(0x10, ®s, ®s);
123 return regs.x.eax & 0xff;
126 static void setpal4(int idx, int count, const struct vid_color *col)
130 static void getpal4(int idx, int count, struct vid_color *col)
134 static void clear4(uint32_t color)
138 static void blitfb4(void *fb, int pitch)
142 static void fill4(int x, int y, int w, int h, uint32_t color)
146 static void clear8(uint32_t color)
148 memset((void*)0xa0000, color, 64000);
151 static void blitfb8(void *fb, int pitch)
154 unsigned char *src = fb;
155 unsigned char *dest = (unsigned char*)0xa0000;
156 for(i=0; i<200; i++) {
157 memcpy(dest, src, 320);
163 static void fill8(int x, int y, int w, int h, uint32_t color)
166 unsigned char *fbptr = (unsigned char*)0xa0000;
168 fbptr += y * 320 + x;
170 memset(fbptr, color, w);