xref: /freebsd/sys/i386/include/param.h (revision 3208d3ff4695a322ed9ab7bbd38445a5fc7efd51)
15b81b6b3SRodney W. Grimes /*-
25b81b6b3SRodney W. Grimes  * Copyright (c) 1990 The Regents of the University of California.
35b81b6b3SRodney W. Grimes  * All rights reserved.
45b81b6b3SRodney W. Grimes  *
55b81b6b3SRodney W. Grimes  * This code is derived from software contributed to Berkeley by
65b81b6b3SRodney W. Grimes  * William Jolitz.
75b81b6b3SRodney W. Grimes  *
85b81b6b3SRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
95b81b6b3SRodney W. Grimes  * modification, are permitted provided that the following conditions
105b81b6b3SRodney W. Grimes  * are met:
115b81b6b3SRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
125b81b6b3SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
135b81b6b3SRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
145b81b6b3SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
155b81b6b3SRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
165b81b6b3SRodney W. Grimes  * 4. Neither the name of the University nor the names of its contributors
175b81b6b3SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
185b81b6b3SRodney W. Grimes  *    without specific prior written permission.
195b81b6b3SRodney W. Grimes  *
205b81b6b3SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
215b81b6b3SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
225b81b6b3SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
235b81b6b3SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
245b81b6b3SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
255b81b6b3SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
265b81b6b3SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
275b81b6b3SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
285b81b6b3SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
295b81b6b3SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
305b81b6b3SRodney W. Grimes  * SUCH DAMAGE.
315b81b6b3SRodney W. Grimes  *
3289ec6ec6SRodney W. Grimes  *	from: @(#)param.h	5.8 (Berkeley) 6/28/91
33c3aac50fSPeter Wemm  * $FreeBSD$
345b81b6b3SRodney W. Grimes  */
355b81b6b3SRodney W. Grimes 
36a254d1f1SPoul-Henning Kamp 
37a254d1f1SPoul-Henning Kamp #ifndef _I386_INCLUDE_PARAM_H_
38a254d1f1SPoul-Henning Kamp #define	_I386_INCLUDE_PARAM_H_
39a254d1f1SPoul-Henning Kamp 
40c67f5b54STijl Coosemans #include <machine/_align.h>
41c67f5b54STijl Coosemans 
425b81b6b3SRodney W. Grimes /*
435b81b6b3SRodney W. Grimes  * Machine dependent constants for Intel 386.
445b81b6b3SRodney W. Grimes  */
456b1d8ceaSJeroen Ruigrok van der Werven 
466b1d8ceaSJeroen Ruigrok van der Werven 
47d5e61c97SWarner Losh #define __HAVE_ACPI
481368987aSJohn Baldwin #define	__HAVE_PIR
49d5e61c97SWarner Losh #define __PCI_REROUTE_INTERRUPT
50d5e61c97SWarner Losh 
516b1d8ceaSJeroen Ruigrok van der Werven #ifndef MACHINE
526b1d8ceaSJeroen Ruigrok van der Werven #define MACHINE		"i386"
536b1d8ceaSJeroen Ruigrok van der Werven #endif
541684ea57SWarner Losh #ifndef MACHINE_ARCH
55582e5286SKATO Takenori #define	MACHINE_ARCH	"i386"
561684ea57SWarner Losh #endif
57f0c2a198SBruce Evans #define MID_MACHINE	MID_I386
58f0c2a198SBruce Evans 
59e4839437SJohn Birrell #if defined(SMP) || defined(KLD_MODULE)
6068b739cdSAttilio Rao #ifndef MAXCPU
613d074cf3SJohn Baldwin #define MAXCPU		32
6268b739cdSAttilio Rao #endif
6375d23f5fSSteve Passe #else
6492b123a0SPaul Saab #define MAXCPU		1
65e4839437SJohn Birrell #endif /* SMP || KLD_MODULE */
664a73d99fSSteve Passe 
67941646f5SAttilio Rao #ifndef MAXMEMDOM
68941646f5SAttilio Rao #define	MAXMEMDOM	1
69941646f5SAttilio Rao #endif
70941646f5SAttilio Rao 
716b1d8ceaSJeroen Ruigrok van der Werven #define ALIGNBYTES	_ALIGNBYTES
726b1d8ceaSJeroen Ruigrok van der Werven #define ALIGN(p)	_ALIGN(p)
738c393fd1SSam Leffler /*
748c393fd1SSam Leffler  * ALIGNED_POINTER is a boolean macro that checks whether an address
758c393fd1SSam Leffler  * is valid to fetch data elements of type t from on this architecture.
768c393fd1SSam Leffler  * This does not reflect the optimal alignment, just the possibility
778c393fd1SSam Leffler  * (within reasonable limits).
788c393fd1SSam Leffler  */
798c393fd1SSam Leffler #define	ALIGNED_POINTER(p, t)	1
80f798d060SNate Williams 
8122037b2dSRobert Watson /*
8222037b2dSRobert Watson  * CACHE_LINE_SIZE is the compile-time maximum cache line size for an
8322037b2dSRobert Watson  * architecture.  It should be used with appropriate caution.
8422037b2dSRobert Watson  */
858aba835bSJohn Baldwin #define	CACHE_LINE_SHIFT	7
86a93fa8f2SRobert Watson #define	CACHE_LINE_SIZE		(1 << CACHE_LINE_SHIFT)
87a93fa8f2SRobert Watson 
88e911eafcSPoul-Henning Kamp #define PAGE_SHIFT	12		/* LOG2(PAGE_SIZE) */
89e911eafcSPoul-Henning Kamp #define PAGE_SIZE	(1<<PAGE_SHIFT)	/* bytes/page */
90ec120393SDavid Greenman #define PAGE_MASK	(PAGE_SIZE-1)
91e911eafcSPoul-Henning Kamp #define NPTEPG		(PAGE_SIZE/(sizeof (pt_entry_t)))
925b81b6b3SRodney W. Grimes 
9334c15db9SKonstantin Belousov #if defined(PAE) || defined(PAE_TABLES)
947ab9b220SJake Burkholder #define NPGPTD		4
957ab9b220SJake Burkholder #define PDRSHIFT	21		/* LOG2(NBPDR) */
96dec9f635SKip Macy #define NPGPTD_SHIFT	9
977ab9b220SJake Burkholder #else
98910548deSJake Burkholder #define NPGPTD		1
995b81b6b3SRodney W. Grimes #define PDRSHIFT	22		/* LOG2(NBPDR) */
100dec9f635SKip Macy #define NPGPTD_SHIFT	10
1017ab9b220SJake Burkholder #endif
102910548deSJake Burkholder 
103910548deSJake Burkholder #define NBPTD		(NPGPTD<<PAGE_SHIFT)
104910548deSJake Burkholder #define NPDEPTD		(NBPTD/(sizeof (pd_entry_t)))
105910548deSJake Burkholder #define NPDEPG		(PAGE_SIZE/(sizeof (pd_entry_t)))
106c77ba360SRodney W. Grimes #define NBPDR		(1<<PDRSHIFT)	/* bytes/page dir */
107d3d1eb99SJohn Dyson #define PDRMASK		(NBPDR-1)
1085b81b6b3SRodney W. Grimes 
109fe105d45SAlan Cox #define	MAXPAGESIZES	2	/* maximum number of supported page sizes */
110fe105d45SAlan Cox 
11148a09cf2SJohn Dyson #define IOPAGES	2		/* pages of i/o permission bitmap */
112268bdb43SPeter Wemm 
113b40ce416SJulian Elischer #ifndef KSTACK_PAGES
114b40ce416SJulian Elischer #define KSTACK_PAGES 2		/* Includes pcb! */
115268bdb43SPeter Wemm #endif
11649a2507bSAlan Cox #define KSTACK_GUARD_PAGES 1	/* pages of kstack guard; 0 disables */
117*3208d3ffSKonstantin Belousov #if KSTACK_PAGES < 4
118*3208d3ffSKonstantin Belousov #define	TD0_KSTACK_PAGES 4
119*3208d3ffSKonstantin Belousov #else
120*3208d3ffSKonstantin Belousov #define	TD0_KSTACK_PAGES KSTACK_PAGES
121*3208d3ffSKonstantin Belousov #endif
122b40ce416SJulian Elischer 
1235b81b6b3SRodney W. Grimes /*
124ae7f84a9SDag-Erling Smørgrav  * Ceiling on amount of swblock kva space, can be changed via
125ae7f84a9SDag-Erling Smørgrav  * the kern.maxswzone /boot/loader.conf variable.
126ae7f84a9SDag-Erling Smørgrav  *
127ae7f84a9SDag-Erling Smørgrav  * 276 is sizeof(struct swblock), but we do not always have a definition
128ae7f84a9SDag-Erling Smørgrav  * in scope for struct swblock, so we have to hardcode it.  Each struct
129ae7f84a9SDag-Erling Smørgrav  * swblock holds metadata for 32 pages, so in theory, this is enough for
130ae7f84a9SDag-Erling Smørgrav  * 16 GB of swap.  In practice, however, the usable amount is considerably
131ae7f84a9SDag-Erling Smørgrav  * lower due to fragmentation.
132ae7f84a9SDag-Erling Smørgrav  */
133ae7f84a9SDag-Erling Smørgrav #ifndef VM_SWZONE_SIZE_MAX
134ae7f84a9SDag-Erling Smørgrav #define VM_SWZONE_SIZE_MAX	(276 * 128 * 1024)
135ae7f84a9SDag-Erling Smørgrav #endif
136ae7f84a9SDag-Erling Smørgrav 
137ae7f84a9SDag-Erling Smørgrav /*
1382f9e4e80SMatthew Dillon  * Ceiling on size of buffer cache (really only effects write queueing,
139ec61f55dSMatthew Dillon  * the VM page cache is not effected), can be changed via
140ec61f55dSMatthew Dillon  * the kern.maxbcache /boot/loader.conf variable.
141d4e9009cSKonstantin Belousov  *
142d4e9009cSKonstantin Belousov  * The value is equal to the size of the auto-tuned buffer map for
143d4e9009cSKonstantin Belousov  * the machine with 4GB of RAM, see vfs_bio.c:kern_vfs_bio_buffer_alloc().
1442f9e4e80SMatthew Dillon  */
1452f9e4e80SMatthew Dillon #ifndef VM_BCACHE_SIZE_MAX
146d4e9009cSKonstantin Belousov #define VM_BCACHE_SIZE_MAX	(7224 * 16 * 1024)
1472f9e4e80SMatthew Dillon #endif
1482f9e4e80SMatthew Dillon 
1495b81b6b3SRodney W. Grimes /*
1505b81b6b3SRodney W. Grimes  * Mach derived conversion macros
1515b81b6b3SRodney W. Grimes  */
1526cde7a16SDavid Greenman #define trunc_page(x)		((x) & ~PAGE_MASK)
1536cde7a16SDavid Greenman #define round_page(x)		(((x) + PAGE_MASK) & ~PAGE_MASK)
154227f9a1cSJake Burkholder #define trunc_4mpage(x)		((x) & ~PDRMASK)
155227f9a1cSJake Burkholder #define round_4mpage(x)		((((x)) + PDRMASK) & ~PDRMASK)
15626f9a767SRodney W. Grimes 
157227f9a1cSJake Burkholder #define atop(x)			((x) >> PAGE_SHIFT)
158227f9a1cSJake Burkholder #define ptoa(x)			((x) << PAGE_SHIFT)
159ec120393SDavid Greenman 
160227f9a1cSJake Burkholder #define i386_btop(x)		((x) >> PAGE_SHIFT)
161227f9a1cSJake Burkholder #define i386_ptob(x)		((x) << PAGE_SHIFT)
162d529c3d8SRodney W. Grimes 
1631c6d46f9SLuoqi Chen #define	pgtok(x)		((x) * (PAGE_SIZE / 1024))
1641c6d46f9SLuoqi Chen 
1656fdfd882SKonstantin Belousov #define INKERNEL(va)	(((vm_offset_t)(va)) >= VM_MAXUSER_ADDRESS && \
1666fdfd882SKonstantin Belousov     ((vm_offset_t)(va)) < VM_MAX_KERNEL_ADDRESS)
1676fdfd882SKonstantin Belousov 
168a254d1f1SPoul-Henning Kamp #endif /* !_I386_INCLUDE_PARAM_H_ */
169