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