param.h revision 80708
1/*- 2 * Copyright (c) 1990 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * William Jolitz. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * from: @(#)param.h 5.8 (Berkeley) 6/28/91 30 * $FreeBSD: head/sys/sparc64/include/param.h 80708 2001-07-31 05:45:16Z jake $ 31 */ 32 33/* 34 * Machine dependent constants for sparc64. 35 */ 36 37#define TODO \ 38 panic("implement " __func__) 39 40/* 41 * Round p (pointer or byte index) up to a correctly-aligned value 42 * for all data types (int, long, ...). The result is unsigned int 43 * and must be cast to any desired pointer type. 44 */ 45#ifndef _ALIGNBYTES 46#define _ALIGNBYTES 0xf 47#endif 48#ifndef _ALIGN 49#define _ALIGN(p) (((u_long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) 50#endif 51 52#ifndef _MACHINE 53#define _MACHINE sparc64 54#endif 55#ifndef _MACHINE_ARCH 56#define _MACHINE_ARCH sparc64 57#endif 58 59#ifndef _NO_NAMESPACE_POLLUTION 60 61#ifndef _MACHINE_PARAM_H_ 62#define _MACHINE_PARAM_H_ 63 64#ifndef MACHINE 65#define MACHINE "sparc64" 66#endif 67#ifndef MACHINE_ARCH 68#define MACHINE_ARCH "sparc64" 69#endif 70#define MID_MACHINE MID_SPARC64 71 72/* 73 * OBJFORMAT_NAMES is a comma-separated list of the object formats 74 * that are supported on the architecture. 75 */ 76#define OBJFORMAT_NAMES "elf" 77#define OBJFORMAT_DEFAULT "elf" 78 79#ifdef SMP 80#define MAXCPU 16 81#else 82#define MAXCPU 1 83#endif /* SMP */ 84 85#define ALIGNBYTES _ALIGNBYTES 86#define ALIGN(p) _ALIGN(p) 87 88#define PAGE_SHIFT 13 /* LOG2(PAGE_SIZE) */ 89#define PAGE_SIZE (1<<PAGE_SHIFT) /* bytes/page */ 90#define PAGE_MASK (PAGE_SIZE-1) 91#define NPTEPG (PAGE_SIZE/(sizeof (pt_entry_t))) 92 93#define NPDEPG (PAGE_SIZE/(sizeof (pd_entry_t))) 94#define PDRSHIFT 22 /* LOG2(NBPDR) */ 95#define NBPDR (1<<PDRSHIFT) /* bytes/page dir */ 96#define PDRMASK (NBPDR-1) 97 98#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 99#define DEV_BSIZE (1<<DEV_BSHIFT) 100 101#ifndef BLKDEV_IOSIZE 102#define BLKDEV_IOSIZE PAGE_SIZE /* default block device I/O size */ 103#endif 104#define DFLTPHYS (64 * 1024) /* default max raw I/O transfer size */ 105#define MAXPHYS (128 * 1024) /* max raw I/O transfer size */ 106#define MAXDUMPPGS (DFLTPHYS/PAGE_SIZE) 107 108#define IOPAGES 2 /* pages of i/o permission bitmap */ 109#define UPAGES 2 /* pages of u-area */ 110 111/* 112 * Constants related to network buffer management. 113 * MCLBYTES must be no larger than PAGE_SIZE. 114 */ 115#ifndef MSIZE 116#define MSIZE 256 /* size of an mbuf */ 117#endif /* MSIZE */ 118 119#ifndef MCLSHIFT 120#define MCLSHIFT 11 /* convert bytes to mbuf clusters */ 121#endif /* MCLSHIFT */ 122#define MCLBYTES (1 << MCLSHIFT) /* size of an mbuf cluster */ 123 124/* 125 * Some macros for units conversion 126 */ 127 128/* clicks to bytes */ 129#define ctob(x) ((x)<<PAGE_SHIFT) 130 131/* bytes to clicks */ 132#define btoc(x) (((unsigned)(x)+PAGE_MASK)>>PAGE_SHIFT) 133 134/* 135 * btodb() is messy and perhaps slow because `bytes' may be an off_t. We 136 * want to shift an unsigned type to avoid sign extension and we don't 137 * want to widen `bytes' unnecessarily. Assume that the result fits in 138 * a daddr_t. 139 */ 140#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 141 (sizeof (bytes) > sizeof(long) \ 142 ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \ 143 : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT)) 144 145#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 146 ((off_t)(db) << DEV_BSHIFT) 147 148/* 149 * Mach derived conversion macros 150 */ 151#define trunc_page(x) ((unsigned long)(x) & ~PAGE_MASK) 152#define round_page(x) (((unsigned long)(x) + PAGE_MASK) & ~PAGE_MASK) 153#define trunc_4mpage(x) ((unsigned long)(x) & ~PDRMASK) 154#define round_4mpage(x) ((((unsigned long)(x)) + PDRMASK) & ~PDRMASK) 155 156#define atop(x) ((unsigned long)(x) >> PAGE_SHIFT) 157#define ptoa(x) ((unsigned long)(x) << PAGE_SHIFT) 158 159#define sparc64_btop(x) ((unsigned long)(x) >> PAGE_SHIFT) 160#define sparc64_ptob(x) ((unsigned long)(x) << PAGE_SHIFT) 161 162#define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024)) 163 164#endif /* !_MACHINE_PARAM_H_ */ 165#endif /* !_NO_NAMESPACE_POLLUTION */ 166