xref: /illumos-gate/usr/src/uts/i86pc/sys/machparam.h (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1988 AT&T	*/
28*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #ifndef _SYS_MACHPARAM_H
32*7c478bd9Sstevel@tonic-gate #define	_SYS_MACHPARAM_H
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
39*7c478bd9Sstevel@tonic-gate extern "C" {
40*7c478bd9Sstevel@tonic-gate #endif
41*7c478bd9Sstevel@tonic-gate 
42*7c478bd9Sstevel@tonic-gate #ifndef _ASM
43*7c478bd9Sstevel@tonic-gate #define	ADDRESS_C(c)    c ## ul
44*7c478bd9Sstevel@tonic-gate #else   /* _ASM */
45*7c478bd9Sstevel@tonic-gate #define	ADDRESS_C(c)    (c)
46*7c478bd9Sstevel@tonic-gate #endif  /* _ASM */
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate /*
49*7c478bd9Sstevel@tonic-gate  * Machine dependent parameters and limits - PC version.
50*7c478bd9Sstevel@tonic-gate  */
51*7c478bd9Sstevel@tonic-gate #define	NCPU 	21
52*7c478bd9Sstevel@tonic-gate 
53*7c478bd9Sstevel@tonic-gate /*
54*7c478bd9Sstevel@tonic-gate  * The value defined below could grow to 16. hat structure and
55*7c478bd9Sstevel@tonic-gate  * page_t have room for 16 nodes.
56*7c478bd9Sstevel@tonic-gate  */
57*7c478bd9Sstevel@tonic-gate #define	MAXNODES 	4
58*7c478bd9Sstevel@tonic-gate #define	NUMA_NODEMASK	0x0f
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate /*
62*7c478bd9Sstevel@tonic-gate  * Define the FPU symbol if we could run on a machine with an external
63*7c478bd9Sstevel@tonic-gate  * FPU (i.e. not integrated with the normal machine state like the vax).
64*7c478bd9Sstevel@tonic-gate  *
65*7c478bd9Sstevel@tonic-gate  * The fpu is defined in the architecture manual, and the kernel hides
66*7c478bd9Sstevel@tonic-gate  * its absence if it is not present, that's pretty integrated, no?
67*7c478bd9Sstevel@tonic-gate  */
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate /* supported page sizes */
70*7c478bd9Sstevel@tonic-gate #define	MMU_PAGE_SIZES	2
71*7c478bd9Sstevel@tonic-gate 
72*7c478bd9Sstevel@tonic-gate /*
73*7c478bd9Sstevel@tonic-gate  * MMU_PAGES* describes the physical page size used by the mapping hardware.
74*7c478bd9Sstevel@tonic-gate  * PAGES* describes the logical page size used by the system.
75*7c478bd9Sstevel@tonic-gate  */
76*7c478bd9Sstevel@tonic-gate 
77*7c478bd9Sstevel@tonic-gate #define	MMU_PAGESIZE	0x1000		/* 4096 bytes */
78*7c478bd9Sstevel@tonic-gate #define	MMU_PAGESHIFT	12		/* log2(MMU_PAGESIZE) */
79*7c478bd9Sstevel@tonic-gate #define	MMU_PAGEOFFSET	(MMU_PAGESIZE-1) /* Mask of address bits in page */
80*7c478bd9Sstevel@tonic-gate #define	MMU_PAGEMASK	(~MMU_PAGEOFFSET)
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate #define	PAGESIZE	0x1000		/* All of the above, for logical */
83*7c478bd9Sstevel@tonic-gate #define	PAGESHIFT	12
84*7c478bd9Sstevel@tonic-gate #define	PAGEOFFSET	(PAGESIZE - 1)
85*7c478bd9Sstevel@tonic-gate #define	PAGEMASK	(~PAGEOFFSET)
86*7c478bd9Sstevel@tonic-gate 
87*7c478bd9Sstevel@tonic-gate /*
88*7c478bd9Sstevel@tonic-gate  * DATA_ALIGN is used to define the alignment of the Unix data segment.
89*7c478bd9Sstevel@tonic-gate  */
90*7c478bd9Sstevel@tonic-gate #define	DATA_ALIGN	PAGESIZE
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate /*
93*7c478bd9Sstevel@tonic-gate  * DEFAULT KERNEL THREAD stack size.
94*7c478bd9Sstevel@tonic-gate  */
95*7c478bd9Sstevel@tonic-gate #if defined(__amd64)
96*7c478bd9Sstevel@tonic-gate #define	DEFAULTSTKSZ	(5 * PAGESIZE)
97*7c478bd9Sstevel@tonic-gate #elif defined(__i386)
98*7c478bd9Sstevel@tonic-gate #define	DEFAULTSTKSZ	(2 * PAGESIZE)
99*7c478bd9Sstevel@tonic-gate #endif
100*7c478bd9Sstevel@tonic-gate 
101*7c478bd9Sstevel@tonic-gate /*
102*7c478bd9Sstevel@tonic-gate  * KERNELBASE is the virtual address at which the kernel segments start in
103*7c478bd9Sstevel@tonic-gate  * all contexts.
104*7c478bd9Sstevel@tonic-gate  *
105*7c478bd9Sstevel@tonic-gate  * KERNELBASE is not fixed on 32-bit systems.  The value of KERNELBASE can
106*7c478bd9Sstevel@tonic-gate  * change with installed memory and the eprom variable 'eprom_kernelbase'.
107*7c478bd9Sstevel@tonic-gate  * This value is fixed on 64-bit systems.
108*7c478bd9Sstevel@tonic-gate  *
109*7c478bd9Sstevel@tonic-gate  * common/conf/param.c requires a compile time defined value for KERNELBASE
110*7c478bd9Sstevel@tonic-gate  * which it saves in the variable _kernelbase.  If kernelbase is modifed on
111*7c478bd9Sstevel@tonic-gate  * a 32-bit system, _kernelbase will be updated with the new value in
112*7c478bd9Sstevel@tonic-gate  * i86pc/os/startup.c.
113*7c478bd9Sstevel@tonic-gate  *
114*7c478bd9Sstevel@tonic-gate  * i86 and i86pc files use kernelbase instead of KERNELBASE, which is
115*7c478bd9Sstevel@tonic-gate  * initialized in i86pc/os/startup.c.
116*7c478bd9Sstevel@tonic-gate  */
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate #if defined(__amd64)
119*7c478bd9Sstevel@tonic-gate 
120*7c478bd9Sstevel@tonic-gate #define	KERNELBASE	ADDRESS_C(0xfffffd8000000000)
121*7c478bd9Sstevel@tonic-gate 
122*7c478bd9Sstevel@tonic-gate /*
123*7c478bd9Sstevel@tonic-gate  * Size of the unmapped "red zone" at the very bottom of the kernel's
124*7c478bd9Sstevel@tonic-gate  * address space.  Corresponds to 1 slot in the toplevel pagetable.
125*7c478bd9Sstevel@tonic-gate  */
126*7c478bd9Sstevel@tonic-gate #define	KERNEL_REDZONE_SIZE   ((uintptr_t)1 << 39)
127*7c478bd9Sstevel@tonic-gate 
128*7c478bd9Sstevel@tonic-gate /*
129*7c478bd9Sstevel@tonic-gate  * Base of 'core' heap area, which is used for kernel and module text/data
130*7c478bd9Sstevel@tonic-gate  * that must be within a 2GB range to allow for rip-relative addressing.
131*7c478bd9Sstevel@tonic-gate  *
132*7c478bd9Sstevel@tonic-gate  * XX64: because vmx and boot cannot be trusted to stay in a 1GB playpen at
133*7c478bd9Sstevel@tonic-gate  * the bottom of the upper 4GB range, we need to restrict the core heap to
134*7c478bd9Sstevel@tonic-gate  * the top 1GB for now.
135*7c478bd9Sstevel@tonic-gate  */
136*7c478bd9Sstevel@tonic-gate #define	COREHEAP_BASE	ADDRESS_C(0xffffffffc0000000)
137*7c478bd9Sstevel@tonic-gate 
138*7c478bd9Sstevel@tonic-gate /*
139*7c478bd9Sstevel@tonic-gate  * Beginning of the segkpm window
140*7c478bd9Sstevel@tonic-gate  */
141*7c478bd9Sstevel@tonic-gate #define	SEGKPM_BASE	ADDRESS_C(0xfffffe0000000000)
142*7c478bd9Sstevel@tonic-gate 
143*7c478bd9Sstevel@tonic-gate /*
144*7c478bd9Sstevel@tonic-gate  * default and boundary sizes for segkp
145*7c478bd9Sstevel@tonic-gate  */
146*7c478bd9Sstevel@tonic-gate #define	SEGKPDEFSIZE	(2L * 1024L * 1024L * 1024L)		/*   2G */
147*7c478bd9Sstevel@tonic-gate #define	SEGKPMAXSIZE	(8L * 1024L * 1024L * 1024L)		/*   8G */
148*7c478bd9Sstevel@tonic-gate #define	SEGKPMINSIZE	(200L * 1024 * 1024L)			/* 200M */
149*7c478bd9Sstevel@tonic-gate 
150*7c478bd9Sstevel@tonic-gate /*
151*7c478bd9Sstevel@tonic-gate  * Boot (or, more precisely, vmx) maps most pages twice - once in the
152*7c478bd9Sstevel@tonic-gate  * bottom 2GB of memory and once in the bottom 2GB of the topmost 4GB.
153*7c478bd9Sstevel@tonic-gate  * When boot is unmapped this range is available to the kernel, but until
154*7c478bd9Sstevel@tonic-gate  * then we have to leave it untouched.
155*7c478bd9Sstevel@tonic-gate  */
156*7c478bd9Sstevel@tonic-gate #define	BOOT_DOUBLEMAP_BASE	ADDRESS_C(0xffffffff00000000)
157*7c478bd9Sstevel@tonic-gate #define	BOOT_DOUBLEMAP_SIZE	ADDRESS_C(0x80000000)
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate /*
160*7c478bd9Sstevel@tonic-gate  * VMWare works best if we don't use the top 64Meg of memory for amd64.
161*7c478bd9Sstevel@tonic-gate  * Set KERNEL_TEXT to top_o_memory - 64Meg - 8 Meg for 8Meg of nucleus pages.
162*7c478bd9Sstevel@tonic-gate  */
163*7c478bd9Sstevel@tonic-gate #define	PROMSTART	ADDRESS_C(0xffc00000)
164*7c478bd9Sstevel@tonic-gate #define	KERNEL_TEXT	ADDRESS_C(0xfffffffffb800000)
165*7c478bd9Sstevel@tonic-gate 
166*7c478bd9Sstevel@tonic-gate /*
167*7c478bd9Sstevel@tonic-gate  * Define upper limit on user address space
168*7c478bd9Sstevel@tonic-gate  *
169*7c478bd9Sstevel@tonic-gate  * In amd64, the upper limit on a 64-bit user address space is 1 large page
170*7c478bd9Sstevel@tonic-gate  * (2MB) below kernelbase.  The upper limit for a 32-bit user address space
171*7c478bd9Sstevel@tonic-gate  * is 1 small page (4KB) below the top of the 32-bit range.  The 64-bit
172*7c478bd9Sstevel@tonic-gate  * limit give dtrace the red zone it needs below kernelbase.  The 32-bit
173*7c478bd9Sstevel@tonic-gate  * limit gives us a small red zone to detect address-space overruns in a
174*7c478bd9Sstevel@tonic-gate  * user program.
175*7c478bd9Sstevel@tonic-gate  */
176*7c478bd9Sstevel@tonic-gate #define	USERLIMIT	ADDRESS_C(0xfffffd7fffe00000)
177*7c478bd9Sstevel@tonic-gate #ifdef bug_5074717_is_fixed
178*7c478bd9Sstevel@tonic-gate #define	USERLIMIT32	ADDRESS_C(0xfffff000)
179*7c478bd9Sstevel@tonic-gate #else
180*7c478bd9Sstevel@tonic-gate #define	USERLIMIT32	ADDRESS_C(0xfefff000)
181*7c478bd9Sstevel@tonic-gate #endif
182*7c478bd9Sstevel@tonic-gate 
183*7c478bd9Sstevel@tonic-gate #elif defined(__i386)
184*7c478bd9Sstevel@tonic-gate 
185*7c478bd9Sstevel@tonic-gate #ifdef DEBUG
186*7c478bd9Sstevel@tonic-gate #define	KERNELBASE	ADDRESS_C(0xc8000000)
187*7c478bd9Sstevel@tonic-gate #else
188*7c478bd9Sstevel@tonic-gate #define	KERNELBASE	ADDRESS_C(0xd4000000)
189*7c478bd9Sstevel@tonic-gate #endif
190*7c478bd9Sstevel@tonic-gate 
191*7c478bd9Sstevel@tonic-gate #define	KERNELBASE_MAX	ADDRESS_C(0xe0000000)
192*7c478bd9Sstevel@tonic-gate 
193*7c478bd9Sstevel@tonic-gate /*
194*7c478bd9Sstevel@tonic-gate  * The i386 ABI requires that the user address space be at least 3Gb
195*7c478bd9Sstevel@tonic-gate  * in size.  KERNELBASE_ABI_MIN is used as the default KERNELBASE for
196*7c478bd9Sstevel@tonic-gate  * physical memory configurations > 4gb.
197*7c478bd9Sstevel@tonic-gate  */
198*7c478bd9Sstevel@tonic-gate #define	KERNELBASE_ABI_MIN	ADDRESS_C(0xc0000000)
199*7c478bd9Sstevel@tonic-gate 
200*7c478bd9Sstevel@tonic-gate /*
201*7c478bd9Sstevel@tonic-gate  * Size of the unmapped "red zone" at the very bottom of the kernel's
202*7c478bd9Sstevel@tonic-gate  * address space.  Since segmap start immediately above the red zone, this
203*7c478bd9Sstevel@tonic-gate  * needs to be MAXBSIZE aligned.
204*7c478bd9Sstevel@tonic-gate  */
205*7c478bd9Sstevel@tonic-gate #define	KERNEL_REDZONE_SIZE   MAXBSIZE
206*7c478bd9Sstevel@tonic-gate 
207*7c478bd9Sstevel@tonic-gate /*
208*7c478bd9Sstevel@tonic-gate  * This is the last 4MB of the 4G address space. Some psm modules
209*7c478bd9Sstevel@tonic-gate  * need this region of virtual address space mapped 1-1
210*7c478bd9Sstevel@tonic-gate  */
211*7c478bd9Sstevel@tonic-gate #define	PROMSTART	ADDRESS_C(0xffc00000)
212*7c478bd9Sstevel@tonic-gate #define	KERNEL_TEXT	ADDRESS_C(0xfe800000)
213*7c478bd9Sstevel@tonic-gate 
214*7c478bd9Sstevel@tonic-gate /*
215*7c478bd9Sstevel@tonic-gate  * Define upper limit on user address space
216*7c478bd9Sstevel@tonic-gate  */
217*7c478bd9Sstevel@tonic-gate #define	USERLIMIT	KERNELBASE
218*7c478bd9Sstevel@tonic-gate #define	USERLIMIT32	USERLIMIT
219*7c478bd9Sstevel@tonic-gate 
220*7c478bd9Sstevel@tonic-gate #endif	/* __i386 */
221*7c478bd9Sstevel@tonic-gate 
222*7c478bd9Sstevel@tonic-gate #if	!defined(_KADB)
223*7c478bd9Sstevel@tonic-gate extern uintptr_t kernelbase, segkmap_start, segmapsize;
224*7c478bd9Sstevel@tonic-gate #endif
225*7c478bd9Sstevel@tonic-gate 
226*7c478bd9Sstevel@tonic-gate /*
227*7c478bd9Sstevel@tonic-gate  * ARGSBASE is the base virtual address of the range which
228*7c478bd9Sstevel@tonic-gate  * the kernel uses to map the arguments for exec.
229*7c478bd9Sstevel@tonic-gate  */
230*7c478bd9Sstevel@tonic-gate #define	ARGSBASE	PROMSTART
231*7c478bd9Sstevel@tonic-gate 
232*7c478bd9Sstevel@tonic-gate /*
233*7c478bd9Sstevel@tonic-gate  * reserve space for modules
234*7c478bd9Sstevel@tonic-gate  */
235*7c478bd9Sstevel@tonic-gate #define	MODTEXT	(1024 * 1024 * 2)
236*7c478bd9Sstevel@tonic-gate #define	MODDATA	(1024 * 300)
237*7c478bd9Sstevel@tonic-gate 
238*7c478bd9Sstevel@tonic-gate /*
239*7c478bd9Sstevel@tonic-gate  * The heap has a region allocated from it of HEAPTEXT_SIZE bytes specifically
240*7c478bd9Sstevel@tonic-gate  * for module text.
241*7c478bd9Sstevel@tonic-gate  */
242*7c478bd9Sstevel@tonic-gate #define	HEAPTEXT_SIZE		(64 * 1024 * 1024)	/* bytes */
243*7c478bd9Sstevel@tonic-gate 
244*7c478bd9Sstevel@tonic-gate /*
245*7c478bd9Sstevel@tonic-gate  * Size of a kernel threads stack.  It must be a whole number of pages
246*7c478bd9Sstevel@tonic-gate  * since the segment it comes from will only allocate space in pages.
247*7c478bd9Sstevel@tonic-gate  */
248*7c478bd9Sstevel@tonic-gate #define	T_STACKSZ	2*PAGESIZE
249*7c478bd9Sstevel@tonic-gate 
250*7c478bd9Sstevel@tonic-gate /*
251*7c478bd9Sstevel@tonic-gate  * Size of a cpu startup thread stack.  (It must be a whole number of pages
252*7c478bd9Sstevel@tonic-gate  * since the containing segment only allocates space in pages.)
253*7c478bd9Sstevel@tonic-gate  */
254*7c478bd9Sstevel@tonic-gate 
255*7c478bd9Sstevel@tonic-gate #define	STARTUP_STKSZ	3*PAGESIZE
256*7c478bd9Sstevel@tonic-gate 
257*7c478bd9Sstevel@tonic-gate /*
258*7c478bd9Sstevel@tonic-gate  * Bus types
259*7c478bd9Sstevel@tonic-gate  */
260*7c478bd9Sstevel@tonic-gate #define	BTISA		1
261*7c478bd9Sstevel@tonic-gate #define	BTEISA		2
262*7c478bd9Sstevel@tonic-gate #define	BTMCA		3
263*7c478bd9Sstevel@tonic-gate 
264*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
265*7c478bd9Sstevel@tonic-gate }
266*7c478bd9Sstevel@tonic-gate #endif
267*7c478bd9Sstevel@tonic-gate 
268*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_MACHPARAM_H */
269