From 3d2aff0c44e7a28c51e9c43f02871617101acbd1 Mon Sep 17 00:00:00 2001 From: Martin Reindl Date: Fri, 2 Nov 2007 19:18:55 +0000 Subject: replace ctob/btoc with ptoa/atop (plus the usual round_page() where needed) --- sys/arch/hp300/hp300/hpux_machdep.c | 6 +++--- sys/arch/hp300/hp300/machdep.c | 16 ++++++++-------- sys/arch/hp300/include/cpu.h | 4 ++-- sys/arch/m68k/include/param.h | 6 +----- sys/arch/m68k/m68k/sig_machdep.c | 4 ++-- sys/arch/m68k/m68k/sunos_machdep.c | 4 ++-- sys/arch/mac68k/include/cpu.h | 4 ++-- sys/arch/mac68k/mac68k/machdep.c | 10 +++++----- sys/arch/mac68k/mac68k/pmap_bootstrap.c | 4 ++-- sys/arch/mvme68k/mvme68k/autoconf.c | 6 +++--- sys/arch/mvme68k/mvme68k/hpux_machdep.c | 6 +++--- sys/arch/mvme68k/mvme68k/machdep.c | 10 +++++----- sys/arch/mvme68k/mvme68k/vm_machdep.c | 12 ++++++------ sys/compat/hpux/m68k/hpux_exec.c | 6 +++--- 14 files changed, 47 insertions(+), 51 deletions(-) (limited to 'sys') diff --git a/sys/arch/hp300/hp300/hpux_machdep.c b/sys/arch/hp300/hp300/hpux_machdep.c index 2253a52c63b..e180c0a2789 100644 --- a/sys/arch/hp300/hp300/hpux_machdep.c +++ b/sys/arch/hp300/hp300/hpux_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hpux_machdep.c,v 1.20 2005/11/06 17:23:39 miod Exp $ */ +/* $OpenBSD: hpux_machdep.c,v 1.21 2007/11/02 19:18:54 martin Exp $ */ /* $NetBSD: hpux_machdep.c,v 1.19 1998/02/16 20:58:30 thorpej Exp $ */ /* @@ -296,7 +296,7 @@ hpux_to_bsd_uoff(off, isps, p) * so we convert off to an absolute address (if not already) * for simplicity. */ - if (off < (int *)ctob(UPAGES)) + if (off < (int *)ptoa(UPAGES)) off = (int *)((u_int)off + (u_int)p->p_addr); /* XXX */ /* @@ -410,7 +410,7 @@ hpux_sendsig(catcher, sig, mask, code, type, val) psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else fp = (struct hpuxsigframe *)(frame->f_regs[SP] - fsize); - if ((unsigned)fp <= USRSTACK - ctob(p->p_vmspace->vm_ssize)) + if ((unsigned)fp <= USRSTACK - ptoa(p->p_vmspace->vm_ssize)) (void)uvm_grow(p, (unsigned)fp); #ifdef DEBUG diff --git a/sys/arch/hp300/hp300/machdep.c b/sys/arch/hp300/hp300/machdep.c index 67f3611ad3d..1e36b081f5a 100644 --- a/sys/arch/hp300/hp300/machdep.c +++ b/sys/arch/hp300/hp300/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.115 2007/06/06 17:15:11 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.116 2007/11/02 19:18:54 martin Exp $ */ /* $NetBSD: machdep.c,v 1.121 1999/03/26 23:41:29 mycroft Exp $ */ /* @@ -213,7 +213,7 @@ consinit() * Initialize the bus resource map. */ extio = extent_create("extio", - (u_long)extiobase, (u_long)extiobase + ctob(eiomapsize), + (u_long)extiobase, (u_long)extiobase + ptoa(eiomapsize), M_DEVBUF, extiospace, sizeof(extiospace), EX_NOWAIT); /* @@ -257,7 +257,7 @@ cpu_startup() * Initialize error message buffer (at end of core). * avail_end was pre-decremented in pmap_bootstrap to compensate. */ - for (i = 0; i < btoc(MSGBUFSIZE); i++) + for (i = 0; i < atop(MSGBUFSIZE); i++) pmap_enter(pmap_kernel(), (vaddr_t)msgbufp + i * NBPG, avail_end + i * NBPG, VM_PROT_READ|VM_PROT_WRITE, VM_PROT_READ|VM_PROT_WRITE|PMAP_WIRED); @@ -269,8 +269,8 @@ cpu_startup() */ printf(version); identifycpu(); - printf("real mem = %u (%uMB)\n", ctob(physmem), - ctob(physmem)/1024/1024); + printf("real mem = %u (%uMB)\n", ptoa(physmem), + ptoa(physmem)/1024/1024); /* * Find out how much space we need, allocate it, @@ -734,7 +734,7 @@ dumpconf(void) /* hp300 only uses a single segment. */ cpu_kcore_hdr.ram_segs[0].start = lowram; - cpu_kcore_hdr.ram_segs[0].size = ctob(dumpsize); + cpu_kcore_hdr.ram_segs[0].size = ptoa(dumpsize); cpu_kcore_hdr.mmutype = mmutype; cpu_kcore_hdr.kernel_pa = lowram; cpu_kcore_hdr.sysseg_pa = pmap_kernel()->pm_stpa; @@ -1066,7 +1066,7 @@ parityerrorfind() * for has just occurred (longjmp above) at the current pg+o */ if (setjmp(&parcatch)) { - printf("Parity error at 0x%x\n", ctob(pg)|o); + printf("Parity error at 0x%x\n", ptoa(pg)|o); found = 1; goto done; } @@ -1079,7 +1079,7 @@ parityerrorfind() */ looking = 1; ecacheoff(); - for (pg = btoc(lowram); pg < btoc(lowram)+physmem; pg++) { + for (pg = atop(lowram); pg < atop(lowram)+physmem; pg++) { pmap_kenter_pa((vaddr_t)vmmap, ptoa(pg), VM_PROT_READ); pmap_update(pmap_kernel()); ip = (int *)vmmap; diff --git a/sys/arch/hp300/include/cpu.h b/sys/arch/hp300/include/cpu.h index 8df6120d17b..76afb0a716c 100644 --- a/sys/arch/hp300/include/cpu.h +++ b/sys/arch/hp300/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.34 2007/05/30 17:10:42 miod Exp $ */ +/* $OpenBSD: cpu.h,v 1.35 2007/11/02 19:18:54 martin Exp $ */ /* $NetBSD: cpu.h,v 1.28 1998/02/13 07:41:51 scottr Exp $ */ /* @@ -177,7 +177,7 @@ void dumpconf(void); #define IIOV(pa) ((int)(pa)-INTIOBASE+(int)intiobase) #define IIOP(va) ((int)(va)-(int)intiobase+INTIOBASE) #define IIOPOFF(pa) ((int)(pa)-INTIOBASE) -#define IIOMAPSIZE btoc(INTIOTOP-INTIOBASE) /* 2mb */ +#define IIOMAPSIZE atop(INTIOTOP-INTIOBASE) /* 2mb */ /* * HP MMU diff --git a/sys/arch/m68k/include/param.h b/sys/arch/m68k/include/param.h index 3315b3a56ce..b571e1acde6 100644 --- a/sys/arch/m68k/include/param.h +++ b/sys/arch/m68k/include/param.h @@ -1,4 +1,4 @@ -/* $OpenBSD: param.h,v 1.22 2007/05/28 21:02:49 thib Exp $ */ +/* $OpenBSD: param.h,v 1.23 2007/11/02 19:18:54 martin Exp $ */ /* $NetBSD: param.h,v 1.2 1997/06/10 18:21:23 veego Exp $ */ /* @@ -118,10 +118,6 @@ #define ctod(x) ((x) << (PAGE_SHIFT - DEV_BSHIFT)) #define dtoc(x) ((x) >> (PAGE_SHIFT - DEV_BSHIFT)) -/* pages to bytes */ -#define ctob(x) ((x) << PAGE_SHIFT) -#define btoc(x) (((x) + PAGE_MASK) >> PAGE_SHIFT) - /* bytes to disk blocks */ #define btodb(x) ((x) >> DEV_BSHIFT) #define dbtob(x) ((x) << DEV_BSHIFT) diff --git a/sys/arch/m68k/m68k/sig_machdep.c b/sys/arch/m68k/m68k/sig_machdep.c index c4b7864c491..36832c6bc55 100644 --- a/sys/arch/m68k/m68k/sig_machdep.c +++ b/sys/arch/m68k/m68k/sig_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sig_machdep.c,v 1.18 2006/06/11 20:48:13 miod Exp $ */ +/* $OpenBSD: sig_machdep.c,v 1.19 2007/11/02 19:18:54 martin Exp $ */ /* $NetBSD: sig_machdep.c,v 1.3 1997/04/30 23:28:03 gwr Exp $ */ /* @@ -152,7 +152,7 @@ sendsig(catcher, sig, mask, code, type, val) psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else fp = (struct sigframe *)(frame->f_regs[SP] - fsize); - if ((unsigned)fp <= USRSTACK - ctob(p->p_vmspace->vm_ssize)) + if ((unsigned)fp <= USRSTACK - ptoa(p->p_vmspace->vm_ssize)) (void)uvm_grow(p, (unsigned)fp); #ifdef DEBUG if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) diff --git a/sys/arch/m68k/m68k/sunos_machdep.c b/sys/arch/m68k/m68k/sunos_machdep.c index f95a7024e9a..43efc4be400 100644 --- a/sys/arch/m68k/m68k/sunos_machdep.c +++ b/sys/arch/m68k/m68k/sunos_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sunos_machdep.c,v 1.18 2005/11/06 17:23:41 miod Exp $ */ +/* $OpenBSD: sunos_machdep.c,v 1.19 2007/11/02 19:18:54 martin Exp $ */ /* $NetBSD: sunos_machdep.c,v 1.12 1996/10/13 03:19:22 christos Exp $ */ /* @@ -135,7 +135,7 @@ sunos_sendsig(catcher, sig, mask, code, type, val) psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else fp = (struct sunos_sigframe *)frame->f_regs[SP] - 1; - if ((vaddr_t)fp <= USRSTACK - ctob(p->p_vmspace->vm_ssize)) + if ((vaddr_t)fp <= USRSTACK - ptoa(p->p_vmspace->vm_ssize)) (void)uvm_grow(p, (unsigned)fp); #ifdef DEBUG if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) diff --git a/sys/arch/mac68k/include/cpu.h b/sys/arch/mac68k/include/cpu.h index 8c49d8ec0a1..f3562fbdc94 100644 --- a/sys/arch/mac68k/include/cpu.h +++ b/sys/arch/mac68k/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.45 2007/07/29 21:24:05 miod Exp $ */ +/* $OpenBSD: cpu.h,v 1.46 2007/11/02 19:18:54 martin Exp $ */ /* $NetBSD: cpu.h,v 1.45 1997/02/10 22:13:40 scottr Exp $ */ /* @@ -269,7 +269,7 @@ extern unsigned long load_addr; #define NBSTOP 0xF0000000 #define NBBASE 0xF9000000 /* NUBUS space */ #define NBTOP 0xFF000000 /* NUBUS space */ -#define NBMAPSIZE btoc(NBTOP-NBBASE) /* ~ 96 megs */ +#define NBMAPSIZE atop(NBTOP-NBBASE) /* ~ 96 megs */ #define NBMEMSIZE 0x01000000 /* 16 megs per card */ #define NBROMOFFSET 0x00FF0000 /* Last 64K == ROM */ diff --git a/sys/arch/mac68k/mac68k/machdep.c b/sys/arch/mac68k/mac68k/machdep.c index 8a57e65711a..d45ebd3cefe 100644 --- a/sys/arch/mac68k/mac68k/machdep.c +++ b/sys/arch/mac68k/mac68k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.142 2007/07/29 21:24:05 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.143 2007/11/02 19:18:54 martin Exp $ */ /* $NetBSD: machdep.c,v 1.207 1998/07/08 04:39:34 thorpej Exp $ */ /* @@ -371,7 +371,7 @@ cpu_startup(void) * Initialize error message buffer (at end of core). * high[numranges-1] was decremented in pmap_bootstrap. */ - for (i = 0; i < btoc(MSGBUFSIZE); i++) + for (i = 0; i < atop(MSGBUFSIZE); i++) pmap_enter(pmap_kernel(), (vaddr_t)msgbufp + i * NBPG, high[numranges - 1] + i * NBPG, VM_PROT_READ|VM_PROT_WRITE, @@ -398,8 +398,8 @@ cpu_startup(void) printf("this kernel.\n\n"); for (delay = 0; delay < 1000000; delay++); } - printf("real mem = %u (%uMB)\n", ctob(physmem), - ctob(physmem)/1024/1024); + printf("real mem = %u (%uMB)\n", ptoa(physmem), + ptoa(physmem)/1024/1024); /* * Find out how much space we need, allocate it, @@ -705,7 +705,7 @@ dumpconf(void) dumpsize = 0; for (i = 0; h->ram_segs[i].size && i < NPHYS_RAM_SEGS; i++) - dumpsize += btoc(h->ram_segs[i].size); + dumpsize += atop(h->ram_segs[i].size); dumpsize += cpu_dumpsize(); /* Always skip the first block, in case there is a label there. */ diff --git a/sys/arch/mac68k/mac68k/pmap_bootstrap.c b/sys/arch/mac68k/mac68k/pmap_bootstrap.c index 9f20b440c11..2a8e4a8dc48 100644 --- a/sys/arch/mac68k/mac68k/pmap_bootstrap.c +++ b/sys/arch/mac68k/mac68k/pmap_bootstrap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap_bootstrap.c,v 1.38 2006/07/06 17:49:45 miod Exp $ */ +/* $OpenBSD: pmap_bootstrap.c,v 1.39 2007/11/02 19:18:54 martin Exp $ */ /* $NetBSD: pmap_bootstrap.c,v 1.50 1999/04/07 06:14:33 scottr Exp $ */ /* @@ -67,7 +67,7 @@ u_long low[8]; u_long high[8]; u_long maxaddr; /* PA of the last physical page */ int vidlen; -#define VIDMAPSIZE btoc(vidlen) +#define VIDMAPSIZE atop(vidlen) extern u_int32_t mac68k_vidphys; extern u_int32_t videoaddr; extern u_int32_t videorowbytes; diff --git a/sys/arch/mvme68k/mvme68k/autoconf.c b/sys/arch/mvme68k/mvme68k/autoconf.c index 0a83e329c69..4b5122a29b8 100644 --- a/sys/arch/mvme68k/mvme68k/autoconf.c +++ b/sys/arch/mvme68k/mvme68k/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.40 2007/06/15 01:19:08 deraadt Exp $ */ +/* $OpenBSD: autoconf.c,v 1.41 2007/11/02 19:18:54 martin Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -188,7 +188,7 @@ cpu_configure() init_intrs(); extio = extent_create("extio", - (u_long)extiobase, (u_long)extiobase + ctob(EIOMAPSIZE), + (u_long)extiobase, (u_long)extiobase + ptoa(EIOMAPSIZE), M_DEVBUF, extiospace, sizeof(extiospace), EX_NOWAIT); if (config_rootfound("mainbus", NULL) == NULL) @@ -252,7 +252,7 @@ unmapiodev(kva, size) vaddr_t va; #ifdef DEBUG - if (kva < extiobase || kva + size >= extiobase + ctob(EIOMAPSIZE)) + if (kva < extiobase || kva + size >= extiobase + ptoa(EIOMAPSIZE)) panic("unmapiodev: bad address"); #endif diff --git a/sys/arch/mvme68k/mvme68k/hpux_machdep.c b/sys/arch/mvme68k/mvme68k/hpux_machdep.c index e5bea5c0e0c..b454ace3c01 100644 --- a/sys/arch/mvme68k/mvme68k/hpux_machdep.c +++ b/sys/arch/mvme68k/mvme68k/hpux_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hpux_machdep.c,v 1.14 2005/11/06 17:23:41 miod Exp $ */ +/* $OpenBSD: hpux_machdep.c,v 1.15 2007/11/02 19:18:54 martin Exp $ */ /* $NetBSD: hpux_machdep.c,v 1.9 1997/03/16 10:00:45 thorpej Exp $ */ /* @@ -335,7 +335,7 @@ hpux_to_bsd_uoff(off, isps, p) * so we convert off to an absolute address (if not already) * for simplicity. */ - if (off < (int *)ctob(UPAGES)) + if (off < (int *)ptoa(UPAGES)) off = (int *)((u_int)off + (u_int)p->p_addr); /* XXX */ /* @@ -449,7 +449,7 @@ hpux_sendsig(catcher, sig, mask, code, type, val) psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else fp = (struct hpuxsigframe *)(frame->f_regs[SP] - fsize); - if ((unsigned)fp <= USRSTACK - ctob(p->p_vmspace->vm_ssize)) + if ((unsigned)fp <= USRSTACK - ptoa(p->p_vmspace->vm_ssize)) (void)uvm_grow(p, (unsigned)fp); #ifdef DEBUG diff --git a/sys/arch/mvme68k/mvme68k/machdep.c b/sys/arch/mvme68k/mvme68k/machdep.c index 335be2eda67..f4bf15e6421 100644 --- a/sys/arch/mvme68k/mvme68k/machdep.c +++ b/sys/arch/mvme68k/mvme68k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.106 2007/06/06 17:15:12 deraadt Exp $ */ +/* $OpenBSD: machdep.c,v 1.107 2007/11/02 19:18:54 martin Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -229,7 +229,7 @@ cpu_startup() * Initialize error message buffer (at end of core). * avail_end was pre-decremented in pmap_bootstrap to compensate. */ - for (i = 0; i < btoc(MSGBUFSIZE); i++) + for (i = 0; i < atop(MSGBUFSIZE); i++) pmap_kenter_pa((vaddr_t)msgbufp + i * PAGE_SIZE, avail_end + i * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE); pmap_update(pmap_kernel()); @@ -240,8 +240,8 @@ cpu_startup() */ printf("%s", version); identifycpu(); - printf("real mem = %u (%uMB)\n", ctob(physmem), - ctob(physmem) / 1024 / 1024); + printf("real mem = %u (%uMB)\n", ptoa(physmem), + ptoa(physmem) / 1024 / 1024); /* * Find out how much space we need, allocate it, @@ -577,7 +577,7 @@ dumpconf(void) /* mvme68k only uses a single segment. */ cpu_kcore_hdr.ram_segs[0].start = 0; - cpu_kcore_hdr.ram_segs[0].size = ctob(physmem); + cpu_kcore_hdr.ram_segs[0].size = ptoa(physmem); cpu_kcore_hdr.mmutype = mmutype; cpu_kcore_hdr.kernel_pa = 0; cpu_kcore_hdr.sysseg_pa = pmap_kernel()->pm_stpa; diff --git a/sys/arch/mvme68k/mvme68k/vm_machdep.c b/sys/arch/mvme68k/mvme68k/vm_machdep.c index f738389d254..ebfa1402ba6 100644 --- a/sys/arch/mvme68k/mvme68k/vm_machdep.c +++ b/sys/arch/mvme68k/mvme68k/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.47 2007/10/13 07:18:01 miod Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.48 2007/11/02 19:18:54 martin Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -227,8 +227,8 @@ vmapbuf(bp, siz) addr = bp->b_saveaddr = bp->b_data; off = (int)addr & PGOFSET; p = bp->b_proc; - npf = btoc(round_page(bp->b_bcount + off)); - kva = uvm_km_valloc_wait(phys_map, ctob(npf)); + npf = atop(round_page(bp->b_bcount + off)); + kva = uvm_km_valloc_wait(phys_map, ptoa(npf)); bp->b_data = (caddr_t)(kva + off); while (npf--) { if (pmap_extract(vm_map_pmap(&p->p_vmspace->vm_map), @@ -260,11 +260,11 @@ vunmapbuf(bp, siz) #endif addr = bp->b_data; - npf = btoc(round_page(bp->b_bcount + ((int)addr & PGOFSET))); + npf = atop(round_page(bp->b_bcount + ((int)addr & PGOFSET))); kva = (vaddr_t)((int)addr & ~PGOFSET); - pmap_remove(vm_map_pmap(phys_map), kva, kva + ctob(npf)); + pmap_remove(vm_map_pmap(phys_map), kva, kva + ptoa(npf)); pmap_update(vm_map_pmap(phys_map)); - uvm_km_free_wakeup(phys_map, kva, ctob(npf)); + uvm_km_free_wakeup(phys_map, kva, ptoa(npf)); bp->b_data = bp->b_saveaddr; bp->b_saveaddr = NULL; } diff --git a/sys/compat/hpux/m68k/hpux_exec.c b/sys/compat/hpux/m68k/hpux_exec.c index ce5b1d26ec9..ac83a6ff412 100644 --- a/sys/compat/hpux/m68k/hpux_exec.c +++ b/sys/compat/hpux/m68k/hpux_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hpux_exec.c,v 1.2 2005/12/30 19:46:55 miod Exp $ */ +/* $OpenBSD: hpux_exec.c,v 1.3 2007/11/02 19:18:54 martin Exp $ */ /* $NetBSD: hpux_exec.c,v 1.8 1997/03/16 10:14:44 thorpej Exp $ */ /* @@ -199,8 +199,8 @@ exec_hpux_prep_zmagic(p, epp) * sizes frobbed. */ nontext = execp->ha_data + execp->ha_bss; - execp->ha_text = ctob(btoc(execp->ha_text)); - execp->ha_data = ctob(btoc(execp->ha_data)); + execp->ha_text = round_page(execp->ha_text); + execp->ha_data = round_page(execp->ha_data); execp->ha_bss = nontext - execp->ha_data; if (execp->ha_bss < 0) execp->ha_bss = 0; -- cgit v1.2.3