14Srgrimes/*-
24Srgrimes * Copyright (c) 1990 The Regents of the University of California.
34Srgrimes * All rights reserved.
44Srgrimes *
54Srgrimes * This code is derived from software contributed to Berkeley by
64Srgrimes * William Jolitz.
74Srgrimes *
84Srgrimes * Redistribution and use in source and binary forms, with or without
94Srgrimes * modification, are permitted provided that the following conditions
104Srgrimes * are met:
114Srgrimes * 1. Redistributions of source code must retain the above copyright
124Srgrimes *    notice, this list of conditions and the following disclaimer.
134Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
144Srgrimes *    notice, this list of conditions and the following disclaimer in the
154Srgrimes *    documentation and/or other materials provided with the distribution.
164Srgrimes * 4. Neither the name of the University nor the names of its contributors
174Srgrimes *    may be used to endorse or promote products derived from this software
184Srgrimes *    without specific prior written permission.
194Srgrimes *
204Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
214Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
224Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
234Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
244Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
254Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
264Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
274Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
284Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
294Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
304Srgrimes * SUCH DAMAGE.
314Srgrimes *
32551Srgrimes *	from: @(#)param.h	5.8 (Berkeley) 6/28/91
3350477Speter * $FreeBSD: releng/11.0/sys/i386/include/param.h 286288 2015-08-04 13:50:52Z kib $
344Srgrimes */
354Srgrimes
36196994Sphk
37196994Sphk#ifndef _I386_INCLUDE_PARAM_H_
38196994Sphk#define	_I386_INCLUDE_PARAM_H_
39196994Sphk
40249722Stijl#include <machine/_align.h>
41249722Stijl
424Srgrimes/*
434Srgrimes * Machine dependent constants for Intel 386.
444Srgrimes */
4568498Sasmodai
4668498Sasmodai
47154128Simp#define __HAVE_ACPI
48223440Sjhb#define	__HAVE_PIR
49154128Simp#define __PCI_REROUTE_INTERRUPT
50154128Simp
5144364Simp#ifndef MACHINE
52551Srgrimes#define MACHINE		"i386"
5344364Simp#endif
5444364Simp#ifndef MACHINE_ARCH
5538673Skato#define	MACHINE_ARCH	"i386"
5644364Simp#endif
5736977Sbde#define MID_MACHINE	MID_I386
5836977Sbde
59177661Sjb#if defined(SMP) || defined(KLD_MODULE)
60224207Sattilio#ifndef MAXCPU
61183525Sjhb#define MAXCPU		32
62224207Sattilio#endif
6328354Sfsmp#else
6466296Sps#define MAXCPU		1
65177661Sjb#endif /* SMP || KLD_MODULE */
664Srgrimes
67250338Sattilio#ifndef MAXMEMDOM
68250338Sattilio#define	MAXMEMDOM	1
69250338Sattilio#endif
70250338Sattilio
7168498Sasmodai#define ALIGNBYTES	_ALIGNBYTES
7268498Sasmodai#define ALIGN(p)	_ALIGN(p)
73195376Ssam/*
74195376Ssam * ALIGNED_POINTER is a boolean macro that checks whether an address
75195376Ssam * is valid to fetch data elements of type t from on this architecture.
76195376Ssam * This does not reflect the optimal alignment, just the possibility
77195376Ssam * (within reasonable limits).
78195376Ssam */
79195376Ssam#define	ALIGNED_POINTER(p, t)	1
804Srgrimes
81191278Srwatson/*
82191278Srwatson * CACHE_LINE_SIZE is the compile-time maximum cache line size for an
83191278Srwatson * architecture.  It should be used with appropriate caution.
84191278Srwatson */
85192331Sjhb#define	CACHE_LINE_SHIFT	7
86191276Srwatson#define	CACHE_LINE_SIZE		(1 << CACHE_LINE_SHIFT)
87191276Srwatson
8815543Sphk#define PAGE_SHIFT	12		/* LOG2(PAGE_SIZE) */
8915565Sphk#define PAGE_SIZE	(1<<PAGE_SHIFT)	/* bytes/page */
901045Sdg#define PAGE_MASK	(PAGE_SIZE-1)
9115543Sphk#define NPTEPG		(PAGE_SIZE/(sizeof (pt_entry_t)))
9215565Sphk
93281495Skib#if defined(PAE) || defined(PAE_TABLES)
94112841Sjake#define NPGPTD		4
95112841Sjake#define PDRSHIFT	21		/* LOG2(NBPDR) */
96183343Skmacy#define NPGPTD_SHIFT	9
97112841Sjake#else
98111363Sjake#define NPGPTD		1
99111363Sjake#define PDRSHIFT	22		/* LOG2(NBPDR) */
100183343Skmacy#define NPGPTD_SHIFT	10
101112841Sjake#endif
102111363Sjake
103111363Sjake#define NBPTD		(NPGPTD<<PAGE_SHIFT)
104111363Sjake#define NPDEPTD		(NBPTD/(sizeof (pd_entry_t)))
10515543Sphk#define NPDEPG		(PAGE_SIZE/(sizeof (pd_entry_t)))
10615565Sphk#define NBPDR		(1<<PDRSHIFT)	/* bytes/page dir */
10727950Sdyson#define PDRMASK		(NBPDR-1)
1084Srgrimes
109197316Salc#define	MAXPAGESIZES	2	/* maximum number of supported page sizes */
110197316Salc
11127993Sdyson#define IOPAGES	2		/* pages of i/o permission bitmap */
11282309Speter
11383366Sjulian#ifndef KSTACK_PAGES
11483366Sjulian#define KSTACK_PAGES 2		/* Includes pcb! */
11582309Speter#endif
116116355Salc#define KSTACK_GUARD_PAGES 1	/* pages of kstack guard; 0 disables */
117286288Skib#if KSTACK_PAGES < 4
118286288Skib#define	TD0_KSTACK_PAGES 4
119286288Skib#else
120286288Skib#define	TD0_KSTACK_PAGES KSTACK_PAGES
121286288Skib#endif
1224Srgrimes
1234Srgrimes/*
124239730Sdes * Ceiling on amount of swblock kva space, can be changed via
125239730Sdes * the kern.maxswzone /boot/loader.conf variable.
126239730Sdes *
127239730Sdes * 276 is sizeof(struct swblock), but we do not always have a definition
128239730Sdes * in scope for struct swblock, so we have to hardcode it.  Each struct
129239730Sdes * swblock holds metadata for 32 pages, so in theory, this is enough for
130239730Sdes * 16 GB of swap.  In practice, however, the usable amount is considerably
131239730Sdes * lower due to fragmentation.
132239730Sdes */
133239730Sdes#ifndef VM_SWZONE_SIZE_MAX
134239730Sdes#define VM_SWZONE_SIZE_MAX	(276 * 128 * 1024)
135239730Sdes#endif
136239730Sdes
137239730Sdes/*
13881933Sdillon * Ceiling on size of buffer cache (really only effects write queueing,
139102738Sdillon * the VM page cache is not effected), can be changed via
140102738Sdillon * the kern.maxbcache /boot/loader.conf variable.
141248789Skib *
142248789Skib * The value is equal to the size of the auto-tuned buffer map for
143248789Skib * the machine with 4GB of RAM, see vfs_bio.c:kern_vfs_bio_buffer_alloc().
14481933Sdillon */
14581933Sdillon#ifndef VM_BCACHE_SIZE_MAX
146248789Skib#define VM_BCACHE_SIZE_MAX	(7224 * 16 * 1024)
14781933Sdillon#endif
14881933Sdillon
14981933Sdillon/*
1504Srgrimes * Mach derived conversion macros
1514Srgrimes */
15240286Sdg#define trunc_page(x)		((x) & ~PAGE_MASK)
15340286Sdg#define round_page(x)		(((x) + PAGE_MASK) & ~PAGE_MASK)
154112569Sjake#define trunc_4mpage(x)		((x) & ~PDRMASK)
155112569Sjake#define round_4mpage(x)		((((x)) + PDRMASK) & ~PDRMASK)
1561549Srgrimes
157112569Sjake#define atop(x)			((x) >> PAGE_SHIFT)
158112569Sjake#define ptoa(x)			((x) << PAGE_SHIFT)
1591045Sdg
160112569Sjake#define i386_btop(x)		((x) >> PAGE_SHIFT)
161112569Sjake#define i386_ptob(x)		((x) << PAGE_SHIFT)
162584Srgrimes
16344157Sluoqi#define	pgtok(x)		((x) * (PAGE_SIZE / 1024))
16444157Sluoqi
165285041Skib#define INKERNEL(va)	(((vm_offset_t)(va)) >= VM_MAXUSER_ADDRESS && \
166285041Skib    ((vm_offset_t)(va)) < VM_MAX_KERNEL_ADDRESS)
167285041Skib
168196994Sphk#endif /* !_I386_INCLUDE_PARAM_H_ */
169