param.h revision 191278
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 191278 2009-04-19 21:26:36Z rwatson $ 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 _NO_NAMESPACE_POLLUTION 6899123Sobrien 69154128Simp#define __HAVE_ACPI 70154128Simp#define __PCI_REROUTE_INTERRUPT 71154128Simp 7299123Sobrien#ifndef _MACHINE_PARAM_H_ 7399123Sobrien#define _MACHINE_PARAM_H_ 7499123Sobrien 7599123Sobrien#ifndef MACHINE 76114346Speter#define MACHINE "amd64" 7799123Sobrien#endif 7899123Sobrien#ifndef MACHINE_ARCH 79114346Speter#define MACHINE_ARCH "amd64" 8099123Sobrien#endif 8199123Sobrien 82177661Sjb#if defined(SMP) || defined(KLD_MODULE) 83183525Sjhb#define MAXCPU 32 84122849Speter#else 8599123Sobrien#define MAXCPU 1 86122849Speter#endif 8799123Sobrien 8899123Sobrien#define ALIGNBYTES _ALIGNBYTES 8999123Sobrien#define ALIGN(p) _ALIGN(p) 90115795Speter#define ALIGNED_POINTER(p,t) _ALIGNED_POINTER(p,t) 9199123Sobrien 92191278Srwatson/* 93191278Srwatson * CACHE_LINE_SIZE is the compile-time maximum cache line size for an 94191278Srwatson * architecture. It should be used with appropriate caution. 95191278Srwatson */ 96191276Srwatson#ifndef CACHE_LINE_SHIFT 97191276Srwatson#define CACHE_LINE_SHIFT 6 98191276Srwatson#endif 99191276Srwatson#define CACHE_LINE_SIZE (1 << CACHE_LINE_SHIFT) 100115251Speter 101114349Speter/* Size of the level 1 page table units */ 102114349Speter#define NPTEPG (PAGE_SIZE/(sizeof (pt_entry_t))) 103115251Speter#define NPTEPGSHIFT 9 /* LOG2(NPTEPG) */ 10499123Sobrien#define PAGE_SHIFT 12 /* LOG2(PAGE_SIZE) */ 10599123Sobrien#define PAGE_SIZE (1<<PAGE_SHIFT) /* bytes/page */ 10699123Sobrien#define PAGE_MASK (PAGE_SIZE-1) 107114349Speter/* Size of the level 2 page directory units */ 108114349Speter#define NPDEPG (PAGE_SIZE/(sizeof (pd_entry_t))) 109115251Speter#define NPDEPGSHIFT 9 /* LOG2(NPDEPG) */ 110114349Speter#define PDRSHIFT 21 /* LOG2(NBPDR) */ 111114349Speter#define NBPDR (1<<PDRSHIFT) /* bytes/page dir */ 112114349Speter#define PDRMASK (NBPDR-1) 113114349Speter/* Size of the level 3 page directory pointer table units */ 114114349Speter#define NPDPEPG (PAGE_SIZE/(sizeof (pdp_entry_t))) 115115251Speter#define NPDPEPGSHIFT 9 /* LOG2(NPDPEPG) */ 116114349Speter#define PDPSHIFT 30 /* LOG2(NBPDP) */ 117114349Speter#define NBPDP (1<<PDPSHIFT) /* bytes/page dir ptr table */ 118114349Speter#define PDPMASK (NBPDP-1) 119114349Speter/* Size of the level 4 page-map level-4 table units */ 120114349Speter#define NPML4EPG (PAGE_SIZE/(sizeof (pml4_entry_t))) 121115251Speter#define NPML4EPGSHIFT 9 /* LOG2(NPML4EPG) */ 122130218Speter#define PML4SHIFT 39 /* LOG2(NBPML4) */ 123130218Speter#define NBPML4 (1ul<<PML4SHIFT)/* bytes/page map lev4 table */ 124130218Speter#define PML4MASK (NBPML4-1) 12599123Sobrien 12699123Sobrien#define IOPAGES 2 /* pages of i/o permission bitmap */ 12799123Sobrien 128118236Speter#ifndef KSTACK_PAGES 129114349Speter#define KSTACK_PAGES 4 /* pages of kstack (with pcb) */ 130118236Speter#endif 131116355Salc#define KSTACK_GUARD_PAGES 1 /* pages of kstack guard; 0 disables */ 13299123Sobrien 13399123Sobrien/* 134114349Speter * Ceiling on amount of swblock kva space, can be changed via 135114349Speter * the kern.maxswzone /boot/loader.conf variable. 136114349Speter */ 137114349Speter#ifndef VM_SWZONE_SIZE_MAX 138114349Speter#define VM_SWZONE_SIZE_MAX (32 * 1024 * 1024) 139114349Speter#endif 140114349Speter 141114349Speter/* 142114349Speter * Ceiling on size of buffer cache (really only effects write queueing, 143114349Speter * the VM page cache is not effected), can be changed via 144114349Speter * the kern.maxbcache /boot/loader.conf variable. 145114349Speter */ 146114349Speter#ifndef VM_BCACHE_SIZE_MAX 147180623Salc#define VM_BCACHE_SIZE_MAX (1024 * 1024 * 1024) 148114349Speter#endif 149114349Speter 150114349Speter/* 15199123Sobrien * Mach derived conversion macros 15299123Sobrien */ 15399123Sobrien#define round_page(x) ((((unsigned long)(x)) + PAGE_MASK) & ~(PAGE_MASK)) 15499123Sobrien#define trunc_page(x) ((unsigned long)(x) & ~(PAGE_MASK)) 155114349Speter#define trunc_2mpage(x) ((unsigned long)(x) & ~PDRMASK) 156114349Speter#define round_2mpage(x) ((((unsigned long)(x)) + PDRMASK) & ~PDRMASK) 157181112Salc#define trunc_1gpage(x) ((unsigned long)(x) & ~PDPMASK) 15899123Sobrien 15999123Sobrien#define atop(x) ((unsigned long)(x) >> PAGE_SHIFT) 16099123Sobrien#define ptoa(x) ((unsigned long)(x) << PAGE_SHIFT) 16199123Sobrien 162114346Speter#define amd64_btop(x) ((unsigned long)(x) >> PAGE_SHIFT) 163114346Speter#define amd64_ptob(x) ((unsigned long)(x) << PAGE_SHIFT) 16499123Sobrien 165114349Speter#define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024)) 16699123Sobrien 16799123Sobrien#endif /* !_MACHINE_PARAM_H_ */ 16899123Sobrien#endif /* !_NO_NAMESPACE_POLLUTION */ 169