pmap.h revision 108166
133965Sjdp/* 277298Sobrien * Copyright (c) 1991 Regents of the University of California. 377298Sobrien * All rights reserved. 433965Sjdp * 533965Sjdp * This code is derived from software contributed to Berkeley by 660484Sobrien * the Systems Programming Group of the University of Utah Computer 760484Sobrien * Science Department and William Jolitz of UUNET Technologies Inc. 833965Sjdp * 960484Sobrien * Redistribution and use in source and binary forms, with or without 1060484Sobrien * modification, are permitted provided that the following conditions 1160484Sobrien * are met: 1260484Sobrien * 1. Redistributions of source code must retain the above copyright 1333965Sjdp * notice, this list of conditions and the following disclaimer. 1460484Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1560484Sobrien * notice, this list of conditions and the following disclaimer in the 1660484Sobrien * documentation and/or other materials provided with the distribution. 1760484Sobrien * 3. All advertising materials mentioning features or use of this software 1860484Sobrien * must display the following acknowledgement: 1960484Sobrien * This product includes software developed by the University of 2060484Sobrien * California, Berkeley and its contributors. 2160484Sobrien * 4. Neither the name of the University nor the names of its contributors 2260484Sobrien * may be used to endorse or promote products derived from this software 2360484Sobrien * without specific prior written permission. 2433965Sjdp * 2533965Sjdp * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2633965Sjdp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2733965Sjdp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2833965Sjdp * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2933965Sjdp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3033965Sjdp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3133965Sjdp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3233965Sjdp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3333965Sjdp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3433965Sjdp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3533965Sjdp * SUCH DAMAGE. 3633965Sjdp * 3733965Sjdp * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90 3833965Sjdp * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91 3933965Sjdp * from: FreeBSD: src/sys/i386/include/pmap.h,v 1.70 2000/11/30 4033965Sjdp * $FreeBSD: head/sys/sparc64/include/pmap.h 108166 2002-12-21 22:43:19Z jake $ 4133965Sjdp */ 4233965Sjdp 4333965Sjdp#ifndef _MACHINE_PMAP_H_ 4433965Sjdp#define _MACHINE_PMAP_H_ 4533965Sjdp 4633965Sjdp#include <sys/queue.h> 4733965Sjdp#include <machine/tte.h> 4833965Sjdp 4933965Sjdp#define DCACHE_COLOR_BITS (1) 5033965Sjdp#define DCACHE_COLORS (1 << DCACHE_COLOR_BITS) 5133965Sjdp#define DCACHE_COLOR_MASK (DCACHE_COLORS - 1) 5233965Sjdp#define DCACHE_COLOR(va) (((va) >> PAGE_SHIFT) & DCACHE_COLOR_MASK) 5333965Sjdp#define DCACHE_OTHER_COLOR(color) \ 5433965Sjdp ((color) ^ DCACHE_COLOR_BITS) 5533965Sjdp 5633965Sjdp#define PMAP_CONTEXT_MAX 8192 5733965Sjdp 5833965Sjdp#define pmap_page_is_mapped(m) (!TAILQ_EMPTY(&(m)->md.tte_list)) 5933965Sjdp#define pmap_resident_count(pm) (pm->pm_stats.resident_count) 6033965Sjdp 6133965Sjdptypedef struct pmap *pmap_t; 6233965Sjdp 6333965Sjdpstruct md_page { 6433965Sjdp TAILQ_HEAD(, tte) tte_list; 6533965Sjdp struct pmap *pmap; 6633965Sjdp uint32_t colors[DCACHE_COLORS]; 6733965Sjdp int32_t color; 6833965Sjdp uint32_t flags; 6933965Sjdp}; 7033965Sjdp 7133965Sjdpstruct pmap { 7233965Sjdp struct tte *pm_tsb; 7333965Sjdp vm_object_t pm_tsb_obj; 7433965Sjdp u_int pm_active; 7533965Sjdp u_int pm_context[MAXCPU]; 7633965Sjdp struct pmap_statistics pm_stats; 7733965Sjdp}; 7833965Sjdp 7933965Sjdpvoid pmap_bootstrap(vm_offset_t ekva); 8033965Sjdpvoid pmap_context_rollover(void); 8133965Sjdpvm_offset_t pmap_kextract(vm_offset_t va); 8233965Sjdpvoid pmap_kenter_flags(vm_offset_t va, vm_offset_t pa, u_long flags); 8333965Sjdpvoid pmap_kremove_flags(vm_offset_t va); 8433965Sjdp 8533965Sjdpint pmap_cache_enter(vm_page_t m, vm_offset_t va); 8633965Sjdpvoid pmap_cache_remove(vm_page_t m, vm_offset_t va); 8733965Sjdp 8833965Sjdpint pmap_remove_tte(struct pmap *pm1, struct pmap *pm2, struct tte *tp, 8933965Sjdp vm_offset_t va); 9033965Sjdpint pmap_protect_tte(struct pmap *pm1, struct pmap *pm2, struct tte *tp, 9133965Sjdp vm_offset_t va); 9233965Sjdp 9333965Sjdpvoid pmap_map_tsb(void); 9433965Sjdp 9533965Sjdpvoid pmap_clear_write(vm_page_t m); 9633965Sjdp 9733965Sjdp#define vtophys(va) pmap_kextract(((vm_offset_t)(va))) 9833965Sjdp 9933965Sjdpextern vm_offset_t avail_start; 10033965Sjdpextern vm_offset_t avail_end; 10133965Sjdpextern struct pmap kernel_pmap_store; 10233965Sjdp#define kernel_pmap (&kernel_pmap_store) 10333965Sjdpextern vm_offset_t phys_avail[]; 10433965Sjdpextern vm_offset_t virtual_avail; 10533965Sjdpextern vm_offset_t virtual_end; 10633965Sjdp 10733965Sjdpextern vm_offset_t msgbuf_phys; 10833965Sjdp 10960484Sobrienstatic __inline int 11060484Sobrienpmap_track_modified(pmap_t pm, vm_offset_t va) 11160484Sobrien{ 11260484Sobrien if (pm == kernel_pmap) 11360484Sobrien return ((va < kmi.clean_sva) || (va >= kmi.clean_eva)); 11460484Sobrien else 11533965Sjdp return (1); 11633965Sjdp} 11733965Sjdp 11833965Sjdp#endif /* !_MACHINE_PMAP_H_ */ 11933965Sjdp