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