47 Ccursorbypass2 = 1<<7,
48 C8bitemulation = 1<<8,
54 typedef struct Vmware Vmware;
102 vmrd(Vmware *vm, int i)
105 return inportl(vm->rd);
109 vmwr(Vmware *vm, int i, ulong v)
127 snarf(Vga* vga, Ctlr* ctlr)
135 error("%s: vga->pci not set\n", ctlr->name);
137 vm = alloc(sizeof(Vmware));
140 case 0x710: /* VMware video chipset #1 */
145 case 0x405: /* VMware video chipset #2, untested */
146 vm->ra = p->mem[0].bar&~3;
151 error("%s: unrecognized chipset %.4ux\n", ctlr->name, p->did);
154 for(i=0; i<Nreg; i++)
155 vm->r[i] = vmrd(vm, i);
157 //vmwr(vm, Renable, 0);
159 * Figure out color channel. Delay errors until init,
160 * which is after the register dump.
162 vm->depth = vm->r[Rbpp];
163 extra = vm->r[Rbpp] - vm->r[Rdepth];
164 if(vm->r[Rrmask] > vm->r[Rgmask] && vm->r[Rgmask] > vm->r[Rbmask]){
166 sprint(vm->chan, "x%d", extra);
169 sprint(vm->chan+strlen(vm->chan), "r%dg%db%d", bits(vm->r[Rrmask]),
170 bits(vm->r[Rgmask]), bits(vm->r[Rbmask]));
171 }else if(vm->r[Rbmask] > vm->r[Rgmask] && vm->r[Rgmask] > vm->r[Rrmask]){
172 sprint(vm->chan, "b%dg%dr%d", bits(vm->r[Rbmask]),
173 bits(vm->r[Rgmask]), bits(vm->r[Rrmask]));
175 sprint(vm->chan+strlen(vm->chan), "x%d", extra);
177 sprint(vm->chan, "unknown");
179 /* Record the frame buffer start, size */
180 vga->vmb = vm->r[Rfbstart];
181 vga->apz = vm->r[Rfbmaxsize];
184 ctlr->flag |= Fsnarf;
189 options(Vga*, Ctlr* ctlr)
191 ctlr->flag |= Hlinear|Henhanced|Foptions;
198 /* BEST CLOCK ROUTINE EVER! */
202 init(Vga* vga, Ctlr* ctlr)
208 vmwr(vm, Rid, (0x900000<<8)|2);
209 if(vmrd(vm, Rid)&0xFF != 2)
210 error("old vmware svga version %lud; need version 2\n",
213 ctlr->flag |= Ulinear;
214 if(strcmp(vm->chan, "unknown") == 0)
215 error("couldn't translate color masks into channel\n");
217 /* Always use the screen depth, and clip the screen size */
218 vga->mode->z = vm->r[Rbpp];
219 if(vga->mode->x > vm->r[Rmaxwidth])
220 vga->mode->x = vm->r[Rmaxwidth];
221 if(vga->mode->y > vm->r[Rmaxheight])
222 vga->mode->y = vm->r[Rmaxheight];
224 vm->r[Rwidth] = vga->mode->x;
225 vm->r[Rheight] = vga->mode->y;
227 /* Figure out the channel string */
228 strcpy(vga->mode->chan, vm->chan);
230 /* Record the bytes per line */
235 load(Vga* vga, Ctlr *ctlr)
242 vmwr(vm, Rwidth, vm->r[Rwidth]);
243 vmwr(vm, Rheight, vm->r[Rheight]);
244 vmwr(vm, Renable, 1);
245 vmwr(vm, Rguestid, 0x5010); /* OS type is "Other" */
247 x = vmrd(vm, Rbpl)/(vm->depth/8);
248 if(x != vga->mode->x){
250 sprint(buf, "%ludx%ludx%d %s", vga->virtx, vga->virty,
251 vga->mode->z, vga->mode->chan);
252 vgactlw("size", buf);
258 dump(Vga* vga, Ctlr* ctlr)
265 for(i=0; i<Nreg; i++){
266 printitem(ctlr->name, rname[i]);
267 Bprint(&stdout, " %.8lux\n", vm->r[i]);
270 printitem(ctlr->name, "chan");
271 Bprint(&stdout, " %s\n", vm->chan);
272 printitem(ctlr->name, "depth");
273 Bprint(&stdout, " %d\n", vm->depth);
274 printitem(ctlr->name, "linear");
281 options, /* options */
288 "vmwarehwgc", /* name */