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$
344Srgrimes */
354Srgrimes
36196994Sphk#include <machine/_align.h>
37196994Sphk
38196994Sphk#ifndef _I386_INCLUDE_PARAM_H_
39196994Sphk#define	_I386_INCLUDE_PARAM_H_
40196994Sphk
414Srgrimes/*
424Srgrimes * Machine dependent constants for Intel 386.
434Srgrimes */
4468498Sasmodai
4568498Sasmodai/*
4668498Sasmodai * Round p (pointer or byte index) up to a correctly-aligned value
4768498Sasmodai * for all data types (int, long, ...).   The result is unsigned int
4868498Sasmodai * and must be cast to any desired pointer type.
4968498Sasmodai */
5068498Sasmodai#ifndef _ALIGNBYTES
5168498Sasmodai#define _ALIGNBYTES	(sizeof(int) - 1)
5268498Sasmodai#endif
5368498Sasmodai#ifndef _ALIGN
5468498Sasmodai#define _ALIGN(p)	(((unsigned)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
5568498Sasmodai#endif
5668498Sasmodai
5768498Sasmodai
58154128Simp#define __HAVE_ACPI
59223440Sjhb#define	__HAVE_PIR
60154128Simp#define __PCI_REROUTE_INTERRUPT
61154128Simp
6244364Simp#ifndef MACHINE
63551Srgrimes#define MACHINE		"i386"
6444364Simp#endif
6544364Simp#ifndef MACHINE_ARCH
6638673Skato#define	MACHINE_ARCH	"i386"
6744364Simp#endif
6836977Sbde#define MID_MACHINE	MID_I386
6936977Sbde
70177661Sjb#if defined(SMP) || defined(KLD_MODULE)
71224207Sattilio#ifndef MAXCPU
72183525Sjhb#define MAXCPU		32
73224207Sattilio#endif
7428354Sfsmp#else
7566296Sps#define MAXCPU		1
76177661Sjb#endif /* SMP || KLD_MODULE */
774Srgrimes
7868498Sasmodai#define ALIGNBYTES	_ALIGNBYTES
7968498Sasmodai#define ALIGN(p)	_ALIGN(p)
80195376Ssam/*
81195376Ssam * ALIGNED_POINTER is a boolean macro that checks whether an address
82195376Ssam * is valid to fetch data elements of type t from on this architecture.
83195376Ssam * This does not reflect the optimal alignment, just the possibility
84195376Ssam * (within reasonable limits).
85195376Ssam */
86195376Ssam#define	ALIGNED_POINTER(p, t)	1
874Srgrimes
88191278Srwatson/*
89191278Srwatson * CACHE_LINE_SIZE is the compile-time maximum cache line size for an
90191278Srwatson * architecture.  It should be used with appropriate caution.
91191278Srwatson */
92192331Sjhb#define	CACHE_LINE_SHIFT	7
93191276Srwatson#define	CACHE_LINE_SIZE		(1 << CACHE_LINE_SHIFT)
94191276Srwatson
9515543Sphk#define PAGE_SHIFT	12		/* LOG2(PAGE_SIZE) */
9615565Sphk#define PAGE_SIZE	(1<<PAGE_SHIFT)	/* bytes/page */
971045Sdg#define PAGE_MASK	(PAGE_SIZE-1)
9815543Sphk#define NPTEPG		(PAGE_SIZE/(sizeof (pt_entry_t)))
9915565Sphk
100112841Sjake#ifdef PAE
101112841Sjake#define NPGPTD		4
102112841Sjake#define PDRSHIFT	21		/* LOG2(NBPDR) */
103183343Skmacy#define NPGPTD_SHIFT	9
104112841Sjake#else
105111363Sjake#define NPGPTD		1
106111363Sjake#define PDRSHIFT	22		/* LOG2(NBPDR) */
107183343Skmacy#define NPGPTD_SHIFT	10
108112841Sjake#endif
109111363Sjake
110111363Sjake#define NBPTD		(NPGPTD<<PAGE_SHIFT)
111111363Sjake#define NPDEPTD		(NBPTD/(sizeof (pd_entry_t)))
11215543Sphk#define NPDEPG		(PAGE_SIZE/(sizeof (pd_entry_t)))
11315565Sphk#define NBPDR		(1<<PDRSHIFT)	/* bytes/page dir */
11427950Sdyson#define PDRMASK		(NBPDR-1)
1154Srgrimes
116197316Salc#define	MAXPAGESIZES	2	/* maximum number of supported page sizes */
117197316Salc
11827993Sdyson#define IOPAGES	2		/* pages of i/o permission bitmap */
11982309Speter
12083366Sjulian#ifndef KSTACK_PAGES
12183366Sjulian#define KSTACK_PAGES 2		/* Includes pcb! */
12282309Speter#endif
123116355Salc#define KSTACK_GUARD_PAGES 1	/* pages of kstack guard; 0 disables */
1244Srgrimes
1254Srgrimes/*
126102738Sdillon * Ceiling on amount of swblock kva space, can be changed via
127102738Sdillon * the kern.maxswzone /boot/loader.conf variable.
128240097Sdes *
129240097Sdes * 276 is sizeof(struct swblock), but we do not always have a definition
130240097Sdes * in scope for struct swblock, so we have to hardcode it.  Each struct
131240097Sdes * swblock holds metadata for 32 pages, so in theory, this is enough for
132240097Sdes * 16 GB of swap.  In practice, however, the usable amount is considerably
133240097Sdes * lower due to fragmentation.
13481933Sdillon */
13581933Sdillon#ifndef VM_SWZONE_SIZE_MAX
136240097Sdes#define VM_SWZONE_SIZE_MAX	(276 * 128 * 1024)
13781933Sdillon#endif
13881933Sdillon
13981933Sdillon/*
14081933Sdillon * Ceiling on size of buffer cache (really only effects write queueing,
141102738Sdillon * the VM page cache is not effected), can be changed via
142102738Sdillon * the kern.maxbcache /boot/loader.conf variable.
143251897Sscottl *
144251897Sscottl * The value is equal to the size of the auto-tuned buffer map for
145251897Sscottl * the machine with 4GB of RAM, see vfs_bio.c:kern_vfs_bio_buffer_alloc().
14681933Sdillon */
14781933Sdillon#ifndef VM_BCACHE_SIZE_MAX
148251897Sscottl#define VM_BCACHE_SIZE_MAX	(7224 * 16 * 1024)
14981933Sdillon#endif
15081933Sdillon
15181933Sdillon/*
1524Srgrimes * Mach derived conversion macros
1534Srgrimes */
15440286Sdg#define trunc_page(x)		((x) & ~PAGE_MASK)
15540286Sdg#define round_page(x)		(((x) + PAGE_MASK) & ~PAGE_MASK)
156112569Sjake#define trunc_4mpage(x)		((x) & ~PDRMASK)
157112569Sjake#define round_4mpage(x)		((((x)) + PDRMASK) & ~PDRMASK)
1581549Srgrimes
159112569Sjake#define atop(x)			((x) >> PAGE_SHIFT)
160112569Sjake#define ptoa(x)			((x) << PAGE_SHIFT)
1611045Sdg
162112569Sjake#define i386_btop(x)		((x) >> PAGE_SHIFT)
163112569Sjake#define i386_ptob(x)		((x) << PAGE_SHIFT)
164584Srgrimes
16544157Sluoqi#define	pgtok(x)		((x) * (PAGE_SIZE / 1024))
16644157Sluoqi
167196994Sphk#endif /* !_I386_INCLUDE_PARAM_H_ */
168