1 /* 2 * Copyright (c) 1987 Carnegie-Mellon University 3 * Copyright (c) 1992 Regents of the University of California. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Ralph Campbell. 8 * 9 * %sccs.include.redist.c% 10 * 11 * @(#)pmap.h 7.1 (Berkeley) 01/07/92 12 */ 13 14 #ifndef _PMAP_MACHINE_ 15 #define _PMAP_MACHINE_ 16 17 /* 18 * TLB hash table values. 19 * SHIFT2 should shift virtual address bit 22 to the high bit of the index. 20 * address: index: 21 * USRTEXT 0x00400000 10xxxxxxx 22 * USRDATA 0x10000000 00xxxxxxx 23 * USRSTACK 0x7FFFFFFF 11xxxxxxx 24 * This gives 1/2 the table to data, 1/4 for text and 1/4 for stack. 25 * Note: the current process has its hash table mapped at PMAP_HASH_UADDR. 26 * the kernel's hash table is mapped at PMAP_HASH_KADDR. 27 * The size of the hash table is known in locore.s. 28 * The wired entries in the TLB will contain the following: 29 * UPAGES (for curproc) 30 * PMAP_HASH_UPAGES (for curproc) 31 * PMAP_HASH_KPAGES (for kernel) 32 * The kernel doesn't actual use a pmap_hash_t, the pm_hash field is NULL and 33 * all the PTE entries are stored in a single array at PMAP_HASH_KADDR. 34 * If we need more KPAGES that the TLB has wired entries, then we can switch 35 * to a global pointer for the kernel TLB table. 36 * If we try to use a hash table for the kernel, wired TLB entries become a 37 * problem. 38 * Note: PMAP_HASH_UPAGES should be a multiple of MACH pages (see pmap_enter()). 39 */ 40 #define PMAP_HASH_UPAGES 1 41 #define PMAP_HASH_KPAGES 2 42 #define PMAP_HASH_UADDR (UADDR - PMAP_HASH_UPAGES * NBPG) 43 #define PMAP_HASH_KADDR (UADDR - (PMAP_HASH_UPAGES + PMAP_HASH_KPAGES) * NBPG) 44 #define PMAP_HASH_NUM_ENTRIES 512 45 #define PMAP_HASH_SIZE_SHIFT 3 46 #define PMAP_HASH_SHIFT1 12 47 #define PMAP_HASH_SHIFT2 14 48 #define PMAP_HASH_MASK1 0x07f 49 #define PMAP_HASH_MASK2 0x180 50 #define PMAP_HASH_SIZE (PMAP_HASH_NUM_ENTRIES*sizeof(struct pmap_hash)) 51 52 /* compute pointer to pmap hash table */ 53 #define PMAP_HASH(va) \ 54 ((((va) >> PMAP_HASH_SHIFT1) & PMAP_HASH_MASK1) | \ 55 (((va) >> PMAP_HASH_SHIFT2) & PMAP_HASH_MASK2)) 56 57 /* 58 * A TLB hash entry. 59 */ 60 typedef struct pmap_hash { 61 u_int low; /* The TLB low register value. */ 62 u_int high; /* The TLB high register value. */ 63 } *pmap_hash_t; 64 65 /* 66 * Machine dependent pmap structure. 67 */ 68 typedef struct pmap { 69 int pm_count; /* pmap reference count */ 70 simple_lock_data_t pm_lock; /* lock on pmap */ 71 struct pmap_statistics pm_stats; /* pmap statistics */ 72 int pm_flags; /* see below */ 73 int pm_tlbpid; /* address space tag */ 74 pmap_hash_t pm_hash; /* TLB cache */ 75 unsigned pm_hash_ptes[PMAP_HASH_UPAGES]; 76 } *pmap_t; 77 78 #define PM_MODIFIED 1 /* flush tlbpid before resume() */ 79 80 /* 81 * Defines for pmap_attributes[phys_mach_page]; 82 */ 83 #define PMAP_ATTR_MOD 0x01 /* page has been modified */ 84 #define PMAP_ATTR_REF 0x02 /* page has been referenced */ 85 86 #ifdef KERNEL 87 #define pmap_kernel() (kernel_pmap) 88 89 extern pmap_t kernel_pmap; 90 extern char *pmap_attributes; /* reference and modify bits */ 91 #endif KERNEL 92 #endif _PMAP_MACHINE_ 93