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.6 (Berkeley) 02/04/93 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 actually 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 5 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 256 45 #define PMAP_HASH_SIZE_SHIFT 4 46 #define PMAP_HASH_SHIFT1 12 47 #define PMAP_HASH_SHIFT2 21 48 #define PMAP_HASH_MASK1 0x07f 49 #define PMAP_HASH_MASK2 0x080 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 struct { 62 u_int low; /* The TLB low register value. */ 63 u_int high; /* The TLB high register value. */ 64 } pmh_pte[2]; 65 } *pmap_hash_t; 66 67 /* 68 * Machine dependent pmap structure. 69 */ 70 typedef struct pmap { 71 int pm_count; /* pmap reference count */ 72 simple_lock_data_t pm_lock; /* lock on pmap */ 73 struct pmap_statistics pm_stats; /* pmap statistics */ 74 int pm_flags; /* see below */ 75 int pm_tlbpid; /* address space tag */ 76 pmap_hash_t pm_hash; /* TLB cache */ 77 unsigned pm_hash_ptes[PMAP_HASH_UPAGES]; 78 } *pmap_t; 79 80 #define PM_MODIFIED 1 /* flush tlbpid before resume() */ 81 82 /* 83 * Defines for pmap_attributes[phys_mach_page]; 84 */ 85 #define PMAP_ATTR_MOD 0x01 /* page has been modified */ 86 #define PMAP_ATTR_REF 0x02 /* page has been referenced */ 87 88 #ifdef KERNEL 89 extern struct pmap kernel_pmap_store; 90 #define kernel_pmap (&kernel_pmap_store) 91 extern char *pmap_attributes; /* reference and modify bits */ 92 #endif KERNEL 93 #endif _PMAP_MACHINE_ 94