1 /* $NetBSD: pte.h,v 1.4 1996/02/01 22:28:56 mycroft 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 typedef u_int64_t pt_entry_t; 44 #define PT_ENTRY_NULL ((pt_entry_t *) 0) 45 #define PTESHIFT 3 /* pte size == 1 << PTESHIFT */ 46 47 #define PG_V 0x0000000000000001 /* PFN Valid */ 48 #define PG_NV 0x0000000000000000 /* PFN NOT Valid */ 49 #define PG_FOR 0x0000000000000002 /* Fault on read */ 50 #define PG_FOW 0x0000000000000004 /* Fault on write */ 51 #define PG_FOE 0x0000000000000008 /* Fault on execute */ 52 #define PG_ASM 0x0000000000000010 /* Address space match */ 53 #define PG_GH 0x0000000000000060 /* Granularity hint */ 54 #define PG_KRE 0x0000000000000100 /* Kernel read enable */ 55 #define PG_URE 0x0000000000000200 /* User read enable */ 56 #define PG_KWE 0x0000000000001000 /* Kernel write enable */ 57 #define PG_UWE 0x0000000000002000 /* User write enable */ 58 #define PG_PROT 0x000000000000ff00 59 #define PG_RSVD 0x000000000000cc80 /* Reserved fpr hardware */ 60 #define PG_WIRED 0x0000000000010000 /* Wired. [SOFTWARE] */ 61 #define PG_FRAME 0xffffffff00000000 62 #define PG_SHIFT 32 63 #define PG_PFNUM(x) (((x) & PG_FRAME) >> PG_SHIFT) 64 65 #define K0SEG_BEGIN 0xfffffc0000000000 /* unmapped, cached */ 66 #define K0SEG_END 0xfffffe0000000000 67 #define PHYS_UNCACHED 0x0000000040000000 68 69 #ifndef _LOCORE 70 #define k0segtophys(x) ((vm_offset_t)(x) & 0x00000003ffffffff) 71 #define phystok0seg(x) ((vm_offset_t)(x) | K0SEG_BEGIN) 72 73 #define phystouncached(x) ((vm_offset_t)(x) | PHYS_UNCACHED) 74 #define uncachedtophys(x) ((vm_offset_t)(x) & ~PHYS_UNCACHED) 75 76 #define PTEMASK (NPTEPG - 1) 77 #define vatopte(va) (((va) >> PGSHIFT) & PTEMASK) 78 #define vatoste(va) (((va) >> SEGSHIFT) & PTEMASK) 79 #define vatopa(va) \ 80 ((PG_PFNUM(*kvtopte(va)) << PGSHIFT) | ((vm_offset_t)(va) & PGOFSET)) 81 82 #define ALPHA_STSIZE ((u_long)NBPG) /* 8k */ 83 #define ALPHA_MAX_PTSIZE ((u_long)(NPTEPG * NBPG)) /* 8M */ 84 85 #ifdef _KERNEL 86 /* 87 * Kernel virtual address to Sysmap entry and visa versa. 88 */ 89 #define kvtopte(va) \ 90 (Sysmap + (((vm_offset_t)(va) - VM_MIN_KERNEL_ADDRESS) >> PGSHIFT)) 91 #define ptetokv(pte) \ 92 ((((pt_entry_t *)(pte) - Sysmap) << PGSHIFT) + VM_MIN_KERNEL_ADDRESS) 93 94 /* 95 * Kernel virtual address to Lev1map entry index. 96 */ 97 #define kvtol1pte(va) \ 98 (((vm_offset_t)(va) >> (PGSHIFT + 2*(PGSHIFT-PTESHIFT))) & PTEMASK) 99 100 #define loadustp(stpte) { \ 101 Lev1map[kvtol1pte(VM_MIN_ADDRESS)] = stpte; \ 102 TBIAP(); \ 103 } 104 105 extern pt_entry_t *Lev1map; /* Alpha Level One page table */ 106 extern pt_entry_t *Sysmap; /* kernel pte table */ 107 extern vm_size_t Sysmapsize; /* number of pte's in Sysmap */ 108 #endif 109 #endif 110