1 /* $OpenBSD: pmap.h,v 1.50 2014/01/30 18:16:41 miod Exp $ */ 2 /* $NetBSD: pmap.h,v 1.1 1996/09/30 16:34:29 ws Exp $ */ 3 4 /*- 5 * Copyright (C) 1995, 1996 Wolfgang Solfrank. 6 * Copyright (C) 1995, 1996 TooLs GmbH. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. All advertising materials mentioning features or use of this software 18 * must display the following acknowledgement: 19 * This product includes software developed by TooLs GmbH. 20 * 4. The name of TooLs GmbH may not be used to endorse or promote products 21 * derived from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 29 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 31 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 32 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35 #ifndef _POWERPC_PMAP_H_ 36 #define _POWERPC_PMAP_H_ 37 38 #include <machine/pte.h> 39 40 /* 41 * Segment registers 42 */ 43 #ifndef _LOCORE 44 typedef u_int sr_t; 45 #endif /* _LOCORE */ 46 #define SR_TYPE 0x80000000 47 #define SR_SUKEY 0x40000000 48 #define SR_PRKEY 0x20000000 49 #define SR_NOEXEC 0x10000000 50 #define SR_VSID 0x00ffffff 51 /* 52 * bit 53 * 3 2 2 2 2 1 1 1 1 1 0 54 * 1 8 7 4 0 9 6 5 2 1 0 55 * |XXXX|XXXX XXXX|XXXX XXXX|XXXX XXXX XXXX 56 * 57 * bits 28 - 31 contain SR 58 * bits 20 - 27 contain L1 for VtoP translation 59 * bits 12 - 19 contain L2 for VtoP translation 60 * bits 0 - 11 contain page offset 61 */ 62 #ifndef _LOCORE 63 /* V->P mapping data */ 64 #define VP_SR_SIZE 16 65 #define VP_SR_MASK (VP_SR_SIZE-1) 66 #define VP_SR_POS 28 67 #define VP_IDX1_SIZE 256 68 #define VP_IDX1_MASK (VP_IDX1_SIZE-1) 69 #define VP_IDX1_POS 20 70 #define VP_IDX2_SIZE 256 71 #define VP_IDX2_MASK (VP_IDX2_SIZE-1) 72 #define VP_IDX2_POS 12 73 74 /* functions used by the bus layer for device accesses */ 75 void pmap_kenter_cache(vaddr_t va, paddr_t pa, vm_prot_t prot, int cacheable); 76 void pmap_kremove_pg(vaddr_t va); 77 78 /* cache flags */ 79 #define PMAP_CACHE_DEFAULT 0 /* WB cache managed mem, devices not */ 80 #define PMAP_CACHE_CI 1 /* cache inhibit */ 81 #define PMAP_CACHE_WT 2 /* writethru */ 82 #define PMAP_CACHE_WB 3 /* writeback */ 83 84 #ifdef _KERNEL 85 86 /* 87 * Pmap stuff 88 */ 89 struct pmap { 90 sr_t pm_sr[16]; /* segments used in this pmap */ 91 struct pmapvp *pm_vp[VP_SR_SIZE]; /* virtual to physical table */ 92 u_int32_t pm_exec[16]; /* segments used in this pmap */ 93 int pm_refs; /* ref count */ 94 struct pmap_statistics pm_stats; /* pmap statistics */ 95 }; 96 97 /* 98 * Segment handling stuff 99 */ 100 #define PPC_SEGMENT_LENGTH 0x10000000 101 #define PPC_SEGMENT_MASK 0xf0000000 102 103 /* 104 * Some system constants 105 */ 106 #ifndef NPMAPS 107 #define NPMAPS 32768 /* Number of pmaps in system */ 108 #endif 109 110 typedef struct pmap *pmap_t; 111 112 extern struct pmap kernel_pmap_; 113 #define pmap_kernel() (&kernel_pmap_) 114 boolean_t pteclrbits(struct vm_page *pg, u_int mask, u_int clear); 115 116 117 #define pmap_clear_modify(page) \ 118 (pteclrbits((page), PG_PMAP_MOD, TRUE)) 119 #define pmap_clear_reference(page) \ 120 (pteclrbits((page), PG_PMAP_REF, TRUE)) 121 #define pmap_is_modified(page) \ 122 (pteclrbits((page), PG_PMAP_MOD, FALSE)) 123 #define pmap_is_referenced(page) \ 124 (pteclrbits((page), PG_PMAP_REF, FALSE)) 125 126 #define pmap_unwire(pm, va) 127 #define pmap_update(pmap) /* nothing (yet) */ 128 129 #define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) 130 131 /* 132 * Alternate mapping methods for pool. 133 * Really simple. 0x0->0x80000000 contain 1->1 mappings of the physical 134 * memory. - XXX 135 */ 136 #define pmap_map_direct(pg) ((vaddr_t)VM_PAGE_TO_PHYS(pg)) 137 #define pmap_unmap_direct(va) PHYS_TO_VM_PAGE((paddr_t)va) 138 #define __HAVE_PMAP_DIRECT 139 140 void pmap_bootstrap(u_int kernelstart, u_int kernelend); 141 142 void pmap_pinit(struct pmap *); 143 void pmap_release(struct pmap *); 144 145 void pmap_real_memory(vaddr_t *start, vsize_t *size); 146 void switchexit(struct proc *); 147 148 int pte_spill_v(struct pmap *pm, u_int32_t va, u_int32_t dsisr, int exec_fault); 149 #define pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr) ; 150 int reserve_dumppages(caddr_t p); 151 152 #define pmap_unuse_final(p) /* nothing */ 153 #define pmap_remove_holes(map) do { /* nothing */ } while (0) 154 155 #define PMAP_STEAL_MEMORY 156 157 #define PG_PMAP_MOD PG_PMAP0 158 #define PG_PMAP_REF PG_PMAP1 159 #define PG_PMAP_EXE PG_PMAP2 160 161 /* 162 * MD flags to pmap_enter: 163 */ 164 165 /* to get just the pa from params to pmap_enter */ 166 #define PMAP_PA_MASK ~((paddr_t)PAGE_MASK) 167 #define PMAP_NOCACHE 0x1 /* map uncached */ 168 169 #endif /* _KERNEL */ 170 171 struct vm_page_md { 172 LIST_HEAD(,pte_desc) pv_list; 173 }; 174 175 #define VM_MDPAGE_INIT(pg) do { \ 176 LIST_INIT(&((pg)->mdpage.pv_list)); \ 177 } while (0) 178 179 #endif /* _LOCORE */ 180 181 #endif /* _POWERPC_PMAP_H_ */ 182