2 #include "../port/lib.h"
7 #include "../port/error.h"
32 i81xblank(VGAscr *scr, int blank)
34 char *srx, *srxd, *dpms;
37 srx = (char *)scr->mmio+SRX;
39 dpms = (char *)scr->mmio+DPMSsync;
59 while((p = pcimatch(p, 0x8086, 0)) != nil){
69 case 0x3577: /* IBM R31 uses intel 830M chipset */
77 i81xenable(VGAscr* scr)
82 ulong *pgtbl, *rp, cursor, *pte, fbuf, fbend;
89 scr->mmio = vmap(p->mem[1].bar & ~0x0F, p->mem[1].size);
92 addvgaseg("i81xmmio", p->mem[1].bar&~0x0F, p->mem[1].size);
94 /* allocate page table */
95 pgtbl = xspanalloc(64*1024, BY2PG, 0);
96 scr->mmio[0x2020/4] = PADDR(pgtbl) | 1;
98 size = p->mem[0].size;
101 vgalinearaddr(scr, p->mem[0].bar&~0xF, size);
102 addvgaseg("i81xscreen", p->mem[0].bar&~0xF, size);
105 * allocate backing store for frame buffer
106 * and populate device page tables.
108 fbuf = PADDR(xspanalloc(size, BY2PG, 0));
109 fbend = PGROUND(fbuf+size);
110 rp = scr->mmio+0x10000/4;
111 while(fbuf < fbend) {
117 * allocate space for the cursor data in system memory.
120 cursor = (ulong)xspanalloc(BY2PG, BY2PG, 0);
122 pte = mmuwalk(mach0->pdb, cursor, 2, 0);
124 panic("i81x cursor mmuwalk");
126 scr->storage = cursor;
128 scr->blank = i81xblank;
133 i81xcurdisable(VGAscr* scr)
139 hwcurs = (void*)((uchar*)scr->mmio+hwCur);
140 hwcurs->ctl = (1<<4);
144 i81xcurload(VGAscr* scr, Cursor* curs)
152 hwcurs = (void*)((uchar*)scr->mmio+hwCur);
155 * Disable the cursor then load the new image in
156 * the top-left of the 32x32 array.
157 * Unused portions of the image have been initialised to be
160 hwcurs->ctl = (1<<4);
161 p = (uchar*)scr->storage;
162 for(y = 0; y < 16; y += 2) {
163 *p++ = ~(curs->clr[2*y]|curs->set[2*y]);
164 *p++ = ~(curs->clr[2*y+1]|curs->set[2*y+1]);
166 *p++ = ~(curs->clr[2*y+2]|curs->set[2*y+2]);
167 *p++ = ~(curs->clr[2*y+3]|curs->set[2*y+3]);
169 *p++ = curs->set[2*y];
170 *p++ = curs->set[2*y+1];
172 *p++ = curs->set[2*y+2];
173 *p++ = curs->set[2*y+3];
178 * Save the cursor hotpoint and enable the cursor.
179 * The 0,0 cursor point is top-left.
181 scr->offset.x = curs->offset.x;
182 scr->offset.y = curs->offset.y;
183 hwcurs->ctl = (1<<4)|1;
187 i81xcurmove(VGAscr* scr, Point p)
195 hwcurs = (void*)((uchar*)scr->mmio+hwCur);
197 x = p.x+scr->offset.x;
198 y = p.y+scr->offset.y;
208 pos |= ((y&0x7ff)<<16)|(x&0x7ff);
215 i81xcurenable(VGAscr* scr)
224 hwcurs = (void*)((uchar*)scr->mmio+hwCur);
227 * Initialise the 32x32 cursor to be transparent in 2bpp mode.
229 hwcurs->base = PADDR(scr->storage);
230 p = (uchar*)scr->storage;
231 for(i = 0; i < 32/2; i++) {
237 * Load, locate and enable the 32x32 cursor in 2bpp mode.
239 i81xcurload(scr, &arrow);
240 i81xcurmove(scr, ZP);
243 VGAdev vgai81xdev = {
252 VGAcur vgai81xcur = {