summaryrefslogtreecommitdiff
path: root/sys/src/9/pc
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2021-11-26 20:51:45 +0000
committercinap_lenrek <cinap_lenrek@felloff.net>2021-11-26 20:51:45 +0000
commit20ea113790c22e5fc8dd0051baa359e4fa083425 (patch)
treea64dbfef9f4e41db253a1d8f240bf6b060639b27 /sys/src/9/pc
parentadd3a0a4da2f46f69a87782699e77c794a8b2cb9 (diff)
kernel: support large 64-bit pci membars, increase pc64 VMAPSIZE to 1TB
This makes vmap()/vunmap() take a vlong size argument, and change the type of Pci.mem[].size to vlong as well. Even if vmap() wont support large mappings, it is nice to get the original unruncated value for error checking. pc64 needs a bigger VMAP window, as system76 pangolin puts the framebuffer at a physical address > 512GB.
Diffstat (limited to 'sys/src/9/pc')
-rw-r--r--sys/src/9/pc/devpccard.c4
-rw-r--r--sys/src/9/pc/etherwavelan.c4
-rw-r--r--sys/src/9/pc/fns.h10
-rw-r--r--sys/src/9/pc/memory.c6
-rw-r--r--sys/src/9/pc/mmu.c12
-rw-r--r--sys/src/9/pc/pcipc.c2
-rw-r--r--sys/src/9/pc/screen.c21
-rw-r--r--sys/src/9/pc/screen.h4
-rw-r--r--sys/src/9/pc/usbehcipc.c2
-rw-r--r--sys/src/9/pc/usbohci.c2
-rw-r--r--sys/src/9/pc/usbuhci.c2
-rw-r--r--sys/src/9/pc/vga.c4
-rw-r--r--sys/src/9/pc/vganeomagic.c4
13 files changed, 37 insertions, 40 deletions
diff --git a/sys/src/9/pc/devpccard.c b/sys/src/9/pc/devpccard.c
index 88d29fb31..0ceadbd37 100644
--- a/sys/src/9/pc/devpccard.c
+++ b/sys/src/9/pc/devpccard.c
@@ -1266,11 +1266,11 @@ pccardread(Chan *c, void *a, long n, vlong offset)
for (i = 0; i < nelem(pci->mem); i++)
if (pci->mem[i].size)
p = seprint(p, e,
- "\tmem[%d] %.8ullX (%.8uX)\n",
+ "\tmem[%d] %.8ullX (%.8ullX)\n",
i, pci->mem[i].bar,
pci->mem[i].size);
if (pci->rom.size)
- p = seprint(p, e, "\tROM %.8ullX (%.8uX)\n",
+ p = seprint(p, e, "\tROM %.8ullX (%.8ullX)\n",
pci->rom.bar, pci->rom.size);
pci = pci->link;
}
diff --git a/sys/src/9/pc/etherwavelan.c b/sys/src/9/pc/etherwavelan.c
index 4bbc94770..f315f5cbb 100644
--- a/sys/src/9/pc/etherwavelan.c
+++ b/sys/src/9/pc/etherwavelan.c
@@ -113,7 +113,7 @@ wavelanpciscan(void)
* On the Prism, bar[0] is the memory-mapped register address (4KB),
*/
if((p->mem[0].bar & 1) != 0 || p->mem[0].size != 4096){
- print("wavelanpci: %.4ux %.4ux: unlikely mmio bar %llux size %d\n",
+ print("wavelanpci: %.4ux %.4ux: unlikely mmio bar %llux size %lld\n",
p->vid, p->did, p->mem[0].bar, p->mem[0].size);
continue;
}
@@ -126,7 +126,7 @@ wavelanpciscan(void)
ctlr->pcidev = p;
mem = vmap(p->mem[0].bar&~0xF, p->mem[0].size);
if(mem == nil){
- print("wavelanpci: %.4ux %.4ux: vmap %llux %d failed\n",
+ print("wavelanpci: %.4ux %.4ux: vmap %llux %lld failed\n",
p->vid, p->did, p->mem[0].bar&~0xF, p->mem[0].size);
free(ctlr);
continue;
diff --git a/sys/src/9/pc/fns.h b/sys/src/9/pc/fns.h
index 89ffd5e19..994362489 100644
--- a/sys/src/9/pc/fns.h
+++ b/sys/src/9/pc/fns.h
@@ -159,15 +159,15 @@ int tas(void*);
uvlong tscticks(uvlong*);
ulong umballoc(ulong, ulong, ulong);
void umbfree(ulong, ulong);
-uvlong upaalloc(uvlong, ulong, ulong);
-uvlong upaallocwin(uvlong, ulong, ulong, ulong);
-void upafree(uvlong, ulong);
+uvlong upaalloc(uvlong, uvlong, uvlong);
+uvlong upaallocwin(uvlong, uvlong, uvlong, uvlong);
+void upafree(uvlong, uvlong);
void vectortable(void);
-void* vmap(uvlong, int);
+void* vmap(uvlong, vlong);
int vmapsync(ulong);
void vmxprocrestore(Proc *);
void vmxshutdown(void);
-void vunmap(void*, int);
+void vunmap(void*, vlong);
void wbinvd(void);
void writeconf(void);
int wrmsr(int, vlong);
diff --git a/sys/src/9/pc/memory.c b/sys/src/9/pc/memory.c
index 8853d4c0b..8b6cf8620 100644
--- a/sys/src/9/pc/memory.c
+++ b/sys/src/9/pc/memory.c
@@ -245,13 +245,13 @@ rsdsearch(void)
* Call vmap to do that.
*/
uvlong
-upaalloc(uvlong pa, ulong size, ulong align)
+upaalloc(uvlong pa, uvlong size, uvlong align)
{
return memmapalloc(pa, size, align, MemUPA);
}
uvlong
-upaallocwin(uvlong pa, ulong win, ulong size, ulong align)
+upaallocwin(uvlong pa, uvlong win, uvlong size, uvlong align)
{
uvlong a, base, top = pa + win;
@@ -269,7 +269,7 @@ upaallocwin(uvlong pa, ulong win, ulong size, ulong align)
}
void
-upafree(uvlong pa, ulong size)
+upafree(uvlong pa, uvlong size)
{
memmapfree(pa, size, MemUPA);
}
diff --git a/sys/src/9/pc/mmu.c b/sys/src/9/pc/mmu.c
index a21c94197..be5b9fd25 100644
--- a/sys/src/9/pc/mmu.c
+++ b/sys/src/9/pc/mmu.c
@@ -530,13 +530,13 @@ static void pdbunmap(ulong*, ulong, int);
* Add a device mapping to the vmap range.
*/
void*
-vmap(uvlong pa, int size)
+vmap(uvlong pa, vlong size)
{
- int osize;
+ vlong osize;
ulong o, va;
if(pa < BY2PG || size <= 0 || ((pa+size) >> 32) != 0 || size > VMAPSIZE){
- print("vmap pa=%llux size=%d pc=%#p\n", pa, size, getcallerpc(&pa));
+ print("vmap pa=%llux size=%lld pc=%#p\n", pa, size, getcallerpc(&pa));
return nil;
}
@@ -560,7 +560,7 @@ vmap(uvlong pa, int size)
vmapsync(va+i);
*/
USED(osize);
-// print(" vmap %#.8lux %d => %#.8lux\n", pa+o, osize, va+o);
+// print(" vmap %#.8lux %lld => %#.8lux\n", pa+o, osize, va+o);
return (void*)(va + o);
}
@@ -621,7 +621,7 @@ vmapalloc(ulong size)
* the call need not be interlocked with vmap.
*/
void
-vunmap(void *v, int size)
+vunmap(void *v, vlong size)
{
ulong va, o;
@@ -635,7 +635,7 @@ vunmap(void *v, int size)
size = ROUND(size, BY2PG);
if(size < 0 || va < VMAP || va+size > VMAP+VMAPSIZE)
- panic("vunmap va=%#.8lux size=%#x pc=%#.8lux",
+ panic("vunmap va=%#.8lux size=%lld pc=%#.8lux",
va, size, getcallerpc(&v));
pdbunmap(MACHP(0)->pdb, va, size);
diff --git a/sys/src/9/pc/pcipc.c b/sys/src/9/pc/pcipc.c
index f5bb530bb..9e5ecdefd 100644
--- a/sys/src/9/pc/pcipc.c
+++ b/sys/src/9/pc/pcipc.c
@@ -603,7 +603,7 @@ pcireserve(void)
p->mem[i].bar |= pa;
}
pcisetbar(p, PciBAR0 + i*4, p->mem[i].bar);
- DBG("%s: bar%d: fixed %.8lluX %d\n", tag, i, p->mem[i].bar, p->mem[i].size);
+ DBG("%s: bar%d: fixed %.8lluX %lld\n", tag, i, p->mem[i].bar, p->mem[i].size);
}
}
}
diff --git a/sys/src/9/pc/screen.c b/sys/src/9/pc/screen.c
index 8efb9fc50..072cbb7c4 100644
--- a/sys/src/9/pc/screen.c
+++ b/sys/src/9/pc/screen.c
@@ -563,9 +563,10 @@ blankscreen(int blank)
}
static char*
-vgalinearaddr0(VGAscr *scr, uvlong paddr, int size)
+vgalinearaddr0(VGAscr *scr, uvlong paddr, vlong size)
{
- int x, nsize;
+ int x;
+ vlong nsize;
uvlong npaddr;
/*
@@ -603,7 +604,7 @@ vgalinearaddr0(VGAscr *scr, uvlong paddr, int size)
scr->vaddr = (char*)scr->vaddr+x;
scr->paddr = paddr;
- scr->apsize = nsize;
+ scr->apsize = (int)nsize;
mtrr(npaddr, nsize, "wc");
@@ -613,8 +614,7 @@ vgalinearaddr0(VGAscr *scr, uvlong paddr, int size)
static char*
vgalinearpci0(VGAscr *scr)
{
- int i, size, best;
- uvlong paddr;
+ int i, best;
Pcidev *p;
p = scr->pci;
@@ -645,12 +645,9 @@ vgalinearpci0(VGAscr *scr)
&& !(p->mem[best].bar&8)))
best = i;
}
- if(best >= 0){
- paddr = p->mem[best].bar & ~0x0F;
- size = p->mem[best].size;
- return vgalinearaddr0(scr, paddr, size);
- }
- return "no video memory found on pci card";
+ if(best < 0)
+ return "no video memory found on pci card";
+ return vgalinearaddr0(scr, p->mem[best].bar&~0xF, p->mem[best].size);
}
void
@@ -665,7 +662,7 @@ vgalinearpci(VGAscr *scr)
}
void
-vgalinearaddr(VGAscr *scr, uvlong paddr, int size)
+vgalinearaddr(VGAscr *scr, uvlong paddr, vlong size)
{
char *err;
diff --git a/sys/src/9/pc/screen.h b/sys/src/9/pc/screen.h
index 7e0e97628..1b87d5112 100644
--- a/sys/src/9/pc/screen.h
+++ b/sys/src/9/pc/screen.h
@@ -136,7 +136,7 @@ extern char *tiltstr[4];
extern Rectangle actualscreensize(VGAscr*);
extern void setactualsize(VGAscr*, Rectangle);
extern void setscreensize(VGAscr*, int, int, int, ulong, int);
-extern void addvgaseg(char*, uvlong, ulong);
+extern void addvgaseg(char*, uvlong, vlong);
extern Memdata* attachscreen(Rectangle*, ulong*, int*, int*, int*);
extern void flushmemscreen(Rectangle);
extern void cursoron(void);
@@ -159,7 +159,7 @@ extern QLock drawlock;
extern void vgascreenwin(VGAscr*);
extern void vgaimageinit(ulong);
extern void vgalinearpci(VGAscr*);
-extern void vgalinearaddr(VGAscr*, uvlong, int);
+extern void vgalinearaddr(VGAscr*, uvlong, vlong);
extern void vgablank(VGAscr*, int);
extern Lock vgascreenlock;
diff --git a/sys/src/9/pc/usbehcipc.c b/sys/src/9/pc/usbehcipc.c
index 08cfe0630..ca40a5112 100644
--- a/sys/src/9/pc/usbehcipc.c
+++ b/sys/src/9/pc/usbehcipc.c
@@ -184,7 +184,7 @@ scanpci(void)
if(io == 0)
continue;
- print("usbehci: %#x %#x: port %llux size %d irq %d\n",
+ print("usbehci: %#x %#x: port %llux size %lld irq %d\n",
p->vid, p->did, io, p->mem[0].size, p->intl);
ctlr = malloc(sizeof(Ctlr));
diff --git a/sys/src/9/pc/usbohci.c b/sys/src/9/pc/usbohci.c
index 6dcaf623f..be4ea879c 100644
--- a/sys/src/9/pc/usbohci.c
+++ b/sys/src/9/pc/usbohci.c
@@ -2401,7 +2401,7 @@ scanpci(void)
io = p->mem[0].bar & ~0xFULL;
if(io == 0)
continue;
- print("usbohci: %#x %#x: port %llux size %#x irq %d\n",
+ print("usbohci: %#x %#x: port %llux size %lld irq %d\n",
p->vid, p->did, io, p->mem[0].size, p->intl);
ctlr = malloc(sizeof(Ctlr));
if(ctlr == nil){
diff --git a/sys/src/9/pc/usbuhci.c b/sys/src/9/pc/usbuhci.c
index f1c084371..744960b09 100644
--- a/sys/src/9/pc/usbuhci.c
+++ b/sys/src/9/pc/usbuhci.c
@@ -2146,7 +2146,7 @@ scanpci(void)
continue;
}
- print("uhci: %#x %#x: port %#ux size %#x irq %d\n",
+ print("uhci: %#x %#x: port %#ux size %lld irq %d\n",
p->vid, p->did, io, p->mem[4].size, p->intl);
ctlr = malloc(sizeof(Ctlr));
diff --git a/sys/src/9/pc/vga.c b/sys/src/9/pc/vga.c
index 6eb1e965a..90682cd96 100644
--- a/sys/src/9/pc/vga.c
+++ b/sys/src/9/pc/vga.c
@@ -252,11 +252,11 @@ vgablank(VGAscr*, int blank)
}
void
-addvgaseg(char *name, uvlong pa, ulong size)
+addvgaseg(char *name, uvlong pa, vlong size)
{
Physseg seg;
- if((uintptr)pa != pa || size == 0 || -(uintptr)pa < size){
+ if((uintptr)pa != pa || size <= 0 || -(uintptr)pa < size){
print("addvgaseg %s: bad address %llux-%llux pc %#p\n",
name, pa, pa+size, getcallerpc(&name));
return;
diff --git a/sys/src/9/pc/vganeomagic.c b/sys/src/9/pc/vganeomagic.c
index ad7208f6a..4815041b7 100644
--- a/sys/src/9/pc/vganeomagic.c
+++ b/sys/src/9/pc/vganeomagic.c
@@ -29,7 +29,7 @@ neomagicenable(VGAscr* scr)
Pcidev *p;
int bar, curoff, vmsize;
uvlong ioaddr;
- ulong iosize;
+ vlong iosize;
/*
* scr->mmio holds the virtual address of the cursor registers
@@ -78,7 +78,7 @@ neomagicenable(VGAscr* scr)
default:
return;
}
- if(p->mem[bar].bar & 1)
+ if(p->mem[bar].bar & 1 || p->mem[bar].size == 0)
return;
ioaddr = p->mem[bar].bar & ~0x0F;
iosize = p->mem[bar].size;