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