Home | History | Annotate | Line # | Download | only in uvm
uvm_pmap.h revision 1.36
      1  1.36  jmcneill /*	$NetBSD: uvm_pmap.h,v 1.36 2011/02/11 23:05:55 jmcneill Exp $	*/
      2   1.1       mrg 
      3   1.7       chs /*
      4   1.1       mrg  * Copyright (c) 1991, 1993
      5   1.1       mrg  *	The Regents of the University of California.  All rights reserved.
      6   1.1       mrg  *
      7   1.1       mrg  * This code is derived from software contributed to Berkeley by
      8   1.1       mrg  * The Mach Operating System project at Carnegie-Mellon University.
      9   1.1       mrg  *
     10   1.1       mrg  * Redistribution and use in source and binary forms, with or without
     11   1.1       mrg  * modification, are permitted provided that the following conditions
     12   1.1       mrg  * are met:
     13   1.1       mrg  * 1. Redistributions of source code must retain the above copyright
     14   1.1       mrg  *    notice, this list of conditions and the following disclaimer.
     15   1.1       mrg  * 2. Redistributions in binary form must reproduce the above copyright
     16   1.1       mrg  *    notice, this list of conditions and the following disclaimer in the
     17   1.1       mrg  *    documentation and/or other materials provided with the distribution.
     18  1.15       agc  * 3. Neither the name of the University nor the names of its contributors
     19   1.1       mrg  *    may be used to endorse or promote products derived from this software
     20   1.1       mrg  *    without specific prior written permission.
     21   1.1       mrg  *
     22   1.1       mrg  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     23   1.1       mrg  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24   1.1       mrg  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25   1.1       mrg  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     26   1.1       mrg  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27   1.1       mrg  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28   1.1       mrg  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29   1.1       mrg  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30   1.1       mrg  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31   1.1       mrg  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32   1.1       mrg  * SUCH DAMAGE.
     33   1.1       mrg  *
     34   1.1       mrg  *	@(#)pmap.h	8.1 (Berkeley) 6/11/93
     35   1.1       mrg  *
     36   1.1       mrg  *
     37   1.1       mrg  * Copyright (c) 1987, 1990 Carnegie-Mellon University.
     38   1.1       mrg  * All rights reserved.
     39   1.1       mrg  *
     40   1.1       mrg  * Author: Avadis Tevanian, Jr.
     41   1.7       chs  *
     42   1.1       mrg  * Permission to use, copy, modify and distribute this software and
     43   1.1       mrg  * its documentation is hereby granted, provided that both the copyright
     44   1.1       mrg  * notice and this permission notice appear in all copies of the
     45   1.1       mrg  * software, derivative works or modified versions, and any portions
     46   1.1       mrg  * thereof, and that both notices appear in supporting documentation.
     47   1.7       chs  *
     48   1.7       chs  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     49   1.7       chs  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     50   1.1       mrg  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     51   1.7       chs  *
     52   1.1       mrg  * Carnegie Mellon requests users of this software to return to
     53   1.1       mrg  *
     54   1.1       mrg  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     55   1.1       mrg  *  School of Computer Science
     56   1.1       mrg  *  Carnegie Mellon University
     57   1.1       mrg  *  Pittsburgh PA 15213-3890
     58   1.1       mrg  *
     59   1.1       mrg  * any improvements or extensions that they make and grant Carnegie the
     60   1.1       mrg  * rights to redistribute these changes.
     61   1.1       mrg  */
     62   1.1       mrg 
     63   1.1       mrg /*
     64   1.1       mrg  *	Machine address mapping definitions -- machine-independent
     65   1.1       mrg  *	section.  [For machine-dependent section, see "machine/pmap.h".]
     66   1.1       mrg  */
     67   1.1       mrg 
     68   1.1       mrg #ifndef	_PMAP_VM_
     69   1.1       mrg #define	_PMAP_VM_
     70   1.1       mrg 
     71  1.12   thorpej struct lwp;		/* for pmap_activate()/pmap_deactivate() proto */
     72   1.1       mrg 
     73  1.24     pooka struct pmap;
     74  1.24     pooka typedef struct pmap *pmap_t;
     75  1.24     pooka 
     76   1.1       mrg /*
     77   1.1       mrg  * Each machine dependent implementation is expected to
     78   1.1       mrg  * keep certain statistics.  They may do this anyway they
     79   1.1       mrg  * so choose, but are expected to return the statistics
     80   1.1       mrg  * in the following structure.
     81   1.1       mrg  */
     82   1.1       mrg struct pmap_statistics {
     83   1.1       mrg 	long		resident_count;	/* # of pages mapped (total)*/
     84   1.1       mrg 	long		wired_count;	/* # of pages wired */
     85   1.1       mrg };
     86   1.1       mrg typedef struct pmap_statistics	*pmap_statistics_t;
     87   1.1       mrg 
     88   1.8      matt #ifdef _KERNEL
     89  1.34  christos 
     90  1.34  christos extern struct pmap	*const kernel_pmap_ptr;
     91  1.34  christos #define pmap_kernel()	kernel_pmap_ptr
     92  1.34  christos 
     93  1.35       mrg #include <machine/pmap.h>
     94  1.35       mrg 
     95   1.8      matt #endif
     96   1.1       mrg 
     97   1.1       mrg /*
     98   1.1       mrg  * Flags passed to pmap_enter().  Note the bottom 3 bits are VM_PROT_*
     99   1.1       mrg  * bits, used to indicate the access type that was made (to seed modified
    100   1.1       mrg  * and referenced information).
    101  1.29   thorpej  *
    102  1.29   thorpej  * Flags marked [PA] are for pmap_kenter_pa() only.  Flags marked [BOTH]
    103  1.29   thorpej  * apply to pmap_kenter_pa() and pmap_enter().  All other flags are valid
    104  1.29   thorpej  * for pmap_enter() only.
    105   1.1       mrg  */
    106   1.1       mrg #define	PMAP_WIRED	0x00000010	/* wired mapping */
    107   1.1       mrg #define	PMAP_CANFAIL	0x00000020	/* can fail if resource shortage */
    108  1.30   thorpej #if defined(PMAP_ENABLE_PMAP_KMPAGE)
    109  1.29   thorpej #define	PMAP_KMPAGE	0x00000040	/* [PA] page used for kernel memory */
    110  1.30   thorpej #else
    111  1.30   thorpej #define	PMAP_KMPAGE	0x00000000
    112  1.30   thorpej #endif /* PMAP_ENABLE_PMAP_KMPAGE */
    113  1.26    cegger 
    114  1.33    cegger #define	PMAP_MD_MASK	0xff000000	/* [BOTH] Machine-dependent bits */
    115  1.33    cegger #define PMAP_PROT_MASK	0x0000000f	/* [BOTH] VM_PROT_* bit mask */
    116  1.33    cegger 
    117  1.33    cegger /*
    118  1.33    cegger  * Cache Type Encodings
    119  1.33    cegger  */
    120  1.33    cegger #define PMAP_CACHE_MASK		0x00000f00
    121  1.33    cegger 
    122  1.33    cegger /* All accesses are uncacheable. No speculative accesses. */
    123  1.33    cegger #define PMAP_NOCACHE		0x00000100	/* [BOTH] */
    124  1.33    cegger 
    125  1.33    cegger /* All accesses are uncacheable. No speculative accesses.
    126  1.33    cegger  * Writes are combined. */
    127  1.33    cegger #define PMAP_WRITE_COMBINE	0x00000200	/* [BOTH] */
    128  1.33    cegger 
    129  1.33    cegger /* On reads, cachelines become shared or exclusive if allocated on cache miss.
    130  1.33    cegger  * On writes, cachelines become modified on a cache miss.  */
    131  1.33    cegger #define PMAP_WRITE_BACK		0x00000300	/* [BOTH] */
    132  1.33    cegger 
    133  1.33    cegger /* = PMAP_NOCACHE but overrideable (e.g. on x86 by MTRRs) */
    134  1.33    cegger #define PMAP_NOCACHE_OVR	0x00000400	/* [BOTH] */
    135  1.33    cegger 
    136  1.26    cegger 
    137   1.1       mrg #ifndef PMAP_EXCLUDE_DECLS	/* Used in Sparc port to virtualize pmap mod */
    138   1.1       mrg #ifdef _KERNEL
    139   1.1       mrg __BEGIN_DECLS
    140  1.17  junyoung void		pmap_activate(struct lwp *);
    141  1.17  junyoung void		pmap_deactivate(struct lwp *);
    142  1.17  junyoung void		pmap_unwire(pmap_t, vaddr_t);
    143   1.1       mrg 
    144   1.1       mrg #if !defined(pmap_clear_modify)
    145  1.20   thorpej bool		pmap_clear_modify(struct vm_page *);
    146   1.1       mrg #endif
    147   1.1       mrg #if !defined(pmap_clear_reference)
    148  1.20   thorpej bool		pmap_clear_reference(struct vm_page *);
    149   1.1       mrg #endif
    150   1.1       mrg 
    151  1.16  junyoung #if !defined(pmap_copy)
    152  1.17  junyoung void		pmap_copy(pmap_t, pmap_t, vaddr_t, vsize_t, vaddr_t);
    153  1.16  junyoung #endif
    154  1.10   thorpej #if !defined(pmap_copy_page)
    155  1.17  junyoung void		pmap_copy_page(paddr_t, paddr_t);
    156  1.10   thorpej #endif
    157  1.17  junyoung struct pmap	*pmap_create(void);
    158  1.17  junyoung void		pmap_destroy(pmap_t);
    159  1.27    cegger int		pmap_enter(pmap_t, vaddr_t, paddr_t, vm_prot_t, u_int);
    160  1.20   thorpej bool		pmap_extract(pmap_t, vaddr_t, paddr_t *);
    161   1.1       mrg #if defined(PMAP_GROWKERNEL)
    162  1.17  junyoung vaddr_t		pmap_growkernel(vaddr_t);
    163   1.1       mrg #endif
    164   1.1       mrg 
    165  1.17  junyoung void		pmap_init(void);
    166   1.1       mrg 
    167  1.32    cegger void		pmap_kenter_pa(vaddr_t, paddr_t, vm_prot_t, u_int);
    168  1.17  junyoung void		pmap_kremove(vaddr_t, vsize_t);
    169   1.1       mrg #if !defined(pmap_is_modified)
    170  1.20   thorpej bool		pmap_is_modified(struct vm_page *);
    171   1.1       mrg #endif
    172   1.1       mrg #if !defined(pmap_is_referenced)
    173  1.20   thorpej bool		pmap_is_referenced(struct vm_page *);
    174   1.1       mrg #endif
    175   1.1       mrg 
    176  1.17  junyoung void		pmap_page_protect(struct vm_page *, vm_prot_t);
    177   1.1       mrg 
    178   1.1       mrg #if !defined(pmap_phys_address)
    179  1.21  macallan paddr_t		pmap_phys_address(paddr_t);
    180   1.1       mrg #endif
    181  1.36  jmcneill #if !defined(pmap_mmap_flags)
    182  1.36  jmcneill #define pmap_mmap_flags(x)	0
    183  1.36  jmcneill #endif
    184  1.17  junyoung void		pmap_protect(pmap_t, vaddr_t, vaddr_t, vm_prot_t);
    185  1.18        he #if !defined(pmap_reference)
    186  1.17  junyoung void		pmap_reference(pmap_t);
    187  1.18        he #endif
    188  1.18        he #if !defined(pmap_remove)
    189  1.17  junyoung void		pmap_remove(pmap_t, vaddr_t, vaddr_t);
    190  1.18        he #endif
    191  1.17  junyoung void		pmap_remove_all(struct pmap *);
    192  1.16  junyoung #if !defined(pmap_update)
    193  1.17  junyoung void		pmap_update(pmap_t);
    194  1.16  junyoung #endif
    195   1.6   thorpej #if !defined(pmap_resident_count)
    196  1.17  junyoung long		pmap_resident_count(pmap_t);
    197   1.6   thorpej #endif
    198   1.6   thorpej #if !defined(pmap_wired_count)
    199  1.17  junyoung long		pmap_wired_count(pmap_t);
    200   1.6   thorpej #endif
    201  1.10   thorpej #if !defined(pmap_zero_page)
    202  1.17  junyoung void		pmap_zero_page(paddr_t);
    203  1.10   thorpej #endif
    204   1.1       mrg 
    205  1.17  junyoung void		pmap_virtual_space(vaddr_t *, vaddr_t *);
    206   1.1       mrg #if defined(PMAP_STEAL_MEMORY)
    207  1.17  junyoung vaddr_t		pmap_steal_memory(vsize_t, vaddr_t *, vaddr_t *);
    208   1.1       mrg #endif
    209   1.1       mrg 
    210   1.1       mrg #if defined(PMAP_FORK)
    211  1.17  junyoung void		pmap_fork(pmap_t, pmap_t);
    212   1.1       mrg #endif
    213   1.1       mrg __END_DECLS
    214   1.1       mrg #endif	/* kernel*/
    215   1.1       mrg #endif  /* PMAP_EXCLUDE_DECLS */
    216   1.1       mrg 
    217   1.1       mrg #endif /* _PMAP_VM_ */
    218