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