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