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.13 (Berkeley) 06/02/93 13 */ 14 15 #ifndef _PMAP_MACHINE_ 16 #define _PMAP_MACHINE_ 17 18 #define HP_PAGE_SIZE NBPG 19 #if defined(HP380) 20 #define HP_SEG_SIZE (mmutype == MMU_68040 ? 0x40000 : NBSEG) 21 #else 22 #define HP_SEG_SIZE NBSEG 23 #endif 24 25 #define hp300_trunc_seg(x) (((unsigned)(x)) & ~(HP_SEG_SIZE-1)) 26 #define hp300_round_seg(x) hp300_trunc_seg((unsigned)(x) + HP_SEG_SIZE-1) 27 28 /* 29 * Pmap stuff 30 */ 31 struct pmap { 32 struct pte *pm_ptab; /* KVA of page table */ 33 struct ste *pm_stab; /* KVA of segment table */ 34 int pm_stchanged; /* ST changed */ 35 int pm_stfree; /* 040: free lev2 blocks */ 36 struct ste *pm_stpa; /* 040: ST phys addr */ 37 short pm_sref; /* segment table ref count */ 38 short pm_count; /* pmap reference count */ 39 simple_lock_data_t pm_lock; /* lock on pmap */ 40 struct pmap_statistics pm_stats; /* pmap statistics */ 41 long pm_ptpages; /* more stats: PT pages */ 42 }; 43 44 typedef struct pmap *pmap_t; 45 46 extern struct pmap kernel_pmap_store; 47 48 #define kernel_pmap (&kernel_pmap_store) 49 #define active_pmap(pm) \ 50 ((pm) == kernel_pmap || (pm) == curproc->p_vmspace->vm_map.pmap) 51 52 /* 53 * On the 040 we keep track of which level 2 blocks are already in use 54 * with the pm_stfree mask. Bits are arranged from LSB (block 0) to MSB 55 * (block 31). For convenience, the level 1 table is considered to be 56 * block 0. 57 * 58 * MAX[KU]L2SIZE control how many pages of level 2 descriptors are allowed. 59 * for the kernel and users. 8 implies only the initial "segment table" 60 * page is used. WARNING: don't change MAXUL2SIZE unless you can allocate 61 * physically contiguous pages for the ST in pmap.c! 62 */ 63 #define MAXKL2SIZE 32 64 #define MAXUL2SIZE 8 65 #define l2tobm(n) (1 << (n)) 66 #define bmtol2(n) (ffs(n) - 1) 67 68 /* 69 * Macros for speed 70 */ 71 #define PMAP_ACTIVATE(pmapp, pcbp, iscurproc) \ 72 if ((pmapp) != NULL && (pmapp)->pm_stchanged) { \ 73 (pcbp)->pcb_ustp = hp300_btop((vm_offset_t)(pmapp)->pm_stpa); \ 74 if (iscurproc) \ 75 loadustp((pcbp)->pcb_ustp); \ 76 (pmapp)->pm_stchanged = FALSE; \ 77 } 78 #define PMAP_DEACTIVATE(pmapp, pcbp) 79 80 /* 81 * For each vm_page_t, there is a list of all currently valid virtual 82 * mappings of that page. An entry is a pv_entry_t, the list is pv_table. 83 */ 84 typedef struct pv_entry { 85 struct pv_entry *pv_next; /* next pv_entry */ 86 struct pmap *pv_pmap; /* pmap where mapping lies */ 87 vm_offset_t pv_va; /* virtual address for mapping */ 88 struct ste *pv_ptste; /* non-zero if VA maps a PT page */ 89 struct pmap *pv_ptpmap; /* if pv_ptste, pmap for PT page */ 90 int pv_flags; /* flags */ 91 } *pv_entry_t; 92 93 #define PV_CI 0x01 /* header: all entries are cache inhibited */ 94 #define PV_PTPAGE 0x02 /* header: entry maps a page table page */ 95 96 #ifdef KERNEL 97 #if defined(HP320) || defined(HP350) 98 #define HAVEVAC /* include cheezy VAC support */ 99 #endif 100 101 pv_entry_t pv_table; /* array of entries, one per page */ 102 103 #define pa_index(pa) atop(pa - vm_first_phys) 104 #define pa_to_pvh(pa) (&pv_table[pa_index(pa)]) 105 106 #define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) 107 #define pmap_wired_count(pmap) ((pmap)->pm_stats.wired_count) 108 109 extern struct pte *Sysmap; 110 extern char *vmmap; /* map for mem, dumps, etc. */ 111 #endif /* KERNEL */ 112 113 #endif /* _PMAP_MACHINE_ */ 114