1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 /* Copyright (c) 1988 AT&T */ 27 /* All Rights Reserved */ 28 29 30 #ifndef _SYS_MACHPARAM_H 31 #define _SYS_MACHPARAM_H 32 33 #pragma ident "%Z%%M% %I% %E% SMI" 34 35 #if !defined(_ASM) 36 #include <sys/types.h> 37 #endif 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 #ifndef _ASM 44 #define ADDRESS_C(c) c ## ul 45 #else /* _ASM */ 46 #define ADDRESS_C(c) (c) 47 #endif /* _ASM */ 48 49 /* 50 * Machine dependent parameters and limits. 51 */ 52 #if defined(__amd64) 53 #define NCPU 64 /* NBBY * sizeof (ulong_t) for simple cpuset_t */ 54 #elif defined(__i386) 55 #define NCPU 32 56 #else 57 #error "port me" 58 #endif 59 60 /* 61 * The value defined below could grow to 16. hat structure and 62 * page_t have room for 16 nodes. 63 */ 64 #define MAXNODES 4 65 #define NUMA_NODEMASK 0x0f 66 67 68 /* 69 * Define the FPU symbol if we could run on a machine with an external 70 * FPU (i.e. not integrated with the normal machine state like the vax). 71 * 72 * The fpu is defined in the architecture manual, and the kernel hides 73 * its absence if it is not present, that's pretty integrated, no? 74 */ 75 76 /* supported page sizes */ 77 #define MMU_PAGE_SIZES 2 78 79 /* 80 * MMU_PAGES* describes the physical page size used by the mapping hardware. 81 * PAGES* describes the logical page size used by the system. 82 */ 83 84 #define MMU_PAGESIZE 0x1000 /* 4096 bytes */ 85 #define MMU_PAGESHIFT 12 /* log2(MMU_PAGESIZE) */ 86 87 #if !defined(_ASM) 88 #define MMU_PAGEOFFSET (MMU_PAGESIZE-1) /* Mask of address bits in page */ 89 #else /* !_ASM */ 90 #define MMU_PAGEOFFSET _CONST(MMU_PAGESIZE-1) /* assembler lameness */ 91 #endif /* !_ASM */ 92 93 #define MMU_PAGEMASK (~MMU_PAGEOFFSET) 94 95 #define PAGESIZE 0x1000 /* All of the above, for logical */ 96 #define PAGESHIFT 12 97 #define PAGEOFFSET (PAGESIZE - 1) 98 #define PAGEMASK (~PAGEOFFSET) 99 100 /* 101 * DATA_ALIGN is used to define the alignment of the Unix data segment. 102 */ 103 #define DATA_ALIGN PAGESIZE 104 105 /* 106 * DEFAULT KERNEL THREAD stack size (in pages). 107 */ 108 #if defined(__amd64) 109 #define DEFAULTSTKSZ_NPGS 5 110 #elif defined(__i386) 111 #define DEFAULTSTKSZ_NPGS 2 112 #endif 113 114 #if !defined(_ASM) 115 #define DEFAULTSTKSZ (DEFAULTSTKSZ_NPGS * PAGESIZE) 116 #else /* !_ASM */ 117 #define DEFAULTSTKSZ _MUL(DEFAULTSTKSZ_NPGS, PAGESIZE) /* as(1) lameness */ 118 #endif /* !_ASM */ 119 120 /* 121 * KERNELBASE is the virtual address at which the kernel segments start in 122 * all contexts. 123 * 124 * KERNELBASE is not fixed on 32-bit systems. The value of KERNELBASE can 125 * change with installed memory and the eprom variable 'eprom_kernelbase'. 126 * This value is fixed on 64-bit systems. 127 * 128 * common/conf/param.c requires a compile time defined value for KERNELBASE 129 * which it saves in the variable _kernelbase. If kernelbase is modifed on 130 * a 32-bit system, _kernelbase will be updated with the new value in 131 * i86pc/os/startup.c. 132 * 133 * i86 and i86pc files use kernelbase instead of KERNELBASE, which is 134 * initialized in i86pc/os/startup.c. 135 */ 136 137 #if defined(__amd64) 138 139 #define KERNELBASE ADDRESS_C(0xfffffd8000000000) 140 141 /* 142 * Size of the unmapped "red zone" at the very bottom of the kernel's 143 * address space. Corresponds to 1 slot in the toplevel pagetable. 144 */ 145 #define KERNEL_REDZONE_SIZE ((uintptr_t)1 << 39) 146 147 /* 148 * Base of 'core' heap area, which is used for kernel and module text/data 149 * that must be within a 2GB range to allow for rip-relative addressing. 150 * 151 * XX64: because vmx and boot cannot be trusted to stay in a 1GB playpen at 152 * the bottom of the upper 4GB range, we need to restrict the core heap to 153 * the top 1GB for now. 154 */ 155 #define COREHEAP_BASE ADDRESS_C(0xffffffffc0000000) 156 157 /* 158 * Beginning of the segkpm window 159 */ 160 #define SEGKPM_BASE ADDRESS_C(0xfffffe0000000000) 161 162 /* 163 * default and boundary sizes for segkp 164 */ 165 #define SEGKPDEFSIZE (2L * 1024L * 1024L * 1024L) /* 2G */ 166 #define SEGKPMAXSIZE (8L * 1024L * 1024L * 1024L) /* 8G */ 167 #define SEGKPMINSIZE (200L * 1024 * 1024L) /* 200M */ 168 169 /* 170 * minimum size for segzio 171 */ 172 #define SEGZIOMINSIZE (400L * 1024 * 1024L) /* 400M */ 173 174 /* 175 * Boot (or, more precisely, vmx) maps most pages twice - once in the 176 * bottom 2GB of memory and once in the bottom 2GB of the topmost 4GB. 177 * When boot is unmapped this range is available to the kernel, but until 178 * then we have to leave it untouched. 179 */ 180 #define BOOT_DOUBLEMAP_BASE ADDRESS_C(0xffffffff00000000) 181 #define BOOT_DOUBLEMAP_SIZE ADDRESS_C(0x80000000) 182 183 /* 184 * VMWare works best if we don't use the top 64Meg of memory for amd64. 185 * Set KERNEL_TEXT to top_o_memory - 64Meg - 8 Meg for 8Meg of nucleus pages. 186 */ 187 #define PROMSTART ADDRESS_C(0xffc00000) 188 #define KERNEL_TEXT ADDRESS_C(0xfffffffffb800000) 189 190 /* 191 * Define upper limit on user address space 192 * 193 * In amd64, the upper limit on a 64-bit user address space is 1 large page 194 * (2MB) below kernelbase. The upper limit for a 32-bit user address space 195 * is 1 small page (4KB) below the top of the 32-bit range. The 64-bit 196 * limit give dtrace the red zone it needs below kernelbase. The 32-bit 197 * limit gives us a small red zone to detect address-space overruns in a 198 * user program. 199 */ 200 #define USERLIMIT ADDRESS_C(0xfffffd7fffe00000) 201 #ifdef bug_5074717_is_fixed 202 #define USERLIMIT32 ADDRESS_C(0xfffff000) 203 #else 204 #define USERLIMIT32 ADDRESS_C(0xfefff000) 205 #endif 206 207 #elif defined(__i386) 208 209 #ifdef DEBUG 210 #define KERNELBASE ADDRESS_C(0xc8000000) 211 #else 212 #define KERNELBASE ADDRESS_C(0xd4000000) 213 #endif 214 215 #define KERNELBASE_MAX ADDRESS_C(0xe0000000) 216 217 /* 218 * The i386 ABI requires that the user address space be at least 3Gb 219 * in size. KERNELBASE_ABI_MIN is used as the default KERNELBASE for 220 * physical memory configurations > 4gb. 221 */ 222 #define KERNELBASE_ABI_MIN ADDRESS_C(0xc0000000) 223 224 /* 225 * Size of the unmapped "red zone" at the very bottom of the kernel's 226 * address space. Since segmap start immediately above the red zone, this 227 * needs to be MAXBSIZE aligned. 228 */ 229 #define KERNEL_REDZONE_SIZE MAXBSIZE 230 231 /* 232 * This is the last 4MB of the 4G address space. Some psm modules 233 * need this region of virtual address space mapped 1-1 234 */ 235 #define PROMSTART ADDRESS_C(0xffc00000) 236 #define KERNEL_TEXT ADDRESS_C(0xfe800000) 237 238 /* 239 * Define upper limit on user address space 240 */ 241 #define USERLIMIT KERNELBASE 242 #define USERLIMIT32 USERLIMIT 243 244 #endif /* __i386 */ 245 246 #if !defined(_ASM) && !defined(_KADB) 247 extern uintptr_t kernelbase, segkmap_start, segmapsize; 248 #endif 249 250 /* 251 * ARGSBASE is the base virtual address of the range which 252 * the kernel uses to map the arguments for exec. 253 */ 254 #define ARGSBASE PROMSTART 255 256 /* 257 * reserve space for modules 258 */ 259 #define MODTEXT (1024 * 1024 * 2) 260 #define MODDATA (1024 * 300) 261 262 /* 263 * The heap has a region allocated from it of HEAPTEXT_SIZE bytes specifically 264 * for module text. 265 */ 266 #define HEAPTEXT_SIZE (64 * 1024 * 1024) /* bytes */ 267 268 /* 269 * Size of a kernel threads stack. It must be a whole number of pages 270 * since the segment it comes from will only allocate space in pages. 271 */ 272 #define T_STACKSZ 2*PAGESIZE 273 274 /* 275 * Size of a cpu startup thread stack. (It must be a whole number of pages 276 * since the containing segment only allocates space in pages.) 277 */ 278 279 #define STARTUP_STKSZ 3*PAGESIZE 280 281 /* 282 * Bus types 283 */ 284 #define BTISA 1 285 #define BTEISA 2 286 #define BTMCA 3 287 288 #ifdef __cplusplus 289 } 290 #endif 291 292 #endif /* _SYS_MACHPARAM_H */ 293