xref: /illumos-gate/usr/src/uts/sun4u/sys/machparam.h (revision 1e2e7a75)
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 /*	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  * Define the userlimits
170  */
171 
172 #define	USERLIMIT	ADDRESS_C(0xFFFFFFFF80000000)
173 #define	USERLIMIT32	ADDRESS_C(0xFFC00000)
174 
175 /*
176  * Define SEGKPBASE, start of the segkp segment.
177  */
178 
179 #define	SEGKPBASE	ADDRESS_C(0x2a100000000)
180 
181 /*
182  * Define SEGMAPBASE, start of the segmap segment.
183  */
184 
185 #define	SEGMAPBASE	ADDRESS_C(0x2a750000000)
186 
187 /*
188  * SYSBASE is the virtual address which the kernel allocated memory
189  * mapping starts in all contexts.  SYSLIMIT is the end of the Sysbase segment.
190  */
191 
192 #define	SYSBASE		ADDRESS_C(0x30000000000)
193 #define	SYSLIMIT	ADDRESS_C(0x70000000000)
194 #define	SYSBASE32	ADDRESS_C(0x70000000)
195 #define	SYSLIMIT32	ADDRESS_C(0x80000000)
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 * 256
240 
241 /*
242  * On systems with <MODTEXT_SM_SIZE MB available physical memory,
243  * cap the in-nucleus module text to MODTEXT_SM_CAP bytes.  The
244  * cap must be a multiple of the base page size.  Also see startup.c.
245  */
246 #define	MODTEXT_SM_CAP		(0x200000)		/* bytes */
247 #define	MODTEXT_SM_SIZE		(256)			/* MB */
248 
249 /*
250  * The heap has a region allocated from it specifically for module text that
251  * cannot fit on the nucleus page.  This region -- which starts at address
252  * HEAPTEXT_BASE and runs for HEAPTEXT_SIZE bytes -- has virtual holes
253  * punched in it: for every HEAPTEXT_MAPPED bytes of available virtual, there
254  * is a virtual hole of size HEAPTEXT_UNMAPPED bytes sitting beneath it.  This
255  * assures that any text address is within HEAPTEXT_MAPPED of an unmapped
256  * region.  The unmapped regions themselves are managed with the routines
257  * kobj_texthole_alloc() and kobj_texthole_free().
258  */
259 #define	HEAPTEXT_SIZE		(128 * 1024 * 1024)	/* bytes */
260 #define	HEAPTEXT_OVERSIZE	(64 * 1024 * 1024)	/* bytes */
261 #define	HEAPTEXT_BASE		(SYSLIMIT32 - HEAPTEXT_SIZE)
262 #define	HEAPTEXT_MAPPED		(2 * 1024 * 1024)
263 #define	HEAPTEXT_UNMAPPED	(2 * 1024 * 1024)
264 
265 #define	HEAPTEXT_NARENAS	\
266 	(HEAPTEXT_SIZE / (HEAPTEXT_MAPPED + HEAPTEXT_UNMAPPED) + 2)
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	(SYSBASE32)
290 
291 #define	PFN_TO_BUSTYPE(pfn)	(((pfn) >> 19) & 0x1FF)
292 #define	BUSTYPE_TO_PFN(btype, pfn)			\
293 	(((pfn_t)(btype) << 19) | ((pfn) & 0x7FFFF))
294 #define	IO_BUSTYPE(pfn)	((PFN_TO_BUSTYPE(pfn) & 0x100) >> 8)
295 
296 #ifdef	_STARFIRE
297 #define	PFN_TO_UPAID(pfn)	BUSTYPE_TO_UPAID(PFN_TO_BUSTYPE(pfn))
298 #else
299 #define	PFN_TO_UPAID(pfn)	(((pfn) >> 20) & 0x1F)
300 #endif	/* _STARFIRE */
301 
302 /*
303  * Defines used for the ptl1_panic parameter, which is passed to the
304  * ptl1_panic assembly routine in %g1.  These #defines have string
305  * names defined in sun4u/os/mach_cpu_states.c which should be kept up to
306  * date if new #defines are added.
307  */
308 #define	PTL1_BAD_DEBUG		0
309 #define	PTL1_BAD_WTRAP		1
310 #define	PTL1_BAD_KMISS		2
311 #define	PTL1_BAD_KPROT_FAULT	3
312 #define	PTL1_BAD_ISM		4
313 #define	PTL1_BAD_MMUTRAP	5
314 #define	PTL1_BAD_TRAP		6
315 #define	PTL1_BAD_FPTRAP		7
316 #define	PTL1_BAD_INTR_REQ	8
317 #define	PTL1_BAD_TRACE_PTR	9
318 #define	PTL1_BAD_STACK		10
319 #define	PTL1_BAD_DTRACE_FLAGS	11
320 #define	PTL1_BAD_CTX_STEAL	12
321 #define	PTL1_BAD_ECC		13
322 #define	PTL1_BAD_CTX		14
323 #define	PTL1_BAD_RAISE_TSBEXCP	20
324 
325 /*
326  * Defines used for ptl1 related data structs.
327  */
328 #define	PTL1_MAXTL		4
329 #define	PTL1_DEBUG_TRAP		0x7C
330 #define	PTL1_SSIZE		1024	/* minimum stack size */
331 #define	CPU_ALLOC_SIZE		MMU_PAGESIZE
332 
333 #ifdef	__cplusplus
334 }
335 #endif
336 
337 #endif	/* _SYS_MACHPARAM_H */
338