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