diff options
author | 2006-06-29 17:53:35 +0000 | |
---|---|---|
committer | 2006-06-29 17:53:35 +0000 | |
commit | c1edca235adad83a84e82c2fc7758da9837f9d97 (patch) | |
tree | 2e2f3e7ae36aaf68b7360c6dc5ba551cd11f37cf /sys | |
parent | Map the correct size for the colormap registers (not that it really matters (diff) | |
download | wireguard-openbsd-c1edca235adad83a84e82c2fc7758da9837f9d97.tar.xz wireguard-openbsd-c1edca235adad83a84e82c2fc7758da9837f9d97.zip |
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.c | 22 |
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 { |