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