summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2006-06-29 17:53:36 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2006-06-29 17:53:36 +0000
commitb72c6ee96af7f31eb5c7b25ede5b193eed0e7053 (patch)
tree6ec5d45f85c7286b97497498cdc17c3870125d7b /sys
parent956a4879acec01534a9a3f87007469db6030d446 (diff)
If invoking mapdev() with a non-aligned pa, make sure we allocate enough pages
if we cross a page boundary; really only necessary for some sun4 tricky attachments, no functional change.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/sparc/sparc/machdep.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/sys/arch/sparc/sparc/machdep.c b/sys/arch/sparc/sparc/machdep.c
index 02fb40a56cb..1a76dc4d19c 100644
--- a/sys/arch/sparc/sparc/machdep.c
+++ b/sys/arch/sparc/sparc/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.108 2006/06/09 06:41:44 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.109 2006/06/29 17:53:35 miod Exp $ */
/* $NetBSD: machdep.c,v 1.85 1997/09/12 08:55:02 pk Exp $ */
/*
@@ -982,7 +982,7 @@ mapdev(phys, virt, offset, size)
int offset, virt, size;
{
vaddr_t va;
- paddr_t pa;
+ paddr_t pa, base;
void *ret;
static vaddr_t iobase;
unsigned int pmtype;
@@ -990,22 +990,24 @@ mapdev(phys, virt, offset, size)
if (iobase == NULL)
iobase = IODEV_BASE;
- size = round_page(size);
- if (size == 0)
- panic("mapdev: zero size");
-
- if (virt)
+ base = (paddr_t)phys->rr_paddr + offset;
+ if (virt != 0) {
va = trunc_page(virt);
- else {
+ size = round_page(virt + size) - va;
+ } else {
+ size = round_page(base + size) - trunc_page(base);
va = iobase;
iobase += size;
if (iobase > IODEV_END) /* unlikely */
panic("mapiodev");
}
- ret = (void *)(va | (((u_long)phys->rr_paddr + offset) & PGOFSET));
+ if (size == 0)
+ panic("mapdev: zero size");
+
+ ret = (void *)(va | (base & PGOFSET));
/* note: preserve page offset */
- pa = trunc_page((vaddr_t)phys->rr_paddr + offset);
+ pa = trunc_page(base);
pmtype = PMAP_IOENC(phys->rr_iospace);
do {