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