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;
54 i81xenable(VGAscr* scr)
58 ulong *pgtbl, *rp, fbuf, fbend;
65 scr->mmio = vmap(p->mem[1].bar & ~0x0F, p->mem[1].size);
68 addvgaseg("i81xmmio", p->mem[1].bar&~0x0F, p->mem[1].size);
70 /* allocate page table */
71 pgtbl = xspanalloc(64*1024, BY2PG, 0);
72 scr->mmio[0x2020/4] = PADDR(pgtbl) | 1;
74 size = p->mem[0].size;
77 vgalinearaddr(scr, p->mem[0].bar&~0xF, size);
78 addvgaseg("i81xscreen", p->mem[0].bar&~0xF, size);
81 * allocate backing store for frame buffer
82 * and populate device page tables.
84 fbuf = PADDR(xspanalloc(size, BY2PG, 0));
85 fbend = PGROUND(fbuf+size);
86 rp = scr->mmio+0x10000/4;
93 scr->blank = i81xblank;
97 i81xcurdisable(VGAscr* scr)
103 hwcurs = (void*)((uchar*)scr->mmio+hwCur);
104 hwcurs->ctl = (1<<4);
108 i81xcurload(VGAscr* scr, Cursor* curs)
114 if(scr->mmio == 0 || scr->storage == 0)
116 hwcurs = (void*)((uchar*)scr->mmio+hwCur);
119 * Disable the cursor then load the new image in
120 * the top-left of the 32x32 array.
121 * Unused portions of the image have been initialised to be
124 hwcurs->ctl = (1<<4);
125 p = (uchar*)scr->storage;
126 for(y = 0; y < 16; y += 2) {
127 *p++ = ~(curs->clr[2*y]|curs->set[2*y]);
128 *p++ = ~(curs->clr[2*y+1]|curs->set[2*y+1]);
130 *p++ = ~(curs->clr[2*y+2]|curs->set[2*y+2]);
131 *p++ = ~(curs->clr[2*y+3]|curs->set[2*y+3]);
133 *p++ = curs->set[2*y];
134 *p++ = curs->set[2*y+1];
136 *p++ = curs->set[2*y+2];
137 *p++ = curs->set[2*y+3];
142 * Save the cursor hotpoint and enable the cursor.
143 * The 0,0 cursor point is top-left.
145 scr->offset.x = curs->offset.x;
146 scr->offset.y = curs->offset.y;
147 hwcurs->ctl = (1<<4)|1;
151 i81xcurmove(VGAscr* scr, Point p)
159 hwcurs = (void*)((uchar*)scr->mmio+hwCur);
161 x = p.x+scr->offset.x;
162 y = p.y+scr->offset.y;
172 pos |= ((y&0x7ff)<<16)|(x&0x7ff);
179 i81xcurenable(VGAscr* scr)
188 if(scr->storage == 0){
190 Page *pg = newpage(0, nil, 0);
191 scr->storage = (uintptr)vmap(pg->pa, BY2PG);
192 if(scr->storage == 0){
196 hwcurs = (void*)((uchar*)scr->mmio+hwCur);
197 hwcurs->base = pg->pa;
201 * Initialise the 32x32 cursor to be transparent in 2bpp mode.
203 p = (uchar*)scr->storage;
204 for(i = 0; i < 32/2; i++) {
211 * Load, locate and enable the 32x32 cursor in 2bpp mode.
213 i81xcurload(scr, &cursor);
214 i81xcurmove(scr, ZP);
217 VGAdev vgai81xdev = {
226 VGAcur vgai81xcur = {