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