summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@centraldogma>2011-11-26 21:24:01 +0100
committercinap_lenrek <cinap_lenrek@centraldogma>2011-11-26 21:24:01 +0100
commit440d68d00350f8dc0d14a7bb8d385a0b6c819bb2 (patch)
tree7b4bd1f45a493361042cc6e7111bc7b132886fd5
parent9b6ecc6114ce0d526f55e25efbc147348f30c178 (diff)
downloadplan9front-440d68d00350f8dc0d14a7bb8d385a0b6c819bb2.tar.xz
vgavesa: some nvidia cards start the framebuffer in the middle of a pci membar
-rw-r--r--sys/src/9/pc/vgavesa.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/sys/src/9/pc/vgavesa.c b/sys/src/9/pc/vgavesa.c
index 7214aae5f..3e7546801 100644
--- a/sys/src/9/pc/vgavesa.c
+++ b/sys/src/9/pc/vgavesa.c
@@ -130,7 +130,6 @@ vesalinear(VGAscr *scr, int, int)
paddr = LONG(p+40);
size = WORD(p+20)*WORD(p+16);
- size = PGROUND(size);
/*
* figure out max size of memory so that we have
@@ -141,23 +140,25 @@ vesalinear(VGAscr *scr, int, int)
while(!havesize && (pci = pcimatch(pci, 0, 0)) != nil){
if(pci->ccrb != Pcibcdisp)
continue;
- for(i=0; i<nelem(pci->mem); i++)
- if(paddr == (pci->mem[i].bar&~0x0F)){
- if(pci->mem[i].size > size)
- size = pci->mem[i].size;
+ for(i=0; i<nelem(pci->mem); i++){
+ ulong a, e;
+
+ a = pci->mem[i].bar & ~0xF;
+ e = a + pci->mem[i].size;
+ if(paddr >= a && (paddr+size) <= e){
+ size = e - paddr;
havesize = 1;
break;
}
+ }
}
/* no pci - heuristic guess */
- if (!havesize)
+ if(!havesize)
if(size < 4*1024*1024)
size = 4*1024*1024;
else
size = ROUND(size, 1024*1024);
- if(size > 16*1024*1024) /* arbitrary */
- size = 16*1024*1024;
vgalinearaddr(scr, paddr, size);
if(scr->apsize)