11.4Sthorpej/*	$NetBSD: pmap_68k.h,v 1.4 2025/11/10 14:32:34 thorpej Exp $	*/
21.1Sthorpej
31.1Sthorpej/*-
41.1Sthorpej * Copyright (c) 2025 The NetBSD Foundation, Inc.
51.1Sthorpej * All rights reserved.
61.1Sthorpej *
71.1Sthorpej * This code is derived from software contributed to The NetBSD Foundation
81.1Sthorpej * by Jason R. Thorpe.
91.1Sthorpej *
101.1Sthorpej * Redistribution and use in source and binary forms, with or without
111.1Sthorpej * modification, are permitted provided that the following conditions
121.1Sthorpej * are met:
131.1Sthorpej * 1. Redistributions of source code must retain the above copyright
141.1Sthorpej *    notice, this list of conditions and the following disclaimer.
151.1Sthorpej * 2. Redistributions in binary form must reproduce the above copyright
161.1Sthorpej *    notice, this list of conditions and the following disclaimer in the
171.1Sthorpej *    documentation and/or other materials provided with the distribution.
181.1Sthorpej *
191.1Sthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
201.1Sthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
211.1Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
221.1Sthorpej * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
231.1Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
241.1Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
251.1Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
261.1Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
271.1Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
281.1Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
291.1Sthorpej * POSSIBILITY OF SUCH DAMAGE.
301.1Sthorpej */
311.1Sthorpej
321.1Sthorpej/*
331.1Sthorpej * Copyright (c) 1987 Carnegie-Mellon University
341.1Sthorpej * Copyright (c) 1991, 1993
351.1Sthorpej *      The Regents of the University of California.  All rights reserved.
361.1Sthorpej *
371.1Sthorpej * This code is derived from software contributed to Berkeley by
381.1Sthorpej * the Systems Programming Group of the University of Utah Computer
391.1Sthorpej * Science Department.
401.1Sthorpej *
411.1Sthorpej * Redistribution and use in source and binary forms, with or without
421.1Sthorpej * modification, are permitted provided that the following conditions
431.1Sthorpej * are met:
441.1Sthorpej * 1. Redistributions of source code must retain the above copyright
451.1Sthorpej *    notice, this list of conditions and the following disclaimer.
461.1Sthorpej * 2. Redistributions in binary form must reproduce the above copyright
471.1Sthorpej *    notice, this list of conditions and the following disclaimer in the
481.1Sthorpej *    documentation and/or other materials provided with the distribution.
491.1Sthorpej * 3. Neither the name of the University nor the names of its contributors
501.1Sthorpej *    may be used to endorse or promote products derived from this software
511.1Sthorpej *    without specific prior written permission.
521.1Sthorpej *
531.1Sthorpej * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
541.1Sthorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
551.1Sthorpej * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
561.1Sthorpej * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
571.1Sthorpej * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
581.1Sthorpej * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
591.1Sthorpej * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
601.1Sthorpej * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
611.1Sthorpej * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
621.1Sthorpej * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
631.1Sthorpej * SUCH DAMAGE.
641.1Sthorpej *
651.1Sthorpej *      @(#)pmap.h      8.1 (Berkeley) 6/10/93
661.1Sthorpej */
671.1Sthorpej
681.1Sthorpej#ifndef _M68K_PMAP_68K_H_
691.1Sthorpej#define	_M68K_PMAP_68K_H_
701.1Sthorpej
711.1Sthorpej#include <sys/rbtree.h>
721.1Sthorpej#include <sys/queue.h>
731.1Sthorpej
741.1Sthorpej#include <m68k/mmu_51.h>
751.1Sthorpej#include <m68k/mmu_40.h>
761.1Sthorpej
771.1Sthorpejtypedef unsigned int	pt_entry_t;
781.1Sthorpej
791.1SthorpejTAILQ_HEAD(pmap_ptpage_list, pmap_ptpage);
801.1SthorpejLIST_HEAD(pmap_pv_list, pv_entry);
811.1Sthorpej
821.1Sthorpejstruct pmap {
831.1Sthorpej	struct pmap_table *pm_lev1map;	/* level 1 table */
841.1Sthorpej	paddr_t            pm_lev1pa;	/* PA of level 1 table */
851.1Sthorpej	unsigned int       pm_refcnt;	/* reference count */
861.1Sthorpej
871.1Sthorpej	struct pmap_table *pm_pt_cache;	/* most recently used leaf table */
881.1Sthorpej
891.1Sthorpej	/* Red-Black tree that contains the active tables. */
901.1Sthorpej	struct rb_tree     pm_tables;	/* lev1map not in here */
911.1Sthorpej
921.1Sthorpej	/* Page table pages for segment and leaf tables. */
931.1Sthorpej	struct pmap_ptpage_list pm_ptpages[2];
941.1Sthorpej
951.1Sthorpej	struct pmap_pv_list pm_pvlist;	/* all associated P->V entries */
961.1Sthorpej
971.1Sthorpej	struct pmap_statistics pm_stats;/* statistics */
981.1Sthorpej};
991.1Sthorpej
1001.1Sthorpej/*
1011.1Sthorpej * One entry per P->V mapping of a managed page.
1021.1Sthorpej *
1031.1Sthorpej * N.B. We want to keep this structure's size to be a multiple of
1041.1Sthorpej * 8; we want to align them to 8 bytes in order to be able to use
1051.1Sthorpej * the lower 3 bits of the pv_entry list head for page attributes.
1061.1Sthorpej */
1071.1Sthorpejstruct pv_entry {
1081.1Sthorpej/* 0*/	struct pv_entry     *pv_next;	/* link on page list */
1091.1Sthorpej/* 4*/	LIST_ENTRY(pv_entry) pv_pmlist;	/* link on pmap list */
1101.1Sthorpej/*12*/	pmap_t               pv_pmap;	/* pmap that contains mapping */
1111.1Sthorpej/*16*/	vaddr_t              pv_vf;	/* virtual address + flags */
1121.1Sthorpej/*20*/	struct pmap_table   *pv_pt;	/* table that contains the PTE */
1131.1Sthorpej/*24*/
1141.1Sthorpej};
1151.1Sthorpej
1161.1Sthorpej/* Upper bits of pv_vf contain the virtual addess */
1171.1Sthorpej#define	PV_VA(pv)	((pv)->pv_vf & ~PAGE_MASK)
1181.1Sthorpej
1191.1Sthorpej/* Lower bits of pv_vf contain flags */
1201.1Sthorpej#define	PV_F_CI_VAC	__BIT(0)	/* mapping CI due to VAC alias */
1211.1Sthorpej#define	PV_F_CI_USR	__BIT(1)	/* mapping CI due to user request */
1221.1Sthorpej
1231.1Sthorpej/*
1241.1Sthorpej * This describes an individual table used by the MMU.  Depending on
1251.1Sthorpej * the MMU configuration, there may be more than one table per physical
1261.1Sthorpej * page.
1271.1Sthorpej *
1281.1Sthorpej * For leaf (page) and inner segment tables, pt_st points to the
1291.1Sthorpej * segment table one level up in the tree that maps it, and pt_stidx
1301.1Sthorpej * is the index into that segment table.  pt_st also serves as a
1311.1Sthorpej * proxy for whether or not the table has been inserted into the
1321.1Sthorpej * table lookup tree.  For the level-1 table, pt_st is NULL and
1331.1Sthorpej * that table is not inserted into the lookup tree.
1341.1Sthorpej */
1351.1Sthorpejstruct pmap_table {
1361.1Sthorpej	struct pmap_ptpage *pt_ptpage;
1371.1Sthorpej	pt_entry_t         *pt_entries;
1381.1Sthorpej	struct pmap_table  *pt_st;
1391.1Sthorpej	unsigned short      pt_holdcnt;
1401.1Sthorpej	unsigned short      pt_stidx;
1411.1Sthorpej	unsigned int        pt_key;
1421.1Sthorpej	union {
1431.1Sthorpej		LIST_ENTRY(pmap_table) pt_freelist;
1441.1Sthorpej		struct rb_node         pt_node;
1451.1Sthorpej	};
1461.1Sthorpej};
1471.1Sthorpej
1481.1Sthorpej/*
1491.1Sthorpej * This describes a page table page, which contains one or more MMU tables.
1501.1Sthorpej * It's variable length, and the table descriptors are allocated along with.
1511.1Sthorpej */
1521.1Sthorpejstruct pmap_ptpage {
1531.1Sthorpej	TAILQ_ENTRY(pmap_ptpage)  ptp_list;
1541.1Sthorpej	LIST_HEAD(, pmap_table)   ptp_freelist;
1551.1Sthorpej	struct vm_page           *ptp_pg;
1561.1Sthorpej	unsigned int              ptp_vpagenum : 23,
1571.1Sthorpej	                          ptp_freecnt : 8,
1581.1Sthorpej	                          ptp_segtab : 1;
1591.1Sthorpej	struct pmap_table         ptp_tables[];
1601.1Sthorpej};
1611.1Sthorpej
1621.1Sthorpej/*
1631.1Sthorpej * Abstract definitions for PTE bits / fields.  C code will compile-time-
1641.1Sthorpej * assert the equivalencies that we assume.
1651.1Sthorpej *
1661.1Sthorpej * N.B. assumes exclusive use of short descriptors on 68851.
1671.1Sthorpej */
1681.1Sthorpej#define	PTE_VALID	PTE40_RESIDENT	/* == DT51_PAGE */
1691.1Sthorpej#define	PTE_WP		PTE40_W		/* == PTE51_WP */
1701.1Sthorpej#define	PTE_M		PTE40_M		/* == PTE51_M */
1711.1Sthorpej#define	PTE_U		PTE40_U		/* == PTE51_U */
1721.1Sthorpej#define	PTE_PVLIST	PTE40_G		/* unused on '51, don't use PFLUSHxN */
1731.1Sthorpej#define	PTE_WIRED	PTE40_UR	/* unused on '51 */
1741.1Sthorpej
1751.1Sthorpej/*
1761.1Sthorpej * PTE40_CM overlaps with PTE51_CI and PTE51_L (which we don't use).
1771.1Sthorpej */
1781.1Sthorpej#define	PTE_CMASK	PTE40_CM
1791.1Sthorpej
1801.1Sthorpej/*
1811.1Sthorpej * Critical bits that, when changed (see pmap_changebit()), require
1821.1Sthorpej * invalidation of the ATC.
1831.1Sthorpej */
1841.1Sthorpej#define	PTE_CRIT_BITS	(PTE_WP | PTE_CMASK)
1851.1Sthorpej
1861.1Sthorpej/*
1871.1Sthorpej * Root Pointer attributes for Supervisor and User modes.
1881.1Sthorpej *
1891.1Sthorpej * Supervisor:
1901.1Sthorpej * - No index limit (Lower limit == 0)
1911.1Sthorpej * - Points to Short format descriptor table.
1921.1Sthorpej * - Shared Globally
1931.1Sthorpej *
1941.1Sthorpej * User:
1951.1Sthorpej * - No index limit (Lower limit == 0)
1961.1Sthorpej * - Points to Short format descriptor table.
1971.1Sthorpej */
1981.1Sthorpej#define	MMU51_SRP_BITS	(DTE51_LOWER | DTE51_SG | DT51_SHORT)
1991.1Sthorpej#define	MMU51_CRP_BITS	(DTE51_LOWER |            DT51_SHORT)
2001.1Sthorpej
2011.1Sthorpej/*
2021.1Sthorpej * Our abstract definition of a "segment" is "that which points to the
2031.1Sthorpej * leaf tables".  On the 2-level configuration, that's the level 1 table,
2041.1Sthorpej * and on the 3-level configuraiton, that's the level 2 table.
2051.1Sthorpej *
2061.1Sthorpej * This is the logical address layout:
2071.1Sthorpej *
2081.1Sthorpej * 2-level 4KB/page: l1,l2,page    == 10,10,12	(HP MMU compatible)
2091.1Sthorpej * 2-level 8KB/page: l1,l2,page    ==  8,11,13
2101.1Sthorpej * 3-level 4KB/page: l1,l2,l3,page == 7,7,6,12
2111.1Sthorpej * 3-level 8KB/page: l1,l2,l3,page == 7,7,5,13
2121.1Sthorpej *
2131.1Sthorpej * The 2-level l2 size is chosen per the number of page table entries
2141.1Sthorpej * per page, to use one whole page for PTEs per one segment table entry.
2151.1Sthorpej *
2161.1Sthorpej * The 3-level layout is defined by the 68040/68060 hardware, and is not
2171.1Sthorpej * configurable (other than chosen page size).  If '851 / '030 chooses
2181.1Sthorpej * to use the 3-level layout, it is specifically configured to be compatible
2191.1Sthorpej * with the 68040.
2201.1Sthorpej */
2211.1Sthorpej							/*  8KB /  4KB  */
2221.1Sthorpej#define	LA2L_L2_NBITS	(PGSHIFT - 2)			/*   11 /   10  */
2231.1Sthorpej#define	LA2L_L2_COUNT	__BIT(LA2L_L2_NBITS)		/* 2048 / 1024  */
2241.1Sthorpej#define	LA2L_L2_SHIFT	PGSHIFT				/*   13 /   12  */
2251.1Sthorpej#define	LA2L_L1_NBITS	(32 - LA2L_L2_NBITS - PGSHIFT)	/*    8 /   10  */
2261.1Sthorpej#define	LA2L_L1_COUNT	__BIT(LA2L_L1_NBITS)		/*  256 / 1024  */
2271.1Sthorpej#define	LA2L_L1_SHIFT	(LA2L_L2_NBITS + PGSHIFT)	/*   24 /   22  */
2281.1Sthorpej
2291.1Sthorpej#define	LA2L_L1_MASK	(__BITS(0,(LA2L_L1_NBITS - 1)) << LA2L_L1_SHIFT)
2301.1Sthorpej#define	LA2L_L2_MASK	(__BITS(0,(LA2L_L2_NBITS - 1)) << LA2L_L2_SHIFT)
2311.1Sthorpej
2321.1Sthorpej#define	LA2L_RI(va)	__SHIFTOUT((va), LA2L_L1_MASK)	/* root index */
2331.1Sthorpej#define	LA2L_PGI(va)	__SHIFTOUT((va), LA2L_L2_MASK)	/* page index */
2341.1Sthorpej
2351.1Sthorpej#define	MMU51_TCR_BITS	(TCR51_E | TCR51_SRE |				\
2361.1Sthorpej			 __SHIFTIN(PGSHIFT, TCR51_PS) |			\
2371.1Sthorpej			 __SHIFTIN(LA2L_L1_NBITS, TCR51_TIA) |		\
2381.1Sthorpej			 __SHIFTIN(LA2L_L2_NBITS, TCR51_TIB))
2391.3Sthorpej
2401.3Sthorpej#define	MMU51_3L_TCR_BITS (TCR51_E | TCR51_SRE |			\
2411.3Sthorpej			__SHIFTIN(PGSHIFT, TCR51_PS) |			\
2421.3Sthorpej			__SHIFTIN(LA40_L1_NBITS, TCR51_TIA) |		\
2431.3Sthorpej			__SHIFTIN(LA40_L2_NBITS, TCR51_TIB) |		\
2441.3Sthorpej			__SHIFTIN(LA40_L3_NBITS, TCR51_TIC))
2451.3Sthorpej
2461.1Sthorpej#define	MMU40_TCR_BITS	(TCR40_E |					\
2471.1Sthorpej			 __SHIFTIN(PGSHIFT - 12, TCR40_P))
2481.1Sthorpej
2491.1Sthorpej/* SEG1SHIFT3L is for the "upper" segment on the 3-level configuration */
2501.1Sthorpej#define	SEGSHIFT2L	(LA2L_L1_SHIFT)			/*   24 /   22  */
2511.1Sthorpej#define	SEGSHIFT3L	(LA40_L2_SHIFT)			/*   18 /   18  */
2521.1Sthorpej#define	SEG1SHIFT3L	(LA40_L1_SHIFT)			/*   25 /   25  */
2531.1Sthorpej
2541.1Sthorpej/* NBSEG13L is for the "upper" segment on the 3-level configuration */
2551.1Sthorpej#define	NBSEG2L		__BIT(SEGSHIFT2L)
2561.1Sthorpej#define	NBSEG3L		__BIT(SEGSHIFT3L)
2571.1Sthorpej#define	NBSEG13L	__BIT(SEG1SHIFT3L)
2581.1Sthorpej
2591.1Sthorpej#define	SEGOFSET2L	(NBSEG2L - 1)
2601.1Sthorpej#define	SEGOFSET3L	(NBSEG3L - 1)
2611.1Sthorpej#define	SEG1OFSET3L	(NBSEG13L - 1)
2621.1Sthorpej
2631.1Sthorpej#define	pmap_trunc_seg_2L(va)	(((vaddr_t)(va)) & ~SEGOFSET2L)
2641.1Sthorpej#define	pmap_round_seg_2L(va)	(pmap_trunc_seg_2L((vaddr_t)(va) + SEGOFSET2L))
2651.1Sthorpej#define	pmap_seg_offset_2L(va)	(((vaddr_t)(va)) & SEGOFSET2L)
2661.1Sthorpej
2671.1Sthorpej#define	pmap_trunc_seg_3L(va)	(((vaddr_t)(va)) & ~SEGOFSET3L)
2681.1Sthorpej#define	pmap_round_seg_3L(va)	(pmap_trunc_seg_3L((vaddr_t)(va) + SEGOFSET3L))
2691.1Sthorpej#define	pmap_seg_offset_3L(va)	(((vaddr_t)(va)) & SEGOFSET3L)
2701.1Sthorpej
2711.1Sthorpej#define	pmap_trunc_seg1_3L(va)	(((vaddr_t)(va)) & ~SEG1OFSET3L)
2721.1Sthorpej#define	pmap_round_seg1_3L(va)	(pmap_trunc_seg1_3L((vaddr_t)(va)+ SEG1OFSET3L))
2731.1Sthorpej#define	pmap_seg1_offset_3L(va)	(((vaddr_t)(va)) & SEG1OFSET3L)
2741.1Sthorpej
2751.1Sthorpej/*
2761.1Sthorpej * pmap-specific data store in the vm_page structure.
2771.1Sthorpej *
2781.1Sthorpej * We keep the U/M attrs in the lower 2 bits of the list head
2791.1Sthorpej * pointer.  This is possible because both the U and M bits are
2801.1Sthorpej * adjacent; we just need to shift them down 3 bit positions.
2811.1Sthorpej *
2821.1Sthorpej * Assumes that PV entries will be 4-byte aligned, but the allocator
2831.1Sthorpej * guarantees this for us.
2841.1Sthorpej */
2851.1Sthorpej#define	__HAVE_VM_PAGE_MD
2861.1Sthorpejstruct vm_page_md {
2871.1Sthorpej	uintptr_t pvh_listx;		/* pv_entry list + attrs */
2881.1Sthorpej};
2891.1Sthorpej
2901.1Sthorpej#define	PVH_UM_SHIFT	3
2911.1Sthorpej#define	PVH_UM_MASK	__BITS(0,1)
2921.1Sthorpej#define	PVH_CI		__BIT(2)
2931.1Sthorpej#define	PVH_ATTR_MASK	(PVH_UM_MASK | PVH_CI)
2941.1Sthorpej#define	PVH_PV_MASK	(~PVH_ATTR_MASK)
2951.1Sthorpej
2961.1Sthorpej#define VM_MDPAGE_INIT(pg)					\
2971.1Sthorpejdo {								\
2981.1Sthorpej	(pg)->mdpage.pvh_listx = 0;				\
2991.1Sthorpej} while (/*CONSTCOND*/0)
3001.1Sthorpej
3011.1Sthorpej#define	VM_MDPAGE_PVS(pg)					\
3021.1Sthorpej	((struct pv_entry *)((pg)->mdpage.pvh_listx & (uintptr_t)PVH_PV_MASK))
3031.1Sthorpej
3041.1Sthorpej#define	VM_MDPAGE_HEAD_PVP(pg)					\
3051.1Sthorpej	((struct pv_entry **)&(pg)->mdpage.pvh_listx)
3061.1Sthorpej
3071.1Sthorpej#define	VM_MDPAGE_SETPVP(pvp, pv)				\
3081.1Sthorpejdo {								\
3091.1Sthorpej	/*							\
3101.1Sthorpej	 * The page attributes are in the lower two bits of	\
3111.1Sthorpej	 * the first PV pointer.  Rather than comparing the	\
3121.1Sthorpej	 * address and branching, we just always preserve what	\
3131.1Sthorpej	 * might be there (either the attribute bits or zero	\
3141.1Sthorpej	 * bits).						\
3151.1Sthorpej	 */							\
3161.1Sthorpej	*(pvp) = (struct pv_entry *)				\
3171.1Sthorpej	    ((uintptr_t)(pv) |					\
3181.1Sthorpej	     (((uintptr_t)(*(pvp))) & (uintptr_t)PVH_ATTR_MASK));\
3191.1Sthorpej} while (/*CONSTCOND*/0)
3201.1Sthorpej
3211.1Sthorpej#define	VM_MDPAGE_UM(pg)					\
3221.1Sthorpej	(((pg)->mdpage.pvh_listx & PVH_UM_MASK) << PVH_UM_SHIFT)
3231.1Sthorpej
3241.1Sthorpej#define	VM_MDPAGE_ADD_UM(pg, a)					\
3251.1Sthorpejdo {								\
3261.1Sthorpej	(pg)->mdpage.pvh_listx |=				\
3271.1Sthorpej	    ((a) >> PVH_UM_SHIFT) & PVH_UM_MASK;		\
3281.1Sthorpej} while (/*CONSTCOND*/0)
3291.1Sthorpej
3301.1Sthorpej#define	VM_MDPAGE_SET_UM(pg, v)					\
3311.1Sthorpejdo {								\
3321.1Sthorpej	(pg)->mdpage.pvh_listx =				\
3331.1Sthorpej	    ((pg)->mdpage.pvh_listx & ~PVH_UM_MASK) |		\
3341.1Sthorpej	    (((v) >> PVH_UM_SHIFT) & PVH_UM_MASK);		\
3351.1Sthorpej} while (/*CONSTCOND*/0)
3361.1Sthorpej
3371.1Sthorpej#define	VM_MDPAGE_SET_CI(pg)					\
3381.1Sthorpejdo {								\
3391.1Sthorpej	(pg)->mdpage.pvh_listx |= PVH_CI;			\
3401.1Sthorpej} while (/*CONSTCOND*/0)
3411.1Sthorpej
3421.1Sthorpej#define VM_MDPAGE_CLR_CI(pg)					\
3431.1Sthorpejdo {								\
3441.1Sthorpej	(pg)->mdpage.pvh_listx &= ~PVH_CI;			\
3451.1Sthorpej} while (/*CONSTCOND*/0)
3461.1Sthorpej
3471.1Sthorpej#define	VM_MDPAGE_CI_P(pg)					\
3481.1Sthorpej	((pg)->mdpage.pvh_listx & PVH_CI)
3491.1Sthorpej
3501.1Sthorpejbool	pmap_testbit(struct vm_page *, pt_entry_t);
3511.1Sthorpej#define	pmap_is_referenced(pg)					\
3521.1Sthorpej	((VM_MDPAGE_UM(pg) & PTE_U) || pmap_testbit((pg), PTE_U))
3531.1Sthorpej#define	pmap_is_modified(pg)					\
3541.1Sthorpej	((VM_MDPAGE_UM(pg) & PTE_M) || pmap_testbit((pg), PTE_M))
3551.1Sthorpej
3561.1Sthorpejbool	pmap_changebit(struct vm_page *, pt_entry_t, pt_entry_t);
3571.1Sthorpej#define	pmap_clear_reference(pg)				\
3581.1Sthorpej	pmap_changebit((pg), 0, (pt_entry_t)~PTE_U)
3591.1Sthorpej#define	pmap_clear_modify(pg)					\
3601.1Sthorpej	pmap_changebit((pg), 0, (pt_entry_t)~PTE_M)
3611.1Sthorpej
3621.1Sthorpej#define	pmap_update(pmap)		__nothing
3631.1Sthorpej#define	pmap_copy(dp, sp, da, l, sa)	__nothing
3641.1Sthorpej
3651.1Sthorpej#define	pmap_resident_count(pmap)	((pmap)->pm_stats.resident_count)
3661.1Sthorpej#define	pmap_wired_count(pmap)		((pmap)->pm_stats.wired_count)
3671.1Sthorpej
3681.1Sthorpej#define	PMAP_GROWKERNEL			/* enable pmap_growkernel() */
3691.1Sthorpej
3701.2Sthorpejvoid	pmap_procwr(struct proc *, vaddr_t, size_t);
3711.2Sthorpej#define	PMAP_NEED_PROCWR
3721.2Sthorpej
3731.1Sthorpej/*
3741.1Sthorpej * pmap_bootstrap1() is called before the MMU is turned on.
3751.1Sthorpej * pmap_bootstrap2() is called after.
3761.1Sthorpej */
3771.4Sthorpejpaddr_t	pmap_bootstrap1(paddr_t/*nextpa*/, paddr_t/*reloff*/);
3781.1Sthorpejvoid *	pmap_bootstrap2(void);
3791.1Sthorpej
3801.2Sthorpej/*
3811.2Sthorpej * Variant of pmap_extract() that returns additional information about
3821.2Sthorpej * the mapping.  Used by bus_dma(9).
3831.2Sthorpej */
3841.1Sthorpejbool	pmap_extract_info(pmap_t, vaddr_t, paddr_t *, int *);
3851.1Sthorpej
3861.1Sthorpej/*
3871.1Sthorpej * Functions exported for compatibility with the Hibler pmap, where
3881.1Sthorpej * these are needed by other shared m68k code.
3891.1Sthorpej *
3901.1Sthorpej * XXX Clean this up eventually.
3911.1Sthorpej */
3921.2Sthorpejpt_entry_t *		pmap_kernel_pte(vaddr_t);
3931.1Sthorpej#define	kvtopte(va)	pmap_kernel_pte(va)
3941.1Sthorpej
3951.1Sthorpejpaddr_t		vtophys(vaddr_t);
3961.1Sthorpej
3971.1Sthorpejextern char *	vmmap;
3981.1Sthorpejextern void *	msgbufaddr;
3991.1Sthorpej
4001.1Sthorpej/* Support functions for HP MMU. */
4011.1Sthorpejvoid	pmap_init_vac(size_t);
4021.1Sthorpejvoid	pmap_prefer(vaddr_t, vaddr_t *, int);
4031.2Sthorpej/* PMAP_PREFER() defined in <machine/pmap.h> on machines were it's needed. */
4041.1Sthorpej
4051.1Sthorpej#endif /* _M68K_PMAP_68K_H_ */
406