param.h revision 134598
178344Sobrien/*-
278344Sobrien * Copyright (c) 1990 The Regents of the University of California.
398184Sgordon * All rights reserved.
498184Sgordon *
578344Sobrien * This code is derived from software contributed to Berkeley by
678344Sobrien * William Jolitz.
778344Sobrien *
878344Sobrien * Redistribution and use in source and binary forms, with or without
998184Sgordon * modification, are permitted provided that the following conditions
1098184Sgordon * are met:
1198184Sgordon * 1. Redistributions of source code must retain the above copyright
1278344Sobrien *    notice, this list of conditions and the following disclaimer.
1398184Sgordon * 2. Redistributions in binary form must reproduce the above copyright
1498184Sgordon *    notice, this list of conditions and the following disclaimer in the
1598184Sgordon *    documentation and/or other materials provided with the distribution.
1678344Sobrien * 4. Neither the name of the University nor the names of its contributors
1778344Sobrien *    may be used to endorse or promote products derived from this software
1878344Sobrien *    without specific prior written permission.
1998184Sgordon *
2078344Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2178344Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22102864Sgordon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23102864Sgordon * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24102864Sgordon * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25102864Sgordon * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26102864Sgordon * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27102864Sgordon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28102864Sgordon * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29102864Sgordon * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30102864Sgordon * SUCH DAMAGE.
31102864Sgordon *
32102864Sgordon *	from: @(#)param.h	5.8 (Berkeley) 6/28/91
33102864Sgordon * $FreeBSD: head/sys/i386/include/param.h 134598 2004-09-01 09:01:32Z julian $
34102864Sgordon */
35102864Sgordon
36102864Sgordon/*
37102864Sgordon * Machine dependent constants for Intel 386.
38102864Sgordon */
39102864Sgordon
40102864Sgordon/*
41102864Sgordon * Round p (pointer or byte index) up to a correctly-aligned value
42102864Sgordon * for all data types (int, long, ...).   The result is unsigned int
43102864Sgordon * and must be cast to any desired pointer type.
44102864Sgordon */
45102864Sgordon#ifndef _ALIGNBYTES
46102864Sgordon#define _ALIGNBYTES	(sizeof(int) - 1)
4778344Sobrien#endif
4878344Sobrien#ifndef _ALIGN
4978344Sobrien#define _ALIGN(p)	(((unsigned)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
5078344Sobrien#endif
5178344Sobrien
5298184Sgordon#ifndef _MACHINE
5378344Sobrien#define	_MACHINE	i386
5478344Sobrien#endif
5578344Sobrien#ifndef _MACHINE_ARCH
5678344Sobrien#define	_MACHINE_ARCH	i386
5778344Sobrien#endif
5878344Sobrien
5978344Sobrien#ifndef _NO_NAMESPACE_POLLUTION
6078344Sobrien
6178344Sobrien#ifndef _MACHINE_PARAM_H_
6278344Sobrien#define	_MACHINE_PARAM_H_
6378344Sobrien
6478344Sobrien#ifndef MACHINE
6578344Sobrien#define MACHINE		"i386"
6678344Sobrien#endif
6778344Sobrien#ifndef MACHINE_ARCH
6878344Sobrien#define	MACHINE_ARCH	"i386"
6978344Sobrien#endif
7078344Sobrien#define MID_MACHINE	MID_I386
7178344Sobrien
7278344Sobrien#ifdef SMP
7378344Sobrien#define MAXCPU		16
7478344Sobrien#else
7598184Sgordon#define MAXCPU		1
7698184Sgordon#endif /* SMP */
7778344Sobrien
7878344Sobrien#define ALIGNBYTES	_ALIGNBYTES
7978344Sobrien#define ALIGN(p)	_ALIGN(p)
8078344Sobrien
8178344Sobrien#define PAGE_SHIFT	12		/* LOG2(PAGE_SIZE) */
8278344Sobrien#define PAGE_SIZE	(1<<PAGE_SHIFT)	/* bytes/page */
8378344Sobrien#define PAGE_MASK	(PAGE_SIZE-1)
8478344Sobrien#define NPTEPG		(PAGE_SIZE/(sizeof (pt_entry_t)))
8598184Sgordon
8698184Sgordon#ifdef PAE
8798184Sgordon#define NPGPTD		4
88102864Sgordon#define PDRSHIFT	21		/* LOG2(NBPDR) */
89102864Sgordon#else
90102864Sgordon#define NPGPTD		1
91102864Sgordon#define PDRSHIFT	22		/* LOG2(NBPDR) */
92102864Sgordon#endif
93102864Sgordon
94102864Sgordon#define NBPTD		(NPGPTD<<PAGE_SHIFT)
95102864Sgordon#define NPDEPTD		(NBPTD/(sizeof (pd_entry_t)))
96102864Sgordon#define NPDEPG		(PAGE_SIZE/(sizeof (pd_entry_t)))
97102864Sgordon#define NBPDR		(1<<PDRSHIFT)	/* bytes/page dir */
9898184Sgordon#define PDRMASK		(NBPDR-1)
9998184Sgordon
10098184Sgordon/* PREEMPTION exposes scheduler bugs that need to be fixed. */
101102864Sgordon#include "opt_sched.h"
102102864Sgordon#ifdef SCHED_4BSD
103102864Sgordon#define	PREEMPTION
104102864Sgordon#endif
105102864Sgordon
106102864Sgordon#define IOPAGES	2		/* pages of i/o permission bitmap */
10798184Sgordon
10898184Sgordon#ifndef KSTACK_PAGES
10998184Sgordon#define KSTACK_PAGES 2		/* Includes pcb! */
110102864Sgordon#endif
111102864Sgordon#define KSTACK_GUARD_PAGES 1	/* pages of kstack guard; 0 disables */
11298184Sgordon#define UAREA_PAGES 1		/* holds struct user WITHOUT PCB (see def.) */
11398184Sgordon
11498184Sgordon/*
11598184Sgordon * Ceiling on amount of swblock kva space, can be changed via
116 * the kern.maxswzone /boot/loader.conf variable.
117 */
118#ifndef VM_SWZONE_SIZE_MAX
119#define VM_SWZONE_SIZE_MAX	(32 * 1024 * 1024)
120#endif
121
122/*
123 * Ceiling on size of buffer cache (really only effects write queueing,
124 * the VM page cache is not effected), can be changed via
125 * the kern.maxbcache /boot/loader.conf variable.
126 */
127#ifndef VM_BCACHE_SIZE_MAX
128#define VM_BCACHE_SIZE_MAX	(200 * 1024 * 1024)
129#endif
130
131/*
132 * Mach derived conversion macros
133 */
134#define trunc_page(x)		((x) & ~PAGE_MASK)
135#define round_page(x)		(((x) + PAGE_MASK) & ~PAGE_MASK)
136#define trunc_4mpage(x)		((x) & ~PDRMASK)
137#define round_4mpage(x)		((((x)) + PDRMASK) & ~PDRMASK)
138
139#define atop(x)			((x) >> PAGE_SHIFT)
140#define ptoa(x)			((x) << PAGE_SHIFT)
141
142#define i386_btop(x)		((x) >> PAGE_SHIFT)
143#define i386_ptob(x)		((x) << PAGE_SHIFT)
144
145#define	pgtok(x)		((x) * (PAGE_SIZE / 1024))
146
147#endif /* !_MACHINE_PARAM_H_ */
148#endif /* !_NO_NAMESPACE_POLLUTION */
149