xref: /freebsd/sys/i386/include/param.h (revision 44bd0e89a1c47c02639f3b2b6b9c7a5ca3aa84be)
15b81b6b3SRodney W. Grimes /*-
251369649SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
351369649SPedro F. Giffuni  *
45b81b6b3SRodney W. Grimes  * Copyright (c) 1990 The Regents of the University of California.
55b81b6b3SRodney W. Grimes  * All rights reserved.
65b81b6b3SRodney W. Grimes  *
75b81b6b3SRodney W. Grimes  * This code is derived from software contributed to Berkeley by
85b81b6b3SRodney W. Grimes  * William Jolitz.
95b81b6b3SRodney W. Grimes  *
105b81b6b3SRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
115b81b6b3SRodney W. Grimes  * modification, are permitted provided that the following conditions
125b81b6b3SRodney W. Grimes  * are met:
135b81b6b3SRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
145b81b6b3SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
155b81b6b3SRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
165b81b6b3SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
175b81b6b3SRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
18fbbd9655SWarner Losh  * 3. Neither the name of the University nor the names of its contributors
195b81b6b3SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
205b81b6b3SRodney W. Grimes  *    without specific prior written permission.
215b81b6b3SRodney W. Grimes  *
225b81b6b3SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
235b81b6b3SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
245b81b6b3SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
255b81b6b3SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
265b81b6b3SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
275b81b6b3SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
285b81b6b3SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
295b81b6b3SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
305b81b6b3SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
315b81b6b3SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
325b81b6b3SRodney W. Grimes  * SUCH DAMAGE.
335b81b6b3SRodney W. Grimes  */
345b81b6b3SRodney W. Grimes 
35a254d1f1SPoul-Henning Kamp #ifndef _I386_INCLUDE_PARAM_H_
36a254d1f1SPoul-Henning Kamp #define	_I386_INCLUDE_PARAM_H_
37a254d1f1SPoul-Henning Kamp 
38c67f5b54STijl Coosemans #include <machine/_align.h>
39c67f5b54STijl Coosemans 
405b81b6b3SRodney W. Grimes /*
415b81b6b3SRodney W. Grimes  * Machine dependent constants for Intel 386.
425b81b6b3SRodney W. Grimes  */
436b1d8ceaSJeroen Ruigrok van der Werven 
441368987aSJohn Baldwin #define	__HAVE_PIR
45d5e61c97SWarner Losh 
466b1d8ceaSJeroen Ruigrok van der Werven #ifndef MACHINE
476b1d8ceaSJeroen Ruigrok van der Werven #define MACHINE		"i386"
486b1d8ceaSJeroen Ruigrok van der Werven #endif
491684ea57SWarner Losh #ifndef MACHINE_ARCH
50582e5286SKATO Takenori #define	MACHINE_ARCH	"i386"
511684ea57SWarner Losh #endif
52f0c2a198SBruce Evans #define MID_MACHINE	MID_I386
53f0c2a198SBruce Evans 
54*c3d326fdSMark Johnston #ifdef SMP
5568b739cdSAttilio Rao #ifndef MAXCPU
563d074cf3SJohn Baldwin #define MAXCPU		32
5768b739cdSAttilio Rao #endif
5875d23f5fSSteve Passe #else
5992b123a0SPaul Saab #define MAXCPU		1
60*c3d326fdSMark Johnston #endif
614a73d99fSSteve Passe 
62941646f5SAttilio Rao #ifndef MAXMEMDOM
63941646f5SAttilio Rao #define	MAXMEMDOM	1
64941646f5SAttilio Rao #endif
65941646f5SAttilio Rao 
666b1d8ceaSJeroen Ruigrok van der Werven #define ALIGNBYTES	_ALIGNBYTES
676b1d8ceaSJeroen Ruigrok van der Werven #define ALIGN(p)	_ALIGN(p)
688c393fd1SSam Leffler /*
698c393fd1SSam Leffler  * ALIGNED_POINTER is a boolean macro that checks whether an address
708c393fd1SSam Leffler  * is valid to fetch data elements of type t from on this architecture.
718c393fd1SSam Leffler  * This does not reflect the optimal alignment, just the possibility
728c393fd1SSam Leffler  * (within reasonable limits).
738c393fd1SSam Leffler  */
748c393fd1SSam Leffler #define	ALIGNED_POINTER(p, t)	1
75f798d060SNate Williams 
7622037b2dSRobert Watson /*
7722037b2dSRobert Watson  * CACHE_LINE_SIZE is the compile-time maximum cache line size for an
7822037b2dSRobert Watson  * architecture.  It should be used with appropriate caution.
7922037b2dSRobert Watson  */
802744a0b6SConrad Meyer #define	CACHE_LINE_SHIFT	6
81a93fa8f2SRobert Watson #define	CACHE_LINE_SIZE		(1 << CACHE_LINE_SHIFT)
82a93fa8f2SRobert Watson 
83e911eafcSPoul-Henning Kamp #define PAGE_SHIFT	12		/* LOG2(PAGE_SIZE) */
84e911eafcSPoul-Henning Kamp #define PAGE_SIZE	(1 << PAGE_SHIFT)	/* bytes/page */
85ec120393SDavid Greenman #define PAGE_MASK	(PAGE_SIZE - 1)
869a527560SKonstantin Belousov #define NPTEPG		(PAGE_SIZE / sizeof(pt_entry_t))
875b81b6b3SRodney W. Grimes 
889a527560SKonstantin Belousov /* Size in bytes of the page directory */
89910548deSJake Burkholder #define NBPTD		(NPGPTD << PAGE_SHIFT)
909a527560SKonstantin Belousov /* Number of PDEs in page directory, 2048 for PAE, 1024 for non-PAE */
919a527560SKonstantin Belousov #define NPDEPTD		(NBPTD / sizeof(pd_entry_t))
929a527560SKonstantin Belousov /* Number of PDEs in one page of the page directory, 512 vs. 1024 */
939a527560SKonstantin Belousov #define NPDEPG		(PAGE_SIZE / sizeof(pd_entry_t))
94d3d1eb99SJohn Dyson #define PDRMASK		(NBPDR - 1)
959a527560SKonstantin Belousov #ifndef PDRSHIFT
969a527560SKonstantin Belousov #define	PDRSHIFT	i386_pmap_PDRSHIFT
979a527560SKonstantin Belousov #endif
989a527560SKonstantin Belousov #ifndef NBPDR
999a527560SKonstantin Belousov #define NBPDR		(1 << PDRSHIFT)	/* bytes/page dir */
1009a527560SKonstantin Belousov #endif
1015b81b6b3SRodney W. Grimes 
102fe105d45SAlan Cox #define	MAXPAGESIZES	2	/* maximum number of supported page sizes */
103fe105d45SAlan Cox 
10448a09cf2SJohn Dyson #define IOPAGES	2		/* pages of i/o permission bitmap */
105268bdb43SPeter Wemm 
106b40ce416SJulian Elischer #ifndef KSTACK_PAGES
1073f6867efSConrad Meyer #define KSTACK_PAGES 4		/* Includes pcb! */
108268bdb43SPeter Wemm #endif
10949a2507bSAlan Cox #define KSTACK_GUARD_PAGES 1	/* pages of kstack guard; 0 disables */
1103208d3ffSKonstantin Belousov #if KSTACK_PAGES < 4
1113208d3ffSKonstantin Belousov #define	TD0_KSTACK_PAGES 4
1123208d3ffSKonstantin Belousov #else
1133208d3ffSKonstantin Belousov #define	TD0_KSTACK_PAGES KSTACK_PAGES
1143208d3ffSKonstantin Belousov #endif
115b40ce416SJulian Elischer 
1165b81b6b3SRodney W. Grimes /*
117ae7f84a9SDag-Erling Smørgrav  * Ceiling on amount of swblock kva space, can be changed via
118ae7f84a9SDag-Erling Smørgrav  * the kern.maxswzone /boot/loader.conf variable.
119ae7f84a9SDag-Erling Smørgrav  *
120ae7f84a9SDag-Erling Smørgrav  * 276 is sizeof(struct swblock), but we do not always have a definition
121ae7f84a9SDag-Erling Smørgrav  * in scope for struct swblock, so we have to hardcode it.  Each struct
122ae7f84a9SDag-Erling Smørgrav  * swblock holds metadata for 32 pages, so in theory, this is enough for
123ae7f84a9SDag-Erling Smørgrav  * 16 GB of swap.  In practice, however, the usable amount is considerably
124ae7f84a9SDag-Erling Smørgrav  * lower due to fragmentation.
125ae7f84a9SDag-Erling Smørgrav  */
126ae7f84a9SDag-Erling Smørgrav #ifndef VM_SWZONE_SIZE_MAX
127ae7f84a9SDag-Erling Smørgrav #define VM_SWZONE_SIZE_MAX	(276 * 128 * 1024)
128ae7f84a9SDag-Erling Smørgrav #endif
129ae7f84a9SDag-Erling Smørgrav 
130ae7f84a9SDag-Erling Smørgrav /*
1312f9e4e80SMatthew Dillon  * Ceiling on size of buffer cache (really only effects write queueing,
132ec61f55dSMatthew Dillon  * the VM page cache is not effected), can be changed via
133ec61f55dSMatthew Dillon  * the kern.maxbcache /boot/loader.conf variable.
134d4e9009cSKonstantin Belousov  *
135d4e9009cSKonstantin Belousov  * The value is equal to the size of the auto-tuned buffer map for
136d4e9009cSKonstantin Belousov  * the machine with 4GB of RAM, see vfs_bio.c:kern_vfs_bio_buffer_alloc().
1372f9e4e80SMatthew Dillon  */
1382f9e4e80SMatthew Dillon #ifndef VM_BCACHE_SIZE_MAX
139d4e9009cSKonstantin Belousov #define VM_BCACHE_SIZE_MAX	(7224 * 16 * 1024)
1402f9e4e80SMatthew Dillon #endif
1412f9e4e80SMatthew Dillon 
1425b81b6b3SRodney W. Grimes /*
1435b81b6b3SRodney W. Grimes  * Mach derived conversion macros
1445b81b6b3SRodney W. Grimes  */
145227f9a1cSJake Burkholder #define trunc_4mpage(x)		((x) & ~PDRMASK)
146227f9a1cSJake Burkholder #define round_4mpage(x)		((((x)) + PDRMASK) & ~PDRMASK)
14726f9a767SRodney W. Grimes 
148227f9a1cSJake Burkholder #define i386_btop(x)		((x) >> PAGE_SHIFT)
149227f9a1cSJake Burkholder #define i386_ptob(x)		((x) << PAGE_SHIFT)
150d529c3d8SRodney W. Grimes 
151d86c1f0dSKonstantin Belousov #define INKERNEL(va)		(TRUE)
1526fdfd882SKonstantin Belousov 
153a254d1f1SPoul-Henning Kamp #endif /* !_I386_INCLUDE_PARAM_H_ */
154