1 /* 2 * Copyright (c) 1987 Carnegie-Mellon University 3 * Copyright (c) 1991 Regents of the University of California. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * The Mach Operating System project at Carnegie-Mellon University. 8 * 9 * The CMU software License Agreement specifies the terms and conditions 10 * for use and redistribution. 11 * 12 * @(#)pmap.h 7.3 (Berkeley) 04/20/91 13 */ 14 15 #ifndef _PMAP_MACHINE_ 16 #define _PMAP_MACHINE_ 17 18 #define HP_PAGE_SIZE NBPG 19 #define HP_SEG_SIZE NBSEG 20 21 /* 22 * Pmap stuff 23 */ 24 struct pmap { 25 struct pte *pm_ptab; /* KVA of page table */ 26 struct ste *pm_stab; /* KVA of segment table */ 27 int pm_stchanged; /* ST changed */ 28 short pm_sref; /* segment table ref count */ 29 short pm_count; /* pmap reference count */ 30 simple_lock_data_t pm_lock; /* lock on pmap */ 31 struct pmap_statistics pm_stats; /* pmap statistics */ 32 long pm_ptpages; /* more stats: PT pages */ 33 }; 34 35 typedef struct pmap *pmap_t; 36 37 extern pmap_t kernel_pmap; 38 39 /* 40 * Macros for speed 41 */ 42 #define PMAP_ACTIVATE(pmapp, pcbp, iscurproc) \ 43 if ((pmapp) != NULL && (pmapp)->pm_stchanged) { \ 44 (pcbp)->pcb_ustp = \ 45 hp300_btop(pmap_extract(kernel_pmap, (pmapp)->pm_stab)); \ 46 if (iscurproc) \ 47 loadustp((pcbp)->pcb_ustp); \ 48 (pmapp)->pm_stchanged = FALSE; \ 49 } 50 #define PMAP_DEACTIVATE(pmapp, pcbp) 51 52 /* 53 * For each vm_page_t, there is a list of all currently valid virtual 54 * mappings of that page. An entry is a pv_entry_t, the list is pv_table. 55 */ 56 typedef struct pv_entry { 57 struct pv_entry *pv_next; /* next pv_entry */ 58 struct pmap *pv_pmap; /* pmap where mapping lies */ 59 vm_offset_t pv_va; /* virtual address for mapping */ 60 struct ste *pv_ptste; /* non-zero if VA maps a PT page */ 61 struct pmap *pv_ptpmap; /* if pv_ptste, pmap for PT page */ 62 int pv_flags; /* flags */ 63 } *pv_entry_t; 64 65 #define PV_CI 0x01 /* all entries must be cache inhibited */ 66 #define PV_PTPAGE 0x02 /* entry maps a page table page */ 67 68 #ifdef KERNEL 69 pv_entry_t pv_table; /* array of entries, one per page */ 70 71 #define pa_index(pa) atop(pa - vm_first_phys) 72 #define pa_to_pvh(pa) (&pv_table[pa_index(pa)]) 73 74 #define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) 75 76 extern struct pte *Sysmap; 77 extern char *vmmap; /* map for mem, dumps, etc. */ 78 #endif KERNEL 79 80 #endif _PMAP_MACHINE_ 81