xref: /titanic_44/usr/src/uts/sun4v/sys/machparam.h (revision 85298dc181bc16dc378c47f19f3785559903a8b9)
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 #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	256
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  * Virtual address range available to the debugger
153  */
154 #define	SEGDEBUGBASE	ADDRESS_C(0xedd00000)
155 #define	SEGDEBUGSIZE	(ADDRESS_C(0xf0000000) - SEGDEBUGBASE)
156 
157 /*
158  * Define the userlimits
159  */
160 
161 #define	USERLIMIT	ADDRESS_C(0xFFFFFFFF80000000)
162 #define	USERLIMIT32	ADDRESS_C(0xFFC00000)
163 
164 /*
165  * Define SEGKPBASE, start of the segkp segment.
166  */
167 
168 #define	SEGKPBASE	ADDRESS_C(0x2a100000000)
169 
170 /*
171  * Define SEGMAPBASE, start of the segmap segment.
172  */
173 
174 #define	SEGMAPBASE	ADDRESS_C(0x2a750000000)
175 
176 /*
177  * SYSBASE is the virtual address which the kernel allocated memory
178  * mapping starts in all contexts.  SYSLIMIT is the end of the Sysbase segment.
179  */
180 
181 #define	SYSBASE		ADDRESS_C(0x30000000000)
182 #define	SYSLIMIT	ADDRESS_C(0x70000000000)
183 #define	SYSBASE32	ADDRESS_C(0x70000000)
184 #define	SYSLIMIT32	ADDRESS_C(0x80000000)
185 
186 /*
187  * MEMSCRUBBASE is the base virtual address for the memory scrubber
188  * to read large pages.  It MUST be 4MB page aligned.
189  */
190 
191 #define	MEMSCRUBBASE	0x2a000000000
192 
193 /*
194  * Define the kernel address space range allocated to Open Firmware
195  */
196 #define	OFW_START_ADDR	0xf0000000
197 #define	OFW_END_ADDR	0xffffffff
198 
199 /*
200  * ARGSBASE is the base virtual address of the range which
201  * the kernel uses to map the arguments for exec.
202  */
203 #define	ARGSBASE	(MEMSCRUBBASE - NCARGS)
204 
205 /*
206  * PPMAPBASE is the base virtual address of the range which
207  * the kernel uses to quickly map pages for operations such
208  * as ppcopy, pagecopy, pagezero, and pagesum.
209  */
210 #define	PPMAPSIZE	(512 * 1024)
211 #define	PPMAPBASE	(ARGSBASE - PPMAPSIZE)
212 
213 #define	MAXPP_SLOTS	ADDRESS_C(16)
214 #define	PPMAP_FAST_SIZE	(MAXPP_SLOTS * PAGESIZE * NCPU)
215 #define	PPMAP_FAST_BASE	(PPMAPBASE - PPMAP_FAST_SIZE)
216 
217 /*
218  * PIOMAPBASE is the base virtual address at which programmable I/O registers
219  * are mapped.  This allows such memory -- which may induce side effects when
220  * read -- to be cordoned off from the system at-large.
221  */
222 #define	PIOMAPSIZE	(1024 * 1024 * 1024 * (uintptr_t)5)
223 #define	PIOMAPBASE	(PPMAP_FAST_BASE - PIOMAPSIZE)
224 
225 /*
226  * Allocate space for kernel modules on nucleus pages
227  */
228 #define	MODDATA	1024 * 256
229 
230 /*
231  * On systems with <MODTEXT_SM_SIZE MB available physical memory,
232  * cap the in-nucleus module text to MODTEXT_SM_CAP bytes.  The
233  * cap must be a multiple of the base page size.  Also see startup.c.
234  */
235 #define	MODTEXT_SM_CAP		(0x200000)		/* bytes */
236 #define	MODTEXT_SM_SIZE		(256)			/* MB */
237 
238 /*
239  * The heap has a region allocated from it specifically for module text that
240  * cannot fit on the nucleus page.  This region -- which starts at address
241  * HEAPTEXT_BASE and runs for HEAPTEXT_SIZE bytes -- has virtual holes
242  * punched in it: for every HEAPTEXT_MAPPED bytes of available virtual, there
243  * is a virtual hole of size HEAPTEXT_UNMAPPED bytes sitting beneath it.  This
244  * assures that any text address is within HEAPTEXT_MAPPED of an unmapped
245  * region.  The unmapped regions themselves are managed with the routines
246  * kobj_texthole_alloc() and kobj_texthole_free().
247  */
248 #define	HEAPTEXT_SIZE		(128 * 1024 * 1024)	/* bytes */
249 #define	HEAPTEXT_OVERSIZE	(64 * 1024 * 1024)	/* bytes */
250 #define	HEAPTEXT_BASE		(SYSLIMIT32 - HEAPTEXT_SIZE)
251 #define	HEAPTEXT_MAPPED		(2 * 1024 * 1024)
252 #define	HEAPTEXT_UNMAPPED	(2 * 1024 * 1024)
253 
254 #define	HEAPTEXT_NARENAS	\
255 	(HEAPTEXT_SIZE / (HEAPTEXT_MAPPED + HEAPTEXT_UNMAPPED) + 2)
256 
257 /*
258  * Establish the space for the MPO support to store its data
259  * structures at startup
260  */
261 
262 #define	MPOBUF_SIZE	(2 * 1024 * 1024)
263 #define	MPOBUF_BASE	(HEAPTEXT_BASE - MPOBUF_SIZE)
264 
265 /*
266  * Preallocate an area for setting up the user stack during
267  * the exec(). This way we have a faster allocator and also
268  * make sure the stack is always VAC aligned correctly. see
269  * get_arg_base() in startup.c.
270  */
271 #define	ARG_SLOT_SIZE	(0x8000)
272 #define	ARG_SLOT_SHIFT	(15)
273 #define	N_ARG_SLOT	(0x80)
274 
275 #define	NARG_BASE	(PIOMAPBASE - (ARG_SLOT_SIZE * N_ARG_SLOT))
276 
277 /*
278  * ktextseg+kvalloc should not use space beyond KERNEL_LIMIT32.
279  */
280 
281 /*
282  * For 64-bit kernels, rename KERNEL_LIMIT to KERNEL_LIMIT32 to more accurately
283  * reflect the fact that it's actually the limit for 32-bit kernel virtual
284  * addresses.
285  */
286 #define	KERNEL_LIMIT32	(SYSBASE32)
287 
288 /*
289  * Defines used for the ptl1_panic parameter, which is passed to the
290  * ptl1_panic assembly routine in %g1.  These #defines have string
291  * names defined in sun4u/os/mach_cpu_states.c which should be kept up to
292  * date if new #defines are added.
293  */
294 #define	PTL1_BAD_DEBUG				0
295 #define	PTL1_BAD_WTRAP				1
296 #define	PTL1_BAD_KMISS				2
297 #define	PTL1_BAD_KPROT_FAULT			3
298 #define	PTL1_BAD_ISM				4
299 #define	PTL1_BAD_MMUTRAP			5
300 #define	PTL1_BAD_TRAP				6
301 #define	PTL1_BAD_FPTRAP				7
302 #define	PTL1_BAD_INTR_VEC			8
303 #define	PTL1_BAD_TRACE_PTR			9
304 #define	PTL1_BAD_STACK				10
305 #define	PTL1_BAD_DTRACE_FLAGS			11
306 #define	PTL1_BAD_CTX_STEAL			12
307 #define	PTL1_BAD_ECC				13
308 #define	PTL1_BAD_HCALL				14
309 #define	PTL1_BAD_GL				15
310 #define	PTL1_BAD_WATCHDOG			16
311 #define	PTL1_BAD_RED				17
312 #define	PTL1_BAD_HCALL_UNMAP_PERM_EINVAL	18
313 #define	PTL1_BAD_HCALL_UNMAP_PERM_ENOMAP	19
314 #define	PTL1_BAD_RAISE_TSBEXCP			20
315 #define	PTL1_NO_SCDTSB8K			21
316 
317 /*
318  * Defines the max trap level allowed
319  */
320 #define	MAXPTL			2
321 
322 /*
323  * Defines used for ptl1 related data structs.
324  */
325 #define	PTL1_MAXTL		MAXPTL
326 #define	PTL1_MAXGL		2
327 #define	PTL1_DEBUG_TRAP		0x7C
328 #define	PTL1_SSIZE		1024	/* minimum stack size */
329 #define	CPU_ALLOC_SIZE		MMU_PAGESIZE
330 
331 #ifdef	__cplusplus
332 }
333 #endif
334 
335 #endif	/* _SYS_MACHPARAM_H */
336