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