xref: /titanic_51/usr/src/boot/sys/i386/include/param.h (revision 4a5d661a82b942b6538acd26209d959ce98b593a)
1*4a5d661aSToomas Soome /*-
2*4a5d661aSToomas Soome  * Copyright (c) 1990 The Regents of the University of California.
3*4a5d661aSToomas Soome  * All rights reserved.
4*4a5d661aSToomas Soome  *
5*4a5d661aSToomas Soome  * This code is derived from software contributed to Berkeley by
6*4a5d661aSToomas Soome  * William Jolitz.
7*4a5d661aSToomas Soome  *
8*4a5d661aSToomas Soome  * Redistribution and use in source and binary forms, with or without
9*4a5d661aSToomas Soome  * modification, are permitted provided that the following conditions
10*4a5d661aSToomas Soome  * are met:
11*4a5d661aSToomas Soome  * 1. Redistributions of source code must retain the above copyright
12*4a5d661aSToomas Soome  *    notice, this list of conditions and the following disclaimer.
13*4a5d661aSToomas Soome  * 2. Redistributions in binary form must reproduce the above copyright
14*4a5d661aSToomas Soome  *    notice, this list of conditions and the following disclaimer in the
15*4a5d661aSToomas Soome  *    documentation and/or other materials provided with the distribution.
16*4a5d661aSToomas Soome  * 4. Neither the name of the University nor the names of its contributors
17*4a5d661aSToomas Soome  *    may be used to endorse or promote products derived from this software
18*4a5d661aSToomas Soome  *    without specific prior written permission.
19*4a5d661aSToomas Soome  *
20*4a5d661aSToomas Soome  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21*4a5d661aSToomas Soome  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22*4a5d661aSToomas Soome  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23*4a5d661aSToomas Soome  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24*4a5d661aSToomas Soome  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25*4a5d661aSToomas Soome  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26*4a5d661aSToomas Soome  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27*4a5d661aSToomas Soome  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28*4a5d661aSToomas Soome  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29*4a5d661aSToomas Soome  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30*4a5d661aSToomas Soome  * SUCH DAMAGE.
31*4a5d661aSToomas Soome  *
32*4a5d661aSToomas Soome  *	from: @(#)param.h	5.8 (Berkeley) 6/28/91
33*4a5d661aSToomas Soome  * $FreeBSD$
34*4a5d661aSToomas Soome  */
35*4a5d661aSToomas Soome 
36*4a5d661aSToomas Soome 
37*4a5d661aSToomas Soome #ifndef _I386_INCLUDE_PARAM_H_
38*4a5d661aSToomas Soome #define	_I386_INCLUDE_PARAM_H_
39*4a5d661aSToomas Soome 
40*4a5d661aSToomas Soome #include <machine/_align.h>
41*4a5d661aSToomas Soome 
42*4a5d661aSToomas Soome /*
43*4a5d661aSToomas Soome  * Machine dependent constants for Intel 386.
44*4a5d661aSToomas Soome  */
45*4a5d661aSToomas Soome 
46*4a5d661aSToomas Soome 
47*4a5d661aSToomas Soome #define __HAVE_ACPI
48*4a5d661aSToomas Soome #define	__HAVE_PIR
49*4a5d661aSToomas Soome #define __PCI_REROUTE_INTERRUPT
50*4a5d661aSToomas Soome 
51*4a5d661aSToomas Soome #ifndef MACHINE
52*4a5d661aSToomas Soome #define MACHINE		"i386"
53*4a5d661aSToomas Soome #endif
54*4a5d661aSToomas Soome #ifndef MACHINE_ARCH
55*4a5d661aSToomas Soome #define	MACHINE_ARCH	"i386"
56*4a5d661aSToomas Soome #endif
57*4a5d661aSToomas Soome #define MID_MACHINE	MID_I386
58*4a5d661aSToomas Soome 
59*4a5d661aSToomas Soome #if defined(SMP) || defined(KLD_MODULE)
60*4a5d661aSToomas Soome #ifndef MAXCPU
61*4a5d661aSToomas Soome #define MAXCPU		32
62*4a5d661aSToomas Soome #endif
63*4a5d661aSToomas Soome #else
64*4a5d661aSToomas Soome #define MAXCPU		1
65*4a5d661aSToomas Soome #endif /* SMP || KLD_MODULE */
66*4a5d661aSToomas Soome 
67*4a5d661aSToomas Soome #ifndef MAXMEMDOM
68*4a5d661aSToomas Soome #define	MAXMEMDOM	1
69*4a5d661aSToomas Soome #endif
70*4a5d661aSToomas Soome 
71*4a5d661aSToomas Soome #define ALIGNBYTES	_ALIGNBYTES
72*4a5d661aSToomas Soome #define ALIGN(p)	_ALIGN(p)
73*4a5d661aSToomas Soome /*
74*4a5d661aSToomas Soome  * ALIGNED_POINTER is a boolean macro that checks whether an address
75*4a5d661aSToomas Soome  * is valid to fetch data elements of type t from on this architecture.
76*4a5d661aSToomas Soome  * This does not reflect the optimal alignment, just the possibility
77*4a5d661aSToomas Soome  * (within reasonable limits).
78*4a5d661aSToomas Soome  */
79*4a5d661aSToomas Soome #define	ALIGNED_POINTER(p, t)	1
80*4a5d661aSToomas Soome 
81*4a5d661aSToomas Soome /*
82*4a5d661aSToomas Soome  * CACHE_LINE_SIZE is the compile-time maximum cache line size for an
83*4a5d661aSToomas Soome  * architecture.  It should be used with appropriate caution.
84*4a5d661aSToomas Soome  */
85*4a5d661aSToomas Soome #define	CACHE_LINE_SHIFT	7
86*4a5d661aSToomas Soome #define	CACHE_LINE_SIZE		(1 << CACHE_LINE_SHIFT)
87*4a5d661aSToomas Soome 
88*4a5d661aSToomas Soome #define PAGE_SHIFT	12		/* LOG2(PAGE_SIZE) */
89*4a5d661aSToomas Soome #define PAGE_SIZE	(1<<PAGE_SHIFT)	/* bytes/page */
90*4a5d661aSToomas Soome #define PAGE_MASK	(PAGE_SIZE-1)
91*4a5d661aSToomas Soome #define NPTEPG		(PAGE_SIZE/(sizeof (pt_entry_t)))
92*4a5d661aSToomas Soome 
93*4a5d661aSToomas Soome #if defined(PAE) || defined(PAE_TABLES)
94*4a5d661aSToomas Soome #define NPGPTD		4
95*4a5d661aSToomas Soome #define PDRSHIFT	21		/* LOG2(NBPDR) */
96*4a5d661aSToomas Soome #define NPGPTD_SHIFT	9
97*4a5d661aSToomas Soome #else
98*4a5d661aSToomas Soome #define NPGPTD		1
99*4a5d661aSToomas Soome #define PDRSHIFT	22		/* LOG2(NBPDR) */
100*4a5d661aSToomas Soome #define NPGPTD_SHIFT	10
101*4a5d661aSToomas Soome #endif
102*4a5d661aSToomas Soome 
103*4a5d661aSToomas Soome #define NBPTD		(NPGPTD<<PAGE_SHIFT)
104*4a5d661aSToomas Soome #define NPDEPTD		(NBPTD/(sizeof (pd_entry_t)))
105*4a5d661aSToomas Soome #define NPDEPG		(PAGE_SIZE/(sizeof (pd_entry_t)))
106*4a5d661aSToomas Soome #define NBPDR		(1<<PDRSHIFT)	/* bytes/page dir */
107*4a5d661aSToomas Soome #define PDRMASK		(NBPDR-1)
108*4a5d661aSToomas Soome 
109*4a5d661aSToomas Soome #define	MAXPAGESIZES	2	/* maximum number of supported page sizes */
110*4a5d661aSToomas Soome 
111*4a5d661aSToomas Soome #define IOPAGES	2		/* pages of i/o permission bitmap */
112*4a5d661aSToomas Soome 
113*4a5d661aSToomas Soome #ifndef KSTACK_PAGES
114*4a5d661aSToomas Soome #define KSTACK_PAGES 2		/* Includes pcb! */
115*4a5d661aSToomas Soome #endif
116*4a5d661aSToomas Soome #define KSTACK_GUARD_PAGES 1	/* pages of kstack guard; 0 disables */
117*4a5d661aSToomas Soome #if KSTACK_PAGES < 4
118*4a5d661aSToomas Soome #define	TD0_KSTACK_PAGES 4
119*4a5d661aSToomas Soome #else
120*4a5d661aSToomas Soome #define	TD0_KSTACK_PAGES KSTACK_PAGES
121*4a5d661aSToomas Soome #endif
122*4a5d661aSToomas Soome 
123*4a5d661aSToomas Soome /*
124*4a5d661aSToomas Soome  * Ceiling on amount of swblock kva space, can be changed via
125*4a5d661aSToomas Soome  * the kern.maxswzone /boot/loader.conf variable.
126*4a5d661aSToomas Soome  *
127*4a5d661aSToomas Soome  * 276 is sizeof(struct swblock), but we do not always have a definition
128*4a5d661aSToomas Soome  * in scope for struct swblock, so we have to hardcode it.  Each struct
129*4a5d661aSToomas Soome  * swblock holds metadata for 32 pages, so in theory, this is enough for
130*4a5d661aSToomas Soome  * 16 GB of swap.  In practice, however, the usable amount is considerably
131*4a5d661aSToomas Soome  * lower due to fragmentation.
132*4a5d661aSToomas Soome  */
133*4a5d661aSToomas Soome #ifndef VM_SWZONE_SIZE_MAX
134*4a5d661aSToomas Soome #define VM_SWZONE_SIZE_MAX	(276 * 128 * 1024)
135*4a5d661aSToomas Soome #endif
136*4a5d661aSToomas Soome 
137*4a5d661aSToomas Soome /*
138*4a5d661aSToomas Soome  * Ceiling on size of buffer cache (really only effects write queueing,
139*4a5d661aSToomas Soome  * the VM page cache is not effected), can be changed via
140*4a5d661aSToomas Soome  * the kern.maxbcache /boot/loader.conf variable.
141*4a5d661aSToomas Soome  *
142*4a5d661aSToomas Soome  * The value is equal to the size of the auto-tuned buffer map for
143*4a5d661aSToomas Soome  * the machine with 4GB of RAM, see vfs_bio.c:kern_vfs_bio_buffer_alloc().
144*4a5d661aSToomas Soome  */
145*4a5d661aSToomas Soome #ifndef VM_BCACHE_SIZE_MAX
146*4a5d661aSToomas Soome #define VM_BCACHE_SIZE_MAX	(7224 * 16 * 1024)
147*4a5d661aSToomas Soome #endif
148*4a5d661aSToomas Soome 
149*4a5d661aSToomas Soome /*
150*4a5d661aSToomas Soome  * Mach derived conversion macros
151*4a5d661aSToomas Soome  */
152*4a5d661aSToomas Soome #define trunc_page(x)		((x) & ~PAGE_MASK)
153*4a5d661aSToomas Soome #define round_page(x)		(((x) + PAGE_MASK) & ~PAGE_MASK)
154*4a5d661aSToomas Soome #define trunc_4mpage(x)		((x) & ~PDRMASK)
155*4a5d661aSToomas Soome #define round_4mpage(x)		((((x)) + PDRMASK) & ~PDRMASK)
156*4a5d661aSToomas Soome 
157*4a5d661aSToomas Soome #define atop(x)			((x) >> PAGE_SHIFT)
158*4a5d661aSToomas Soome #define ptoa(x)			((x) << PAGE_SHIFT)
159*4a5d661aSToomas Soome 
160*4a5d661aSToomas Soome #define i386_btop(x)		((x) >> PAGE_SHIFT)
161*4a5d661aSToomas Soome #define i386_ptob(x)		((x) << PAGE_SHIFT)
162*4a5d661aSToomas Soome 
163*4a5d661aSToomas Soome #define	pgtok(x)		((x) * (PAGE_SIZE / 1024))
164*4a5d661aSToomas Soome 
165*4a5d661aSToomas Soome #define INKERNEL(va)	(((vm_offset_t)(va)) >= VM_MAXUSER_ADDRESS && \
166*4a5d661aSToomas Soome     ((vm_offset_t)(va)) < VM_MAX_KERNEL_ADDRESS)
167*4a5d661aSToomas Soome 
168*4a5d661aSToomas Soome #endif /* !_I386_INCLUDE_PARAM_H_ */
169