param.h revision 1.13
11.13Scgd/* $NetBSD: param.h,v 1.13 1996/03/04 05:04:20 cgd Exp $ */ 21.1Sleo 31.1Sleo/* 41.1Sleo * Copyright (c) 1988 University of Utah. 51.1Sleo * Copyright (c) 1982, 1986, 1990 The Regents of the University of California. 61.1Sleo * All rights reserved. 71.1Sleo * 81.1Sleo * This code is derived from software contributed to Berkeley by 91.1Sleo * the Systems Programming Group of the University of Utah Computer 101.1Sleo * Science Department. 111.1Sleo * 121.1Sleo * Redistribution and use in source and binary forms, with or without 131.1Sleo * modification, are permitted provided that the following conditions 141.1Sleo * are met: 151.1Sleo * 1. Redistributions of source code must retain the above copyright 161.1Sleo * notice, this list of conditions and the following disclaimer. 171.1Sleo * 2. Redistributions in binary form must reproduce the above copyright 181.1Sleo * notice, this list of conditions and the following disclaimer in the 191.1Sleo * documentation and/or other materials provided with the distribution. 201.1Sleo * 3. All advertising materials mentioning features or use of this software 211.1Sleo * must display the following acknowledgement: 221.1Sleo * This product includes software developed by the University of 231.1Sleo * California, Berkeley and its contributors. 241.1Sleo * 4. Neither the name of the University nor the names of its contributors 251.1Sleo * may be used to endorse or promote products derived from this software 261.1Sleo * without specific prior written permission. 271.1Sleo * 281.1Sleo * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 291.1Sleo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 301.1Sleo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 311.1Sleo * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 321.1Sleo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 331.1Sleo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 341.1Sleo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 351.1Sleo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 361.1Sleo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 371.1Sleo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 381.1Sleo * SUCH DAMAGE. 391.1Sleo * 401.1Sleo * from: Utah $Hdr: machparam.h 1.11 89/08/14$ 411.1Sleo * 421.1Sleo * @(#)param.h 7.8 (Berkeley) 6/28/91 431.1Sleo */ 441.1Sleo 451.1Sleo#ifndef _MACHINE_PARAM_H_ 461.1Sleo#define _MACHINE_PARAM_H_ 471.1Sleo 481.1Sleo/* 491.1Sleo * Machine dependent constants for atari 501.1Sleo */ 511.13Scgd#define _MACHINE atari 521.1Sleo#define MACHINE "atari" 531.13Scgd#define _MACHINE_ARCH m68k 541.12Scgd#define MACHINE_ARCH "m68k" 551.12Scgd#define MID_MACHINE MID_M68K 561.1Sleo 571.1Sleo/* 581.1Sleo * Round p (pointer or byte index) up to a correctly-aligned value 591.1Sleo * for all data types (int, long, ...). The result is u_int and 601.1Sleo * must be cast to any desired pointer type. 611.1Sleo */ 621.1Sleo#define ALIGNBYTES (sizeof(int) - 1) 631.1Sleo#define ALIGN(p) (((u_int)(p) + (sizeof(int) - 1)) &~ (sizeof(int) - 1)) 641.1Sleo 651.1Sleo#define NBPG 8192 /* bytes/page */ 661.1Sleo#define PGOFSET (NBPG-1) /* byte offset into page */ 671.1Sleo#define PGSHIFT 13 /* LOG2(NBPG) */ 681.1Sleo#define NPTEPG (NBPG/(sizeof(u_int))) 691.1Sleo 701.1Sleo#define NBSEG (cpu040 ? 32*NBPG : 2048*NBPG) /* bytes/segment */ 711.1Sleo#define SEGOFSET (NBSEG-1) /* byte offset into segment */ 721.6Sleo#define SEGSHIFT 24 /* LOG2(NBSEG) [68030 value] */ 731.1Sleo 741.1Sleo#define KERNBASE 0x0 /* start of kernel virtual */ 751.1Sleo#define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 761.1Sleo 771.1Sleo#define DEV_BSIZE 512 781.1Sleo#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 791.1Sleo#define BLKDEV_IOSIZE 2048 801.1Sleo#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 811.1Sleo 821.1Sleo#define CLSIZE 1 831.1Sleo#define CLSIZELOG2 0 841.1Sleo 851.1Sleo/* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */ 861.1Sleo#define SSIZE 1 /* initial stack size/NBPG */ 871.1Sleo#define SINCR 1 /* increment of stack/NBPG */ 881.1Sleo 891.1Sleo#define UPAGES 2 /* pages of u-area */ 901.1Sleo#define USPACE (UPAGES * NBPG) 911.1Sleo 921.1Sleo/* 931.1Sleo * Constants related to network buffer management. 941.1Sleo * MCLBYTES must be no larger than CLBYTES (the software page size), and, 951.1Sleo * on machines that exchange pages of input or output buffers with mbuf 961.1Sleo * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 971.1Sleo * of the hardware page size. 981.1Sleo */ 991.1Sleo#define MSIZE 128 /* size of an mbuf */ 1001.1Sleo#define MCLBYTES 1024 1011.1Sleo#define MCLSHIFT 10 1021.1Sleo#define MCLOFSET (MCLBYTES - 1) 1031.1Sleo#ifndef NMBCLUSTERS 1041.1Sleo#ifdef GATEWAY 1051.1Sleo#define NMBCLUSTERS 512 /* map size, max cluster allocation */ 1061.1Sleo#else 1071.1Sleo#define NMBCLUSTERS 256 /* map size, max cluster allocation */ 1081.1Sleo#endif 1091.1Sleo#endif 1101.1Sleo 1111.1Sleo/* 1121.1Sleo * Size of kernel malloc arena in CLBYTES-sized logical pages 1131.1Sleo */ 1141.1Sleo#ifndef NKMEMCLUSTERS 1151.1Sleo#define NKMEMCLUSTERS (3072*1024/CLBYTES) 1161.1Sleo#endif 1171.1Sleo 1181.1Sleo/* pages ("clicks") to disk blocks */ 1191.7Scgd#define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT)) 1201.7Scgd#define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT)) 1211.1Sleo 1221.1Sleo/* pages to bytes */ 1231.7Scgd#define ctob(x) ((x) << PGSHIFT) 1241.7Scgd#define btoc(x) (((x) + PGOFSET) >> PGSHIFT) 1251.1Sleo 1261.7Scgd/* bytes to disk blocks */ 1271.7Scgd#define btodb(x) ((x) >> DEV_BSHIFT) 1281.7Scgd#define dbtob(x) ((x) << DEV_BSHIFT) 1291.1Sleo 1301.1Sleo/* 1311.1Sleo * Map a ``block device block'' to a file system block. 1321.1Sleo * This should be device dependent, and should use the bsize 1331.1Sleo * field from the disk label. 1341.1Sleo * For now though just use DEV_BSIZE. 1351.1Sleo */ 1361.1Sleo#define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 1371.1Sleo 1381.1Sleo/* 1391.1Sleo * Mach derived conversion macros 1401.1Sleo */ 1411.1Sleo#define atari_round_seg(x) ((((unsigned)(x)) + NBSEG - 1) & ~(NBSEG-1)) 1421.1Sleo#define atari_trunc_seg(x) ((unsigned)(x) & ~(NBSEG-1)) 1431.1Sleo#define atari_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1)) 1441.1Sleo#define atari_trunc_page(x) ((unsigned)(x) & ~(NBPG-1)) 1451.1Sleo#define atari_btos(x) ((unsigned)(x) >> SEGSHIFT) 1461.1Sleo#define atari_stob(x) ((unsigned)(x) << SEGSHIFT) 1471.1Sleo#define atari_btop(x) ((unsigned)(x) >> PGSHIFT) 1481.1Sleo#define atari_ptob(x) ((unsigned)(x) << PGSHIFT) 1491.1Sleo 1501.1Sleo/* 1511.1Sleo * spl functions; all but spl0 are done in-line 1521.1Sleo */ 1531.1Sleo#include <machine/psl.h> 1541.1Sleo 1551.1Sleo#define _debug_spl(s) \ 1561.1Sleo({ \ 1571.1Sleo register int _spl_r; \ 1581.1Sleo\ 1591.1Sleo __asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" : \ 1601.1Sleo "&=d" (_spl_r) : "di" (s)); \ 1611.1Sleo if ((_spl_r&PSL_IPL) > (s&PSL_IPL)) \ 1621.1Sleo printf ("%s:%d:spl(%d) ==> spl(%d)!!\n",__FILE__,__LINE__, \ 1631.1Sleo ((PSL_IPL&_spl_r)>>8), ((PSL_IPL&s)>>8)); \ 1641.1Sleo _spl_r; \ 1651.1Sleo}) 1661.1Sleo 1671.1Sleo#define _spl_no_check(s) \ 1681.1Sleo({ \ 1691.1Sleo register int _spl_r; \ 1701.1Sleo\ 1711.1Sleo __asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" : \ 1721.1Sleo "&=d" (_spl_r) : "di" (s)); \ 1731.1Sleo _spl_r; \ 1741.1Sleo}) 1751.1Sleo#if defined (DEBUG) 1761.1Sleo#define _spl _debug_spl 1771.1Sleo#else 1781.1Sleo#define _spl _spl_no_check 1791.1Sleo#endif 1801.1Sleo 1811.1Sleo/* spl0 requires checking for software interrupts */ 1821.1Sleo#define spl1() _spl(PSL_S|PSL_IPL1) 1831.1Sleo#define spl2() _spl(PSL_S|PSL_IPL2) 1841.1Sleo#define spl3() _spl(PSL_S|PSL_IPL3) 1851.1Sleo#define spl4() _spl(PSL_S|PSL_IPL4) 1861.1Sleo#define spl5() _spl(PSL_S|PSL_IPL5) 1871.1Sleo#define spl6() _spl(PSL_S|PSL_IPL6) 1881.1Sleo#define spl7() _spl(PSL_S|PSL_IPL7) 1891.1Sleo 1901.1Sleo#define splnone() spl0() 1911.1Sleo#define splsoftclock() spl1() 1921.9Smycroft#define splsoftnet() spl1() 1931.1Sleo#define splbio() spl3() 1941.9Smycroft#define splnet() spl3() 1951.1Sleo/* 1961.1Sleo * lowered to spl4 to allow for serial input into 1971.1Sleo * private ringbuffer inspite of spltty 1981.1Sleo */ 1991.1Sleo#define spltty() spl4() 2001.9Smycroft#define splimp() spl4() 2011.1Sleo#define splclock() spl6() 2021.1Sleo#define splstatclock() spl6() 2031.1Sleo#define splvm() spl6() 2041.1Sleo#define splhigh() spl7() 2051.1Sleo#define splsched() spl7() 2061.1Sleo 2071.1Sleo#define splx(s) (s & PSL_IPL ? _spl_no_check(s) : spl0()) 2081.1Sleo 2091.4Sleo#ifdef _KERNEL 2101.11Sleoint spl0 __P((void)); 2111.1Sleovoid delay __P((int)); 2121.5Sleo 2131.5Sleo#define DELAY(n) delay(n) 2141.5Sleo#endif /* _KERNEL */ 2151.1Sleo 2161.1Sleo#endif /* !_MACHINE_PARAM_H_ */ 217