199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright (c) 2002 David E. O'Brien. All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright (c) 1992, 1993
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The Regents of the University of California. All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This code is derived from software contributed to Berkeley by
199767f8919635c4928607450d9e0abb932109ceToomas Soome * the Systems Programming Group of the University of Utah Computer
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Science Department and Ralph Campbell.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Redistribution and use in source and binary forms, with or without
199767f8919635c4928607450d9e0abb932109ceToomas Soome * modification, are permitted provided that the following conditions
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 1. Redistributions of source code must retain the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 2. Redistributions in binary form must reproduce the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer in the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * documentation and/or other materials provided with the distribution.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 3. All advertising materials mentioning features or use of this software
199767f8919635c4928607450d9e0abb932109ceToomas Soome * must display the following acknowledgement:
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This product includes software developed by the University of
199767f8919635c4928607450d9e0abb932109ceToomas Soome * California, Berkeley and its contributors.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 4. Neither the name of the University nor the names of its contributors
199767f8919635c4928607450d9e0abb932109ceToomas Soome * may be used to endorse or promote products derived from this software
199767f8919635c4928607450d9e0abb932109ceToomas Soome * without specific prior written permission.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
199767f8919635c4928607450d9e0abb932109ceToomas Soome * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
199767f8919635c4928607450d9e0abb932109ceToomas Soome * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
199767f8919635c4928607450d9e0abb932109ceToomas Soome * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
199767f8919635c4928607450d9e0abb932109ceToomas Soome * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
199767f8919635c4928607450d9e0abb932109ceToomas Soome * SUCH DAMAGE.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * @(#)param.h 8.1 (Berkeley) 6/10/93
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Machine dependent constants for AMD64.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * ALIGNED_POINTER is a boolean macro that checks whether an address
199767f8919635c4928607450d9e0abb932109ceToomas Soome * is valid to fetch data elements of type t from on this architecture.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This does not reflect the optimal alignment, just the possibility
199767f8919635c4928607450d9e0abb932109ceToomas Soome * (within reasonable limits).
199767f8919635c4928607450d9e0abb932109ceToomas Soome * CACHE_LINE_SIZE is the compile-time maximum cache line size for an
199767f8919635c4928607450d9e0abb932109ceToomas Soome * architecture. It should be used with appropriate caution.
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Size of the level 1 page table units */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define NPTEPG (PAGE_SIZE/(sizeof (pt_entry_t)))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define PAGE_SIZE (1<<PAGE_SHIFT) /* bytes/page */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Size of the level 2 page directory units */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define NPDEPG (PAGE_SIZE/(sizeof (pd_entry_t)))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define NBPDR (1<<PDRSHIFT) /* bytes/page dir */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Size of the level 3 page directory pointer table units */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define NPDPEPG (PAGE_SIZE/(sizeof (pdp_entry_t)))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define NBPDP (1<<PDPSHIFT) /* bytes/page dir ptr table */
199767f8919635c4928607450d9e0abb932109ceToomas Soome/* Size of the level 4 page-map level-4 table units */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define NPML4EPG (PAGE_SIZE/(sizeof (pml4_entry_t)))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define NBPML4 (1UL<<PML4SHIFT)/* bytes/page map lev4 table */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define MAXPAGESIZES 3 /* maximum number of supported page sizes */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IOPAGES 2 /* pages of i/o permission bitmap */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * I/O permission bitmap has a bit for each I/O port plus an additional
199767f8919635c4928607450d9e0abb932109ceToomas Soome * byte at the end with all bits set. See section "I/O Permission Bit Map"
199767f8919635c4928607450d9e0abb932109ceToomas Soome * in the Intel SDM for more details.
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define IOPERM_BITMAP_SIZE (IOPAGES * PAGE_SIZE + 1)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define KSTACK_PAGES 4 /* pages of kstack (with pcb) */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define KSTACK_GUARD_PAGES 1 /* pages of kstack guard; 0 disables */
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Mach derived conversion macros
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define round_page(x) ((((unsigned long)(x)) + PAGE_MASK) & ~(PAGE_MASK))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define trunc_page(x) ((unsigned long)(x) & ~(PAGE_MASK))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define trunc_2mpage(x) ((unsigned long)(x) & ~PDRMASK)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define round_2mpage(x) ((((unsigned long)(x)) + PDRMASK) & ~PDRMASK)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define trunc_1gpage(x) ((unsigned long)(x) & ~PDPMASK)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define atop(x) ((unsigned long)(x) >> PAGE_SHIFT)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define ptoa(x) ((unsigned long)(x) << PAGE_SHIFT)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define amd64_btop(x) ((unsigned long)(x) >> PAGE_SHIFT)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define amd64_ptob(x) ((unsigned long)(x) << PAGE_SHIFT)
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define INKERNEL(va) (((va) >= DMAP_MIN_ADDRESS && (va) < DMAP_MAX_ADDRESS) \
199767f8919635c4928607450d9e0abb932109ceToomas Soome || ((va) >= VM_MIN_KERNEL_ADDRESS && (va) < VM_MAX_KERNEL_ADDRESS))
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* !_AMD64_INCLUDE_PARAM_H_ */