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 2007 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 53 #if defined(__amd64) 54 #define NCPU 64 /* NBBY * sizeof (ulong_t) for simple cpuset_t */ 55 #elif defined(__i386) 56 #define NCPU 32 57 #endif 58 59 /* 60 * The value defined below could grow to 16. hat structure and 61 * page_t have room for 16 nodes. 62 */ 63 #define MAXNODES 4 64 #define NUMA_NODEMASK 0x0f 65 66 67 /* 68 * Define the FPU symbol if we could run on a machine with an external 69 * FPU (i.e. not integrated with the normal machine state like the vax). 70 * 71 * The fpu is defined in the architecture manual, and the kernel hides 72 * its absence if it is not present, that's pretty integrated, no? 73 */ 74 75 /* supported page sizes */ 76 #define MMU_PAGE_SIZES 2 77 78 /* 79 * MMU_PAGES* describes the physical page size used by the mapping hardware. 80 * PAGES* describes the logical page size used by the system. 81 */ 82 83 #define MMU_PAGESIZE 0x1000 /* 4096 bytes */ 84 #define MMU_PAGESHIFT 12 /* log2(MMU_PAGESIZE) */ 85 86 #if !defined(_ASM) 87 #define MMU_PAGEOFFSET (MMU_PAGESIZE-1) /* Mask of address bits in page */ 88 #else /* _ASM */ 89 #define MMU_PAGEOFFSET _CONST(MMU_PAGESIZE-1) /* assembler lameness */ 90 #endif /* _ASM */ 91 92 #define MMU_PAGEMASK (~MMU_PAGEOFFSET) 93 94 #define PAGESIZE 0x1000 /* All of the above, for logical */ 95 #define PAGESHIFT 12 96 #define PAGEOFFSET (PAGESIZE - 1) 97 #define PAGEMASK (~PAGEOFFSET) 98 99 /* 100 * DATA_ALIGN is used to define the alignment of the Unix data segment. 101 */ 102 #define DATA_ALIGN PAGESIZE 103 104 /* 105 * DEFAULT KERNEL THREAD stack size (in pages). 106 */ 107 #if defined(__amd64) 108 #define DEFAULTSTKSZ_NPGS 5 109 #elif defined(__i386) 110 #define DEFAULTSTKSZ_NPGS 2 111 #endif 112 113 #if !defined(_ASM) 114 #define DEFAULTSTKSZ (DEFAULTSTKSZ_NPGS * PAGESIZE) 115 #else /* !_ASM */ 116 #define DEFAULTSTKSZ _MUL(DEFAULTSTKSZ_NPGS, PAGESIZE) /* as(1) lameness */ 117 #endif /* !_ASM */ 118 119 /* 120 * KERNELBASE is the virtual address at which the kernel segments start in 121 * all contexts. 122 * 123 * KERNELBASE is not fixed on 32-bit systems. The value of KERNELBASE can 124 * change with installed memory and the eprom variable 'eprom_kernelbase'. 125 * This value is fixed on 64-bit systems. 126 * 127 * common/conf/param.c requires a compile time defined value for KERNELBASE 128 * which it saves in the variable _kernelbase. If kernelbase is modifed on 129 * a 32-bit system, _kernelbase will be updated with the new value in 130 * i86pc/os/startup.c. 131 * 132 * i86 and i86pc files use kernelbase instead of KERNELBASE, which is 133 * initialized in i86pc/os/startup.c. 134 */ 135 #define KERNEL_TEXT_amd64 UINT64_C(0xfffffffffb800000) 136 #define KERNEL_TEXT_i386 ADDRESS_C(0xfe800000) 137 138 #if defined(__amd64) 139 140 #define KERNELBASE ADDRESS_C(0xfffffd8000000000) 141 142 /* 143 * Size of the unmapped "red zone" at the very bottom of the kernel's 144 * address space. Corresponds to 1 slot in the toplevel pagetable. 145 */ 146 #define KERNEL_REDZONE_SIZE ((uintptr_t)1 << 39) 147 148 /* 149 * Base of 'core' heap area, which is used for kernel and module text/data 150 * that must be within a 2GB range to allow for rip-relative addressing. 151 * 152 * XX64: because vmx and boot cannot be trusted to stay in a 1GB playpen at 153 * the bottom of the upper 4GB range, we need to restrict the core heap to 154 * the top 1GB for now. 155 */ 156 #define COREHEAP_BASE ADDRESS_C(0xffffffffc0000000) 157 158 /* 159 * Beginning of the segkpm window 160 */ 161 #define SEGKPM_BASE ADDRESS_C(0xfffffe0000000000) 162 163 /* 164 * This is valloc_base, above seg_kpm, but below everything else 165 */ 166 #define VALLOC_BASE ADDRESS_C(0xffffff0000000000) 167 168 /* 169 * default and boundary sizes for segkp 170 */ 171 #define SEGKPDEFSIZE (2L * 1024L * 1024L * 1024L) /* 2G */ 172 #define SEGKPMAXSIZE (8L * 1024L * 1024L * 1024L) /* 8G */ 173 #define SEGKPMINSIZE (200L * 1024 * 1024L) /* 200M */ 174 175 /* 176 * minimum size for segzio 177 */ 178 #define SEGZIOMINSIZE (400L * 1024 * 1024L) /* 400M */ 179 180 /* 181 * During intial boot we limit heap to the top 4Gig. 182 */ 183 #define BOOT_KERNELHEAP_BASE ADDRESS_C(0xffffffff00000000) 184 185 /* 186 * VMWare works best if we don't use the top 64Meg of memory for amd64. 187 * Set KERNEL_TEXT to top_o_memory - 64Meg - 8 Meg for 8Meg of nucleus pages. 188 */ 189 #define PROMSTART ADDRESS_C(0xffc00000) 190 #define KERNEL_TEXT KERNEL_TEXT_amd64 191 192 /* 193 * Virtual address range available to the debugger 194 */ 195 #define SEGDEBUGBASE ADDRESS_C(0xffffffffff800000) 196 #define SEGDEBUGSIZE ADDRESS_C(0x400000) 197 198 /* 199 * Define upper limit on user address space 200 * 201 * In amd64, the upper limit on a 64-bit user address space is 1 large page 202 * (2MB) below kernelbase. The upper limit for a 32-bit user address space 203 * is 1 small page (4KB) below the top of the 32-bit range. The 64-bit 204 * limit give dtrace the red zone it needs below kernelbase. The 32-bit 205 * limit gives us a small red zone to detect address-space overruns in a 206 * user program. 207 */ 208 #define USERLIMIT ADDRESS_C(0xfffffd7fffe00000) 209 #ifdef bug_5074717_is_fixed 210 #define USERLIMIT32 ADDRESS_C(0xfffff000) 211 #else 212 #define USERLIMIT32 ADDRESS_C(0xfefff000) 213 #endif 214 215 #elif defined(__i386) 216 217 #ifdef DEBUG 218 #define KERNELBASE ADDRESS_C(0xc8000000) 219 #else 220 #define KERNELBASE ADDRESS_C(0xd4000000) 221 #endif 222 223 #define KERNELBASE_MAX ADDRESS_C(0xe0000000) 224 225 /* 226 * The i386 ABI requires that the user address space be at least 3Gb 227 * in size. KERNELBASE_ABI_MIN is used as the default KERNELBASE for 228 * physical memory configurations > 4gb. 229 */ 230 #define KERNELBASE_ABI_MIN ADDRESS_C(0xc0000000) 231 232 /* 233 * Size of the unmapped "red zone" at the very bottom of the kernel's 234 * address space. Since segmap start immediately above the red zone, this 235 * needs to be MAXBSIZE aligned. 236 */ 237 #define KERNEL_REDZONE_SIZE MAXBSIZE 238 239 /* 240 * This is the last 4MB of the 4G address space. Some psm modules 241 * need this region of virtual address space mapped 1-1 242 */ 243 #define PROMSTART ADDRESS_C(0xffc00000) 244 #define KERNEL_TEXT KERNEL_TEXT_i386 245 246 /* 247 * Virtual address range available to the debugger 248 * We place it just above the kernel text (4M) and kernel data (4M). 249 */ 250 #define SEGDEBUGBASE (KERNEL_TEXT + ADDRESS_C(0x800000)) 251 #define SEGDEBUGSIZE ADDRESS_C(0x400000) 252 253 /* 254 * Define upper limit on user address space 255 */ 256 #define USERLIMIT KERNELBASE 257 #define USERLIMIT32 USERLIMIT 258 259 #endif /* __i386 */ 260 261 /* 262 * Reserve two pages just below KERNEL_TEXT for the GDT and debug info page. 263 */ 264 #if !defined(_ASM) 265 #define MISC_VA_BASE (KERNEL_TEXT - MMU_PAGESIZE * 2) 266 #define GDT_VA (MISC_VA_BASE) 267 #define DEBUG_INFO_VA (MISC_VA_BASE + MMU_PAGESIZE) 268 #endif /* !_ASM */ 269 270 #if !defined(_ASM) && !defined(_KMDB) 271 extern uintptr_t kernelbase, segmap_start, segmapsize; 272 #endif 273 274 /* 275 * ARGSBASE is the base virtual address of the range which 276 * the kernel uses to map the arguments for exec. 277 */ 278 #define ARGSBASE PROMSTART 279 280 /* 281 * reserve space for modules 282 */ 283 #define MODTEXT (1024 * 1024 * 2) 284 #define MODDATA (1024 * 300) 285 286 /* 287 * The heap has a region allocated from it of HEAPTEXT_SIZE bytes specifically 288 * for module text. 289 */ 290 #define HEAPTEXT_SIZE (64 * 1024 * 1024) /* bytes */ 291 292 /* 293 * Size of a kernel threads stack. It must be a whole number of pages 294 * since the segment it comes from will only allocate space in pages. 295 */ 296 #define T_STACKSZ 2*PAGESIZE 297 298 /* 299 * Size of a cpu startup thread stack. (It must be a whole number of pages 300 * since the containing segment only allocates space in pages.) 301 */ 302 303 #define STARTUP_STKSZ 3*PAGESIZE 304 305 /* 306 * Bus types 307 */ 308 #define BTISA 1 309 #define BTEISA 2 310 #define BTMCA 3 311 312 #ifdef __cplusplus 313 } 314 #endif 315 316 #endif /* _SYS_MACHPARAM_H */ 317