1/*- 2 * Copyright (c) 1991 Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * the Systems Programming Group of the University of Utah Computer 7 * Science Department and William Jolitz of UUNET Technologies Inc. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 4. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * Derived from hp300 version by Mike Hibler, this version by William 34 * Jolitz uses a recursive map [a pde points to the page directory] to 35 * map the page tables using the pagetables themselves. This is done to 36 * reduce the impact on kernel virtual memory for lots of sparse address 37 * space, and to reduce the cost of memory to each process. 38 * 39 * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90 40 * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91 41 * from: i386 pmap.h,v 1.54 1997/11/20 19:30:35 bde Exp
| 1/*- 2 * Copyright (c) 1991 Regents of the University of California. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * the Systems Programming Group of the University of Utah Computer 7 * Science Department and William Jolitz of UUNET Technologies Inc. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 4. Neither the name of the University nor the names of its contributors 18 * may be used to endorse or promote products derived from this software 19 * without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * Derived from hp300 version by Mike Hibler, this version by William 34 * Jolitz uses a recursive map [a pde points to the page directory] to 35 * map the page tables using the pagetables themselves. This is done to 36 * reduce the impact on kernel virtual memory for lots of sparse address 37 * space, and to reduce the cost of memory to each process. 38 * 39 * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90 40 * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91 41 * from: i386 pmap.h,v 1.54 1997/11/20 19:30:35 bde Exp
|
42 * $FreeBSD: head/sys/ia64/include/pmap.h 223873 2011-07-08 16:30:54Z marcel $
| 42 * $FreeBSD: head/sys/ia64/include/pmap.h 237168 2012-06-16 18:56:19Z alc $
|
43 */ 44 45#ifndef _MACHINE_PMAP_H_ 46#define _MACHINE_PMAP_H_ 47 48#include <sys/queue.h> 49#include <sys/_lock.h> 50#include <sys/_mutex.h> 51#include <machine/atomic.h> 52#include <machine/pte.h> 53#include <machine/vmparam.h> 54 55#ifdef _KERNEL 56 57#define MAXKPT (PAGE_SIZE/sizeof(vm_offset_t)) 58 59#define vtophys(va) pmap_kextract((vm_offset_t)(va)) 60 61#endif /* _KERNEL */ 62 63/* 64 * Pmap stuff 65 */ 66struct pv_entry; 67 68struct md_page { 69 int pv_list_count; 70 TAILQ_HEAD(,pv_entry) pv_list; 71 vm_memattr_t memattr; 72}; 73 74struct pmap { 75 struct mtx pm_mtx; 76 TAILQ_HEAD(,pv_entry) pm_pvlist; /* list of mappings in pmap */ 77 uint32_t pm_rid[IA64_VM_MINKERN_REGION]; 78 struct pmap_statistics pm_stats; /* pmap statistics */ 79}; 80 81typedef struct pmap *pmap_t; 82 83#ifdef _KERNEL 84extern struct pmap kernel_pmap_store; 85#define kernel_pmap (&kernel_pmap_store) 86 87#define PMAP_LOCK(pmap) mtx_lock(&(pmap)->pm_mtx) 88#define PMAP_LOCK_ASSERT(pmap, type) \ 89 mtx_assert(&(pmap)->pm_mtx, (type)) 90#define PMAP_LOCK_DESTROY(pmap) mtx_destroy(&(pmap)->pm_mtx) 91#define PMAP_LOCK_INIT(pmap) mtx_init(&(pmap)->pm_mtx, "pmap", \ 92 NULL, MTX_DEF) 93#define PMAP_LOCKED(pmap) mtx_owned(&(pmap)->pm_mtx) 94#define PMAP_MTX(pmap) (&(pmap)->pm_mtx) 95#define PMAP_TRYLOCK(pmap) mtx_trylock(&(pmap)->pm_mtx) 96#define PMAP_UNLOCK(pmap) mtx_unlock(&(pmap)->pm_mtx) 97#endif 98 99/* 100 * For each vm_page_t, there is a list of all currently valid virtual 101 * mappings of that page. An entry is a pv_entry_t, the list is pv_list. 102 */ 103typedef struct pv_entry { 104 pmap_t pv_pmap; /* pmap where mapping lies */ 105 vm_offset_t pv_va; /* virtual address for mapping */ 106 TAILQ_ENTRY(pv_entry) pv_list; 107 TAILQ_ENTRY(pv_entry) pv_plist; 108} *pv_entry_t; 109 110#ifdef _KERNEL 111 112extern vm_paddr_t phys_avail[]; 113extern vm_offset_t virtual_avail; 114extern vm_offset_t virtual_end; 115 116extern uint64_t pmap_vhpt_base[]; 117extern int pmap_vhpt_log2size; 118 119#define pmap_page_get_memattr(m) ((m)->md.memattr) 120#define pmap_page_is_mapped(m) (!TAILQ_EMPTY(&(m)->md.pv_list))
| 43 */ 44 45#ifndef _MACHINE_PMAP_H_ 46#define _MACHINE_PMAP_H_ 47 48#include <sys/queue.h> 49#include <sys/_lock.h> 50#include <sys/_mutex.h> 51#include <machine/atomic.h> 52#include <machine/pte.h> 53#include <machine/vmparam.h> 54 55#ifdef _KERNEL 56 57#define MAXKPT (PAGE_SIZE/sizeof(vm_offset_t)) 58 59#define vtophys(va) pmap_kextract((vm_offset_t)(va)) 60 61#endif /* _KERNEL */ 62 63/* 64 * Pmap stuff 65 */ 66struct pv_entry; 67 68struct md_page { 69 int pv_list_count; 70 TAILQ_HEAD(,pv_entry) pv_list; 71 vm_memattr_t memattr; 72}; 73 74struct pmap { 75 struct mtx pm_mtx; 76 TAILQ_HEAD(,pv_entry) pm_pvlist; /* list of mappings in pmap */ 77 uint32_t pm_rid[IA64_VM_MINKERN_REGION]; 78 struct pmap_statistics pm_stats; /* pmap statistics */ 79}; 80 81typedef struct pmap *pmap_t; 82 83#ifdef _KERNEL 84extern struct pmap kernel_pmap_store; 85#define kernel_pmap (&kernel_pmap_store) 86 87#define PMAP_LOCK(pmap) mtx_lock(&(pmap)->pm_mtx) 88#define PMAP_LOCK_ASSERT(pmap, type) \ 89 mtx_assert(&(pmap)->pm_mtx, (type)) 90#define PMAP_LOCK_DESTROY(pmap) mtx_destroy(&(pmap)->pm_mtx) 91#define PMAP_LOCK_INIT(pmap) mtx_init(&(pmap)->pm_mtx, "pmap", \ 92 NULL, MTX_DEF) 93#define PMAP_LOCKED(pmap) mtx_owned(&(pmap)->pm_mtx) 94#define PMAP_MTX(pmap) (&(pmap)->pm_mtx) 95#define PMAP_TRYLOCK(pmap) mtx_trylock(&(pmap)->pm_mtx) 96#define PMAP_UNLOCK(pmap) mtx_unlock(&(pmap)->pm_mtx) 97#endif 98 99/* 100 * For each vm_page_t, there is a list of all currently valid virtual 101 * mappings of that page. An entry is a pv_entry_t, the list is pv_list. 102 */ 103typedef struct pv_entry { 104 pmap_t pv_pmap; /* pmap where mapping lies */ 105 vm_offset_t pv_va; /* virtual address for mapping */ 106 TAILQ_ENTRY(pv_entry) pv_list; 107 TAILQ_ENTRY(pv_entry) pv_plist; 108} *pv_entry_t; 109 110#ifdef _KERNEL 111 112extern vm_paddr_t phys_avail[]; 113extern vm_offset_t virtual_avail; 114extern vm_offset_t virtual_end; 115 116extern uint64_t pmap_vhpt_base[]; 117extern int pmap_vhpt_log2size; 118 119#define pmap_page_get_memattr(m) ((m)->md.memattr) 120#define pmap_page_is_mapped(m) (!TAILQ_EMPTY(&(m)->md.pv_list))
|
| 121#define pmap_page_is_write_mapped(m) (((m)->aflags & PGA_WRITEABLE) != 0)
|
121#define pmap_mapbios(pa, sz) pmap_mapdev(pa, sz) 122#define pmap_unmapbios(va, sz) pmap_unmapdev(va, sz) 123 124vm_offset_t pmap_alloc_vhpt(void); 125void pmap_bootstrap(void); 126void pmap_kenter(vm_offset_t va, vm_offset_t pa); 127vm_paddr_t pmap_kextract(vm_offset_t va); 128void pmap_kremove(vm_offset_t); 129void *pmap_mapdev(vm_paddr_t, vm_size_t); 130void pmap_page_set_memattr(vm_page_t, vm_memattr_t); 131vm_offset_t pmap_page_to_va(vm_page_t); 132vm_offset_t pmap_steal_memory(vm_size_t); 133struct pmap *pmap_switch(struct pmap *pmap); 134void pmap_unmapdev(vm_offset_t, vm_size_t); 135 136#endif /* _KERNEL */ 137 138#endif /* !_MACHINE_PMAP_H_ */
| 122#define pmap_mapbios(pa, sz) pmap_mapdev(pa, sz) 123#define pmap_unmapbios(va, sz) pmap_unmapdev(va, sz) 124 125vm_offset_t pmap_alloc_vhpt(void); 126void pmap_bootstrap(void); 127void pmap_kenter(vm_offset_t va, vm_offset_t pa); 128vm_paddr_t pmap_kextract(vm_offset_t va); 129void pmap_kremove(vm_offset_t); 130void *pmap_mapdev(vm_paddr_t, vm_size_t); 131void pmap_page_set_memattr(vm_page_t, vm_memattr_t); 132vm_offset_t pmap_page_to_va(vm_page_t); 133vm_offset_t pmap_steal_memory(vm_size_t); 134struct pmap *pmap_switch(struct pmap *pmap); 135void pmap_unmapdev(vm_offset_t, vm_size_t); 136 137#endif /* _KERNEL */ 138 139#endif /* !_MACHINE_PMAP_H_ */
|