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 (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved. 23 */ 24 25 /* Copyright (c) 1988 AT&T */ 26 /* All Rights Reserved */ 27 28 #ifndef _SYS_MACHPARAM_H 29 #define _SYS_MACHPARAM_H 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 #ifndef _ASM 36 #define ADDRESS_C(c) c ## ul 37 #else /* _ASM */ 38 #define ADDRESS_C(c) (c) 39 #endif /* _ASM */ 40 41 /* 42 * Machine dependent parameters and limits - sun4u version. 43 */ 44 45 /* 46 * Define the VAC symbol (etc.) if we could run on a machine 47 * which has a Virtual Address Cache 48 * 49 * This stuff gotta go. 50 */ 51 #define VAC /* support virtual addressed caches */ 52 53 /* 54 * The maximum possible number of UPA devices in a system. 55 * MAX_UPA maybe defined in a platform's makefile. 56 */ 57 #ifdef _STARFIRE 58 /* 59 * We have a 7 bit id space for UPA devices in Xfire 60 */ 61 #define MAX_UPA 128 62 #else 63 #ifndef MAX_UPA 64 #define MAX_UPA 32 65 #endif 66 #endif /* _STARFIRE */ 67 68 /* 69 * Maximum cpuid value that we support. NCPU can be defined in a platform's 70 * makefile. 71 */ 72 #if (defined(_STARFIRE) && !defined(lint)) 73 #define NCPU 64 74 #else 75 #ifndef NCPU 76 #define NCPU 32 77 #endif 78 #endif /* _STARFIRE && !lint */ 79 80 #if (NCPU <= 1) 81 #define NCPU_LOG2 0 82 #elif (NCPU <= 2) 83 #define NCPU_LOG2 1 84 #elif (NCPU <= 4) 85 #define NCPU_LOG2 2 86 #elif (NCPU <= 8) 87 #define NCPU_LOG2 3 88 #elif (NCPU <= 16) 89 #define NCPU_LOG2 4 90 #elif (NCPU <= 32) 91 #define NCPU_LOG2 5 92 #elif (NCPU <= 64) 93 #define NCPU_LOG2 6 94 #elif (NCPU <= 128) 95 #define NCPU_LOG2 7 96 #elif (NCPU <= 256) 97 #define NCPU_LOG2 8 98 #elif (NCPU <= 512) 99 #define NCPU_LOG2 9 100 #elif (NCPU <= 1024) 101 #define NCPU_LOG2 10 102 #else 103 #error "add test for larger NCPU" 104 #endif 105 106 /* 107 * Maximum number of processors that we support. With CMP processors, the 108 * portid may not be equal to cpuid. MAX_CPU_CHIPID can be defined in a 109 * platform's makefile. 110 */ 111 #ifndef MAX_CPU_CHIPID 112 #define MAX_CPU_CHIPID NCPU 113 #endif 114 115 /* 116 * Define the FPU symbol if we could run on a machine with an external 117 * FPU (i.e. not integrated with the normal machine state like the vax). 118 * 119 * The fpu is defined in the architecture manual, and the kernel hides 120 * its absence if it is not present, that's pretty integrated, no? 121 */ 122 123 /* 124 * MMU_PAGES* describes the physical page size used by the mapping hardware. 125 * PAGES* describes the logical page size used by the system. 126 */ 127 #define MMU_PAGE_SIZES 6 /* max sun4u mmu-supported page sizes */ 128 #define DEFAULT_MMU_PAGE_SIZES 4 /* default sun4u supported page sizes */ 129 130 /* 131 * XXX make sure the MMU_PAGESHIFT definition here is 132 * consistent with the one in param.h 133 */ 134 #define MMU_PAGESHIFT 13 135 #define MMU_PAGESIZE (1<<MMU_PAGESHIFT) 136 #define MMU_PAGEOFFSET (MMU_PAGESIZE - 1) 137 #define MMU_PAGEMASK (~MMU_PAGEOFFSET) 138 139 #define MMU_PAGESHIFT64K 16 140 #define MMU_PAGESIZE64K (1 << MMU_PAGESHIFT64K) 141 #define MMU_PAGEOFFSET64K (MMU_PAGESIZE64K - 1) 142 #define MMU_PAGEMASK64K (~MMU_PAGEOFFSET64K) 143 144 #define MMU_PAGESHIFT512K 19 145 #define MMU_PAGESIZE512K (1 << MMU_PAGESHIFT512K) 146 #define MMU_PAGEOFFSET512K (MMU_PAGESIZE512K - 1) 147 #define MMU_PAGEMASK512K (~MMU_PAGEOFFSET512K) 148 149 #define MMU_PAGESHIFT4M 22 150 #define MMU_PAGESIZE4M (1 << MMU_PAGESHIFT4M) 151 #define MMU_PAGEOFFSET4M (MMU_PAGESIZE4M - 1) 152 #define MMU_PAGEMASK4M (~MMU_PAGEOFFSET4M) 153 154 #define MMU_PAGESHIFT32M 25 155 #define MMU_PAGESIZE32M (1 << MMU_PAGESHIFT32M) 156 #define MMU_PAGEOFFSET32M (MMU_PAGESIZE32M - 1) 157 #define MMU_PAGEMASK32M (~MMU_PAGEOFFSET32M) 158 159 #define MMU_PAGESHIFT256M 28 160 #define MMU_PAGESIZE256M (1 << MMU_PAGESHIFT256M) 161 #define MMU_PAGEOFFSET256M (MMU_PAGESIZE256M - 1) 162 #define MMU_PAGEMASK256M (~MMU_PAGEOFFSET256M) 163 164 #define PAGESHIFT 13 165 #define PAGESIZE (1<<PAGESHIFT) 166 #define PAGEOFFSET (PAGESIZE - 1) 167 #define PAGEMASK (~PAGEOFFSET) 168 169 /* 170 * DATA_ALIGN is used to define the alignment of the Unix data segment. 171 */ 172 #define DATA_ALIGN ADDRESS_C(0x2000) 173 174 /* 175 * DEFAULT KERNEL THREAD stack size. 176 */ 177 178 #define DEFAULTSTKSZ (3*PAGESIZE) 179 180 /* 181 * DEFAULT initial thread stack size. 182 */ 183 #define T0STKSZ (2 * DEFAULTSTKSZ) 184 185 /* 186 * KERNELBASE is the virtual address which 187 * the kernel text/data mapping starts in all contexts. 188 */ 189 #define KERNELBASE ADDRESS_C(0x01000000) 190 191 /* 192 * Virtual address range available to the debugger 193 */ 194 #define SEGDEBUGBASE ADDRESS_C(0xedd00000) 195 #define SEGDEBUGSIZE (ADDRESS_C(0xf0000000) - SEGDEBUGBASE) 196 197 /* 198 * Define the userlimits 199 */ 200 201 #define USERLIMIT ADDRESS_C(0xFFFFFFFF80000000) 202 #define USERLIMIT32 ADDRESS_C(0xFFC00000) 203 204 /* 205 * Define SEGKPBASE, start of the segkp segment. 206 */ 207 208 #define SEGKPBASE ADDRESS_C(0x2a100000000) 209 210 /* 211 * Define SEGMAPBASE, start of the segmap segment. 212 */ 213 214 #define SEGMAPBASE ADDRESS_C(0x2a750000000) 215 216 /* 217 * SYSBASE is the virtual address which the kernel allocated memory 218 * mapping starts in all contexts. SYSLIMIT is the end of the Sysbase segment. 219 */ 220 221 #define SYSBASE ADDRESS_C(0x30000000000) 222 #define SYSLIMIT ADDRESS_C(0x70000000000) 223 #define SYSBASE32 ADDRESS_C(0x70000000) 224 #define SYSLIMIT32 ADDRESS_C(0x80000000) 225 226 /* 227 * BOOTTMPBASE is the base of a space that can be reclaimed 228 * after the kernel takes over the machine. It contains the 229 * boot archive and memory allocated by krtld before kmem_alloc 230 * is brought online. 231 */ 232 #define BOOTTMPBASE ADDRESS_C(0x4C000000) 233 234 /* 235 * MEMSCRUBBASE is the base virtual address for the memory scrubber 236 * to read large pages. It MUST be 4MB page aligned. 237 */ 238 239 #define MEMSCRUBBASE 0x2a000000000 240 241 /* 242 * Define the kernel address space range allocated to Open Firmware 243 */ 244 #define OFW_START_ADDR 0xf0000000 245 #define OFW_END_ADDR 0xffffffff 246 247 /* 248 * ARGSBASE is the base virtual address of the range which 249 * the kernel uses to map the arguments for exec. 250 */ 251 #define ARGSBASE (MEMSCRUBBASE - NCARGS) 252 253 /* 254 * PPMAPBASE is the base virtual address of the range which 255 * the kernel uses to quickly map pages for operations such 256 * as ppcopy, pagecopy, pagezero, and pagesum. 257 */ 258 #define PPMAPSIZE (512 * 1024) 259 #define PPMAPBASE (ARGSBASE - PPMAPSIZE) 260 261 #define MAXPP_SLOTS ADDRESS_C(16) 262 #define PPMAP_FAST_SIZE (MAXPP_SLOTS * PAGESIZE * NCPU) 263 #define PPMAP_FAST_BASE (PPMAPBASE - PPMAP_FAST_SIZE) 264 265 /* 266 * PIOMAPBASE is the base virtual address at which programmable I/O registers 267 * are mapped. This allows such memory -- which may induce side effects when 268 * read -- to be cordoned off from the system at-large. 269 */ 270 #define PIOMAPSIZE (1024 * 1024 * 1024 * (uintptr_t)5) 271 #define PIOMAPBASE (PPMAP_FAST_BASE - PIOMAPSIZE) 272 273 /* 274 * Allocate space for kernel modules on nucleus pages 275 */ 276 #define MODDATA 1024 * 512 277 278 /* 279 * The heap has a region allocated from it specifically for module text that 280 * cannot fit on the nucleus page. This region -- which starts at address 281 * HEAPTEXT_BASE and runs for HEAPTEXT_SIZE bytes -- has virtual holes 282 * punched in it: for every HEAPTEXT_MAPPED bytes of available virtual, there 283 * is a virtual hole of size HEAPTEXT_UNMAPPED bytes sitting beneath it. This 284 * assures that any text address is within HEAPTEXT_MAPPED of an unmapped 285 * region. The unmapped regions themselves are managed with the routines 286 * kobj_texthole_alloc() and kobj_texthole_free(). 287 */ 288 #define HEAPTEXT_SIZE (128 * 1024 * 1024) /* bytes */ 289 #define HEAPTEXT_OVERSIZE (64 * 1024 * 1024) /* bytes */ 290 #define HEAPTEXT_BASE (SYSLIMIT32 - HEAPTEXT_SIZE) 291 #define HEAPTEXT_MAPPED (2 * 1024 * 1024) 292 #define HEAPTEXT_UNMAPPED (2 * 1024 * 1024) 293 294 #define HEAPTEXT_NARENAS \ 295 (HEAPTEXT_SIZE / (HEAPTEXT_MAPPED + HEAPTEXT_UNMAPPED) + 2) 296 297 /* 298 * Preallocate an area for setting up the user stack during 299 * the exec(). This way we have a faster allocator and also 300 * make sure the stack is always VAC aligned correctly. see 301 * get_arg_base() in startup.c. 302 */ 303 #define ARG_SLOT_SIZE (0x8000) 304 #define ARG_SLOT_SHIFT (15) 305 #define N_ARG_SLOT (0x80) 306 307 #define NARG_BASE (PIOMAPBASE - (ARG_SLOT_SIZE * N_ARG_SLOT)) 308 309 /* 310 * ktextseg+kvalloc should not use space beyond KERNEL_LIMIT32. 311 */ 312 313 /* 314 * For 64-bit kernels, rename KERNEL_LIMIT to KERNEL_LIMIT32 to more accurately 315 * reflect the fact that it's actually the limit for 32-bit kernel virtual 316 * addresses. 317 */ 318 #define KERNEL_LIMIT32 BOOTTMPBASE 319 320 #define PFN_TO_BUSTYPE(pfn) (((pfn) >> 19) & 0x1FF) 321 #define IO_BUSTYPE(pfn) ((PFN_TO_BUSTYPE(pfn) & 0x100) >> 8) 322 323 #ifdef _STARFIRE 324 #define PFN_TO_UPAID(pfn) BUSTYPE_TO_UPAID(PFN_TO_BUSTYPE(pfn)) 325 #else 326 #define PFN_TO_UPAID(pfn) (((pfn) >> 20) & 0x1F) 327 #endif /* _STARFIRE */ 328 329 /* 330 * Defines used for the ptl1_panic parameter, which is passed to the 331 * ptl1_panic assembly routine in %g1. These #defines have string 332 * names defined in sun4u/os/mach_cpu_states.c which should be kept up to 333 * date if new #defines are added. 334 */ 335 #define PTL1_BAD_DEBUG 0 336 #define PTL1_BAD_WTRAP 1 337 #define PTL1_BAD_KMISS 2 338 #define PTL1_BAD_KPROT_FAULT 3 339 #define PTL1_BAD_ISM 4 340 #define PTL1_BAD_MMUTRAP 5 341 #define PTL1_BAD_TRAP 6 342 #define PTL1_BAD_FPTRAP 7 343 #define PTL1_BAD_INTR_VEC 8 344 #define PTL1_BAD_TRACE_PTR 9 345 #define PTL1_BAD_STACK 10 346 #define PTL1_BAD_DTRACE_FLAGS 11 347 #define PTL1_BAD_CTX_STEAL 12 348 #define PTL1_BAD_ECC 13 349 #define PTL1_BAD_CTX 14 350 #define PTL1_BAD_RAISE_TSBEXCP 20 351 #define PTL1_NO_SCDTSB8K 21 352 353 /* 354 * Defines used for ptl1 related data structs. 355 */ 356 #define PTL1_MAXTL 4 357 #define PTL1_DEBUG_TRAP 0x7C 358 #define PTL1_SSIZE 1024 /* minimum stack size */ 359 #define CPU_ALLOC_SIZE MMU_PAGESIZE 360 361 #ifdef __cplusplus 362 } 363 #endif 364 365 #endif /* _SYS_MACHPARAM_H */ 366