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 68284720Skib#define MAXCPU 64 69224207Sattilio#endif 70122849Speter#else 7199123Sobrien#define MAXCPU 1 72122849Speter#endif 7399123Sobrien 74250338Sattilio#ifndef MAXMEMDOM 75250338Sattilio#define MAXMEMDOM 1 76250338Sattilio#endif 77250338Sattilio 7899123Sobrien#define ALIGNBYTES _ALIGNBYTES 7999123Sobrien#define ALIGN(p) _ALIGN(p) 80195376Ssam/* 81195376Ssam * ALIGNED_POINTER is a boolean macro that checks whether an address 82195376Ssam * is valid to fetch data elements of type t from on this architecture. 83195376Ssam * This does not reflect the optimal alignment, just the possibility 84195376Ssam * (within reasonable limits). 85195376Ssam */ 86195376Ssam#define ALIGNED_POINTER(p, t) 1 8799123Sobrien 88191278Srwatson/* 89191278Srwatson * CACHE_LINE_SIZE is the compile-time maximum cache line size for an 90191278Srwatson * architecture. It should be used with appropriate caution. 91191278Srwatson */ 92192331Sjhb#define CACHE_LINE_SHIFT 7 93191276Srwatson#define CACHE_LINE_SIZE (1 << CACHE_LINE_SHIFT) 94115251Speter 95114349Speter/* Size of the level 1 page table units */ 96114349Speter#define NPTEPG (PAGE_SIZE/(sizeof (pt_entry_t))) 97115251Speter#define NPTEPGSHIFT 9 /* LOG2(NPTEPG) */ 9899123Sobrien#define PAGE_SHIFT 12 /* LOG2(PAGE_SIZE) */ 9999123Sobrien#define PAGE_SIZE (1<<PAGE_SHIFT) /* bytes/page */ 10099123Sobrien#define PAGE_MASK (PAGE_SIZE-1) 101114349Speter/* Size of the level 2 page directory units */ 102114349Speter#define NPDEPG (PAGE_SIZE/(sizeof (pd_entry_t))) 103115251Speter#define NPDEPGSHIFT 9 /* LOG2(NPDEPG) */ 104114349Speter#define PDRSHIFT 21 /* LOG2(NBPDR) */ 105114349Speter#define NBPDR (1<<PDRSHIFT) /* bytes/page dir */ 106114349Speter#define PDRMASK (NBPDR-1) 107114349Speter/* Size of the level 3 page directory pointer table units */ 108114349Speter#define NPDPEPG (PAGE_SIZE/(sizeof (pdp_entry_t))) 109115251Speter#define NPDPEPGSHIFT 9 /* LOG2(NPDPEPG) */ 110114349Speter#define PDPSHIFT 30 /* LOG2(NBPDP) */ 111114349Speter#define NBPDP (1<<PDPSHIFT) /* bytes/page dir ptr table */ 112114349Speter#define PDPMASK (NBPDP-1) 113114349Speter/* Size of the level 4 page-map level-4 table units */ 114114349Speter#define NPML4EPG (PAGE_SIZE/(sizeof (pml4_entry_t))) 115115251Speter#define NPML4EPGSHIFT 9 /* LOG2(NPML4EPG) */ 116130218Speter#define PML4SHIFT 39 /* LOG2(NBPML4) */ 117199319Sphk#define NBPML4 (1UL<<PML4SHIFT)/* bytes/page map lev4 table */ 118130218Speter#define PML4MASK (NBPML4-1) 11999123Sobrien 120197316Salc#define MAXPAGESIZES 3 /* maximum number of supported page sizes */ 121197316Salc 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 12999123Sobrien/* 13099123Sobrien * Mach derived conversion macros 13199123Sobrien */ 13299123Sobrien#define round_page(x) ((((unsigned long)(x)) + PAGE_MASK) & ~(PAGE_MASK)) 13399123Sobrien#define trunc_page(x) ((unsigned long)(x) & ~(PAGE_MASK)) 134114349Speter#define trunc_2mpage(x) ((unsigned long)(x) & ~PDRMASK) 135114349Speter#define round_2mpage(x) ((((unsigned long)(x)) + PDRMASK) & ~PDRMASK) 136181112Salc#define trunc_1gpage(x) ((unsigned long)(x) & ~PDPMASK) 13799123Sobrien 13899123Sobrien#define atop(x) ((unsigned long)(x) >> PAGE_SHIFT) 13999123Sobrien#define ptoa(x) ((unsigned long)(x) << PAGE_SHIFT) 14099123Sobrien 141114346Speter#define amd64_btop(x) ((unsigned long)(x) >> PAGE_SHIFT) 142114346Speter#define amd64_ptob(x) ((unsigned long)(x) << PAGE_SHIFT) 14399123Sobrien 144114349Speter#define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024)) 14599123Sobrien 146286305Skib#define INKERNEL(va) (((va) >= DMAP_MIN_ADDRESS && (va) < DMAP_MAX_ADDRESS) \ 147286305Skib || ((va) >= VM_MIN_KERNEL_ADDRESS && (va) < VM_MAX_KERNEL_ADDRESS)) 148286305Skib 149196968Sphk#endif /* !_AMD64_INCLUDE_PARAM_H_ */ 150