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$ 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 62210369Skib#ifndef MACHINE_ARCH32 63210369Skib#define MACHINE_ARCH32 "i386" 64210369Skib#endif 6599123Sobrien 66177661Sjb#if defined(SMP) || defined(KLD_MODULE) 67224207Sattilio#ifndef MAXCPU 68224217Sattilio#define MAXCPU 64 69224207Sattilio#endif 70122849Speter#else 7199123Sobrien#define MAXCPU 1 72122849Speter#endif 7399123Sobrien 7499123Sobrien#define ALIGNBYTES _ALIGNBYTES 7599123Sobrien#define ALIGN(p) _ALIGN(p) 76195376Ssam/* 77195376Ssam * ALIGNED_POINTER is a boolean macro that checks whether an address 78195376Ssam * is valid to fetch data elements of type t from on this architecture. 79195376Ssam * This does not reflect the optimal alignment, just the possibility 80195376Ssam * (within reasonable limits). 81195376Ssam */ 82195376Ssam#define ALIGNED_POINTER(p, t) 1 8399123Sobrien 84191278Srwatson/* 85191278Srwatson * CACHE_LINE_SIZE is the compile-time maximum cache line size for an 86191278Srwatson * architecture. It should be used with appropriate caution. 87191278Srwatson */ 88192331Sjhb#define CACHE_LINE_SHIFT 7 89191276Srwatson#define CACHE_LINE_SIZE (1 << CACHE_LINE_SHIFT) 90115251Speter 91114349Speter/* Size of the level 1 page table units */ 92114349Speter#define NPTEPG (PAGE_SIZE/(sizeof (pt_entry_t))) 93115251Speter#define NPTEPGSHIFT 9 /* LOG2(NPTEPG) */ 9499123Sobrien#define PAGE_SHIFT 12 /* LOG2(PAGE_SIZE) */ 9599123Sobrien#define PAGE_SIZE (1<<PAGE_SHIFT) /* bytes/page */ 9699123Sobrien#define PAGE_MASK (PAGE_SIZE-1) 97114349Speter/* Size of the level 2 page directory units */ 98114349Speter#define NPDEPG (PAGE_SIZE/(sizeof (pd_entry_t))) 99115251Speter#define NPDEPGSHIFT 9 /* LOG2(NPDEPG) */ 100114349Speter#define PDRSHIFT 21 /* LOG2(NBPDR) */ 101114349Speter#define NBPDR (1<<PDRSHIFT) /* bytes/page dir */ 102114349Speter#define PDRMASK (NBPDR-1) 103114349Speter/* Size of the level 3 page directory pointer table units */ 104114349Speter#define NPDPEPG (PAGE_SIZE/(sizeof (pdp_entry_t))) 105115251Speter#define NPDPEPGSHIFT 9 /* LOG2(NPDPEPG) */ 106114349Speter#define PDPSHIFT 30 /* LOG2(NBPDP) */ 107114349Speter#define NBPDP (1<<PDPSHIFT) /* bytes/page dir ptr table */ 108114349Speter#define PDPMASK (NBPDP-1) 109114349Speter/* Size of the level 4 page-map level-4 table units */ 110114349Speter#define NPML4EPG (PAGE_SIZE/(sizeof (pml4_entry_t))) 111115251Speter#define NPML4EPGSHIFT 9 /* LOG2(NPML4EPG) */ 112130218Speter#define PML4SHIFT 39 /* LOG2(NBPML4) */ 113199319Sphk#define NBPML4 (1UL<<PML4SHIFT)/* bytes/page map lev4 table */ 114130218Speter#define PML4MASK (NBPML4-1) 11599123Sobrien 116197316Salc#define MAXPAGESIZES 3 /* maximum number of supported page sizes */ 117197316Salc 11899123Sobrien#define IOPAGES 2 /* pages of i/o permission bitmap */ 11999123Sobrien 120118236Speter#ifndef KSTACK_PAGES 121114349Speter#define KSTACK_PAGES 4 /* pages of kstack (with pcb) */ 122118236Speter#endif 123116355Salc#define KSTACK_GUARD_PAGES 1 /* pages of kstack guard; 0 disables */ 12499123Sobrien 12599123Sobrien/* 12699123Sobrien * Mach derived conversion macros 12799123Sobrien */ 12899123Sobrien#define round_page(x) ((((unsigned long)(x)) + PAGE_MASK) & ~(PAGE_MASK)) 12999123Sobrien#define trunc_page(x) ((unsigned long)(x) & ~(PAGE_MASK)) 130114349Speter#define trunc_2mpage(x) ((unsigned long)(x) & ~PDRMASK) 131114349Speter#define round_2mpage(x) ((((unsigned long)(x)) + PDRMASK) & ~PDRMASK) 132181112Salc#define trunc_1gpage(x) ((unsigned long)(x) & ~PDPMASK) 13399123Sobrien 13499123Sobrien#define atop(x) ((unsigned long)(x) >> PAGE_SHIFT) 13599123Sobrien#define ptoa(x) ((unsigned long)(x) << PAGE_SHIFT) 13699123Sobrien 137114346Speter#define amd64_btop(x) ((unsigned long)(x) >> PAGE_SHIFT) 138114346Speter#define amd64_ptob(x) ((unsigned long)(x) << PAGE_SHIFT) 13999123Sobrien 140114349Speter#define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024)) 14199123Sobrien 142196968Sphk#endif /* !_AMD64_INCLUDE_PARAM_H_ */ 143