pmap.h revision 237168
1296633Sdes/*- 2276707Sdes * Copyright (c) 1991 Regents of the University of California. 3276707Sdes * All rights reserved. 4276707Sdes * 5276707Sdes * This code is derived from software contributed to Berkeley by 6276707Sdes * the Systems Programming Group of the University of Utah Computer 7276707Sdes * Science Department and William Jolitz of UUNET Technologies Inc. 8276707Sdes * 9276707Sdes * Redistribution and use in source and binary forms, with or without 10276707Sdes * modification, are permitted provided that the following conditions 11276707Sdes * are met: 12276707Sdes * 1. Redistributions of source code must retain the above copyright 13276707Sdes * notice, this list of conditions and the following disclaimer. 14276707Sdes * 2. Redistributions in binary form must reproduce the above copyright 15276707Sdes * notice, this list of conditions and the following disclaimer in the 16276707Sdes * documentation and/or other materials provided with the distribution. 17276707Sdes * 4. Neither the name of the University nor the names of its contributors 18276707Sdes * may be used to endorse or promote products derived from this software 19276707Sdes * without specific prior written permission. 20276707Sdes * 21276707Sdes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22276707Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23276707Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24276707Sdes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25276707Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26276707Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27276707Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28276707Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29276707Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30276707Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31276707Sdes * SUCH DAMAGE. 32276707Sdes * 33276707Sdes * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90 34276707Sdes * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91 35276707Sdes * from: FreeBSD: src/sys/i386/include/pmap.h,v 1.70 2000/11/30 36276707Sdes * $FreeBSD: head/sys/sparc64/include/pmap.h 237168 2012-06-16 18:56:19Z alc $ 37276707Sdes */ 38276707Sdes 39276707Sdes#ifndef _MACHINE_PMAP_H_ 40276707Sdes#define _MACHINE_PMAP_H_ 41276707Sdes 42276707Sdes#include <sys/queue.h> 43276707Sdes#include <sys/_cpuset.h> 44276707Sdes#include <sys/_lock.h> 45276707Sdes#include <sys/_mutex.h> 46276707Sdes#include <sys/_rwlock.h> 47276707Sdes#include <machine/cache.h> 48276707Sdes#include <machine/tte.h> 49276707Sdes 50276707Sdes#define PMAP_CONTEXT_MAX 8192 51276707Sdes 52276707Sdestypedef struct pmap *pmap_t; 53276707Sdes 54276707Sdesstruct md_page { 55276707Sdes TAILQ_HEAD(, tte) tte_list; 56294332Sdes struct pmap *pmap; 57276707Sdes uint32_t colors[DCACHE_COLORS]; 58276707Sdes int32_t color; 59276707Sdes uint32_t flags; 60276707Sdes}; 61276707Sdes 62276707Sdesstruct pmap { 63276707Sdes struct mtx pm_mtx; 64276707Sdes struct tte *pm_tsb; 65276707Sdes vm_object_t pm_tsb_obj; 66276707Sdes cpuset_t pm_active; 67276707Sdes u_int pm_context[MAXCPU]; 68276707Sdes struct pmap_statistics pm_stats; 69276707Sdes}; 70276707Sdes 71276707Sdes#define PMAP_LOCK(pmap) mtx_lock(&(pmap)->pm_mtx) 72276707Sdes#define PMAP_LOCK_ASSERT(pmap, type) \ 73276707Sdes mtx_assert(&(pmap)->pm_mtx, (type)) 74276707Sdes#define PMAP_LOCK_DESTROY(pmap) mtx_destroy(&(pmap)->pm_mtx) 75296633Sdes#define PMAP_LOCK_INIT(pmap) mtx_init(&(pmap)->pm_mtx, "pmap", \ 76276707Sdes NULL, MTX_DEF | MTX_DUPOK) 77276707Sdes#define PMAP_LOCKED(pmap) mtx_owned(&(pmap)->pm_mtx) 78276707Sdes#define PMAP_MTX(pmap) (&(pmap)->pm_mtx) 79276707Sdes#define PMAP_TRYLOCK(pmap) mtx_trylock(&(pmap)->pm_mtx) 80276707Sdes#define PMAP_UNLOCK(pmap) mtx_unlock(&(pmap)->pm_mtx) 81296633Sdes 82276707Sdes#define pmap_page_get_memattr(m) VM_MEMATTR_DEFAULT 83276707Sdes#define pmap_page_is_write_mapped(m) (((m)->aflags & PGA_WRITEABLE) != 0) 84276707Sdes#define pmap_page_set_memattr(m, ma) (void)0 85276707Sdes 86276707Sdesvoid pmap_bootstrap(u_int cpu_impl); 87276707Sdesvm_paddr_t pmap_kextract(vm_offset_t va); 88276707Sdesvoid pmap_kenter(vm_offset_t va, vm_page_t m); 89276707Sdesvoid pmap_kremove(vm_offset_t); 90294332Sdesvoid pmap_kenter_flags(vm_offset_t va, vm_paddr_t pa, u_long flags); 91294332Sdesvoid pmap_kremove_flags(vm_offset_t va); 92294332Sdesboolean_t pmap_page_is_mapped(vm_page_t m); 93294332Sdes 94294332Sdesint pmap_cache_enter(vm_page_t m, vm_offset_t va); 95276707Sdes 96276707Sdesint pmap_remove_tte(struct pmap *pm1, struct pmap *pm2, struct tte *tp, 97276707Sdes vm_offset_t va); 98276707Sdes 99276707Sdesvoid pmap_map_tsb(void); 100276707Sdesvoid pmap_set_kctx(void); 101276707Sdes 102276707Sdes#define vtophys(va) pmap_kextract((vm_offset_t)(va)) 103276707Sdes 104276707Sdesextern struct pmap kernel_pmap_store; 105276707Sdes#define kernel_pmap (&kernel_pmap_store) 106276707Sdesextern struct rwlock tte_list_global_lock; 107294332Sdesextern vm_paddr_t phys_avail[]; 108276707Sdesextern vm_offset_t virtual_avail; 109276707Sdesextern vm_offset_t virtual_end; 110276707Sdes 111276707Sdes#ifdef PMAP_STATS 112276707Sdes 113296633SdesSYSCTL_DECL(_debug_pmap_stats); 114276707Sdes 115276707Sdes#define PMAP_STATS_VAR(name) \ 116276707Sdes static long name; \ 117276707Sdes SYSCTL_LONG(_debug_pmap_stats, OID_AUTO, name, CTLFLAG_RW, \ 118276707Sdes &name, 0, "") 119276707Sdes 120276707Sdes#define PMAP_STATS_INC(var) \ 121296633Sdes atomic_add_long(&var, 1) 122276707Sdes 123276707Sdes#else 124276707Sdes 125276707Sdes#define PMAP_STATS_VAR(name) 126276707Sdes#define PMAP_STATS_INC(var) 127276707Sdes 128276707Sdes#endif 129276707Sdes 130276707Sdes#endif /* !_MACHINE_PMAP_H_ */ 131276707Sdes