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 Systems Programming Group of the University of Utah Computer 8 * Science Department. 9 * 10 * %sccs.include.redist.c% 11 * 12 * @(#)pmap.h 7.7 (Berkeley) 11/05/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, \ 46 ((vm_offset_t)(pmapp)->pm_stab))); \ 47 if (iscurproc) \ 48 loadustp((pcbp)->pcb_ustp); \ 49 (pmapp)->pm_stchanged = FALSE; \ 50 } 51 #define PMAP_DEACTIVATE(pmapp, pcbp) 52 53 /* 54 * For each vm_page_t, there is a list of all currently valid virtual 55 * mappings of that page. An entry is a pv_entry_t, the list is pv_table. 56 */ 57 typedef struct pv_entry { 58 struct pv_entry *pv_next; /* next pv_entry */ 59 struct pmap *pv_pmap; /* pmap where mapping lies */ 60 vm_offset_t pv_va; /* virtual address for mapping */ 61 struct ste *pv_ptste; /* non-zero if VA maps a PT page */ 62 struct pmap *pv_ptpmap; /* if pv_ptste, pmap for PT page */ 63 int pv_flags; /* flags */ 64 } *pv_entry_t; 65 66 #define PV_CI 0x01 /* all entries must be cache inhibited */ 67 #define PV_PTPAGE 0x02 /* entry maps a page table page */ 68 69 #ifdef KERNEL 70 pv_entry_t pv_table; /* array of entries, one per page */ 71 72 #define pa_index(pa) atop(pa - vm_first_phys) 73 #define pa_to_pvh(pa) (&pv_table[pa_index(pa)]) 74 75 #define pmap_kernel() (kernel_pmap) 76 #define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) 77 78 extern struct pte *Sysmap; 79 extern char *vmmap; /* map for mem, dumps, etc. */ 80 #endif KERNEL 81 82 #endif _PMAP_MACHINE_ 83