ref: 6e67b04a1fa9da8591abccb3c03859b50e3679d8
parent: 7c3736a16aafe0ca1fe385e86950edf22cf6fe4d
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Fri Jan 9 22:07:29 EST 2015
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.
--- a/sys/src/9/pc/vgaigfx.c
+++ b/sys/src/9/pc/vgaigfx.c
@@ -25,7 +25,7 @@
scr->mmio = vmap(p->mem[0].bar&~0x0F, p->mem[0].size);
if(scr->mmio == nil)
return;
- addvgaseg("igfxmmio", p->mem[0].bar&~0x0F, p->mem[1].size);
+ addvgaseg("igfxmmio", p->mem[0].bar&~0x0F, p->mem[0].size);
if(scr->paddr == 0)
vgalinearpci(scr);
if(scr->apsize){
--- a/sys/src/cmd/aux/vga/igfx.c
+++ b/sys/src/cmd/aux/vga/igfx.c
@@ -119,6 +119,7 @@
Pcidev *pci;
u32int pio;
+ u32int *mmio;
int type;
@@ -157,6 +158,8 @@
if(a == 0)
return 0;
assert((a & 3) == 0);
+ if(igfx->mmio != nil)
+ return igfx->mmio[a/4];
outportl(igfx->pio, a);
return inportl(igfx->pio + 4);
}
@@ -165,8 +168,11 @@
{
if(a == 0) /* invalid */
return;
-
assert((a & 3) == 0);
+ if(igfx->mmio != nil){
+ igfx->mmio[a/4] = v;
+ return;
+ }
outportl(igfx->pio, a);
outportl(igfx->pio + 4, v);
}
@@ -319,11 +325,18 @@
error("%s: unrecognized device\n", ctlr->name);
return;
}
- if((igfx->pci->mem[4].bar & 1) == 0){
- error("%s: no pio bar\n", ctlr->name);
- return;
+ vgactlpci(igfx->pci);
+ if(1){
+ vgactlw("type", ctlr->name);
+ igfx->mmio = segattach(0, "igfxmmio", 0, igfx->pci->mem[0].size);
+ if(igfx->mmio == (u32int*)-1)
+ error("%s: segattach mmio failed: %r\n", ctlr->name);
+ } else {
+ if((igfx->pci->mem[4].bar & 1) == 0)
+ error("%s: no pio bar\n", ctlr->name);
+ igfx->pio = igfx->pci->mem[4].bar & ~1;
+ igfx->mmio = nil;
}
- igfx->pio = igfx->pci->mem[4].bar & ~1;
vga->private = igfx;
}