summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2019-10-02 00:58:46 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2019-10-02 00:58:46 +0200
commit0ee738ef8c34d5494265b8a14435333f45b96dc6 (patch)
tree17546beea3f9c8e4f115ae0ad02eab327dc1725c
parenta524fd06466b057638d8bf40f8f9f380033320fe (diff)
vgai81x: use vmap() for uncached access to cursor data instead of manipulating kernel page table
on 386, the kernel memory region is mapped using huge 4MB pages (when supported by the cpu). so the uncached pte manipulation does not work to map the cursor data with uncached attribute. instead, we allocate a memory page using newpage() and map it globally using vmap(), which maps it uncached.
-rw-r--r--sys/src/9/pc/vgai81x.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/sys/src/9/pc/vgai81x.c b/sys/src/9/pc/vgai81x.c
index 07b8b489d..735f33915 100644
--- a/sys/src/9/pc/vgai81x.c
+++ b/sys/src/9/pc/vgai81x.c
@@ -56,7 +56,7 @@ i81xenable(VGAscr* scr)
Pcidev *p;
int size;
Mach *mach0;
- ulong *pgtbl, *rp, cursor, *pte, fbuf, fbend;
+ ulong *pgtbl, *rp, fbuf, fbend;
if(scr->mmio)
return;
@@ -90,18 +90,7 @@ i81xenable(VGAscr* scr)
fbuf += BY2PG;
}
- /*
- * allocate space for the cursor data in system memory.
- * must be uncached.
- */
- cursor = (ulong)xspanalloc(BY2PG, BY2PG, 0);
- mach0 = MACHP(0);
- pte = mmuwalk(mach0->pdb, cursor, 2, 0);
- if(pte == nil)
- panic("i81x cursor mmuwalk");
- *pte |= PTEUNCACHED;
- scr->storage = cursor;
-
+ scr->storage = 0;
scr->blank = i81xblank;
}
@@ -123,7 +112,7 @@ i81xcurload(VGAscr* scr, Cursor* curs)
uchar *p;
CursorI81x *hwcurs;
- if(scr->mmio == 0)
+ if(scr->mmio == 0 || scr->storage == 0)
return;
hwcurs = (void*)((uchar*)scr->mmio+hwCur);
@@ -192,23 +181,33 @@ i81xcurenable(VGAscr* scr)
{
int i;
uchar *p;
- CursorI81x *hwcurs;
i81xenable(scr);
if(scr->mmio == 0)
return;
- hwcurs = (void*)((uchar*)scr->mmio+hwCur);
+
+ if(scr->storage == 0){
+ CursorI81x *hwcurs;
+ Page *pg = newpage(0, nil, 0);
+ scr->storage = (uintptr)vmap(pg->pa, BY2PG);
+ if(scr->storage == 0){
+ putpage(pg);
+ return;
+ }
+ hwcurs = (void*)((uchar*)scr->mmio+hwCur);
+ hwcurs->base = pg->pa;
+ }
/*
* Initialise the 32x32 cursor to be transparent in 2bpp mode.
*/
- hwcurs->base = PADDR(scr->storage);
p = (uchar*)scr->storage;
for(i = 0; i < 32/2; i++) {
memset(p, 0xff, 8);
memset(p+8, 0, 8);
p += 16;
}
+
/*
* Load, locate and enable the 32x32 cursor in 2bpp mode.
*/