changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: vgai81x: use vmap() for uncached access to cursor data instead of manipulating kernel page table

changeset 7403: c308afa89cfc
parent 7402: 706812d7d85b
child 7404: 6e0c926efd3b
author: cinap_lenrek@felloff.net
date: Wed, 02 Oct 2019 00:58:46 +0200
files: sys/src/9/pc/vgai81x.c
description: 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.
     1.1--- a/sys/src/9/pc/vgai81x.c
     1.2+++ b/sys/src/9/pc/vgai81x.c
     1.3@@ -56,7 +56,7 @@ i81xenable(VGAscr* scr)
     1.4 	Pcidev *p;
     1.5 	int size;
     1.6 	Mach *mach0;
     1.7-	ulong *pgtbl, *rp, cursor, *pte, fbuf, fbend;
     1.8+	ulong *pgtbl, *rp, fbuf, fbend;
     1.9 	
    1.10 	if(scr->mmio)
    1.11 		return;
    1.12@@ -90,18 +90,7 @@ i81xenable(VGAscr* scr)
    1.13 		fbuf += BY2PG;
    1.14 	}
    1.15 
    1.16-	/*
    1.17-	 * allocate space for the cursor data in system memory.
    1.18-	 * must be uncached.
    1.19-	 */
    1.20-	cursor = (ulong)xspanalloc(BY2PG, BY2PG, 0);
    1.21-	mach0 = MACHP(0);
    1.22-	pte = mmuwalk(mach0->pdb, cursor, 2, 0);
    1.23-	if(pte == nil)
    1.24-		panic("i81x cursor mmuwalk");
    1.25-	*pte |= PTEUNCACHED;
    1.26-	scr->storage = cursor;
    1.27-
    1.28+	scr->storage = 0;
    1.29 	scr->blank = i81xblank;
    1.30 }
    1.31 
    1.32@@ -123,7 +112,7 @@ i81xcurload(VGAscr* scr, Cursor* curs)
    1.33 	uchar *p;
    1.34 	CursorI81x *hwcurs;
    1.35 
    1.36-	if(scr->mmio == 0)
    1.37+	if(scr->mmio == 0 || scr->storage == 0)
    1.38 		return;
    1.39 	hwcurs = (void*)((uchar*)scr->mmio+hwCur);
    1.40 
    1.41@@ -192,23 +181,33 @@ i81xcurenable(VGAscr* scr)
    1.42 {
    1.43 	int i;
    1.44 	uchar *p;
    1.45-	CursorI81x *hwcurs;
    1.46 
    1.47 	i81xenable(scr);
    1.48 	if(scr->mmio == 0)
    1.49 		return;
    1.50-	hwcurs = (void*)((uchar*)scr->mmio+hwCur);
    1.51+
    1.52+	if(scr->storage == 0){
    1.53+		CursorI81x *hwcurs;
    1.54+		Page *pg = newpage(0, nil, 0);
    1.55+		scr->storage = (uintptr)vmap(pg->pa, BY2PG);
    1.56+		if(scr->storage == 0){
    1.57+			putpage(pg);
    1.58+			return;
    1.59+		}
    1.60+		hwcurs = (void*)((uchar*)scr->mmio+hwCur);
    1.61+		hwcurs->base = pg->pa;
    1.62+	}
    1.63 
    1.64 	/*
    1.65 	 * Initialise the 32x32 cursor to be transparent in 2bpp mode.
    1.66 	 */
    1.67-	hwcurs->base = PADDR(scr->storage);
    1.68 	p = (uchar*)scr->storage;
    1.69 	for(i = 0; i < 32/2; i++) {
    1.70 		memset(p, 0xff, 8);
    1.71 		memset(p+8, 0, 8);
    1.72 		p += 16;
    1.73 	}
    1.74+
    1.75 	/*
    1.76 	 * Load, locate and enable the 32x32 cursor in 2bpp mode.
    1.77 	 */