1f9bac91bSBenno Rice /*- 2f9bac91bSBenno Rice * Copyright (C) 1995, 1996 Wolfgang Solfrank. 3f9bac91bSBenno Rice * Copyright (C) 1995, 1996 TooLs GmbH. 4f9bac91bSBenno Rice * All rights reserved. 5f9bac91bSBenno Rice * 6f9bac91bSBenno Rice * Redistribution and use in source and binary forms, with or without 7f9bac91bSBenno Rice * modification, are permitted provided that the following conditions 8f9bac91bSBenno Rice * are met: 9f9bac91bSBenno Rice * 1. Redistributions of source code must retain the above copyright 10f9bac91bSBenno Rice * notice, this list of conditions and the following disclaimer. 11f9bac91bSBenno Rice * 2. Redistributions in binary form must reproduce the above copyright 12f9bac91bSBenno Rice * notice, this list of conditions and the following disclaimer in the 13f9bac91bSBenno Rice * documentation and/or other materials provided with the distribution. 14f9bac91bSBenno Rice * 3. All advertising materials mentioning features or use of this software 15f9bac91bSBenno Rice * must display the following acknowledgement: 16f9bac91bSBenno Rice * This product includes software developed by TooLs GmbH. 17f9bac91bSBenno Rice * 4. The name of TooLs GmbH may not be used to endorse or promote products 18f9bac91bSBenno Rice * derived from this software without specific prior written permission. 19f9bac91bSBenno Rice * 20f9bac91bSBenno Rice * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 21f9bac91bSBenno Rice * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22f9bac91bSBenno Rice * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23f9bac91bSBenno Rice * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24f9bac91bSBenno Rice * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25f9bac91bSBenno Rice * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26f9bac91bSBenno Rice * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27f9bac91bSBenno Rice * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28f9bac91bSBenno Rice * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29f9bac91bSBenno Rice * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30f9bac91bSBenno Rice * 31f9bac91bSBenno Rice * $NetBSD: pmap.h,v 1.17 2000/03/30 16:18:24 jdolecek Exp $ 32f9bac91bSBenno Rice * $FreeBSD$ 33f9bac91bSBenno Rice */ 34f9bac91bSBenno Rice 35f9bac91bSBenno Rice #ifndef _MACHINE_PMAP_H_ 36f9bac91bSBenno Rice #define _MACHINE_PMAP_H_ 37f9bac91bSBenno Rice 3848d0b1a0SAlan Cox #include <sys/queue.h> 3948d0b1a0SAlan Cox #include <sys/_lock.h> 4048d0b1a0SAlan Cox #include <sys/_mutex.h> 415244eac9SBenno Rice #include <machine/sr.h> 427f89270bSPeter Grehan #include <machine/pte.h> 43f9bac91bSBenno Rice 447c277971SPeter Grehan #if !defined(NPMAPS) 457c277971SPeter Grehan #define NPMAPS 32768 467c277971SPeter Grehan #endif /* !defined(NPMAPS) */ 477c277971SPeter Grehan 48f9bac91bSBenno Rice struct pmap { 4948d0b1a0SAlan Cox struct mtx pm_mtx; 505244eac9SBenno Rice u_int pm_sr[16]; 515244eac9SBenno Rice u_int pm_active; 525244eac9SBenno Rice u_int pm_context; 535244eac9SBenno Rice struct pmap_statistics pm_stats; 54f9bac91bSBenno Rice }; 55f9bac91bSBenno Rice 56f9bac91bSBenno Rice typedef struct pmap *pmap_t; 57f9bac91bSBenno Rice 585244eac9SBenno Rice struct pvo_entry { 595244eac9SBenno Rice LIST_ENTRY(pvo_entry) pvo_vlink; /* Link to common virt page */ 605244eac9SBenno Rice LIST_ENTRY(pvo_entry) pvo_olink; /* Link to overflow entry */ 615244eac9SBenno Rice struct pte pvo_pte; /* PTE */ 625244eac9SBenno Rice pmap_t pvo_pmap; /* Owning pmap */ 635244eac9SBenno Rice vm_offset_t pvo_vaddr; /* VA of entry */ 645244eac9SBenno Rice }; 655244eac9SBenno Rice LIST_HEAD(pvo_head, pvo_entry); 665244eac9SBenno Rice 675244eac9SBenno Rice struct md_page { 685244eac9SBenno Rice u_int mdpg_attrs; 695244eac9SBenno Rice struct pvo_head mdpg_pvoh; 705244eac9SBenno Rice }; 715244eac9SBenno Rice 725244eac9SBenno Rice extern struct pmap kernel_pmap_store; 735244eac9SBenno Rice #define kernel_pmap (&kernel_pmap_store) 745244eac9SBenno Rice 75dde5f194SAlan Cox #define pmap_page_is_mapped(m) (!LIST_EMPTY(&(m)->md.mdpg_pvoh)) 76f9bac91bSBenno Rice 77f9bac91bSBenno Rice #ifdef _KERNEL 78f9bac91bSBenno Rice 7948d0b1a0SAlan Cox #define PMAP_LOCK(pmap) mtx_lock(&(pmap)->pm_mtx) 8048d0b1a0SAlan Cox #define PMAP_LOCK_ASSERT(pmap, type) \ 8148d0b1a0SAlan Cox mtx_assert(&(pmap)->pm_mtx, (type)) 8248d0b1a0SAlan Cox #define PMAP_LOCK_DESTROY(pmap) mtx_destroy(&(pmap)->pm_mtx) 8348d0b1a0SAlan Cox #define PMAP_LOCK_INIT(pmap) mtx_init(&(pmap)->pm_mtx, "pmap", \ 8448d0b1a0SAlan Cox NULL, MTX_DEF) 8548d0b1a0SAlan Cox #define PMAP_LOCKED(pmap) mtx_owned(&(pmap)->pm_mtx) 8648d0b1a0SAlan Cox #define PMAP_MTX(pmap) (&(pmap)->pm_mtx) 8748d0b1a0SAlan Cox #define PMAP_TRYLOCK(pmap) mtx_trylock(&(pmap)->pm_mtx) 8848d0b1a0SAlan Cox #define PMAP_UNLOCK(pmap) mtx_unlock(&(pmap)->pm_mtx) 8948d0b1a0SAlan Cox 905244eac9SBenno Rice void pmap_bootstrap(vm_offset_t, vm_offset_t); 915501d40bSJake Burkholder void pmap_kenter(vm_offset_t va, vm_offset_t pa); 925501d40bSJake Burkholder void pmap_kremove(vm_offset_t); 938bbfa33aSBenno Rice void *pmap_mapdev(vm_offset_t, vm_size_t); 948bbfa33aSBenno Rice void pmap_unmapdev(vm_offset_t, vm_size_t); 95ac6ba8bdSBenno Rice void pmap_deactivate(struct thread *); 965244eac9SBenno Rice vm_offset_t pmap_kextract(vm_offset_t); 97c0763d37SSuleiman Souhlal int pmap_dev_direct_mapped(vm_offset_t, vm_size_t); 98c0763d37SSuleiman Souhlal 99f9c702dbSPeter Grehan boolean_t pmap_mmu_install(char *name, int prio); 100f9c702dbSPeter Grehan 101696effb6SJohn Baldwin #define vtophys(va) pmap_kextract((vm_offset_t)(va)) 102a0889814SBenno Rice 103f9c702dbSPeter Grehan #define PHYS_AVAIL_SZ 128 104f9c702dbSPeter Grehan extern vm_offset_t phys_avail[PHYS_AVAIL_SZ]; 105f9bac91bSBenno Rice extern vm_offset_t virtual_avail; 106f9bac91bSBenno Rice extern vm_offset_t virtual_end; 107f9bac91bSBenno Rice 1085244eac9SBenno Rice extern vm_offset_t msgbuf_phys; 109f9bac91bSBenno Rice 110f9c702dbSPeter Grehan extern int pmap_bootstrapped; 111f9c702dbSPeter Grehan 112f9bac91bSBenno Rice #endif 113f9bac91bSBenno Rice 1145244eac9SBenno Rice #endif /* !_MACHINE_PMAP_H_ */ 115