15b81b6b3SRodney W. Grimes /*- 25b81b6b3SRodney W. Grimes * Copyright (c) 1990 The Regents of the University of California. 35b81b6b3SRodney W. Grimes * All rights reserved. 45b81b6b3SRodney W. Grimes * 55b81b6b3SRodney W. Grimes * This code is derived from software contributed to Berkeley by 65b81b6b3SRodney W. Grimes * William Jolitz. 75b81b6b3SRodney W. Grimes * 85b81b6b3SRodney W. Grimes * Redistribution and use in source and binary forms, with or without 95b81b6b3SRodney W. Grimes * modification, are permitted provided that the following conditions 105b81b6b3SRodney W. Grimes * are met: 115b81b6b3SRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 125b81b6b3SRodney W. Grimes * notice, this list of conditions and the following disclaimer. 135b81b6b3SRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 145b81b6b3SRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 155b81b6b3SRodney W. Grimes * documentation and/or other materials provided with the distribution. 165b81b6b3SRodney W. Grimes * 3. All advertising materials mentioning features or use of this software 175b81b6b3SRodney W. Grimes * must display the following acknowledgement: 185b81b6b3SRodney W. Grimes * This product includes software developed by the University of 195b81b6b3SRodney W. Grimes * California, Berkeley and its contributors. 205b81b6b3SRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 215b81b6b3SRodney W. Grimes * may be used to endorse or promote products derived from this software 225b81b6b3SRodney W. Grimes * without specific prior written permission. 235b81b6b3SRodney W. Grimes * 245b81b6b3SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 255b81b6b3SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 265b81b6b3SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 275b81b6b3SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 285b81b6b3SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 295b81b6b3SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 305b81b6b3SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 315b81b6b3SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 325b81b6b3SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 335b81b6b3SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 345b81b6b3SRodney W. Grimes * SUCH DAMAGE. 355b81b6b3SRodney W. Grimes * 365b81b6b3SRodney W. Grimes * @(#)param.h 5.8 (Berkeley) 6/28/91 375b81b6b3SRodney W. Grimes * 385b81b6b3SRodney W. Grimes * PATCHES MAGIC LEVEL PATCH THAT GOT US HERE 395b81b6b3SRodney W. Grimes * -------------------- ----- ---------------------- 405b81b6b3SRodney W. Grimes * CURRENT PATCH LEVEL: 2 00166 415b81b6b3SRodney W. Grimes * -------------------- ----- ---------------------- 425b81b6b3SRodney W. Grimes * 435b81b6b3SRodney W. Grimes * 08 Apr 93 Andrew Herbert Fixes for kmem_alloc panics 445b81b6b3SRodney W. Grimes * Rodney W. Grimes Tuneable mbuf sizes 455b81b6b3SRodney W. Grimes * 04 Jun 93 Rodney W. Grimes Change default mbuf size to 2048 via 465b81b6b3SRodney W. Grimes * MCLSHIFT. 475b81b6b3SRodney W. Grimes */ 485b81b6b3SRodney W. Grimes 495b81b6b3SRodney W. Grimes /* 505b81b6b3SRodney W. Grimes * Machine dependent constants for Intel 386. 515b81b6b3SRodney W. Grimes */ 525b81b6b3SRodney W. Grimes 535b81b6b3SRodney W. Grimes #define MACHINE "i386" 545b81b6b3SRodney W. Grimes 555b81b6b3SRodney W. Grimes /* 565b81b6b3SRodney W. Grimes * Round p (pointer or byte index) up to a correctly-aligned value 575b81b6b3SRodney W. Grimes * for all data types (int, long, ...). The result is u_int and 585b81b6b3SRodney W. Grimes * must be cast to any desired pointer type. 595b81b6b3SRodney W. Grimes */ 605b81b6b3SRodney W. Grimes #define ALIGN(p) (((u_int)(p) + (sizeof(int) - 1)) &~ (sizeof(int) - 1)) 615b81b6b3SRodney W. Grimes 625b81b6b3SRodney W. Grimes #define NBPG 4096 /* bytes/page */ 635b81b6b3SRodney W. Grimes #define PGOFSET (NBPG-1) /* byte offset into page */ 645b81b6b3SRodney W. Grimes #define PGSHIFT 12 /* LOG2(NBPG) */ 655b81b6b3SRodney W. Grimes #define NPTEPG (NBPG/(sizeof (struct pte))) 665b81b6b3SRodney W. Grimes 675b81b6b3SRodney W. Grimes #define NBPDR (1024*NBPG) /* bytes/page dir */ 685b81b6b3SRodney W. Grimes #define PDROFSET (NBPDR-1) /* byte offset into page dir */ 695b81b6b3SRodney W. Grimes #define PDRSHIFT 22 /* LOG2(NBPDR) */ 705b81b6b3SRodney W. Grimes 715b81b6b3SRodney W. Grimes #define KERNBASE 0xFE000000 /* start of kernel virtual */ 725b81b6b3SRodney W. Grimes #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 735b81b6b3SRodney W. Grimes 745b81b6b3SRodney W. Grimes #define DEV_BSIZE 512 755b81b6b3SRodney W. Grimes #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 765b81b6b3SRodney W. Grimes #define BLKDEV_IOSIZE 2048 775b81b6b3SRodney W. Grimes #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 785b81b6b3SRodney W. Grimes 795b81b6b3SRodney W. Grimes #define CLSIZE 1 805b81b6b3SRodney W. Grimes #define CLSIZELOG2 0 815b81b6b3SRodney W. Grimes 825b81b6b3SRodney W. Grimes /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */ 835b81b6b3SRodney W. Grimes #define SSIZE 1 /* initial stack size/NBPG */ 845b81b6b3SRodney W. Grimes #define SINCR 1 /* increment of stack/NBPG */ 855b81b6b3SRodney W. Grimes 865b81b6b3SRodney W. Grimes #define UPAGES 2 /* pages of u-area */ 875b81b6b3SRodney W. Grimes 885b81b6b3SRodney W. Grimes /* 895b81b6b3SRodney W. Grimes * Constants related to network buffer management. 905b81b6b3SRodney W. Grimes * MCLBYTES must be no larger than CLBYTES (the software page size), and, 915b81b6b3SRodney W. Grimes * on machines that exchange pages of input or output buffers with mbuf 925b81b6b3SRodney W. Grimes * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 935b81b6b3SRodney W. Grimes * of the hardware page size. 945b81b6b3SRodney W. Grimes */ 955b81b6b3SRodney W. Grimes #ifndef MSIZE 965b81b6b3SRodney W. Grimes #define MSIZE 128 /* size of an mbuf */ 975b81b6b3SRodney W. Grimes #endif /* MSIZE */ 985b81b6b3SRodney W. Grimes 995b81b6b3SRodney W. Grimes #ifndef MCLSHIFT 1005b81b6b3SRodney W. Grimes #define MCLSHIFT 11 /* convert bytes to m_buf clusters */ 1015b81b6b3SRodney W. Grimes #endif /* MCLSHIFT */ 1025b81b6b3SRodney W. Grimes #define MCLBYTES (1 << MCLSHIFT) /* size of an m_buf cluster */ 1035b81b6b3SRodney W. Grimes #define MCLOFSET (MCLBYTES - 1) /* offset within an m_buf cluster */ 1045b81b6b3SRodney W. Grimes 1055b81b6b3SRodney W. Grimes #ifndef NMBCLUSTERS 1065b81b6b3SRodney W. Grimes #ifdef GATEWAY 1075b81b6b3SRodney W. Grimes #define NMBCLUSTERS 512 /* map size, max cluster allocation */ 1085b81b6b3SRodney W. Grimes #else 1095b81b6b3SRodney W. Grimes #define NMBCLUSTERS 256 /* map size, max cluster allocation */ 1105b81b6b3SRodney W. Grimes #endif /* GATEWAY */ 1115b81b6b3SRodney W. Grimes #endif /* NMBCLUSTERS */ 1125b81b6b3SRodney W. Grimes 1135b81b6b3SRodney W. Grimes /* 1145b81b6b3SRodney W. Grimes * Size of kernel malloc arena in CLBYTES-sized logical pages 1155b81b6b3SRodney W. Grimes */ 1165b81b6b3SRodney W. Grimes #ifndef NKMEMCLUSTERS 1175b81b6b3SRodney W. Grimes #define NKMEMCLUSTERS (3072*1024/CLBYTES) 1185b81b6b3SRodney W. Grimes #endif 1195b81b6b3SRodney W. Grimes /* 1205b81b6b3SRodney W. Grimes * Some macros for units conversion 1215b81b6b3SRodney W. Grimes */ 1225b81b6b3SRodney W. Grimes /* Core clicks (4096 bytes) to segments and vice versa */ 1235b81b6b3SRodney W. Grimes #define ctos(x) (x) 1245b81b6b3SRodney W. Grimes #define stoc(x) (x) 1255b81b6b3SRodney W. Grimes 1265b81b6b3SRodney W. Grimes /* Core clicks (4096 bytes) to disk blocks */ 1275b81b6b3SRodney W. Grimes #define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT)) 1285b81b6b3SRodney W. Grimes #define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT)) 1295b81b6b3SRodney W. Grimes #define dtob(x) ((x)<<DEV_BSHIFT) 1305b81b6b3SRodney W. Grimes 1315b81b6b3SRodney W. Grimes /* clicks to bytes */ 1325b81b6b3SRodney W. Grimes #define ctob(x) ((x)<<PGSHIFT) 1335b81b6b3SRodney W. Grimes 1345b81b6b3SRodney W. Grimes /* bytes to clicks */ 1355b81b6b3SRodney W. Grimes #define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT) 1365b81b6b3SRodney W. Grimes 1375b81b6b3SRodney W. Grimes #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 1385b81b6b3SRodney W. Grimes ((unsigned)(bytes) >> DEV_BSHIFT) 1395b81b6b3SRodney W. Grimes #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 1405b81b6b3SRodney W. Grimes ((unsigned)(db) << DEV_BSHIFT) 1415b81b6b3SRodney W. Grimes 1425b81b6b3SRodney W. Grimes /* 1435b81b6b3SRodney W. Grimes * Map a ``block device block'' to a file system block. 1445b81b6b3SRodney W. Grimes * This should be device dependent, and will be if we 1455b81b6b3SRodney W. Grimes * add an entry to cdevsw/bdevsw for that purpose. 1465b81b6b3SRodney W. Grimes * For now though just use DEV_BSIZE. 1475b81b6b3SRodney W. Grimes */ 1485b81b6b3SRodney W. Grimes #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 1495b81b6b3SRodney W. Grimes 1505b81b6b3SRodney W. Grimes /* 1515b81b6b3SRodney W. Grimes * Mach derived conversion macros 1525b81b6b3SRodney W. Grimes */ 1535b81b6b3SRodney W. Grimes #define i386_round_pdr(x) ((((unsigned)(x)) + NBPDR - 1) & ~(NBPDR-1)) 1545b81b6b3SRodney W. Grimes #define i386_trunc_pdr(x) ((unsigned)(x) & ~(NBPDR-1)) 1555b81b6b3SRodney W. Grimes #define i386_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1)) 1565b81b6b3SRodney W. Grimes #define i386_trunc_page(x) ((unsigned)(x) & ~(NBPG-1)) 1575b81b6b3SRodney W. Grimes #define i386_btod(x) ((unsigned)(x) >> PDRSHIFT) 1585b81b6b3SRodney W. Grimes #define i386_dtob(x) ((unsigned)(x) << PDRSHIFT) 1595b81b6b3SRodney W. Grimes #define i386_btop(x) ((unsigned)(x) >> PGSHIFT) 1605b81b6b3SRodney W. Grimes #define i386_ptob(x) ((unsigned)(x) << PGSHIFT) 1615b81b6b3SRodney W. Grimes 1625b81b6b3SRodney W. Grimes #ifndef KERNEL 1635b81b6b3SRodney W. Grimes #define DELAY(n) { volatile int N = (n); while (--N > 0); } 1645b81b6b3SRodney W. Grimes #endif 165