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