param.h revision 197316
1139731Simp/*-
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 197316 2009-09-18 17:04:57Z alc $
4099123Sobrien */
4199123Sobrien
42196994Sphk
43196968Sphk#ifndef _AMD64_INCLUDE_PARAM_H_
44196968Sphk#define	_AMD64_INCLUDE_PARAM_H_
45196968Sphk
46196994Sphk#include <machine/_align.h>
47196994Sphk
4899123Sobrien/*
49114349Speter * Machine dependent constants for AMD64.
5099123Sobrien */
5199123Sobrien
5299123Sobrien
53154128Simp#define __HAVE_ACPI
54154128Simp#define __PCI_REROUTE_INTERRUPT
55154128Simp
5699123Sobrien#ifndef MACHINE
57114346Speter#define	MACHINE		"amd64"
5899123Sobrien#endif
5999123Sobrien#ifndef MACHINE_ARCH
60114346Speter#define	MACHINE_ARCH	"amd64"
6199123Sobrien#endif
6299123Sobrien
63177661Sjb#if defined(SMP) || defined(KLD_MODULE)
64183525Sjhb#define MAXCPU		32
65122849Speter#else
6699123Sobrien#define MAXCPU		1
67122849Speter#endif
6899123Sobrien
6999123Sobrien#define	ALIGNBYTES		_ALIGNBYTES
7099123Sobrien#define	ALIGN(p)		_ALIGN(p)
71195376Ssam/*
72195376Ssam * ALIGNED_POINTER is a boolean macro that checks whether an address
73195376Ssam * is valid to fetch data elements of type t from on this architecture.
74195376Ssam * This does not reflect the optimal alignment, just the possibility
75195376Ssam * (within reasonable limits).
76195376Ssam */
77195376Ssam#define	ALIGNED_POINTER(p, t)	1
7899123Sobrien
79191278Srwatson/*
80191278Srwatson * CACHE_LINE_SIZE is the compile-time maximum cache line size for an
81191278Srwatson * architecture.  It should be used with appropriate caution.
82191278Srwatson */
83192331Sjhb#define	CACHE_LINE_SHIFT	7
84191276Srwatson#define	CACHE_LINE_SIZE		(1 << CACHE_LINE_SHIFT)
85115251Speter
86114349Speter/* Size of the level 1 page table units */
87114349Speter#define NPTEPG		(PAGE_SIZE/(sizeof (pt_entry_t)))
88115251Speter#define	NPTEPGSHIFT	9		/* LOG2(NPTEPG) */
8999123Sobrien#define PAGE_SHIFT	12		/* LOG2(PAGE_SIZE) */
9099123Sobrien#define PAGE_SIZE	(1<<PAGE_SHIFT)	/* bytes/page */
9199123Sobrien#define PAGE_MASK	(PAGE_SIZE-1)
92114349Speter/* Size of the level 2 page directory units */
93114349Speter#define	NPDEPG		(PAGE_SIZE/(sizeof (pd_entry_t)))
94115251Speter#define	NPDEPGSHIFT	9		/* LOG2(NPDEPG) */
95114349Speter#define	PDRSHIFT	21              /* LOG2(NBPDR) */
96114349Speter#define	NBPDR		(1<<PDRSHIFT)   /* bytes/page dir */
97114349Speter#define	PDRMASK		(NBPDR-1)
98114349Speter/* Size of the level 3 page directory pointer table units */
99114349Speter#define	NPDPEPG		(PAGE_SIZE/(sizeof (pdp_entry_t)))
100115251Speter#define	NPDPEPGSHIFT	9		/* LOG2(NPDPEPG) */
101114349Speter#define	PDPSHIFT	30		/* LOG2(NBPDP) */
102114349Speter#define	NBPDP		(1<<PDPSHIFT)	/* bytes/page dir ptr table */
103114349Speter#define	PDPMASK		(NBPDP-1)
104114349Speter/* Size of the level 4 page-map level-4 table units */
105114349Speter#define	NPML4EPG	(PAGE_SIZE/(sizeof (pml4_entry_t)))
106115251Speter#define	NPML4EPGSHIFT	9		/* LOG2(NPML4EPG) */
107130218Speter#define	PML4SHIFT	39		/* LOG2(NBPML4) */
108130218Speter#define	NBPML4		(1ul<<PML4SHIFT)/* bytes/page map lev4 table */
109130218Speter#define	PML4MASK	(NBPML4-1)
11099123Sobrien
111197316Salc#define	MAXPAGESIZES	3	/* maximum number of supported page sizes */
112197316Salc
11399123Sobrien#define IOPAGES	2		/* pages of i/o permission bitmap */
11499123Sobrien
115118236Speter#ifndef	KSTACK_PAGES
116114349Speter#define	KSTACK_PAGES	4	/* pages of kstack (with pcb) */
117118236Speter#endif
118116355Salc#define	KSTACK_GUARD_PAGES 1	/* pages of kstack guard; 0 disables */
11999123Sobrien
12099123Sobrien/*
121114349Speter * Ceiling on amount of swblock kva space, can be changed via
122114349Speter * the kern.maxswzone /boot/loader.conf variable.
123114349Speter */
124114349Speter#ifndef VM_SWZONE_SIZE_MAX
125114349Speter#define	VM_SWZONE_SIZE_MAX	(32 * 1024 * 1024)
126114349Speter#endif
127114349Speter
128114349Speter/*
12999123Sobrien * Mach derived conversion macros
13099123Sobrien */
13199123Sobrien#define	round_page(x)	((((unsigned long)(x)) + PAGE_MASK) & ~(PAGE_MASK))
13299123Sobrien#define	trunc_page(x)	((unsigned long)(x) & ~(PAGE_MASK))
133114349Speter#define trunc_2mpage(x)	((unsigned long)(x) & ~PDRMASK)
134114349Speter#define round_2mpage(x)	((((unsigned long)(x)) + PDRMASK) & ~PDRMASK)
135181112Salc#define trunc_1gpage(x)	((unsigned long)(x) & ~PDPMASK)
13699123Sobrien
13799123Sobrien#define	atop(x)		((unsigned long)(x) >> PAGE_SHIFT)
13899123Sobrien#define	ptoa(x)		((unsigned long)(x) << PAGE_SHIFT)
13999123Sobrien
140114346Speter#define	amd64_btop(x)	((unsigned long)(x) >> PAGE_SHIFT)
141114346Speter#define	amd64_ptob(x)	((unsigned long)(x) << PAGE_SHIFT)
14299123Sobrien
143114349Speter#define	pgtok(x)	((unsigned long)(x) * (PAGE_SIZE / 1024))
14499123Sobrien
145196968Sphk#endif /* !_AMD64_INCLUDE_PARAM_H_ */
146