pmap.h revision 85142
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 * 3. All advertising materials mentioning features or use of this software 18 * must display the following acknowledgement: 19 * This product includes software developed by the University of 20 * California, Berkeley and its contributors. 21 * 4. Neither the name of the University nor the names of its contributors 22 * may be used to endorse or promote products derived from this software 23 * without specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * Derived from hp300 version by Mike Hibler, this version by William 38 * Jolitz uses a recursive map [a pde points to the page directory] to 39 * map the page tables using the pagetables themselves. This is done to 40 * reduce the impact on kernel virtual memory for lots of sparse address 41 * space, and to reduce the cost of memory to each process. 42 * 43 * from: hp300: @(#)pmap.h 7.2 (Berkeley) 12/16/90 44 * from: @(#)pmap.h 7.4 (Berkeley) 5/12/91 45 * from: i386 pmap.h,v 1.54 1997/11/20 19:30:35 bde Exp 46 * $FreeBSD: head/sys/ia64/include/pmap.h 85142 2001-10-19 09:47:02Z dfr $ 47 */ 48 49#ifndef _MACHINE_PMAP_H_ 50#define _MACHINE_PMAP_H_ 51 52#include <sys/queue.h> 53#include <machine/pte.h> 54 55#ifdef _KERNEL 56 57#ifndef NKPT 58#define NKPT 30 /* initial number of kernel page tables */ 59#endif 60#define MAXKPT (PAGE_SIZE/sizeof(vm_offset_t)) 61 62 63/* 64 * Routine: pmap_kextract 65 * Function: 66 * Extract the physical page address associated 67 * kernel virtual address. 68 */ 69static __inline vm_offset_t 70pmap_kextract(vm_offset_t va) 71{ 72 return ia64_tpa(va); 73} 74 75#define vtophys(va) pmap_kextract(((vm_offset_t) (va))) 76 77#endif /* _KERNEL */ 78 79/* 80 * Pmap stuff 81 */ 82struct pv_entry; 83 84struct md_page { 85 int pv_list_count; 86 TAILQ_HEAD(,pv_entry) pv_list; 87}; 88 89struct pmap { 90 TAILQ_HEAD(,pv_entry) pm_pvlist; /* list of mappings in pmap */ 91 u_int64_t pm_rid; /* base RID for pmap */ 92 int pm_count; /* reference count */ 93 int pm_flags; /* pmap flags */ 94 int pm_active; /* active flag */ 95 struct pmap_statistics pm_stats; /* pmap statistics */ 96 struct vm_page *pm_ptphint; /* pmap ptp hint */ 97}; 98 99#define pmap_resident_count(pmap) (pmap)->pm_stats.resident_count 100 101#define PM_FLAG_LOCKED 0x1 102#define PM_FLAG_WANTED 0x2 103 104typedef struct pmap *pmap_t; 105 106#ifdef _KERNEL 107extern pmap_t kernel_pmap; 108#endif 109 110/* 111 * For each vm_page_t, there is a list of all currently valid virtual 112 * mappings of that page. An entry is a pv_entry_t, the list is pv_table. 113 */ 114typedef struct pv_entry { 115 pmap_t pv_pmap; /* pmap where mapping lies */ 116 vm_offset_t pv_va; /* virtual address for mapping */ 117 TAILQ_ENTRY(pv_entry) pv_list; 118 TAILQ_ENTRY(pv_entry) pv_plist; 119} *pv_entry_t; 120 121#define PV_ENTRY_NULL ((pv_entry_t) 0) 122 123#ifdef _KERNEL 124 125extern vm_offset_t avail_end; 126extern vm_offset_t avail_start; 127extern vm_offset_t clean_eva; 128extern vm_offset_t clean_sva; 129extern vm_offset_t phys_avail[]; 130extern vm_offset_t virtual_avail; 131extern vm_offset_t virtual_end; 132 133vm_offset_t pmap_steal_memory __P((vm_size_t)); 134void pmap_bootstrap __P((void)); 135void pmap_setdevram __P((unsigned long long basea, vm_offset_t sizea)); 136int pmap_uses_prom_console __P((void)); 137pmap_t pmap_kernel __P((void)); 138void *pmap_mapdev __P((vm_offset_t, vm_size_t)); 139void pmap_unmapdev __P((vm_offset_t, vm_size_t)); 140unsigned *pmap_pte __P((pmap_t, vm_offset_t)) __pure2; 141vm_page_t pmap_use_pt __P((pmap_t, vm_offset_t)); 142void pmap_set_opt __P((unsigned *)); 143void pmap_set_opt_bsp __P((void)); 144struct pmap *pmap_install __P((struct pmap *pmap)); 145 146#endif /* _KERNEL */ 147 148#endif /* !_MACHINE_PMAP_H_ */ 149