param.h revision 112569
1178172Simp/*-
2178172Simp * Copyright (c) 1990 The Regents of the University of California.
3178172Simp * All rights reserved.
4178172Simp *
5178172Simp * This code is derived from software contributed to Berkeley by
6178172Simp * William Jolitz.
7178172Simp *
8178172Simp * Redistribution and use in source and binary forms, with or without
9178172Simp * modification, are permitted provided that the following conditions
10178172Simp * are met:
11178172Simp * 1. Redistributions of source code must retain the above copyright
12178172Simp *    notice, this list of conditions and the following disclaimer.
13178172Simp * 2. Redistributions in binary form must reproduce the above copyright
14178172Simp *    notice, this list of conditions and the following disclaimer in the
15178172Simp *    documentation and/or other materials provided with the distribution.
16178172Simp * 3. All advertising materials mentioning features or use of this software
17178172Simp *    must display the following acknowledgement:
18178172Simp *	This product includes software developed by the University of
19178172Simp *	California, Berkeley and its contributors.
20178172Simp * 4. Neither the name of the University nor the names of its contributors
21178172Simp *    may be used to endorse or promote products derived from this software
22178172Simp *    without specific prior written permission.
23178172Simp *
24178172Simp * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25178172Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26178172Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27178172Simp * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28178172Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29178172Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30178172Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31178172Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32178172Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33178172Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34178172Simp * SUCH DAMAGE.
35178172Simp *
36178172Simp *	from: @(#)param.h	5.8 (Berkeley) 6/28/91
37178172Simp * $FreeBSD: head/sys/i386/include/param.h 112569 2003-03-25 00:07:06Z jake $
38178172Simp */
39178172Simp
40178172Simp/*
41178172Simp * Machine dependent constants for Intel 386.
42178172Simp */
43178172Simp
44232449Sjmallett/*
45202046Simp * Round p (pointer or byte index) up to a correctly-aligned value
46202046Simp * for all data types (int, long, ...).   The result is unsigned int
47178172Simp * and must be cast to any desired pointer type.
48178172Simp */
49178172Simp#ifndef _ALIGNBYTES
50178172Simp#define _ALIGNBYTES	(sizeof(int) - 1)
51199135Skib#endif
52232449Sjmallett#ifndef _ALIGN
53178172Simp#define _ALIGN(p)	(((unsigned)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
54178172Simp#endif
55178172Simp
56178172Simp#ifndef _MACHINE
57178172Simp#define	_MACHINE	i386
58178172Simp#endif
59178172Simp#ifndef _MACHINE_ARCH
60202046Simp#define	_MACHINE_ARCH	i386
61178172Simp#endif
62178172Simp
63178172Simp#ifndef _NO_NAMESPACE_POLLUTION
64178172Simp
65178172Simp#ifndef _MACHINE_PARAM_H_
66178172Simp#define	_MACHINE_PARAM_H_
67206714Sjmallett
68206714Sjmallett#ifndef MACHINE
69178172Simp#define MACHINE		"i386"
70206714Sjmallett#endif
71178172Simp#ifndef MACHINE_ARCH
72206714Sjmallett#define	MACHINE_ARCH	"i386"
73206714Sjmallett#endif
74206714Sjmallett#define MID_MACHINE	MID_I386
75206714Sjmallett
76178172Simp#ifdef SMP
77178172Simp#define MAXCPU		16
78178172Simp#else
79178172Simp#define MAXCPU		1
80178172Simp#endif /* SMP */
81178172Simp
82178172Simp#define ALIGNBYTES	_ALIGNBYTES
83178172Simp#define ALIGN(p)	_ALIGN(p)
84178172Simp
85250137Simp#define PAGE_SHIFT	12		/* LOG2(PAGE_SIZE) */
86250137Simp#define PAGE_SIZE	(1<<PAGE_SHIFT)	/* bytes/page */
87250137Simp#define PAGE_MASK	(PAGE_SIZE-1)
88250137Simp#define NPTEPG		(PAGE_SIZE/(sizeof (pt_entry_t)))
89250137Simp
90250137Simp#define NPGPTD		1
91250137Simp#define PDRSHIFT	22		/* LOG2(NBPDR) */
92250137Simp
93250137Simp#define NBPTD		(NPGPTD<<PAGE_SHIFT)
94250137Simp#define NPDEPTD		(NBPTD/(sizeof (pd_entry_t)))
95250137Simp#define NPDEPG		(PAGE_SIZE/(sizeof (pd_entry_t)))
96250137Simp#define NBPDR		(1<<PDRSHIFT)	/* bytes/page dir */
97217944Sjchandra#define PDRMASK		(NBPDR-1)
98178172Simp
99178172Simp#define IOPAGES	2		/* pages of i/o permission bitmap */
100178172Simp
101178172Simp#ifndef KSTACK_PAGES
102206714Sjmallett#define KSTACK_PAGES 2		/* Includes pcb! */
103206714Sjmallett#endif
104178172Simp#define UAREA_PAGES 1		/* holds struct user WITHOUT PCB (see def.) */
105206714Sjmallett
106206714Sjmallett#define KSTACK_GUARD		/* compile in the kstack guard page */
107206714Sjmallett
108206714Sjmallett/*
109178172Simp * Ceiling on amount of swblock kva space, can be changed via
110178172Simp * the kern.maxswzone /boot/loader.conf variable.
111217944Sjchandra */
112178172Simp#ifndef VM_SWZONE_SIZE_MAX
113178172Simp#define VM_SWZONE_SIZE_MAX	(32 * 1024 * 1024)
114178172Simp#endif
115178172Simp
116178172Simp/*
117178172Simp * Ceiling on size of buffer cache (really only effects write queueing,
118178172Simp * the VM page cache is not effected), can be changed via
119178172Simp * the kern.maxbcache /boot/loader.conf variable.
120178172Simp */
121178172Simp#ifndef VM_BCACHE_SIZE_MAX
122178172Simp#define VM_BCACHE_SIZE_MAX	(200 * 1024 * 1024)
123178172Simp#endif
124178172Simp
125178172Simp/*
126178172Simp * Mach derived conversion macros
127178172Simp */
128178172Simp#define trunc_page(x)		((x) & ~PAGE_MASK)
129178172Simp#define round_page(x)		(((x) + PAGE_MASK) & ~PAGE_MASK)
130178172Simp#define trunc_4mpage(x)		((x) & ~PDRMASK)
131178172Simp#define round_4mpage(x)		((((x)) + PDRMASK) & ~PDRMASK)
132178172Simp
133178172Simp#define atop(x)			((x) >> PAGE_SHIFT)
134178172Simp#define ptoa(x)			((x) << PAGE_SHIFT)
135178172Simp
136178172Simp#define i386_btop(x)		((x) >> PAGE_SHIFT)
137178172Simp#define i386_ptob(x)		((x) << PAGE_SHIFT)
138215034Sbrucec
139215034Sbrucec#define	pgtok(x)		((x) * (PAGE_SIZE / 1024))
140178172Simp
141178172Simp#endif /* !_MACHINE_PARAM_H_ */
142178172Simp#endif /* !_NO_NAMESPACE_POLLUTION */
143178172Simp