1 /* $NetBSD: param.h,v 1.17 2000/05/22 02:35:24 mrg Exp $ */ 2 3 /* 4 * Copyright (c) 1992, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This software was developed by the Computer Systems Engineering group 8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 9 * contributed to Berkeley. 10 * 11 * All advertising materials mentioning features or use of this software 12 * must display the following acknowledgement: 13 * This product includes software developed by the University of 14 * California, Lawrence Berkeley Laboratory. 15 * 16 * Redistribution and use in source and binary forms, with or without 17 * modification, are permitted provided that the following conditions 18 * are met: 19 * 1. Redistributions of source code must retain the above copyright 20 * notice, this list of conditions and the following disclaimer. 21 * 2. Redistributions in binary form must reproduce the above copyright 22 * notice, this list of conditions and the following disclaimer in the 23 * documentation and/or other materials provided with the distribution. 24 * 3. All advertising materials mentioning features or use of this software 25 * must display the following acknowledgement: 26 * This product includes software developed by the University of 27 * California, Berkeley and its contributors. 28 * 4. Neither the name of the University nor the names of its contributors 29 * may be used to endorse or promote products derived from this software 30 * without specific prior written permission. 31 * 32 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 34 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 35 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 36 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 40 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 41 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 42 * SUCH DAMAGE. 43 * 44 * @(#)param.h 8.1 (Berkeley) 6/11/93 45 */ 46 47 /* 48 * Copyright (c) 1996-1999 Eduardo Horvath 49 * 50 * Redistribution and use in source and binary forms, with or without 51 * modification, are permitted provided that the following conditions 52 * are met: 53 * 1. Redistributions of source code must retain the above copyright 54 * notice, this list of conditions and the following disclaimer. 55 * 56 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND 57 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 58 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 59 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE 60 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 61 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 62 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 63 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 64 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 65 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 66 * SUCH DAMAGE. 67 * 68 */ 69 70 71 72 #define _MACHINE sparc64 73 #define MACHINE "sparc64" 74 #ifdef __arch64__ 75 #define _MACHINE_ARCH sparc64 76 #define MACHINE_ARCH "sparc64" 77 #define MID_MACHINE MID_SPARC64 78 #else 79 #define _MACHINE_ARCH sparc 80 #define MACHINE_ARCH "sparc" 81 #define MID_MACHINE MID_SPARC 82 #endif 83 84 #ifdef _KERNEL /* XXX */ 85 #ifndef _LOCORE /* XXX */ 86 #include <machine/cpu.h> /* XXX */ 87 #endif /* XXX */ 88 #endif /* XXX */ 89 90 /* 91 * Round p (pointer or byte index) up to a correctly-aligned value for 92 * the machine's strictest data type. The result is u_int and must be 93 * cast to any desired pointer type. 94 * 95 * ALIGNED_POINTER is a boolean macro that checks whether an address 96 * is valid to fetch data elements of type t from on this architecture. 97 * This does not reflect the optimal alignment, just the possibility 98 * (within reasonable limits). 99 * 100 */ 101 #define ALIGNBYTES32 0x7 102 #define ALIGNBYTES64 0xf 103 #ifdef __arch64__ 104 #define ALIGNBYTES ALIGNBYTES64 105 #else 106 #define ALIGNBYTES ALIGNBYTES32 107 #endif 108 #define ALIGN(p) (((u_long)(p) + ALIGNBYTES) & ~ALIGNBYTES) 109 #define ALIGN32(p) (((u_long)(p) + ALIGNBYTES32) & ~ALIGNBYTES32) 110 #define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0) 111 112 113 /* 114 * The following variables are always defined and initialized (in locore) 115 * so independently compiled modules (e.g. LKMs) can be used irrespective 116 * of the `options SUN4?' combination a particular kernel was configured with. 117 * See also the definitions of NBPG, PGOFSET and PGSHIFT below. 118 */ 119 #if (defined(_KERNEL) || defined(_STANDALONE)) && !defined(_LOCORE) 120 extern int nbpg, pgofset, pgshift; 121 #endif 122 123 #define KERNBASE 0xf1000000 /* start of kernel virtual space */ 124 #define KERNEND 0xfe000000 /* start of kernel virtual space */ 125 #define VM_MAX_KERNEL_BUF ((KERNEND-KERNBASE)/4) 126 127 #define DEV_BSIZE 512 128 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 129 #define BLKDEV_IOSIZE 2048 130 #define MAXPHYS (64 * 1024) 131 132 #ifdef __arch64__ 133 /* We get stack overflows w/8K stacks in 64-bit mode */ 134 #define SSIZE 2 /* initial stack size in pages */ 135 #else 136 #define SSIZE 1 137 #endif 138 #define USPACE (SSIZE*8192) 139 140 /* 141 * Constants related to network buffer management. 142 * MCLBYTES must be no larger than NBPG (the software page size), and, 143 * on machines that exchange pages of input or output buffers with mbuf 144 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 145 * of the hardware page size. 146 */ 147 #define MSIZE 128 /* size of an mbuf */ 148 #define MCLBYTES 2048 /* enough for whole Ethernet packet */ 149 #define MCLSHIFT 11 /* log2(MCLBYTES) */ 150 #define MCLOFSET (MCLBYTES - 1) 151 152 #if defined(_KERNEL) && !defined(_LKM) 153 #include "opt_gateway.h" 154 #endif /* _KERNEL && ! _LKM */ 155 156 #ifndef NMBCLUSTERS 157 #ifdef GATEWAY 158 #define NMBCLUSTERS 512 /* map size, max cluster allocation */ 159 #else 160 #define NMBCLUSTERS 256 /* map size, max cluster allocation */ 161 #endif 162 #endif 163 164 #define MSGBUFSIZE NBPG 165 166 /* 167 * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized 168 * logical pages. 169 */ 170 #define NKMEMPAGES_MIN_DEFAULT ((6 * 1024 * 1024) >> PAGE_SHIFT) 171 #define NKMEMPAGES_MAX_DEFAULT ((6 * 1024 * 1024) >> PAGE_SHIFT) 172 173 /* pages ("clicks") to disk blocks */ 174 #define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT)) 175 #define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT)) 176 177 /* pages to bytes */ 178 #define ctob(x) ((x) << PGSHIFT) 179 #define btoc(x) (((x) + PGOFSET) >> PGSHIFT) 180 181 /* bytes to disk blocks */ 182 #define btodb(x) ((x) >> DEV_BSHIFT) 183 #define dbtob(x) ((x) << DEV_BSHIFT) 184 185 /* 186 * Map a ``block device block'' to a file system block. 187 * This should be device dependent, and should use the bsize 188 * field from the disk label. 189 * For now though just use DEV_BSIZE. 190 */ 191 #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE / DEV_BSIZE)) 192 193 /* 194 * dvmamap manages a range of DVMA addresses intended to create double 195 * mappings of physical memory. In a way, `dvmamap' is a submap of the 196 * VM map `phys_map'. The difference is the use of the `resource map' 197 * routines to manage page allocation, allowing DVMA addresses to be 198 * allocated and freed from within interrupt routines. 199 * 200 * Note that `phys_map' can still be used to allocate memory-backed pages 201 * in DVMA space. 202 */ 203 #ifdef _KERNEL 204 #ifndef _LOCORE 205 extern vaddr_t dvma_base; 206 extern vaddr_t dvma_end; 207 extern struct map *dvmamap; 208 /* 209 * The dvma resource map is defined in page units, which are numbered 1 to N. 210 * Use these macros to convert to/from virtual addresses. 211 */ 212 #define rctov(n) (ctob(((n)-1))+dvma_base) 213 #define vtorc(v) ((btoc((v)-dvma_base))+1) 214 215 extern caddr_t kdvma_mapin __P((caddr_t, int, int)); 216 extern caddr_t dvma_malloc __P((size_t, void *, int)); 217 extern void dvma_free __P((caddr_t, size_t, void *)); 218 219 extern void delay __P((unsigned int)); 220 #define DELAY(n) delay(n) 221 222 extern int cputyp; 223 extern int cpumod; 224 extern int mmumod; 225 226 #endif /* _LOCORE */ 227 #endif /* _KERNEL */ 228 229 /* 230 * Values for the cputyp variable. 231 */ 232 #define CPU_SUN4 0 233 #define CPU_SUN4C 1 234 #define CPU_SUN4M 2 235 #define CPU_SUN4U 3 236 237 /* 238 * Shorthand CPU-type macros. Enumerate all eight cases. 239 * Let compiler optimize away code conditional on constants. 240 * 241 * On a sun4 machine, the page size is 8192, while on a sun4c and sun4m 242 * it is 4096. Therefore, in the (SUN4 && (SUN4C || SUN4M)) cases below, 243 * NBPG, PGOFSET and PGSHIFT are defined as variables which are initialized 244 * early in locore.s after the machine type has been detected. 245 * 246 * Note that whenever the macros defined below evaluate to expressions 247 * involving variables, the kernel will perform slighly worse due to the 248 * extra memory references they'll generate. 249 */ 250 251 #define CPU_ISSUN4U (1) 252 #define CPU_ISSUN4MOR4U (1) 253 #define CPU_ISSUN4M (0) 254 #define CPU_ISSUN4C (0) 255 #define CPU_ISSUN4 (0) 256 #define CPU_ISSUN4OR4C (0) 257 #define CPU_ISSUN4COR4M (0) 258 #define NBPG 8192 /* bytes/page */ 259 #define PGOFSET (NBPG-1) /* byte offset into page */ 260 #define PGSHIFT 13 /* log2(NBPG) */ 261