xref: /titanic_52/usr/src/uts/i86pc/sys/machparam.h (revision 2f172c55ef76964744bc62b4500ece87f3089b4d)
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 2008 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 
30 #ifndef _SYS_MACHPARAM_H
31 #define	_SYS_MACHPARAM_H
32 
33 #if !defined(_ASM)
34 #include <sys/types.h>
35 
36 #if defined(__xpv)
37 #include <sys/xpv_impl.h>
38 #endif
39 
40 #endif
41 
42 #ifdef	__cplusplus
43 extern "C" {
44 #endif
45 
46 #ifndef _ASM
47 #define	ADDRESS_C(c)    c ## ul
48 #else   /* _ASM */
49 #define	ADDRESS_C(c)    (c)
50 #endif  /* _ASM */
51 
52 /*
53  * Machine dependent parameters and limits.
54  */
55 
56 #if defined(__amd64)
57 #define	NCPU	256
58 #elif defined(__i386)
59 #define	NCPU	32
60 #endif
61 
62 /*
63  * The value defined below could grow to 16. hat structure and
64  * page_t have room for 16 nodes.
65  */
66 #define	MAXNODES 	4
67 #define	NUMA_NODEMASK	0x0f
68 
69 /*
70  * Define the FPU symbol if we could run on a machine with an external
71  * FPU (i.e. not integrated with the normal machine state like the vax).
72  *
73  * The fpu is defined in the architecture manual, and the kernel hides
74  * its absence if it is not present, that's pretty integrated, no?
75  */
76 
77 /* supported page sizes */
78 #define	MMU_PAGE_SIZES	3
79 
80 /*
81  * MMU_PAGES* describes the physical page size used by the mapping hardware.
82  * PAGES* describes the logical page size used by the system.
83  */
84 
85 #define	MMU_PAGESIZE	0x1000		/* 4096 bytes */
86 #define	MMU_PAGESHIFT	12		/* log2(MMU_PAGESIZE) */
87 
88 #if !defined(_ASM)
89 #define	MMU_PAGEOFFSET	(MMU_PAGESIZE-1) /* Mask of address bits in page */
90 #else	/* _ASM */
91 #define	MMU_PAGEOFFSET	_CONST(MMU_PAGESIZE-1)	/* assembler lameness */
92 #endif	/* _ASM */
93 
94 #define	MMU_PAGEMASK	(~MMU_PAGEOFFSET)
95 
96 #define	PAGESIZE	0x1000		/* All of the above, for logical */
97 #define	PAGESHIFT	12
98 #define	PAGEOFFSET	(PAGESIZE - 1)
99 #define	PAGEMASK	(~PAGEOFFSET)
100 
101 /*
102  * DATA_ALIGN is used to define the alignment of the Unix data segment.
103  */
104 #define	DATA_ALIGN	PAGESIZE
105 
106 /*
107  * DEFAULT KERNEL THREAD stack size (in pages).
108  */
109 #if defined(__amd64)
110 #define	DEFAULTSTKSZ_NPGS	5
111 #elif defined(__i386)
112 #define	DEFAULTSTKSZ_NPGS	3
113 #endif
114 
115 #if !defined(_ASM)
116 #define	DEFAULTSTKSZ	(DEFAULTSTKSZ_NPGS * PAGESIZE)
117 #else	/* !_ASM */
118 #define	DEFAULTSTKSZ	_MUL(DEFAULTSTKSZ_NPGS, PAGESIZE) /* as(1) lameness */
119 #endif	/* !_ASM */
120 
121 /*
122  * KERNELBASE is the virtual address at which the kernel segments start in
123  * all contexts.
124  *
125  * KERNELBASE is not fixed.  The value of KERNELBASE can change with
126  * installed memory or on 32 bit systems the eprom variable 'eprom_kernelbase'.
127  *
128  * common/conf/param.c requires a compile time defined value for KERNELBASE.
129  * This value is save in the variable _kernelbase.  _kernelbase may then be
130  * modified with to a different value in i86pc/os/startup.c.
131  *
132  * Most code should be using kernelbase, which resolves to a reference to
133  * _kernelbase.
134  */
135 #define	KERNEL_TEXT_amd64	UINT64_C(0xfffffffffb800000)
136 
137 #ifdef __i386
138 
139 #define	KERNEL_TEXT_i386	ADDRESS_C(0xfe800000)
140 
141 /*
142  * We don't use HYPERVISOR_VIRT_START, as we need both the PAE and non-PAE
143  * versions in our code. We always compile based on the lower PAE address.
144  */
145 #define	KERNEL_TEXT_i386_xpv	\
146 	(HYPERVISOR_VIRT_START_PAE - 3 * ADDRESS_C(0x400000))
147 
148 #endif /* __i386 */
149 
150 #if defined(__amd64)
151 
152 #define	KERNELBASE	ADDRESS_C(0xfffffd8000000000)
153 
154 /*
155  * Size of the unmapped "red zone" at the very bottom of the kernel's
156  * address space.  Corresponds to 1 slot in the toplevel pagetable.
157  */
158 #define	KERNEL_REDZONE_SIZE   ((uintptr_t)1 << 39)
159 
160 /*
161  * Base of 'core' heap area, which is used for kernel and module text/data
162  * that must be within a 2GB range to allow for rip-relative addressing.
163  */
164 #define	COREHEAP_BASE	ADDRESS_C(0xffffffffc0000000)
165 
166 /*
167  * Beginning of the segkpm window. A lower value than this is used if
168  * physical addresses exceed 1TB. See i86pc/os/startup.c
169  */
170 #define	SEGKPM_BASE	ADDRESS_C(0xfffffe0000000000)
171 
172 /*
173  * This is valloc_base, above seg_kpm, but below everything else.
174  * A lower value than this may be used if SEGKPM_BASE is adjusted.
175  * See i86pc/os/startup.c
176  */
177 #define	VALLOC_BASE	ADDRESS_C(0xffffff0000000000)
178 
179 /*
180  * default and boundary sizes for segkp
181  */
182 #define	SEGKPDEFSIZE	(2L * 1024L * 1024L * 1024L)		/*   2G */
183 #define	SEGKPMAXSIZE	(8L * 1024L * 1024L * 1024L)		/*   8G */
184 #define	SEGKPMINSIZE	(200L * 1024 * 1024L)			/* 200M */
185 
186 /*
187  * minimum size for segzio
188  */
189 #define	SEGZIOMINSIZE	(400L * 1024 * 1024L)			/* 400M */
190 #define	SEGZIOMAXSIZE	(512L * 1024L * 1024L * 1024L)		/* 512G */
191 
192 /*
193  * During intial boot we limit heap to the top 4Gig.
194  */
195 #define	BOOT_KERNELHEAP_BASE	ADDRESS_C(0xffffffff00000000)
196 
197 /*
198  * VMWare works best if we don't use the top 64Meg of memory for amd64.
199  * Set KERNEL_TEXT to top_o_memory - 64Meg - 8 Meg for 8Meg of nucleus pages.
200  */
201 #define	PROMSTART	ADDRESS_C(0xffc00000)
202 #define	KERNEL_TEXT	KERNEL_TEXT_amd64
203 
204 /*
205  * Virtual address range available to the debugger
206  */
207 #define	SEGDEBUGBASE	ADDRESS_C(0xffffffffff800000)
208 #define	SEGDEBUGSIZE	ADDRESS_C(0x400000)
209 
210 /*
211  * Define upper limit on user address space
212  *
213  * In amd64, the upper limit on a 64-bit user address space is 1 large page
214  * (2MB) below kernelbase.  The upper limit for a 32-bit user address space
215  * is 1 small page (4KB) below the top of the 32-bit range.  The 64-bit
216  * limit give dtrace the red zone it needs below kernelbase.  The 32-bit
217  * limit gives us a small red zone to detect address-space overruns in a
218  * user program.
219  *
220  * On the hypervisor, we limit the user to memory below the VA hole.
221  * Subtract 1 large page for a red zone.
222  */
223 #if defined(__xpv)
224 #define	USERLIMIT	ADDRESS_C(0x00007fffffe00000)
225 #else
226 #define	USERLIMIT	ADDRESS_C(0xfffffd7fffe00000)
227 #endif
228 
229 #ifdef bug_5074717_is_fixed
230 #define	USERLIMIT32	ADDRESS_C(0xfffff000)
231 #else
232 #define	USERLIMIT32	ADDRESS_C(0xfefff000)
233 #endif
234 
235 #elif defined(__i386)
236 
237 #ifdef DEBUG
238 #define	KERNELBASE	ADDRESS_C(0xc8000000)
239 #else
240 #define	KERNELBASE	ADDRESS_C(0xd4000000)
241 #endif
242 
243 #define	KERNELBASE_MAX	ADDRESS_C(0xe0000000)
244 
245 /*
246  * The i386 ABI requires that the user address space be at least 3Gb
247  * in size.  KERNELBASE_ABI_MIN is used as the default KERNELBASE for
248  * physical memory configurations > 4gb.
249  */
250 #define	KERNELBASE_ABI_MIN	ADDRESS_C(0xc0000000)
251 
252 /*
253  * Size of the unmapped "red zone" at the very bottom of the kernel's
254  * address space.  Since segmap start immediately above the red zone, this
255  * needs to be MAXBSIZE aligned.
256  */
257 #define	KERNEL_REDZONE_SIZE   MAXBSIZE
258 
259 /*
260  * This is the last 4MB of the 4G address space. Some psm modules
261  * need this region of virtual address space mapped 1-1
262  * The top 64MB of the address space is reserved for the hypervisor.
263  */
264 #define	PROMSTART	ADDRESS_C(0xffc00000)
265 #ifdef __xpv
266 #define	KERNEL_TEXT	KERNEL_TEXT_i386_xpv
267 #else
268 #define	KERNEL_TEXT	KERNEL_TEXT_i386
269 #endif
270 
271 /*
272  * Virtual address range available to the debugger
273  * We place it just above the kernel text (4M) and kernel data (4M).
274  */
275 #define	SEGDEBUGBASE	(KERNEL_TEXT + ADDRESS_C(0x800000))
276 #define	SEGDEBUGSIZE	ADDRESS_C(0x400000)
277 
278 /*
279  * Define upper limit on user address space
280  */
281 #define	USERLIMIT	KERNELBASE
282 #define	USERLIMIT32	USERLIMIT
283 
284 #endif	/* __i386 */
285 
286 /*
287  * Reserve pages just below KERNEL_TEXT for the GDT, IDT, TSS and debug info.
288  *
289  * For now, DEBUG_INFO_VA must be first in this list for "xm" initiated dumps
290  * of solaris domUs to be usable with mdb. Relying on a fixed VA is not viable
291  * long term, but it's the best we've got for now.
292  */
293 #if !defined(_ASM)
294 #define	DEBUG_INFO_VA	(KERNEL_TEXT - MMU_PAGESIZE)
295 #define	GDT_VA		(DEBUG_INFO_VA - MMU_PAGESIZE)
296 #define	IDT_VA		(GDT_VA - MMU_PAGESIZE)
297 #define	KTSS_VA		(IDT_VA - MMU_PAGESIZE)
298 #define	DFTSS_VA	(KTSS_VA - MMU_PAGESIZE)
299 #define	MISC_VA_BASE	(DFTSS_VA)
300 #define	MISC_VA_SIZE	(KERNEL_TEXT - MISC_VA_BASE)
301 #endif /* !_ASM */
302 
303 #if !defined(_ASM) && !defined(_KMDB)
304 extern uintptr_t kernelbase, segmap_start, segmapsize;
305 #endif
306 
307 /*
308  * ARGSBASE is the base virtual address of the range which
309  * the kernel uses to map the arguments for exec.
310  */
311 #define	ARGSBASE	PROMSTART
312 
313 /*
314  * reserve space for modules
315  */
316 #define	MODTEXT	(1024 * 1024 * 2)
317 #define	MODDATA	(1024 * 300)
318 
319 /*
320  * The heap has a region allocated from it of HEAPTEXT_SIZE bytes specifically
321  * for module text.
322  */
323 #define	HEAPTEXT_SIZE		(64 * 1024 * 1024)	/* bytes */
324 
325 /*
326  * Size of a kernel threads stack.  It must be a whole number of pages
327  * since the segment it comes from will only allocate space in pages.
328  */
329 #define	T_STACKSZ	2*PAGESIZE
330 
331 /*
332  * Size of a cpu startup thread stack.  (It must be a whole number of pages
333  * since the containing segment only allocates space in pages.)
334  */
335 
336 #define	STARTUP_STKSZ	3*PAGESIZE
337 
338 /*
339  * Bus types
340  */
341 #define	BTISA		1
342 #define	BTEISA		2
343 #define	BTMCA		3
344 
345 #ifdef	__cplusplus
346 }
347 #endif
348 
349 #endif	/* _SYS_MACHPARAM_H */
350