/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
* NASA Ames Research Center.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Copyright 1996 The Board of Trustees of The Leland Stanford
* Junior University. All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies. Stanford University
* makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without
* express or implied warranty.
*/
#if defined(cobalt) || defined(newsmips) || defined(pmax) /* otherwise ok */
/* this is not error in general. */
KASSERTMSG((pa & 0x80000000) == 0, "%#"PRIxPADDR, pa);
#endif
if (mdpg != NULL) {
if ((prot & VM_PROT_WRITE) == 0) {
/*
* If page is not yet referenced, we could emulate this
* by not setting the page valid, and setting the
* referenced status in the TLB fault handler, similar
* to how page modified status is done for UTLBmod
* exceptions.
*/
pte = mips_pg_ropage_bit();
#if defined(_MIPS_PADDR_T_64BIT) || defined(_LP64)
} else if (cached == false) {
if (VM_PAGEMD_MODIFIED_P(mdpg)) {
pte = mips_pg_rwncpage_bit();
} else {
pte = mips_pg_cwncpage_bit();
}
#endif
} else {
if (VM_PAGEMD_MODIFIED_P(mdpg)) {
pte = mips_pg_rwpage_bit();
} else {
pte = mips_pg_cwpage_bit();
}
}
} else if (MIPS_HAS_R4K_MMU) {
/*
* Assumption: if it is not part of our managed memory
* then it must be device memory which may be volatile.
*/
u_int cca = PMAP_CCA_FOR_PA(pa);
#if defined(_MIPS_PADDR_T_64BIT) || defined(_LP64)
if (prefetch)
cca = mips_options.mips3_cca_devmem;
#endif
pte = MIPS3_PG_IOPAGE(cca) & ~MIPS3_PG_G;
} else if (prot & VM_PROT_WRITE) {
pte = MIPS1_PG_N | MIPS1_PG_D;
} else {
pte = MIPS1_PG_N | MIPS1_PG_RO;
}