Home | History | Annotate | Line # | Download | only in include
      1 /* $NetBSD: pte.h,v 1.31 2012/02/06 02:14:13 matt Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 1998 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9  * NASA Ames Research Center.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  *
     20  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30  * POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 
     33 /*
     34  * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
     35  * All rights reserved.
     36  *
     37  * Author: Chris G. Demetriou
     38  *
     39  * Permission to use, copy, modify and distribute this software and
     40  * its documentation is hereby granted, provided that both the copyright
     41  * notice and this permission notice appear in all copies of the
     42  * software, derivative works or modified versions, and any portions
     43  * thereof, and that both notices appear in supporting documentation.
     44  *
     45  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     46  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     47  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     48  *
     49  * Carnegie Mellon requests users of this software to return to
     50  *
     51  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     52  *  School of Computer Science
     53  *  Carnegie Mellon University
     54  *  Pittsburgh PA 15213-3890
     55  *
     56  * any improvements or extensions that they make and grant Carnegie the
     57  * rights to redistribute these changes.
     58  */
     59 
     60 #ifndef _ALPHA_PTE_H_
     61 #define	_ALPHA_PTE_H_
     62 
     63 /*
     64  * Alpha page table entry.
     65  * Things which are in the VMS PALcode but not in the OSF PALcode
     66  * are marked with "(VMS)".
     67  *
     68  * This information derived from pp. (II) 3-3 - (II) 3-6 and
     69  * (III) 3-3 - (III) 3-5 of the "Alpha Architecture Reference Manual" by
     70  * Richard L. Sites.
     71  */
     72 
     73 /*
     74  * Alpha Page Table Entry
     75  */
     76 
     77 #include <machine/alpha_cpu.h>
     78 
     79 typedef	alpha_pt_entry_t	pt_entry_t;
     80 
     81 #define	PTESHIFT	3			/* pte size == 1 << PTESHIFT */
     82 
     83 #define	PG_V		ALPHA_PTE_VALID
     84 #define	PG_NV		0
     85 #define	PG_FOR		ALPHA_PTE_FAULT_ON_READ
     86 #define	PG_FOW		ALPHA_PTE_FAULT_ON_WRITE
     87 #define	PG_FOE		ALPHA_PTE_FAULT_ON_EXECUTE
     88 #define	PG_ASM		ALPHA_PTE_ASM
     89 #define	PG_GH		ALPHA_PTE_GRANULARITY
     90 #define	PG_KRE		ALPHA_PTE_KR
     91 #define	PG_URE		ALPHA_PTE_UR
     92 #define	PG_KWE		ALPHA_PTE_KW
     93 #define	PG_UWE		ALPHA_PTE_UW
     94 #define	PG_PROT		(ALPHA_PTE_PROT | PG_EXEC | PG_FOE)
     95 #define	PG_RSVD		0x000000000000cc80	/* Reserved for hardware */
     96 #define	PG_WIRED	0x0000000000010000	/* Wired. [SOFTWARE] */
     97 #define	PG_PVLIST	0x0000000000020000	/* on pv list [SOFTWARE] */
     98 #define	PG_EXEC		0x0000000000040000	/* execute perms [SOFTWARE] */
     99 #define	PG_FRAME	ALPHA_PTE_PFN
    100 #define	PG_SHIFT	32
    101 #define	PG_PFNUM(x)	ALPHA_PTE_TO_PFN(x)
    102 
    103 /*
    104  * These are the PALcode PTE bits that we care about when checking to see
    105  * if a PTE has changed in such a way as to require a TBI.
    106  */
    107 #define	PG_PALCODE(x)	((x) & ALPHA_PTE_PALCODE)
    108 
    109 #if defined(_KERNEL) || defined(__KVM_ALPHA_PRIVATE)
    110 #define	NPTEPG_SHIFT	(PAGE_SHIFT - PTESHIFT)
    111 #define	NPTEPG		(1L << NPTEPG_SHIFT)
    112 
    113 #define	PTEMASK		(NPTEPG - 1)
    114 
    115 #define	l3pte_index(va)	\
    116 	(((vaddr_t)(va) >> PAGE_SHIFT) & PTEMASK)
    117 
    118 #define	l2pte_index(va)	\
    119 	(((vaddr_t)(va) >> (PAGE_SHIFT + NPTEPG_SHIFT)) & PTEMASK)
    120 
    121 #define	l1pte_index(va) \
    122 	(((vaddr_t)(va) >> (PAGE_SHIFT + 2 * NPTEPG_SHIFT)) & PTEMASK)
    123 
    124 #define	VPT_INDEX(va)	\
    125 	(((vaddr_t)(va) >> PAGE_SHIFT) & ((1 << 3 * NPTEPG_SHIFT) - 1))
    126 
    127 /* Space mapped by one level 1 PTE */
    128 #define	ALPHA_L1SEG_SIZE	(1L << ((2 * NPTEPG_SHIFT) + PAGE_SHIFT))
    129 
    130 /* Space mapped by one level 2 PTE */
    131 #define	ALPHA_L2SEG_SIZE	(1L << (NPTEPG_SHIFT + PAGE_SHIFT))
    132 
    133 #define	alpha_trunc_l1seg(x)	(((u_long)(x)) & ~(ALPHA_L1SEG_SIZE-1))
    134 #define	alpha_trunc_l2seg(x)	(((u_long)(x)) & ~(ALPHA_L2SEG_SIZE-1))
    135 #endif /* _KERNEL || __KVM_ALPHA_PRIVATE */
    136 
    137 #ifdef _KERNEL
    138 extern	pt_entry_t *kernel_lev1map;	/* kernel level 1 page table */
    139 #endif /* _KERNEL */
    140 
    141 #endif /* ! _ALPHA_PTE_H_ */
    142