1 /* $NetBSD: pmap_pv.h,v 1.2 2008/01/28 11:06:42 yamt Exp $ */ 2 3 /*- 4 * Copyright (c)2008 YAMAMOTO Takashi, 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 */ 28 29 #ifndef _X86_PMAP_PV_H_ 30 #define _X86_PMAP_PV_H_ 31 32 #include <sys/mutex.h> 33 #include <sys/queue.h> 34 35 struct vm_page; 36 37 /* 38 * structures to track P->V mapping 39 * 40 * this file is intended to be minimum as it's included by <machine/vmparam.h>. 41 */ 42 43 /* 44 * pv_pte: describe a pte 45 */ 46 47 struct pv_pte { 48 struct vm_page *pte_ptp; /* PTP; NULL for pmap_kernel() */ 49 vaddr_t pte_va; /* VA */ 50 }; 51 52 /* 53 * pv_entry: plug pv_pte into lists. 54 */ 55 56 struct pv_entry { 57 struct pv_pte pve_pte; /* should be the first member */ 58 LIST_ENTRY(pv_entry) pve_list; /* on pv_head::pvh_list */ 59 SLIST_ENTRY(pv_entry) pve_hash; 60 }; 61 #define pve_next pve_list.le_next 62 63 /* 64 * pmap_page: a structure which is embedded in each vm_page. 65 */ 66 67 struct pmap_page { 68 kmutex_t pp_lock; 69 union { 70 /* PP_EMBEDDED */ 71 struct pv_pte u_pte; 72 73 /* !PP_EMBEDDED */ 74 struct pv_head { 75 LIST_HEAD(, pv_entry) pvh_list; 76 } u_head; 77 78 /* PTPs */ 79 struct vm_page *u_link; 80 } pp_u; 81 #define pp_pte pp_u.u_pte 82 #define pp_head pp_u.u_head 83 #define pp_link pp_u.u_link 84 uint8_t pp_flags; 85 uint8_t pp_attrs; /* saved PG_M and PG_U */ 86 }; 87 88 /* pp_flags */ 89 #define PP_EMBEDDED 1 90 91 #define PMAP_PAGE_INIT(pp) \ 92 mutex_init(&(pp)->pp_lock, MUTEX_NODEBUG, IPL_VM) 93 94 #endif /* !_X86_PMAP_PV_H_ */ 95