From 440d68d00350f8dc0d14a7bb8d385a0b6c819bb2 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sat, 26 Nov 2011 21:24:01 +0100 Subject: [PATCH] vgavesa: some nvidia cards start the framebuffer in the middle of a pci membar --- sys/src/9/pc/vgavesa.c | 17 +++++++++-------- 1 file 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; imem); i++) - if(paddr == (pci->mem[i].bar&~0x0F)){ - if(pci->mem[i].size > size) - size = pci->mem[i].size; + for(i=0; imem); 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)