1 /* $NetBSD: pte.h,v 1.5 1996/07/09 00:39:30 cgd Exp $ */ 2 3 /* 4 * Copyright (c) 1994, 1995 Carnegie-Mellon University. 5 * All rights reserved. 6 * 7 * Author: Chris G. Demetriou 8 * 9 * Permission to use, copy, modify and distribute this software and 10 * its documentation is hereby granted, provided that both the copyright 11 * notice and this permission notice appear in all copies of the 12 * software, derivative works or modified versions, and any portions 13 * thereof, and that both notices appear in supporting documentation. 14 * 15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 18 * 19 * Carnegie Mellon requests users of this software to return to 20 * 21 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU 22 * School of Computer Science 23 * Carnegie Mellon University 24 * Pittsburgh PA 15213-3890 25 * 26 * any improvements or extensions that they make and grant Carnegie the 27 * rights to redistribute these changes. 28 */ 29 30 /* 31 * Alpha page table entry. 32 * Things which are in the VMS PALcode but not in the OSF PALcode 33 * are marked with "(VMS)". 34 * 35 * This information derived from pp. (II) 3-3 - (II) 3-6 and 36 * (III) 3-3 - (III) 3-5 of the "Alpha Architecture Reference Manual" by 37 * Richard L. Sites. 38 */ 39 40 /* 41 * Alpha Page Table Entry 42 */ 43 44 #include <machine/alpha_cpu.h> 45 46 typedef alpha_pt_entry_t pt_entry_t; 47 48 #define PT_ENTRY_NULL ((pt_entry_t *) 0) 49 #define PTESHIFT 3 /* pte size == 1 << PTESHIFT */ 50 51 #define PG_V ALPHA_PTE_VALID 52 #define PG_NV 0 53 #define PG_FOR ALPHA_PTE_FAULT_ON_READ 54 #define PG_FOW ALPHA_PTE_FAULT_ON_WRITE 55 #define PG_FOE ALPHA_PTE_FAULT_ON_EXECUTE 56 #define PG_ASM ALPHA_PTE_ASM 57 #define PG_GH ALPHA_PTE_GRANULARITY 58 #define PG_KRE ALPHA_PTE_KR 59 #define PG_URE ALPHA_PTE_UR 60 #define PG_KWE ALPHA_PTE_KW 61 #define PG_UWE ALPHA_PTE_UW 62 #define PG_PROT ALPHA_PTE_PROT 63 #define PG_RSVD 0x000000000000cc80 /* Reserved fpr hardware */ 64 #define PG_WIRED 0x0000000000010000 /* Wired. [SOFTWARE] */ 65 #define PG_FRAME ALPHA_PTE_RAME 66 #define PG_SHIFT 32 67 #define PG_PFNUM(x) ALPHA_PTE_TO_PFN(x) 68 69 #if 0 /* XXX NOT HERE */ 70 #define K0SEG_BEGIN 0xfffffc0000000000 /* unmapped, cached */ 71 #define K0SEG_END 0xfffffe0000000000 72 #define PHYS_UNCACHED 0x0000000040000000 73 #endif 74 75 #ifndef _LOCORE 76 #if 0 /* XXX NOT HERE */ 77 #define k0segtophys(x) ((vm_offset_t)(x) & 0x00000003ffffffff) 78 #define phystok0seg(x) ((vm_offset_t)(x) | K0SEG_BEGIN) 79 80 #define phystouncached(x) ((vm_offset_t)(x) | PHYS_UNCACHED) 81 #define uncachedtophys(x) ((vm_offset_t)(x) & ~PHYS_UNCACHED) 82 #endif 83 84 #define PTEMASK (NPTEPG - 1) 85 #define vatopte(va) (((va) >> PGSHIFT) & PTEMASK) 86 #define vatoste(va) (((va) >> SEGSHIFT) & PTEMASK) 87 #define vatopa(va) \ 88 ((PG_PFNUM(*kvtopte(va)) << PGSHIFT) | ((vm_offset_t)(va) & PGOFSET)) 89 90 #define ALPHA_STSIZE ((u_long)NBPG) /* 8k */ 91 #define ALPHA_MAX_PTSIZE ((u_long)(NPTEPG * NBPG)) /* 8M */ 92 93 #ifdef _KERNEL 94 /* 95 * Kernel virtual address to Sysmap entry and visa versa. 96 */ 97 #define kvtopte(va) \ 98 (Sysmap + (((vm_offset_t)(va) - VM_MIN_KERNEL_ADDRESS) >> PGSHIFT)) 99 #define ptetokv(pte) \ 100 ((((pt_entry_t *)(pte) - Sysmap) << PGSHIFT) + VM_MIN_KERNEL_ADDRESS) 101 102 /* 103 * Kernel virtual address to Lev1map entry index. 104 */ 105 #define kvtol1pte(va) \ 106 (((vm_offset_t)(va) >> (PGSHIFT + 2*(PGSHIFT-PTESHIFT))) & PTEMASK) 107 108 #define loadustp(stpte) { \ 109 Lev1map[kvtol1pte(VM_MIN_ADDRESS)] = stpte; \ 110 TBIAP(); \ 111 } 112 113 extern pt_entry_t *Lev1map; /* Alpha Level One page table */ 114 extern pt_entry_t *Sysmap; /* kernel pte table */ 115 extern vm_size_t Sysmapsize; /* number of pte's in Sysmap */ 116 #endif 117 #endif 118