9 static void cleanup(void);
10 static int setmode(int mode);
11 static int curmode(void);
13 static void setpal4(int idx, int count, const struct vid_color *col);
14 static void getpal4(int idx, int count, struct vid_color *col);
15 static void clear4(uint32_t color);
16 static void blitfb4(void *fb, int pitch);
17 static void fill4(int x, int y, int w, int h, uint32_t color);
19 static void clear8(uint32_t color);
20 static void blitfb8(void *fb, int pitch);
21 static void fill8(int x, int y, int w, int h, uint32_t color);
24 static struct vid_driver drv;
25 static struct vid_drvops drvops = {init, cleanup, setmode, curmode};
26 static struct vid_modeinfo modes[] = {
32 static struct vid_gfxops gfxops_mode12h = {
33 0, 0, setpal4, getpal4, vid_vsync, clear4, blitfb4, 0, fill4 };
34 static struct vid_gfxops gfxops_mode13h = {
35 0, 0, vga_setpal, vga_getpal, vid_vsync, clear8, blitfb8, 0, fill8 };
37 void vid_register_vga(void)
45 drv.num_modes = sizeof modes / sizeof *modes;
47 for(i=0; i<drv.num_modes; i++) {
49 modes[i].vmem_addr = 0xa0000;
51 switch(modes[i].modeno) {
53 modes[i].vmem_addr = 0xb8000;
57 modes[i].ops = gfxops_mode13h;
61 modes[i].ops = gfxops_mode12h;
66 vid_drvlist[vid_numdrv++] = &drv;
71 while(inp(VGA_STAT1_PORT) & 8);
72 while((inp(VGA_STAT1_PORT) & 8) == 0);
75 void vga_setpal(int idx, int count, const struct vid_color *col)
78 outp(VGA_DAC_WADDR_PORT, idx);
79 for(i=0; i<count; i++) {
80 outp(VGA_DAC_DATA_PORT, col->r >> 2);
81 outp(VGA_DAC_DATA_PORT, col->g >> 2);
82 outp(VGA_DAC_DATA_PORT, col->b >> 2);
87 void vga_getpal(int idx, int count, struct vid_color *col)
90 outp(VGA_DAC_RADDR_PORT, idx);
91 for(i=0; i<count; i++) {
92 col->r = inp(VGA_DAC_DATA_PORT) << 2;
93 col->g = inp(VGA_DAC_DATA_PORT) << 2;
94 col->b = inp(VGA_DAC_DATA_PORT) << 2;
100 static int init(void)
105 static void cleanup(void)
109 static int setmode(int mode)
111 union REGS regs = {0};
113 int386(0x10, ®s, ®s);
117 static int curmode(void)
119 union REGS regs = {0};
121 int386(0x10, ®s, ®s);
122 return regs.x.eax & 0xff;
125 static void setpal4(int idx, int count, const struct vid_color *col)
129 static void getpal4(int idx, int count, struct vid_color *col)
133 static void clear4(uint32_t color)
137 static void blitfb4(void *fb, int pitch)
141 static void fill4(int x, int y, int w, int h, uint32_t color)
145 static void clear8(uint32_t color)
147 memset((void*)0xa0000, color, 64000);
150 static void blitfb8(void *fb, int pitch)
153 unsigned char *src = fb;
154 unsigned char *dest = (unsigned char*)0xa0000;
155 for(i=0; i<200; i++) {
156 memcpy(dest, src, 320);
162 static void fill8(int x, int y, int w, int h, uint32_t color)
165 unsigned char *fbptr = (unsigned char*)0xa0000;
167 fbptr += y * 320 + x;
169 memset(fbptr, color, w);