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)
59 ulong *pgtbl, *rp, fbuf, fbend;
66 scr->mmio = vmap(p->mem[1].bar & ~0x0F, p->mem[1].size);
69 addvgaseg("i81xmmio", p->mem[1].bar&~0x0F, p->mem[1].size);
71 /* allocate page table */
72 pgtbl = xspanalloc(64*1024, BY2PG, 0);
73 scr->mmio[0x2020/4] = PADDR(pgtbl) | 1;
75 size = p->mem[0].size;
78 vgalinearaddr(scr, p->mem[0].bar&~0xF, size);
79 addvgaseg("i81xscreen", p->mem[0].bar&~0xF, size);
82 * allocate backing store for frame buffer
83 * and populate device page tables.
85 fbuf = PADDR(xspanalloc(size, BY2PG, 0));
86 fbend = PGROUND(fbuf+size);
87 rp = scr->mmio+0x10000/4;
94 scr->blank = i81xblank;
98 i81xcurdisable(VGAscr* scr)
104 hwcurs = (void*)((uchar*)scr->mmio+hwCur);
105 hwcurs->ctl = (1<<4);
109 i81xcurload(VGAscr* scr, Cursor* curs)
115 if(scr->mmio == 0 || scr->storage == 0)
117 hwcurs = (void*)((uchar*)scr->mmio+hwCur);
120 * Disable the cursor then load the new image in
121 * the top-left of the 32x32 array.
122 * Unused portions of the image have been initialised to be
125 hwcurs->ctl = (1<<4);
126 p = (uchar*)scr->storage;
127 for(y = 0; y < 16; y += 2) {
128 *p++ = ~(curs->clr[2*y]|curs->set[2*y]);
129 *p++ = ~(curs->clr[2*y+1]|curs->set[2*y+1]);
131 *p++ = ~(curs->clr[2*y+2]|curs->set[2*y+2]);
132 *p++ = ~(curs->clr[2*y+3]|curs->set[2*y+3]);
134 *p++ = curs->set[2*y];
135 *p++ = curs->set[2*y+1];
137 *p++ = curs->set[2*y+2];
138 *p++ = curs->set[2*y+3];
143 * Save the cursor hotpoint and enable the cursor.
144 * The 0,0 cursor point is top-left.
146 scr->offset.x = curs->offset.x;
147 scr->offset.y = curs->offset.y;
148 hwcurs->ctl = (1<<4)|1;
152 i81xcurmove(VGAscr* scr, Point p)
160 hwcurs = (void*)((uchar*)scr->mmio+hwCur);
162 x = p.x+scr->offset.x;
163 y = p.y+scr->offset.y;
173 pos |= ((y&0x7ff)<<16)|(x&0x7ff);
180 i81xcurenable(VGAscr* scr)
189 if(scr->storage == 0){
191 Page *pg = newpage(0, nil, 0);
192 scr->storage = (uintptr)vmap(pg->pa, BY2PG);
193 if(scr->storage == 0){
197 hwcurs = (void*)((uchar*)scr->mmio+hwCur);
198 hwcurs->base = pg->pa;
202 * Initialise the 32x32 cursor to be transparent in 2bpp mode.
204 p = (uchar*)scr->storage;
205 for(i = 0; i < 32/2; i++) {
212 * Load, locate and enable the 32x32 cursor in 2bpp mode.
214 i81xcurload(scr, &arrow);
215 i81xcurmove(scr, ZP);
218 VGAdev vgai81xdev = {
227 VGAcur vgai81xcur = {