param.h revision 1.1
11.1Schuck/* $NetBSD: param.h,v 1.1 1995/07/25 23:12:16 chuck Exp $ */ 21.1Schuck 31.1Schuck/* 41.1Schuck * Copyright (c) 1988 University of Utah. 51.1Schuck * Copyright (c) 1982, 1986, 1990, 1993 61.1Schuck * The Regents of the University of California. All rights reserved. 71.1Schuck * 81.1Schuck * This code is derived from software contributed to Berkeley by 91.1Schuck * the Systems Programming Group of the University of Utah Computer 101.1Schuck * Science Department. 111.1Schuck * 121.1Schuck * Redistribution and use in source and binary forms, with or without 131.1Schuck * modification, are permitted provided that the following conditions 141.1Schuck * are met: 151.1Schuck * 1. Redistributions of source code must retain the above copyright 161.1Schuck * notice, this list of conditions and the following disclaimer. 171.1Schuck * 2. Redistributions in binary form must reproduce the above copyright 181.1Schuck * notice, this list of conditions and the following disclaimer in the 191.1Schuck * documentation and/or other materials provided with the distribution. 201.1Schuck * 3. All advertising materials mentioning features or use of this software 211.1Schuck * must display the following acknowledgement: 221.1Schuck * This product includes software developed by the University of 231.1Schuck * California, Berkeley and its contributors. 241.1Schuck * 4. Neither the name of the University nor the names of its contributors 251.1Schuck * may be used to endorse or promote products derived from this software 261.1Schuck * without specific prior written permission. 271.1Schuck * 281.1Schuck * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 291.1Schuck * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 301.1Schuck * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 311.1Schuck * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 321.1Schuck * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 331.1Schuck * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 341.1Schuck * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 351.1Schuck * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 361.1Schuck * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 371.1Schuck * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 381.1Schuck * SUCH DAMAGE. 391.1Schuck * 401.1Schuck * from: Utah $Hdr: machparam.h 1.16 92/12/20$ 411.1Schuck * 421.1Schuck * @(#)param.h 8.1 (Berkeley) 6/10/93 431.1Schuck */ 441.1Schuck 451.1Schuck/* 461.1Schuck * Machine dependent constants for mvme68k, based on HP9000 series 300. 471.1Schuck */ 481.1Schuck#define MACHINE "mvme68k" 491.1Schuck#define MACHINE_ARCH "m68k" 501.1Schuck#define MID_MACHINE MID_M68K 511.1Schuck 521.1Schuck/* 531.1Schuck * Round p (pointer or byte index) up to a correctly-aligned value for all 541.1Schuck * data types (int, long, ...). The result is u_int and must be cast to 551.1Schuck * any desired pointer type. 561.1Schuck */ 571.1Schuck#define ALIGNBYTES (sizeof(int) - 1) 581.1Schuck#define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES) 591.1Schuck 601.1Schuck#define PGSHIFT 12 /* LOG2(NBPG) */ 611.1Schuck#define NBPG (1 << PGSHIFT) /* bytes/page */ 621.1Schuck#define PGOFSET (NBPG-1) /* byte offset into page */ 631.1Schuck#define NPTEPG (NBPG/(sizeof (pt_entry_t))) 641.1Schuck 651.1Schuck#define SEGSHIFT 22 /* LOG2(NBSEG) */ 661.1Schuck#define NBSEG (1 << SEGSHIFT) /* bytes/segment */ 671.1Schuck#define SEGOFSET (NBSEG-1) /* byte offset into segment */ 681.1Schuck 691.1Schuck#define KERNBASE 0x00000000 /* start of kernel virtual */ 701.1Schuck#define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 711.1Schuck 721.1Schuck#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 731.1Schuck#define DEV_BSIZE (1 << DEV_BSHIFT) 741.1Schuck#define BLKDEV_IOSIZE 2048 751.1Schuck#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 761.1Schuck 771.1Schuck#define CLSIZELOG2 0 781.1Schuck#define CLSIZE (1 << CLSIZELOG2) 791.1Schuck 801.1Schuck/* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */ 811.1Schuck#define SSIZE 1 /* initial stack size/NBPG */ 821.1Schuck#define SINCR 1 /* increment of stack/NBPG */ 831.1Schuck#define UPAGES 3 /* pages of u-area */ 841.1Schuck#define USPACE (UPAGES * NBPG) /* total size of u-area */ 851.1Schuck 861.1Schuck/* 871.1Schuck * Constants related to network buffer management. 881.1Schuck * MCLBYTES must be no larger than CLBYTES (the software page size), and, 891.1Schuck * on machines that exchange pages of input or output buffers with mbuf 901.1Schuck * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 911.1Schuck * of the hardware page size. 921.1Schuck */ 931.1Schuck#define MSIZE 128 /* size of an mbuf */ 941.1Schuck#define MCLSHIFT 11 951.1Schuck#define MCLBYTES (1 << MCLSHIFT) /* large enough for ether MTU */ 961.1Schuck#define MCLOFSET (MCLBYTES - 1) 971.1Schuck 981.1Schuck#ifndef NMBCLUSTERS 991.1Schuck#ifdef GATEWAY 1001.1Schuck#define NMBCLUSTERS 512 /* map size, max cluster allocation */ 1011.1Schuck#else 1021.1Schuck#define NMBCLUSTERS 256 /* map size, max cluster allocation */ 1031.1Schuck#endif 1041.1Schuck#endif 1051.1Schuck 1061.1Schuck/* 1071.1Schuck * Size of kernel malloc arena in CLBYTES-sized logical pages 1081.1Schuck */ 1091.1Schuck#ifndef NKMEMCLUSTERS 1101.1Schuck#define NKMEMCLUSTERS (2048 * 1024 / CLBYTES) 1111.1Schuck#endif 1121.1Schuck 1131.1Schuck/* pages ("clicks") to disk blocks */ 1141.1Schuck#define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT)) 1151.1Schuck#define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT)) 1161.1Schuck 1171.1Schuck/* pages to bytes */ 1181.1Schuck#define ctob(x) ((x) << PGSHIFT) 1191.1Schuck#define btoc(x) (((x) + PGOFSET) >> PGSHIFT) 1201.1Schuck 1211.1Schuck/* bytes to disk blocks */ 1221.1Schuck#define dbtob(x) ((x) << DEV_BSHIFT) 1231.1Schuck#define btodb(x) ((x) >> DEV_BSHIFT) 1241.1Schuck 1251.1Schuck/* 1261.1Schuck * Map a ``block device block'' to a file system block. 1271.1Schuck * This should be device dependent, and should use the bsize 1281.1Schuck * field from the disk label. 1291.1Schuck * For now though just use DEV_BSIZE. 1301.1Schuck */ 1311.1Schuck#define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE / DEV_BSIZE)) 1321.1Schuck 1331.1Schuck/* 1341.1Schuck * Mach derived conversion macros 1351.1Schuck */ 1361.1Schuck#define m68k_round_page(x) ((((unsigned)(x)) + PGOFSET) & ~PGOFSET) 1371.1Schuck#define m68k_trunc_page(x) ((unsigned)(x) & ~PGOFSET) 1381.1Schuck#define m68k_btop(x) ((unsigned)(x) >> PGSHIFT) 1391.1Schuck#define m68k_ptob(x) ((unsigned)(x) << PGSHIFT) 1401.1Schuck 1411.1Schuck/* 1421.1Schuck * spl functions; all but spl0 are done in-line 1431.1Schuck */ 1441.1Schuck#include <machine/psl.h> 1451.1Schuck 1461.1Schuck#define _spl(s) \ 1471.1Schuck({ \ 1481.1Schuck register int _spl_r; \ 1491.1Schuck\ 1501.1Schuck __asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" : \ 1511.1Schuck "&=d" (_spl_r) : "di" (s)); \ 1521.1Schuck _spl_r; \ 1531.1Schuck}) 1541.1Schuck 1551.1Schuck/* spl0 requires checking for software interrupts */ 1561.1Schuck#define spl1() _spl(PSL_S|PSL_IPL1) 1571.1Schuck#define spl2() _spl(PSL_S|PSL_IPL2) 1581.1Schuck#define spl3() _spl(PSL_S|PSL_IPL3) 1591.1Schuck#define spl4() _spl(PSL_S|PSL_IPL4) 1601.1Schuck#define spl5() _spl(PSL_S|PSL_IPL5) 1611.1Schuck#define spl6() _spl(PSL_S|PSL_IPL6) 1621.1Schuck#define spl7() _spl(PSL_S|PSL_IPL7) 1631.1Schuck 1641.1Schuck#define splsoftclock() spl1() 1651.1Schuck#define splnet() spl1() 1661.1Schuck#define splbio() spl2() 1671.1Schuck#define splimp() spl3() 1681.1Schuck#define spltty() spl3() 1691.1Schuck#define splclock() spl5() 1701.1Schuck#define splstatclock() spl5() 1711.1Schuck#define splvm() spl5() 1721.1Schuck#define splhigh() spl7() 1731.1Schuck#define splsched() spl7() 1741.1Schuck 1751.1Schuck/* watch out for side effects */ 1761.1Schuck#define splx(s) (s & PSL_IPL ? _spl(s) : spl0()) 1771.1Schuck 1781.1Schuck#ifdef _KERNEL 1791.1Schuck#ifndef LOCORE 1801.1Schuckint cpuspeed; 1811.1Schuck#define DELAY(n) { register int N = cpuspeed * (n); while (--N > 0); } 1821.1Schuck#endif 1831.1Schuck#endif 184