Use PAGE_SIZE rather than NBPG.

This commit is contained in:
thorpej 2003-04-02 04:35:22 +00:00
parent c9228c8ddd
commit 02efafccdc
15 changed files with 79 additions and 70 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cgeight.c,v 1.31 2002/10/23 09:12:05 jdolecek Exp $ */
/* $NetBSD: cgeight.c,v 1.32 2003/04/02 04:35:26 thorpej Exp $ */
/*-
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@ -99,6 +99,7 @@
#include <sys/tty.h>
#include <sys/conf.h>
#include <uvm/uvm_extern.h>
#include <machine/autoconf.h>
#include <machine/eeprom.h>
@ -393,8 +394,8 @@ cgeightioctl(dev, cmd, data, flags, p)
*
* The cg8 maps it's overlay plane at 0 for 128K, followed by the
* enable plane for 128K, followed by the colour for as long as it
* goes. Starting at 8MB, it maps the ramdac for NBPG, then the p4
* register for NBPG, then the bootrom for 0x40000.
* goes. Starting at 8MB, it maps the ramdac for PAGE_SIZE, then the p4
* register for PAGE_SIZE, then the bootrom for 0x40000.
*/
paddr_t
cgeightmmap(dev, off, prot)
@ -456,17 +457,17 @@ cgeightmmap(dev, off, prot)
* colour map (Brooktree)
*/
poff = PFOUR_COLOR_OFF_CMAP;
} else if ((u_int)off == START_SPECIAL + NBPG) {
} else if ((u_int)off == START_SPECIAL + PAGE_SIZE) {
/*
* p4 register
*/
poff = 0;
} else if ((u_int)off > (START_SPECIAL + (NBPG * 2)) &&
(u_int) off < (START_SPECIAL + (NBPG * 2) + PROMSIZE)) {
} else if ((u_int)off > (START_SPECIAL + (PAGE_SIZE * 2)) &&
(u_int) off < (START_SPECIAL + (PAGE_SIZE * 2) + PROMSIZE)) {
/*
* rom
*/
poff = 0x8000 + (off - (START_SPECIAL + (NBPG * 2)));
poff = 0x8000 + (off - (START_SPECIAL + (PAGE_SIZE * 2)));
} else
return (-1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: cgfourteen.c,v 1.31 2002/10/23 09:12:07 jdolecek Exp $ */
/* $NetBSD: cgfourteen.c,v 1.32 2003/04/02 04:35:27 thorpej Exp $ */
/*
* Copyright (c) 1996
@ -223,9 +223,9 @@ cgfourteenattach(parent, self, aux)
*/
fb->fb_linebytes = (fb->fb_type.fb_width * fb->fb_type.fb_depth) / 8;
ramsize = roundup(START + (fb->fb_type.fb_height * fb->fb_linebytes),
NBPG);
PAGE_SIZE);
#else
ramsize = roundup(fb->fb_type.fb_height * fb->fb_linebytes, NBPG);
ramsize = roundup(fb->fb_type.fb_height * fb->fb_linebytes, PAGE_SIZE);
#endif
fb->fb_type.fb_cmsize = CG14_CLUT_SIZE;
fb->fb_type.fb_size = ramsize;

View File

@ -1,4 +1,4 @@
/* $NetBSD: cgtwo.c,v 1.42 2002/12/05 18:05:33 fredette Exp $ */
/* $NetBSD: cgtwo.c,v 1.43 2003/04/02 04:35:27 thorpej Exp $ */
/*
* Copyright (c) 1992, 1993
@ -62,6 +62,8 @@
#include <sys/tty.h>
#include <sys/conf.h>
#include <uvm/uvm_extern.h>
#include <machine/autoconf.h>
#include <dev/sun/fbio.h>
@ -170,7 +172,7 @@ cgtwoattach(parent, self, aux)
fb_setsize_eeprom(fb, fb->fb_type.fb_depth, 1152, 900);
fb->fb_type.fb_cmsize = 256;
fb->fb_type.fb_size = roundup(CG2_MAPPED_SIZE, NBPG);
fb->fb_type.fb_size = roundup(CG2_MAPPED_SIZE, PAGE_SIZE);
printf(": cgtwo, %d x %d",
fb->fb_type.fb_width, fb->fb_type.fb_height);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ie_obio.c,v 1.28 2002/12/10 13:44:50 pk Exp $ */
/* $NetBSD: if_ie_obio.c,v 1.29 2003/04/02 04:35:27 thorpej Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -365,13 +365,13 @@ extern void myetheraddr(u_char *); /* should be elsewhere */
* (a side-effect of this double-map is that the ISCP and SCB
* structures also get aliased there, but we ignore this). The
* first page at `maddr' is only used for ISCP, SCB and the aliased
* SCP; the actual buffers start at maddr+NBPG.
* SCP; the actual buffers start at maddr+PAGE_SIZE.
*
* In a picture:
|---//--- ISCP-SCB-----scp-|--//- buffers -//-|... |iscp-scb-----SCP-|
| | | | | | |
| |<----- NBPG --->| | |<----- NBPG -+-->|
| |<---PAGE_SIZE-->| | |<--PAGE_SIZE-+-->|
| |<------------- msize ------------->| | ^ |
| | | |
| \@maddr (last page dbl mapped)
@ -410,8 +410,8 @@ extern void myetheraddr(u_char *); /* should be elsewhere */
* Rest of first page is unused (wasted!); the other pages
* are used for buffers.
*/
sc->buf_area = NBPG;
sc->buf_area_sz = msize - NBPG;
sc->buf_area = PAGE_SIZE;
sc->buf_area_sz = msize - PAGE_SIZE;
if (i82586_proberam(sc) == 0) {
printf(": memory probe failed\n");

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_le_obio.c,v 1.17 2002/12/10 13:44:50 pk Exp $ */
/* $NetBSD: if_le_obio.c,v 1.18 2003/04/02 04:35:27 thorpej Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -46,6 +46,8 @@
#include <sys/malloc.h>
#include <sys/socket.h>
#include <uvm/uvm_extern.h>
#include <net/if.h>
#include <net/if_ether.h>
#include <net/if_media.h>
@ -184,7 +186,7 @@ leattach_obio(parent, self, aux)
}
/* Allocate DMA buffer */
if ((error = bus_dmamem_alloc(dmatag, MEMSIZE, NBPG, 0,
if ((error = bus_dmamem_alloc(dmatag, MEMSIZE, PAGE_SIZE, 0,
&seg, 1, &rseg,
BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) {
printf("%s: DMA memory allocation error %d\n",

View File

@ -1,4 +1,4 @@
/* $NetBSD: obio.c,v 1.60 2003/01/03 11:57:45 mrg Exp $ */
/* $NetBSD: obio.c,v 1.61 2003/04/02 04:35:28 thorpej Exp $ */
/*-
* Copyright (c) 1997,1998 The NetBSD Foundation, Inc.
@ -328,14 +328,14 @@ obio_find_rom_map(ba, len, hp)
int pgtype;
u_long va, pte;
if (len > NBPG)
if (len > PAGE_SIZE)
return (EINVAL);
pa = BUS_ADDR_PADDR(ba);
pf = pa >> PGSHIFT;
pgtype = PMAP_T2PTE_4(PMAP_OBIO);
for (va = OLDMON_STARTVADDR; va < OLDMON_ENDVADDR; va += NBPG) {
for (va = OLDMON_STARTVADDR; va < OLDMON_ENDVADDR; va += PAGE_SIZE) {
pte = getpte(va);
if ((pte & PG_V) == 0 || (pte & PG_TYPE) != pgtype ||
(pte & PG_PFNUM) != pf)

View File

@ -1,4 +1,4 @@
/* $NetBSD: zs_kgdb.c,v 1.10 2002/09/06 13:18:43 gehenna Exp $ */
/* $NetBSD: zs_kgdb.c,v 1.11 2003/04/02 04:35:28 thorpej Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -345,7 +345,7 @@ findzs(zs)
* Have the obio module figure out which virtual
* address the device is mapped to.
*/
if (obio_find_rom_map(paddr, PMAP_OBIO, NBPG, &bh) != 0)
if (obio_find_rom_map(paddr, PMAP_OBIO, PAGE_SIZE, &bh) != 0)
return (NULL);
return ((void *)bh);

View File

@ -1,4 +1,4 @@
/* $NetBSD: autoconf.c,v 1.192 2003/02/26 17:39:06 pk Exp $ */
/* $NetBSD: autoconf.c,v 1.193 2003/04/02 04:35:22 thorpej Exp $ */
/*
* Copyright (c) 1996
@ -937,7 +937,7 @@ cpu_configure()
/* Clear top bits of physical address on 4/100 */
paddr &= ~0xf0000000;
if (obio_find_rom_map(paddr, NBPG, &bh) != 0)
if (obio_find_rom_map(paddr, PAGE_SIZE, &bh) != 0)
panic("configure: ROM hasn't mapped memreg!");
par_err_reg = (volatile int *)bh;

View File

@ -1,4 +1,4 @@
/* $NetBSD: cache.c,v 1.77 2003/01/20 22:15:54 pk Exp $ */
/* $NetBSD: cache.c,v 1.78 2003/04/02 04:35:23 thorpej Exp $ */
/*
* Copyright (c) 1996
@ -65,6 +65,8 @@
#include <sys/systm.h>
#include <sys/kernel.h>
#include <uvm/uvm_extern.h>
#include <machine/ctlreg.h>
#include <machine/pte.h>
@ -372,7 +374,7 @@ sun4_vcache_flush_context(ctx)
cachestats.cs_ncxflush++;
p = (char *)0; /* addresses 0..cacheinfo.c_totalsize will do fine */
if (CACHEINFO.c_hwflush) {
ls = NBPG;
ls = PAGE_SIZE;
i = CACHEINFO.c_totalsize >> PGSHIFT;
for (; --i >= 0; p += ls)
sta(p, ASI_HWFLUSHCTX, 0);
@ -430,7 +432,7 @@ sun4_vcache_flush_segment(vreg, vseg, ctx)
cachestats.cs_nsgflush++;
p = (char *)VSTOVA(vreg, vseg); /* seg..seg+sz rather than 0..sz */
if (CACHEINFO.c_hwflush) {
ls = NBPG;
ls = PAGE_SIZE;
i = CACHEINFO.c_totalsize >> PGSHIFT;
for (; --i >= 0; p += ls)
sta(p, ASI_HWFLUSHSEG, 0);
@ -463,7 +465,7 @@ sun4_vcache_flush_page(va, ctx)
cachestats.cs_npgflush++;
p = (char *)va;
ls = CACHEINFO.c_linesize;
i = NBPG >> CACHEINFO.c_l2linesize;
i = PAGE_SIZE >> CACHEINFO.c_l2linesize;
for (; --i >= 0; p += ls)
sta(p, ASI_FLUSHPG, 0);
}
@ -499,7 +501,7 @@ sun4_vcache_flush_page_hw(va, ctx)
* We choose the best of (context,segment,page) here.
*/
#define CACHE_FLUSH_MAGIC (CACHEINFO.c_totalsize / NBPG)
#define CACHE_FLUSH_MAGIC (CACHEINFO.c_totalsize / PAGE_SIZE)
void
sun4_cache_flush(base, len, ctx)
@ -543,7 +545,7 @@ sun4_cache_flush(base, len, ctx)
/* cache_flush_page, for i pages */
p = (char *)((int)base & ~baseoff);
if (CACHEINFO.c_hwflush) {
for (; --i >= 0; p += NBPG)
for (; --i >= 0; p += PAGE_SIZE)
sta(p, ASI_HWFLUSHPG, 0);
} else {
ls = CACHEINFO.c_linesize;
@ -680,7 +682,7 @@ srmmu_vcache_flush_page(va, ctx)
cachestats.cs_npgflush++;
p = (char *)va;
ls = CACHEINFO.c_linesize;
i = NBPG >> CACHEINFO.c_l2linesize;
i = PAGE_SIZE >> CACHEINFO.c_l2linesize;
octx = getcontext4m();
trapoff();
setcontext4m(ctx);
@ -718,7 +720,7 @@ srmmu_cache_flush_all()
* We choose the best of (context,segment,page) here.
*/
#define CACHE_FLUSH_MAGIC (CACHEINFO.c_totalsize / NBPG)
#define CACHE_FLUSH_MAGIC (CACHEINFO.c_totalsize / PAGE_SIZE)
void
srmmu_cache_flush(base, len, ctx)
@ -729,7 +731,7 @@ srmmu_cache_flush(base, len, ctx)
int i, ls, baseoff;
char *p;
if (len < NBPG) {
if (len < PAGE_SIZE) {
int octx;
/* less than a page, flush just the covered cache lines */
ls = CACHEINFO.c_linesize;

View File

@ -1,4 +1,4 @@
/* $NetBSD: cpu.c,v 1.174 2003/02/26 17:39:07 pk Exp $ */
/* $NetBSD: cpu.c,v 1.175 2003/04/02 04:35:24 thorpej Exp $ */
/*
* Copyright (c) 1996
@ -161,7 +161,7 @@ alloc_cpuinfo_global_va(ismaster, sizep)
* NOTE: we're using the cache properties of the boot CPU to
* determine the alignment (XXX).
*/
align = NBPG;
align = PAGE_SIZE;
if (CACHEINFO.c_totalsize > align)
/* Assumes `c_totalsize' is power of two */
align = CACHEINFO.c_totalsize;
@ -177,8 +177,8 @@ alloc_cpuinfo_global_va(ismaster, sizep)
sz += INT_STACK_SIZE; /* interrupt stack for this CPU */
}
sz = (sz + NBPG - 1) & -NBPG;
esz = sz + align - NBPG;
sz = (sz + PAGE_SIZE - 1) & -PAGE_SIZE;
esz = sz + align - PAGE_SIZE;
if ((sva = uvm_km_valloc(kernel_map, esz)) == 0)
panic("alloc_cpuinfo_global_va: no virtual space");
@ -213,15 +213,15 @@ alloc_cpuinfo()
/* Allocate physical pages */
low = vm_first_phys;
high = vm_first_phys + vm_num_phys - NBPG;
if (uvm_pglistalloc(sz, low, high, NBPG, 0, &mlist, 1, 0) != 0)
high = vm_first_phys + vm_num_phys - PAGE_SIZE;
if (uvm_pglistalloc(sz, low, high, PAGE_SIZE, 0, &mlist, 1, 0) != 0)
panic("alloc_cpuinfo: no pages");
/* Map the pages */
for (m = TAILQ_FIRST(&mlist); m != NULL; m = TAILQ_NEXT(m, pageq)) {
paddr_t pa = VM_PAGE_TO_PHYS(m);
pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE);
va += NBPG;
va += PAGE_SIZE;
}
pmap_update(pmap_kernel());

View File

@ -1,4 +1,4 @@
/* $NetBSD: intr.c,v 1.80 2003/03/02 21:42:48 pk Exp $ */
/* $NetBSD: intr.c,v 1.81 2003/04/02 04:35:24 thorpej Exp $ */
/*
* Copyright (c) 1992, 1993
@ -487,12 +487,13 @@ inst_fasttrap(int level, void (*vec)(void))
s = splhigh();
/* kernel text is write protected -- let us in for a moment */
pmap_kprotect((vaddr_t)tv & -NBPG, NBPG, VM_PROT_READ|VM_PROT_WRITE);
pmap_kprotect((vaddr_t)tv & -PAGE_SIZE, PAGE_SIZE,
VM_PROT_READ|VM_PROT_WRITE);
cpuinfo.cache_flush_all();
tv->tv_instr[0] = I_SETHI(I_L3, hi22); /* sethi %hi(vec),%l3 */
tv->tv_instr[1] = I_JMPLri(I_G0, I_L3, lo10);/* jmpl %l3+%lo(vec),%g0 */
tv->tv_instr[2] = I_RDPSR(I_L0); /* mov %psr, %l0 */
pmap_kprotect((vaddr_t)tv & -NBPG, NBPG, VM_PROT_READ);
pmap_kprotect((vaddr_t)tv & -PAGE_SIZE, PAGE_SIZE, VM_PROT_READ);
cpuinfo.cache_flush_all();
fastvec |= 1 << level;
splx(s);
@ -515,12 +516,13 @@ uninst_fasttrap(int level)
: &sparc_interrupt44c[0] - &tv->tv_instr[1];
/* kernel text is write protected -- let us in for a moment */
pmap_kprotect((vaddr_t)tv & -NBPG, NBPG, VM_PROT_READ|VM_PROT_WRITE);
pmap_kprotect((vaddr_t)tv & -PAGE_SIZE, PAGE_SIZE,
VM_PROT_READ|VM_PROT_WRITE);
cpuinfo.cache_flush_all();
tv->tv_instr[0] = I_MOVi(I_L3, level);
tv->tv_instr[1] = I_BA(0, displ);
tv->tv_instr[2] = I_RDPSR(I_L0);
pmap_kprotect((vaddr_t)tv & -NBPG, NBPG, VM_PROT_READ);
pmap_kprotect((vaddr_t)tv & -PAGE_SIZE, PAGE_SIZE, VM_PROT_READ);
cpuinfo.cache_flush_all();
fastvec &= ~(1 << level);
splx(s);

View File

@ -1,4 +1,4 @@
/* $NetBSD: iommu.c,v 1.74 2003/01/01 02:20:48 thorpej Exp $ */
/* $NetBSD: iommu.c,v 1.75 2003/04/02 04:35:24 thorpej Exp $ */
/*
* Copyright (c) 1996
@ -212,8 +212,8 @@ iommu_attach(parent, self, aux)
sc->sc_hasiocache = 0;
has_iocache = sc->sc_hasiocache; /* Set global flag */
sc->sc_pagesize = js1_implicit_iommu ? NBPG
: PROM_getpropint(node, "page-size", NBPG),
sc->sc_pagesize = js1_implicit_iommu ? PAGE_SIZE
: PROM_getpropint(node, "page-size", PAGE_SIZE),
/*
* Allocate memory for I/O pagetables.
@ -241,7 +241,7 @@ iommu_attach(parent, self, aux)
for (; m != NULL; m = TAILQ_NEXT(m,pageq)) {
paddr_t pa = VM_PAGE_TO_PHYS(m);
pmap_kenter_pa(va, pa | PMAP_NC, VM_PROT_READ | VM_PROT_WRITE);
va += NBPG;
va += PAGE_SIZE;
}
pmap_update(pmap_kernel());
@ -480,9 +480,9 @@ if ((int)sc->sc_dvmacur + len > 0)
pte |= IOMMU_V | IOMMU_W;
sta(sc->sc_ptes + atop(tva - sc->sc_dvmabase), ASI_BYPASS, pte);
sc->sc_reg->io_flushpage = tva;
len -= NBPG;
va += NBPG;
tva += NBPG;
len -= PAGE_SIZE;
va += PAGE_SIZE;
tva += PAGE_SIZE;
}
return iovaddr + off;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: kgdb_machdep.c,v 1.11 2002/07/17 15:57:12 thorpej Exp $ */
/* $NetBSD: kgdb_machdep.c,v 1.12 2003/04/02 04:35:25 thorpej Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* All rights reserved.
@ -370,7 +370,7 @@ kgdb_acc(va, len)
if (va >= (vaddr_t)0xfffff000)
return (0);
for (; va < eva; va += NBPG) {
for (; va < eva; va += PAGE_SIZE) {
#if defined(SUN4M) || defined(SUN4D)
if (CPU_HAS_SRMMU) {
pte = getpte4m(va);

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.222 2003/01/18 06:45:05 thorpej Exp $ */
/* $NetBSD: machdep.c,v 1.223 2003/04/02 04:35:25 thorpej Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@ -315,7 +315,7 @@ cpu_startup()
* "base" pages for the rest.
*/
curbuf = (vaddr_t) buffers + (i * MAXBSIZE);
curbufsize = NBPG * ((i < residual) ? (base+1) : base);
curbufsize = PAGE_SIZE * ((i < residual) ? (base+1) : base);
while (curbufsize) {
pg = uvm_pagealloc(NULL, 0, NULL, 0);
@ -360,7 +360,7 @@ cpu_startup()
#endif
format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
printf("avail memory = %s\n", pbuf);
format_bytes(pbuf, sizeof(pbuf), bufpages * NBPG);
format_bytes(pbuf, sizeof(pbuf), bufpages * PAGE_SIZE);
printf("using %u buffers containing %s of memory\n", nbuf, pbuf);
/*
@ -1148,9 +1148,9 @@ dumpsys()
if (maddr == 0) {
/* Skip first page at physical address 0 */
maddr += NBPG;
i += NBPG;
blkno += btodb(NBPG);
maddr += PAGE_SIZE;
i += PAGE_SIZE;
blkno += btodb(PAGE_SIZE);
}
for (; i < mp->len; i += n) {
@ -1251,7 +1251,7 @@ oldmon_w_trace(va)
uvmexp.softs, uvmexp.faults);
write_user_windows();
#define round_up(x) (( (x) + (NBPG-1) ) & (~(NBPG-1)) )
#define round_up(x) (( (x) + (PAGE_SIZE-1) ) & (~(PAGE_SIZE-1)) )
printf("\nstack trace with sp = 0x%lx\n", va);
stop = round_up(va);

View File

@ -1,4 +1,4 @@
/* $NetBSD: mem.c,v 1.32 2002/10/23 09:12:11 jdolecek Exp $ */
/* $NetBSD: mem.c,v 1.33 2003/04/02 04:35:26 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -125,16 +125,16 @@ mmrw(dev, uio, flags)
trunc_page(pa), prot, prot|PMAP_WIRED);
pmap_update(pmap_kernel());
o = uio->uio_offset & PGOFSET;
c = min(uio->uio_resid, (int)(NBPG - o));
c = min(uio->uio_resid, (int)(PAGE_SIZE - o));
error = uiomove((caddr_t)vmmap + o, c, uio);
pmap_remove(pmap_kernel(),
(vaddr_t)vmmap, (vaddr_t)vmmap + NBPG);
(vaddr_t)vmmap, (vaddr_t)vmmap + PAGE_SIZE);
pmap_update(pmap_kernel());
break;
case DEV_KMEM:
va = (vaddr_t)uio->uio_offset;
if (va >= MSGBUF_VA && va < MSGBUF_VA+NBPG) {
if (va >= MSGBUF_VA && va < MSGBUF_VA+PAGE_SIZE) {
c = min(iov->iov_len, 4096);
} else if (va >= prom_vstart && va < prom_vend &&
uio->uio_rw == UIO_READ) {
@ -173,10 +173,10 @@ mmrw(dev, uio, flags)
}
if (zeropage == NULL) {
zeropage = (caddr_t)
malloc(NBPG, M_TEMP, M_WAITOK);
bzero(zeropage, NBPG);
malloc(PAGE_SIZE, M_TEMP, M_WAITOK);
bzero(zeropage, PAGE_SIZE);
}
c = min(iov->iov_len, NBPG);
c = min(iov->iov_len, PAGE_SIZE);
error = uiomove(zeropage, c, uio);
break;