1 1.27 skrll /* $NetBSD: pte.h,v 1.27 2020/08/22 15:34:51 skrll Exp $ */ 2 1.1 jonathan 3 1.3 jonathan /*- 4 1.3 jonathan * Copyright (c) 1997 The NetBSD Foundation, Inc. 5 1.3 jonathan * All rights reserved. 6 1.3 jonathan * 7 1.3 jonathan * This code is derived from software contributed to The NetBSD Foundation 8 1.3 jonathan * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 9 1.3 jonathan * NASA Ames Research Center. 10 1.3 jonathan * 11 1.3 jonathan * Redistribution and use in source and binary forms, with or without 12 1.3 jonathan * modification, are permitted provided that the following conditions 13 1.3 jonathan * are met: 14 1.3 jonathan * 1. Redistributions of source code must retain the above copyright 15 1.3 jonathan * notice, this list of conditions and the following disclaimer. 16 1.3 jonathan * 2. Redistributions in binary form must reproduce the above copyright 17 1.3 jonathan * notice, this list of conditions and the following disclaimer in the 18 1.3 jonathan * documentation and/or other materials provided with the distribution. 19 1.3 jonathan * 20 1.3 jonathan * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 1.3 jonathan * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 1.3 jonathan * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 1.3 jonathan * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 1.3 jonathan * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 1.3 jonathan * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 1.3 jonathan * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 1.3 jonathan * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 1.3 jonathan * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 1.3 jonathan * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 1.3 jonathan * POSSIBILITY OF SUCH DAMAGE. 31 1.3 jonathan */ 32 1.3 jonathan 33 1.1 jonathan /* 34 1.1 jonathan * Copyright 1996 The Board of Trustees of The Leland Stanford 35 1.1 jonathan * Junior University. All Rights Reserved. 36 1.1 jonathan * 37 1.1 jonathan * Permission to use, copy, modify, and distribute this 38 1.1 jonathan * software and its documentation for any purpose and without 39 1.1 jonathan * fee is hereby granted, provided that the above copyright 40 1.1 jonathan * notice appear in all copies. Stanford University 41 1.1 jonathan * makes no representations about the suitability of this 42 1.1 jonathan * software for any purpose. It is provided "as is" without 43 1.1 jonathan * express or implied warranty. 44 1.1 jonathan */ 45 1.1 jonathan 46 1.1 jonathan #ifndef __MIPS_PTE_H__ 47 1.26 simonb #define __MIPS_PTE_H__ 48 1.1 jonathan 49 1.3 jonathan #include <mips/mips1_pte.h> 50 1.3 jonathan #include <mips/mips3_pte.h> 51 1.3 jonathan 52 1.3 jonathan #define PG_ASID 0x000000ff /* Address space ID */ 53 1.3 jonathan 54 1.3 jonathan #ifndef _LOCORE 55 1.23 matt #ifndef __BSD_PTENTRY_T__ 56 1.26 simonb #define __BSD_PTENTRY_T__ 57 1.23 matt typedef uint32_t pt_entry_t; 58 1.26 simonb #define PRIxPTE PRIx32 59 1.22 matt #endif 60 1.3 jonathan 61 1.3 jonathan /* 62 1.3 jonathan * Macros/inline functions to hide PTE format differences. 63 1.3 jonathan */ 64 1.3 jonathan 65 1.3 jonathan #define mips_pg_nv_bit() (MIPS1_PG_NV) /* same on mips1 and mips3 */ 66 1.3 jonathan 67 1.3 jonathan 68 1.20 matt bool pmap_is_page_ro_p(struct pmap *pmap, vaddr_t, uint32_t); 69 1.3 jonathan 70 1.3 jonathan 71 1.3 jonathan /* MIPS1-only */ 72 1.12 simonb #if defined(MIPS1) && !defined(MIPS3_PLUS) 73 1.3 jonathan #define mips_pg_v(entry) ((entry) & MIPS1_PG_V) 74 1.3 jonathan #define mips_pg_wired(entry) ((entry) & MIPS1_PG_WIRED) 75 1.3 jonathan 76 1.8 nisimura #define mips_pg_m_bit() (MIPS1_PG_D) 77 1.3 jonathan #define mips_pg_rw_bit() (MIPS1_PG_RW) /* no RW bits for mips1 */ 78 1.3 jonathan #define mips_pg_ro_bit() (MIPS1_PG_RO) 79 1.3 jonathan #define mips_pg_ropage_bit() (MIPS1_PG_RO) /* XXX not MIPS1_PG_ROPAGE? */ 80 1.3 jonathan #define mips_pg_rwpage_bit() (MIPS1_PG_RWPAGE) 81 1.17 macallan #define mips_pg_rwncpage_bit() (MIPS1_PG_RWNCPAGE) 82 1.3 jonathan #define mips_pg_cwpage_bit() (MIPS1_PG_CWPAGE) 83 1.17 macallan #define mips_pg_cwncpage_bit() (MIPS1_PG_CWNCPAGE) 84 1.3 jonathan #define mips_pg_global_bit() (MIPS1_PG_G) 85 1.3 jonathan #define mips_pg_wired_bit() (MIPS1_PG_WIRED) 86 1.3 jonathan 87 1.23 matt #define pte_to_paddr(pte) MIPS1_PTE_TO_PADDR((pte)) 88 1.3 jonathan #define PAGE_IS_RDONLY(pte, va) MIPS1_PAGE_IS_RDONLY((pte), (va)) 89 1.3 jonathan 90 1.10 soda #define mips_tlbpfn_to_paddr(x) mips1_tlbpfn_to_paddr((vaddr_t)(x)) 91 1.10 soda #define mips_paddr_to_tlbpfn(x) mips1_paddr_to_tlbpfn((x)) 92 1.3 jonathan #endif /* mips1 */ 93 1.3 jonathan 94 1.3 jonathan 95 1.12 simonb /* MIPS3 (or greater) only */ 96 1.12 simonb #if !defined(MIPS1) && defined(MIPS3_PLUS) 97 1.3 jonathan #define mips_pg_v(entry) ((entry) & MIPS3_PG_V) 98 1.3 jonathan #define mips_pg_wired(entry) ((entry) & MIPS3_PG_WIRED) 99 1.3 jonathan 100 1.8 nisimura #define mips_pg_m_bit() (MIPS3_PG_D) 101 1.8 nisimura #define mips_pg_rw_bit() (MIPS3_PG_D) 102 1.3 jonathan #define mips_pg_ro_bit() (MIPS3_PG_RO) 103 1.3 jonathan #define mips_pg_ropage_bit() (MIPS3_PG_ROPAGE) 104 1.3 jonathan #define mips_pg_rwpage_bit() (MIPS3_PG_RWPAGE) 105 1.17 macallan #define mips_pg_rwncpage_bit() (MIPS3_PG_RWNCPAGE) 106 1.3 jonathan #define mips_pg_cwpage_bit() (MIPS3_PG_CWPAGE) 107 1.17 macallan #define mips_pg_cwncpage_bit() (MIPS3_PG_CWNCPAGE) 108 1.3 jonathan #define mips_pg_global_bit() (MIPS3_PG_G) 109 1.3 jonathan #define mips_pg_wired_bit() (MIPS3_PG_WIRED) 110 1.1 jonathan 111 1.23 matt #define pte_to_paddr(pte) MIPS3_PTE_TO_PADDR((pte)) 112 1.3 jonathan #define PAGE_IS_RDONLY(pte, va) MIPS3_PAGE_IS_RDONLY((pte), (va)) 113 1.3 jonathan 114 1.10 soda #define mips_tlbpfn_to_paddr(x) mips3_tlbpfn_to_paddr((vaddr_t)(x)) 115 1.10 soda #define mips_paddr_to_tlbpfn(x) mips3_paddr_to_tlbpfn((x)) 116 1.3 jonathan #endif /* mips3 */ 117 1.3 jonathan 118 1.12 simonb /* MIPS1 and MIPS3 (or greater) */ 119 1.12 simonb #if defined(MIPS1) && defined(MIPS3_PLUS) 120 1.1 jonathan 121 1.20 matt static __inline bool 122 1.20 matt mips_pg_v(uint32_t entry), 123 1.20 matt mips_pg_wired(uint32_t entry), 124 1.20 matt PAGE_IS_RDONLY(uint32_t pte, vaddr_t va); 125 1.3 jonathan 126 1.20 matt static __inline uint32_t 127 1.20 matt mips_pg_wired_bit(void) __pure, 128 1.20 matt mips_pg_m_bit(void) __pure, 129 1.20 matt mips_pg_ro_bit(void) __pure, 130 1.20 matt mips_pg_rw_bit(void) __pure, 131 1.20 matt mips_pg_ropage_bit(void) __pure, 132 1.20 matt mips_pg_cwpage_bit(void) __pure, 133 1.20 matt mips_pg_rwpage_bit(void) __pure, 134 1.20 matt mips_pg_global_bit(void) __pure; 135 1.23 matt static __inline paddr_t pte_to_paddr(pt_entry_t pte) __pure; 136 1.20 matt static __inline bool PAGE_IS_RDONLY(uint32_t pte, vaddr_t va) __pure; 137 1.3 jonathan 138 1.20 matt static __inline paddr_t mips_tlbpfn_to_paddr(uint32_t pfn) __pure; 139 1.20 matt static __inline uint32_t mips_paddr_to_tlbpfn(paddr_t pa) __pure; 140 1.3 jonathan 141 1.3 jonathan 142 1.20 matt static __inline bool 143 1.20 matt mips_pg_v(uint32_t entry) 144 1.3 jonathan { 145 1.12 simonb if (MIPS_HAS_R4K_MMU) 146 1.20 matt return (entry & MIPS3_PG_V) != 0; 147 1.20 matt return (entry & MIPS1_PG_V) != 0; 148 1.3 jonathan } 149 1.3 jonathan 150 1.20 matt static __inline bool 151 1.20 matt mips_pg_wired(uint32_t entry) 152 1.3 jonathan { 153 1.12 simonb if (MIPS_HAS_R4K_MMU) 154 1.20 matt return (entry & MIPS3_PG_WIRED) != 0; 155 1.20 matt return (entry & MIPS1_PG_WIRED) != 0; 156 1.3 jonathan } 157 1.3 jonathan 158 1.20 matt static __inline uint32_t 159 1.14 simonb mips_pg_m_bit(void) 160 1.3 jonathan { 161 1.12 simonb if (MIPS_HAS_R4K_MMU) 162 1.7 nisimura return (MIPS3_PG_D); 163 1.7 nisimura return (MIPS1_PG_D); 164 1.3 jonathan } 165 1.3 jonathan 166 1.16 perry static __inline unsigned int 167 1.14 simonb mips_pg_ro_bit(void) 168 1.3 jonathan { 169 1.12 simonb if (MIPS_HAS_R4K_MMU) 170 1.3 jonathan return (MIPS3_PG_RO); 171 1.3 jonathan return (MIPS1_PG_RO); 172 1.3 jonathan } 173 1.3 jonathan 174 1.16 perry static __inline unsigned int 175 1.14 simonb mips_pg_rw_bit(void) 176 1.3 jonathan { 177 1.12 simonb if (MIPS_HAS_R4K_MMU) 178 1.7 nisimura return (MIPS3_PG_D); 179 1.3 jonathan return (MIPS1_PG_RW); 180 1.3 jonathan } 181 1.3 jonathan 182 1.16 perry static __inline unsigned int 183 1.14 simonb mips_pg_ropage_bit(void) 184 1.3 jonathan { 185 1.12 simonb if (MIPS_HAS_R4K_MMU) 186 1.3 jonathan return (MIPS3_PG_ROPAGE); 187 1.3 jonathan return (MIPS1_PG_RO); 188 1.3 jonathan } 189 1.3 jonathan 190 1.16 perry static __inline unsigned int 191 1.14 simonb mips_pg_rwpage_bit(void) 192 1.3 jonathan { 193 1.12 simonb if (MIPS_HAS_R4K_MMU) 194 1.3 jonathan return (MIPS3_PG_RWPAGE); 195 1.3 jonathan return (MIPS1_PG_RWPAGE); 196 1.3 jonathan } 197 1.3 jonathan 198 1.16 perry static __inline unsigned int 199 1.14 simonb mips_pg_cwpage_bit(void) 200 1.3 jonathan { 201 1.12 simonb if (MIPS_HAS_R4K_MMU) 202 1.3 jonathan return (MIPS3_PG_CWPAGE); 203 1.3 jonathan return (MIPS1_PG_CWPAGE); 204 1.3 jonathan } 205 1.3 jonathan 206 1.3 jonathan 207 1.16 perry static __inline unsigned int 208 1.14 simonb mips_pg_global_bit(void) 209 1.3 jonathan { 210 1.12 simonb if (MIPS_HAS_R4K_MMU) 211 1.3 jonathan return (MIPS3_PG_G); 212 1.3 jonathan return (MIPS1_PG_G); 213 1.3 jonathan } 214 1.3 jonathan 215 1.16 perry static __inline unsigned int 216 1.14 simonb mips_pg_wired_bit(void) 217 1.3 jonathan { 218 1.12 simonb if (MIPS_HAS_R4K_MMU) 219 1.3 jonathan return (MIPS3_PG_WIRED); 220 1.3 jonathan return (MIPS1_PG_WIRED); 221 1.3 jonathan } 222 1.3 jonathan 223 1.16 perry static __inline paddr_t 224 1.23 matt pte_to_paddr(pt_entry_t pte) 225 1.3 jonathan { 226 1.12 simonb if (MIPS_HAS_R4K_MMU) 227 1.3 jonathan return (MIPS3_PTE_TO_PADDR(pte)); 228 1.3 jonathan return (MIPS1_PTE_TO_PADDR(pte)); 229 1.3 jonathan } 230 1.3 jonathan 231 1.20 matt static __inline bool 232 1.20 matt PAGE_IS_RDONLY(uint32_t pte, vaddr_t va) 233 1.3 jonathan { 234 1.12 simonb if (MIPS_HAS_R4K_MMU) 235 1.3 jonathan return (MIPS3_PAGE_IS_RDONLY(pte, va)); 236 1.3 jonathan return (MIPS1_PAGE_IS_RDONLY(pte, va)); 237 1.3 jonathan } 238 1.3 jonathan 239 1.16 perry static __inline paddr_t 240 1.20 matt mips_tlbpfn_to_paddr(uint32_t pfn) 241 1.3 jonathan { 242 1.12 simonb if (MIPS_HAS_R4K_MMU) 243 1.10 soda return (mips3_tlbpfn_to_paddr(pfn)); 244 1.10 soda return (mips1_tlbpfn_to_paddr(pfn)); 245 1.3 jonathan } 246 1.1 jonathan 247 1.20 matt static __inline uint32_t 248 1.20 matt mips_paddr_to_tlbpfn(paddr_t pa) 249 1.3 jonathan { 250 1.12 simonb if (MIPS_HAS_R4K_MMU) 251 1.10 soda return (mips3_paddr_to_tlbpfn(pa)); 252 1.10 soda return (mips1_paddr_to_tlbpfn(pa)); 253 1.3 jonathan } 254 1.1 jonathan #endif 255 1.1 jonathan 256 1.3 jonathan #endif /* ! _LOCORE */ 257 1.1 jonathan 258 1.1 jonathan #if defined(_KERNEL) && !defined(_LOCORE) 259 1.26 simonb #define MIPS_MMU(X) (MIPS_HAS_R4K_MMU ? MIPS3_##X : MIPS1_##X) 260 1.23 matt static inline bool 261 1.23 matt pte_valid_p(pt_entry_t pte) 262 1.23 matt { 263 1.23 matt return (pte & MIPS_MMU(PG_V)) != 0; 264 1.23 matt } 265 1.23 matt 266 1.23 matt static inline bool 267 1.23 matt pte_modified_p(pt_entry_t pte) 268 1.23 matt { 269 1.23 matt return (pte & MIPS_MMU(PG_D)) != 0; 270 1.23 matt } 271 1.1 jonathan 272 1.23 matt static inline bool 273 1.23 matt pte_global_p(pt_entry_t pte) 274 1.23 matt { 275 1.23 matt return (pte & MIPS_MMU(PG_G)) != 0; 276 1.23 matt } 277 1.21 matt 278 1.21 matt static inline bool 279 1.23 matt pte_wired_p(pt_entry_t pte) 280 1.23 matt { 281 1.23 matt return (pte & MIPS_MMU(PG_WIRED)) != 0; 282 1.23 matt } 283 1.23 matt 284 1.23 matt static inline pt_entry_t 285 1.23 matt pte_wire_entry(pt_entry_t pte) 286 1.23 matt { 287 1.23 matt return pte | MIPS_MMU(PG_WIRED); 288 1.23 matt } 289 1.23 matt 290 1.23 matt static inline pt_entry_t 291 1.23 matt pte_unwire_entry(pt_entry_t pte) 292 1.21 matt { 293 1.23 matt return pte & ~MIPS_MMU(PG_WIRED); 294 1.21 matt } 295 1.21 matt 296 1.21 matt static inline uint32_t 297 1.21 matt pte_value(pt_entry_t pte) 298 1.21 matt { 299 1.23 matt return pte; 300 1.23 matt } 301 1.23 matt 302 1.23 matt static inline bool 303 1.23 matt pte_readonly_p(pt_entry_t pte) 304 1.23 matt { 305 1.23 matt return (pte & MIPS_MMU(PG_RO)) != 0; 306 1.23 matt } 307 1.23 matt 308 1.23 matt static inline bool 309 1.23 matt pte_cached_p(pt_entry_t pte) 310 1.23 matt { 311 1.23 matt if (MIPS_HAS_R4K_MMU) { 312 1.24 skrll return MIPS3_PG_TO_CCA(pte) == MIPS3_PG_TO_CCA(mips_options.mips3_pg_cached); 313 1.23 matt } else { 314 1.23 matt return (pte & MIPS1_PG_N) == 0; 315 1.23 matt } 316 1.23 matt } 317 1.23 matt 318 1.23 matt static inline bool 319 1.23 matt pte_deferred_exec_p(pt_entry_t pte) 320 1.23 matt { 321 1.23 matt return false; 322 1.23 matt } 323 1.23 matt 324 1.23 matt static inline pt_entry_t 325 1.23 matt pte_nv_entry(bool kernel_p) 326 1.23 matt { 327 1.23 matt __CTASSERT(MIPS1_PG_NV == MIPS3_PG_NV); 328 1.23 matt __CTASSERT(MIPS1_PG_NV == 0); 329 1.23 matt return (kernel_p && MIPS_HAS_R4K_MMU) ? MIPS3_PG_G : 0; 330 1.23 matt } 331 1.23 matt 332 1.23 matt static inline pt_entry_t 333 1.23 matt pte_prot_downgrade(pt_entry_t pte, vm_prot_t prot) 334 1.23 matt { 335 1.23 matt const uint32_t ro_bit = MIPS_MMU(PG_RO); 336 1.23 matt const uint32_t rw_bit = MIPS_MMU(PG_D); 337 1.23 matt 338 1.23 matt return (pte & ~(ro_bit|rw_bit)) 339 1.23 matt | ((prot & VM_PROT_WRITE) ? rw_bit : ro_bit); 340 1.23 matt } 341 1.23 matt 342 1.23 matt static inline pt_entry_t 343 1.23 matt pte_prot_nowrite(pt_entry_t pte) 344 1.23 matt { 345 1.23 matt return pte & ~MIPS_MMU(PG_D); 346 1.23 matt } 347 1.23 matt 348 1.23 matt static inline pt_entry_t 349 1.23 matt pte_cached_change(pt_entry_t pte, bool cached) 350 1.23 matt { 351 1.23 matt if (MIPS_HAS_R4K_MMU) { 352 1.23 matt pte &= ~MIPS3_PG_CACHEMODE; 353 1.23 matt pte |= (cached ? MIPS3_PG_CACHED : MIPS3_PG_UNCACHED); 354 1.23 matt } 355 1.23 matt return pte; 356 1.23 matt } 357 1.23 matt 358 1.25 skrll static inline void 359 1.25 skrll pte_set(pt_entry_t *ptep, pt_entry_t pte) 360 1.25 skrll { 361 1.25 skrll *ptep = pte; 362 1.25 skrll } 363 1.25 skrll 364 1.23 matt #ifdef __PMAP_PRIVATE 365 1.23 matt struct vm_page_md; 366 1.23 matt 367 1.23 matt static inline pt_entry_t 368 1.23 matt pte_make_kenter_pa(paddr_t pa, struct vm_page_md *mdpg, vm_prot_t prot, 369 1.23 matt u_int flags) 370 1.23 matt { 371 1.23 matt pt_entry_t pte; 372 1.23 matt if (MIPS_HAS_R4K_MMU) { 373 1.23 matt pte = mips3_paddr_to_tlbpfn(pa) 374 1.23 matt | ((prot & VM_PROT_WRITE) ? MIPS3_PG_D : MIPS3_PG_RO) 375 1.23 matt | ((flags & PMAP_NOCACHE) ? MIPS3_PG_UNCACHED : MIPS3_PG_CACHED) 376 1.23 matt | MIPS3_PG_WIRED | MIPS3_PG_V | MIPS3_PG_G; 377 1.23 matt } else { 378 1.23 matt pte = mips1_paddr_to_tlbpfn(pa) 379 1.23 matt | ((prot & VM_PROT_WRITE) ? MIPS1_PG_D : MIPS1_PG_RO) 380 1.23 matt | ((flags & PMAP_NOCACHE) ? MIPS1_PG_N : 0) 381 1.23 matt | MIPS1_PG_WIRED | MIPS1_PG_V | MIPS1_PG_G; 382 1.23 matt } 383 1.23 matt return pte; 384 1.23 matt } 385 1.23 matt 386 1.23 matt static inline pt_entry_t 387 1.23 matt pte_make_enter(paddr_t pa, const struct vm_page_md *mdpg, vm_prot_t prot, 388 1.23 matt u_int flags, bool is_kernel_pmap_p) 389 1.23 matt { 390 1.23 matt pt_entry_t pte; 391 1.23 matt #if defined(_MIPS_PADDR_T_64BIT) || defined(_LP64) 392 1.23 matt const bool cached = (flags & PMAP_NOCACHE) == 0 393 1.23 matt && (pa & PGC_NOCACHE) == 0; 394 1.23 matt const bool prefetch = (pa & PGC_PREFETCH) != 0; 395 1.23 matt 396 1.23 matt pa &= ~(PGC_NOCACHE|PGC_PREFETCH); 397 1.23 matt #endif 398 1.23 matt 399 1.23 matt #if defined(cobalt) || defined(newsmips) || defined(pmax) /* otherwise ok */ 400 1.23 matt /* this is not error in general. */ 401 1.23 matt KASSERTMSG((pa & 0x80000000) == 0, "%#"PRIxPADDR, pa); 402 1.23 matt #endif 403 1.23 matt 404 1.23 matt if (mdpg != NULL) { 405 1.23 matt if ((prot & VM_PROT_WRITE) == 0) { 406 1.23 matt /* 407 1.23 matt * If page is not yet referenced, we could emulate this 408 1.23 matt * by not setting the page valid, and setting the 409 1.23 matt * referenced status in the TLB fault handler, similar 410 1.23 matt * to how page modified status is done for UTLBmod 411 1.23 matt * exceptions. 412 1.23 matt */ 413 1.23 matt pte = mips_pg_ropage_bit(); 414 1.23 matt #if defined(_MIPS_PADDR_T_64BIT) || defined(_LP64) 415 1.23 matt } else if (cached == false) { 416 1.23 matt if (VM_PAGEMD_MODIFIED_P(mdpg)) { 417 1.23 matt pte = mips_pg_rwncpage_bit(); 418 1.23 matt } else { 419 1.23 matt pte = mips_pg_cwncpage_bit(); 420 1.23 matt } 421 1.23 matt #endif 422 1.23 matt } else { 423 1.23 matt if (VM_PAGEMD_MODIFIED_P(mdpg)) { 424 1.23 matt pte = mips_pg_rwpage_bit(); 425 1.23 matt } else { 426 1.23 matt pte = mips_pg_cwpage_bit(); 427 1.23 matt } 428 1.23 matt } 429 1.23 matt } else if (MIPS_HAS_R4K_MMU) { 430 1.23 matt /* 431 1.23 matt * Assumption: if it is not part of our managed memory 432 1.23 matt * then it must be device memory which may be volatile. 433 1.23 matt */ 434 1.23 matt u_int cca = PMAP_CCA_FOR_PA(pa); 435 1.23 matt #if defined(_MIPS_PADDR_T_64BIT) || defined(_LP64) 436 1.23 matt if (prefetch) 437 1.23 matt cca = mips_options.mips3_cca_devmem; 438 1.23 matt #endif 439 1.23 matt pte = MIPS3_PG_IOPAGE(cca) & ~MIPS3_PG_G; 440 1.23 matt } else if (prot & VM_PROT_WRITE) { 441 1.23 matt pte = MIPS1_PG_N | MIPS1_PG_D; 442 1.23 matt } else { 443 1.23 matt pte = MIPS1_PG_N | MIPS1_PG_RO; 444 1.23 matt } 445 1.23 matt 446 1.23 matt if (MIPS_HAS_R4K_MMU) { 447 1.23 matt pte |= mips3_paddr_to_tlbpfn(pa) 448 1.23 matt | (is_kernel_pmap_p ? MIPS3_PG_G : 0); 449 1.23 matt } else { 450 1.23 matt pte |= mips1_paddr_to_tlbpfn(pa) 451 1.23 matt | MIPS1_PG_V 452 1.23 matt | (is_kernel_pmap_p ? MIPS1_PG_G : 0); 453 1.23 matt } 454 1.23 matt 455 1.23 matt return pte; 456 1.21 matt } 457 1.23 matt #endif /* __PMAP_PRIVATE */ 458 1.21 matt 459 1.1 jonathan #endif /* defined(_KERNEL) && !defined(_LOCORE) */ 460 1.1 jonathan #endif /* __MIPS_PTE_H__ */ 461