param.h revision 122849
199123Sobrien/*
299123Sobrien * Copyright (c) 2002 David E. O'Brien.  All rights reserved.
399123Sobrien * Copyright (c) 1992, 1993
499123Sobrien *	The Regents of the University of California.  All rights reserved.
599123Sobrien *
699123Sobrien * This code is derived from software contributed to Berkeley by
799123Sobrien * the Systems Programming Group of the University of Utah Computer
899123Sobrien * Science Department and Ralph Campbell.
999123Sobrien *
1099123Sobrien * Redistribution and use in source and binary forms, with or without
1199123Sobrien * modification, are permitted provided that the following conditions
1299123Sobrien * are met:
1399123Sobrien * 1. Redistributions of source code must retain the above copyright
1499123Sobrien *    notice, this list of conditions and the following disclaimer.
1599123Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1699123Sobrien *    notice, this list of conditions and the following disclaimer in the
1799123Sobrien *    documentation and/or other materials provided with the distribution.
1899123Sobrien * 3. All advertising materials mentioning features or use of this software
1999123Sobrien *    must display the following acknowledgement:
2099123Sobrien *	This product includes software developed by the University of
2199123Sobrien *	California, Berkeley and its contributors.
2299123Sobrien * 4. Neither the name of the University nor the names of its contributors
2399123Sobrien *    may be used to endorse or promote products derived from this software
2499123Sobrien *    without specific prior written permission.
2599123Sobrien *
2699123Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2799123Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2899123Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2999123Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3099123Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3199123Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3299123Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3399123Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3499123Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3599123Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3699123Sobrien * SUCH DAMAGE.
3799123Sobrien *
3899123Sobrien *	@(#)param.h	8.1 (Berkeley) 6/10/93
3999123Sobrien * $FreeBSD: head/sys/amd64/include/param.h 122849 2003-11-17 08:58:16Z peter $
4099123Sobrien */
4199123Sobrien
4299123Sobrien/*
43114349Speter * Machine dependent constants for AMD64.
4499123Sobrien */
4599123Sobrien
4699123Sobrien/*
4799123Sobrien * Round p (pointer or byte index) up to a correctly-aligned value
4899123Sobrien * for all data types (int, long, ...).   The result is u_long and
4999123Sobrien * must be cast to any desired pointer type.
5099123Sobrien *
5199123Sobrien * ALIGNED_POINTER is a boolean macro that checks whether an address
5299123Sobrien * is valid to fetch data elements of type t from on this architecture.
5399123Sobrien * This does not reflect the optimal alignment, just the possibility
5499123Sobrien * (within reasonable limits).
5599123Sobrien *
5699123Sobrien */
5799123Sobrien#ifndef _ALIGNBYTES
58114349Speter#define	_ALIGNBYTES	(sizeof(long) - 1)
5999123Sobrien#endif
6099123Sobrien#ifndef _ALIGN
6199123Sobrien#define	_ALIGN(p)	(((u_long)(p) + _ALIGNBYTES) &~ _ALIGNBYTES)
6299123Sobrien#endif
6399123Sobrien#ifndef _ALIGNED_POINTER
6499123Sobrien#define	_ALIGNED_POINTER(p,t)	((((u_long)(p)) & (sizeof(t)-1)) == 0)
6599123Sobrien#endif
6699123Sobrien
6799123Sobrien#ifndef _MACHINE
68114346Speter#define	_MACHINE	amd64
6999123Sobrien#endif
7099123Sobrien#ifndef _MACHINE_ARCH
71114346Speter#define	_MACHINE_ARCH	amd64
7299123Sobrien#endif
7399123Sobrien
7499123Sobrien#ifndef _NO_NAMESPACE_POLLUTION
7599123Sobrien
7699123Sobrien#ifndef _MACHINE_PARAM_H_
7799123Sobrien#define	_MACHINE_PARAM_H_
7899123Sobrien
7999123Sobrien#ifndef MACHINE
80114346Speter#define	MACHINE		"amd64"
8199123Sobrien#endif
8299123Sobrien#ifndef MACHINE_ARCH
83114346Speter#define	MACHINE_ARCH	"amd64"
8499123Sobrien#endif
8599123Sobrien
86122849Speter#ifdef SMP
87122849Speter#define MAXCPU		8
88122849Speter#else
8999123Sobrien#define MAXCPU		1
90122849Speter#endif
9199123Sobrien
9299123Sobrien#define	ALIGNBYTES		_ALIGNBYTES
9399123Sobrien#define	ALIGN(p)		_ALIGN(p)
94115795Speter#define	ALIGNED_POINTER(p,t)	_ALIGNED_POINTER(p,t)
9599123Sobrien
96115251Speter
97114349Speter/* Size of the level 1 page table units */
98114349Speter#define NPTEPG		(PAGE_SIZE/(sizeof (pt_entry_t)))
99115251Speter#define	NPTEPGSHIFT	9		/* LOG2(NPTEPG) */
10099123Sobrien#define PAGE_SHIFT	12		/* LOG2(PAGE_SIZE) */
10199123Sobrien#define PAGE_SIZE	(1<<PAGE_SHIFT)	/* bytes/page */
10299123Sobrien#define PAGE_MASK	(PAGE_SIZE-1)
103114349Speter/* Size of the level 2 page directory units */
104114349Speter#define	NPDEPG		(PAGE_SIZE/(sizeof (pd_entry_t)))
105115251Speter#define	NPDEPGSHIFT	9		/* LOG2(NPDEPG) */
106114349Speter#define	PDRSHIFT	21              /* LOG2(NBPDR) */
107114349Speter#define	NBPDR		(1<<PDRSHIFT)   /* bytes/page dir */
108114349Speter#define	PDRMASK		(NBPDR-1)
109114349Speter/* Size of the level 3 page directory pointer table units */
110114349Speter#define	NPDPEPG		(PAGE_SIZE/(sizeof (pdp_entry_t)))
111115251Speter#define	NPDPEPGSHIFT	9		/* LOG2(NPDPEPG) */
112114349Speter#define	PDPSHIFT	30		/* LOG2(NBPDP) */
113114349Speter#define	NBPDP		(1<<PDPSHIFT)	/* bytes/page dir ptr table */
114114349Speter#define	PDPMASK		(NBPDP-1)
115114349Speter/* Size of the level 4 page-map level-4 table units */
116114349Speter#define	NPML4EPG	(PAGE_SIZE/(sizeof (pml4_entry_t)))
117115251Speter#define	NPML4EPGSHIFT	9		/* LOG2(NPML4EPG) */
118114349Speter#define	PML4SHIFT	39		/* LOG2(NBPML4T) */
119114349Speter#define	NBPML4T		(1ul<<PML4SHIFT)/* bytes/page map lev4 table */
120114349Speter#define	PML4MASK	(NBPML4T-1)
12199123Sobrien
12299123Sobrien#define IOPAGES	2		/* pages of i/o permission bitmap */
12399123Sobrien
124118236Speter#ifndef	KSTACK_PAGES
125114349Speter#define	KSTACK_PAGES	4	/* pages of kstack (with pcb) */
126118236Speter#endif
127116355Salc#define	KSTACK_GUARD_PAGES 1	/* pages of kstack guard; 0 disables */
12899123Sobrien#define UAREA_PAGES	1	/* holds struct user WITHOUT PCB (see def.) */
12999123Sobrien
13099123Sobrien
13199123Sobrien/*
132114349Speter * Ceiling on amount of swblock kva space, can be changed via
133114349Speter * the kern.maxswzone /boot/loader.conf variable.
134114349Speter */
135114349Speter#ifndef VM_SWZONE_SIZE_MAX
136114349Speter#define	VM_SWZONE_SIZE_MAX	(32 * 1024 * 1024)
137114349Speter#endif
138114349Speter
139114349Speter/*
140114349Speter * Ceiling on size of buffer cache (really only effects write queueing,
141114349Speter * the VM page cache is not effected), can be changed via
142114349Speter * the kern.maxbcache /boot/loader.conf variable.
143114349Speter */
144114349Speter#ifndef VM_BCACHE_SIZE_MAX
145114349Speter#define	VM_BCACHE_SIZE_MAX	(200 * 1024 * 1024)
146114349Speter#endif
147114349Speter
148114349Speter/*
14999123Sobrien * Mach derived conversion macros
15099123Sobrien */
15199123Sobrien#define	round_page(x)	((((unsigned long)(x)) + PAGE_MASK) & ~(PAGE_MASK))
15299123Sobrien#define	trunc_page(x)	((unsigned long)(x) & ~(PAGE_MASK))
153114349Speter#define trunc_2mpage(x)	((unsigned long)(x) & ~PDRMASK)
154114349Speter#define round_2mpage(x)	((((unsigned long)(x)) + PDRMASK) & ~PDRMASK)
15599123Sobrien
15699123Sobrien#define	atop(x)		((unsigned long)(x) >> PAGE_SHIFT)
15799123Sobrien#define	ptoa(x)		((unsigned long)(x) << PAGE_SHIFT)
15899123Sobrien
159114346Speter#define	amd64_btop(x)	((unsigned long)(x) >> PAGE_SHIFT)
160114346Speter#define	amd64_ptob(x)	((unsigned long)(x) << PAGE_SHIFT)
16199123Sobrien
162114349Speter#define	pgtok(x)	((unsigned long)(x) * (PAGE_SIZE / 1024))
16399123Sobrien
16499123Sobrien#endif /* !_MACHINE_PARAM_H_ */
16599123Sobrien#endif /* !_NO_NAMESPACE_POLLUTION */
166