2 #include "../port/lib.h"
7 #include "../port/pci.h"
8 #include "../port/error.h"
33 i81xblank(VGAscr *scr, int blank)
35 char *srx, *srxd, *dpms;
38 srx = (char *)scr->mmio+SRX;
40 dpms = (char *)scr->mmio+DPMSsync;
55 i81xenable(VGAscr* scr)
67 if((p->mem[0].bar & 1) != 0
68 || (p->mem[1].bar & 1) != 0)
70 scr->mmio = vmap(p->mem[1].bar & ~0x0F, p->mem[1].size);
73 addvgaseg("i81xmmio", p->mem[1].bar&~0x0F, p->mem[1].size);
75 /* allocate page table */
76 pgtbl = xspanalloc(64*1024, BY2PG, 0);
77 scr->mmio[0x2020/4] = PADDR(pgtbl) | 1;
79 size = p->mem[0].size;
82 vgalinearaddr(scr, p->mem[0].bar&~0xF, size);
83 addvgaseg("i81xscreen", p->mem[0].bar&~0xF, size);
86 * allocate backing store for frame buffer
87 * and populate device page tables.
89 fbuf = PADDR(xspanalloc(size, BY2PG, 0));
90 fbend = PGROUND(fbuf+size);
91 rp = scr->mmio+0x10000/4;
98 scr->blank = i81xblank;
102 i81xcurdisable(VGAscr* scr)
108 hwcurs = (void*)((uchar*)scr->mmio+hwCur);
109 hwcurs->ctl = (1<<4);
113 i81xcurload(VGAscr* scr, Cursor* curs)
119 if(scr->mmio == 0 || scr->storage == 0)
121 hwcurs = (void*)((uchar*)scr->mmio+hwCur);
124 * Disable the cursor then load the new image in
125 * the top-left of the 32x32 array.
126 * Unused portions of the image have been initialised to be
129 hwcurs->ctl = (1<<4);
130 p = (uchar*)scr->storage;
131 for(y = 0; y < 16; y += 2) {
132 *p++ = ~(curs->clr[2*y]|curs->set[2*y]);
133 *p++ = ~(curs->clr[2*y+1]|curs->set[2*y+1]);
135 *p++ = ~(curs->clr[2*y+2]|curs->set[2*y+2]);
136 *p++ = ~(curs->clr[2*y+3]|curs->set[2*y+3]);
138 *p++ = curs->set[2*y];
139 *p++ = curs->set[2*y+1];
141 *p++ = curs->set[2*y+2];
142 *p++ = curs->set[2*y+3];
147 * Save the cursor hotpoint and enable the cursor.
148 * The 0,0 cursor point is top-left.
150 scr->offset.x = curs->offset.x;
151 scr->offset.y = curs->offset.y;
152 hwcurs->ctl = (1<<4)|1;
156 i81xcurmove(VGAscr* scr, Point p)
164 hwcurs = (void*)((uchar*)scr->mmio+hwCur);
166 x = p.x+scr->offset.x;
167 y = p.y+scr->offset.y;
177 pos |= ((y&0x7ff)<<16)|(x&0x7ff);
184 i81xcurenable(VGAscr* scr)
193 if(scr->storage == 0){
195 Page *pg = newpage(0, nil, 0);
196 scr->storage = (uintptr)vmap(pg->pa, BY2PG);
197 if(scr->storage == 0){
201 hwcurs = (void*)((uchar*)scr->mmio+hwCur);
202 hwcurs->base = pg->pa;
206 * Initialise the 32x32 cursor to be transparent in 2bpp mode.
208 p = (uchar*)scr->storage;
209 for(i = 0; i < 32/2; i++) {
216 * Load, locate and enable the 32x32 cursor in 2bpp mode.
218 i81xcurload(scr, &cursor);
219 i81xcurmove(scr, ZP);
222 VGAdev vgai81xdev = {
231 VGAcur vgai81xcur = {