Home | History | Annotate | Line # | Download | only in include
pmap_pv.h revision 1.9
      1 /*	$NetBSD: pmap_pv.h,v 1.9 2020/01/04 22:49:20 ad 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 pmap_page::pp_pvlist */
     59 };
     60 #define	pve_next	pve_list.le_next
     61 
     62 /*
     63  * pmap_page: a structure which is embedded in each vm_page.
     64  */
     65 
     66 struct pmap_page {
     67 	union {
     68 		/* PP_EMBEDDED */
     69 		struct pv_pte u_pte;
     70 
     71 		/* PTPs */
     72 		struct vm_page *u_link;
     73 	} pp_u;
     74 	LIST_HEAD(, pv_entry) pp_pvlist;
     75 #define	pp_pte	pp_u.u_pte
     76 #define	pp_link	pp_u.u_link
     77 	uint8_t pp_flags;
     78 	uint8_t pp_attrs;
     79 #define PP_ATTRS_D	0x01	/* Dirty */
     80 #define PP_ATTRS_A	0x02	/* Accessed */
     81 #define PP_ATTRS_W	0x04	/* Writable */
     82 };
     83 
     84 /* pp_flags */
     85 #define	PP_EMBEDDED	1
     86 
     87 #define	PMAP_PAGE_INIT(pp)	LIST_INIT(&(pp)->pp_pvlist)
     88 
     89 #endif /* !_X86_PMAP_PV_H_ */
     90