changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: igfx: use mmio to access registers instead of pio, fix wrong igfxmmio segment size

changeset 4191: 6c111860e9b6
parent 4190: fbe5f205ecc4
child 4192: deca0df1450c
child 4193: cedbb32db01e
author: cinap_lenrek@felloff.net
date: Sat, 10 Jan 2015 03:07:29 +0100
files: sys/src/9/pc/vgaigfx.c sys/src/cmd/aux/vga/igfx.c
description: igfx: use mmio to access registers instead of pio, fix wrong igfxmmio segment size

initially, pio was used to access registers so i didnt need
a kernel driver for initial testing.

pio does not work under efi, so use mmio to access registers.
     1.1--- a/sys/src/9/pc/vgaigfx.c
     1.2+++ b/sys/src/9/pc/vgaigfx.c
     1.3@@ -25,7 +25,7 @@ igfxenable(VGAscr* scr)
     1.4 	scr->mmio = vmap(p->mem[0].bar&~0x0F, p->mem[0].size);
     1.5 	if(scr->mmio == nil)
     1.6 		return;
     1.7-	addvgaseg("igfxmmio", p->mem[0].bar&~0x0F, p->mem[1].size);
     1.8+	addvgaseg("igfxmmio", p->mem[0].bar&~0x0F, p->mem[0].size);
     1.9 	if(scr->paddr == 0)
    1.10 		vgalinearpci(scr);
    1.11 	if(scr->apsize){
     2.1--- a/sys/src/cmd/aux/vga/igfx.c
     2.2+++ b/sys/src/cmd/aux/vga/igfx.c
     2.3@@ -119,6 +119,7 @@ struct Igfx {
     2.4 	Pcidev	*pci;
     2.5 
     2.6 	u32int	pio;
     2.7+	u32int	*mmio;
     2.8 
     2.9 	int	type;
    2.10 
    2.11@@ -157,6 +158,8 @@ rr(Igfx *igfx, u32int a)
    2.12 	if(a == 0)
    2.13 		return 0;
    2.14 	assert((a & 3) == 0);
    2.15+	if(igfx->mmio != nil)
    2.16+		return igfx->mmio[a/4];
    2.17 	outportl(igfx->pio, a);
    2.18 	return inportl(igfx->pio + 4);
    2.19 }
    2.20@@ -165,8 +168,11 @@ wr(Igfx *igfx, u32int a, u32int v)
    2.21 {
    2.22 	if(a == 0)	/* invalid */
    2.23 		return;
    2.24-
    2.25 	assert((a & 3) == 0);
    2.26+	if(igfx->mmio != nil){
    2.27+		igfx->mmio[a/4] = v;
    2.28+		return;
    2.29+	}
    2.30 	outportl(igfx->pio, a);
    2.31 	outportl(igfx->pio + 4, v);
    2.32 }
    2.33@@ -319,11 +325,18 @@ snarf(Vga* vga, Ctlr* ctlr)
    2.34 			error("%s: unrecognized device\n", ctlr->name);
    2.35 			return;
    2.36 		}
    2.37-		if((igfx->pci->mem[4].bar & 1) == 0){
    2.38-			error("%s: no pio bar\n", ctlr->name);
    2.39-			return;
    2.40+		vgactlpci(igfx->pci);
    2.41+		if(1){
    2.42+			vgactlw("type", ctlr->name);
    2.43+			igfx->mmio = segattach(0, "igfxmmio", 0, igfx->pci->mem[0].size);
    2.44+			if(igfx->mmio == (u32int*)-1)
    2.45+				error("%s: segattach mmio failed: %r\n", ctlr->name);
    2.46+		} else {
    2.47+			if((igfx->pci->mem[4].bar & 1) == 0)
    2.48+				error("%s: no pio bar\n", ctlr->name);
    2.49+			igfx->pio = igfx->pci->mem[4].bar & ~1;
    2.50+			igfx->mmio = nil;
    2.51 		}
    2.52-		igfx->pio = igfx->pci->mem[4].bar & ~1;
    2.53 		vga->private = igfx;
    2.54 	}
    2.55