The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/vm/pmap.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* 
    2  * Mach Operating System
    3  * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
    4  * All Rights Reserved.
    5  * 
    6  * Permission to use, copy, modify and distribute this software and its
    7  * documentation is hereby granted, provided that both the copyright
    8  * notice and this permission notice appear in all copies of the
    9  * software, derivative works or modified versions, and any portions
   10  * thereof, and that both notices appear in supporting documentation.
   11  * 
   12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
   14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   15  * 
   16  * Carnegie Mellon requests users of this software to return to
   17  * 
   18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   19  *  School of Computer Science
   20  *  Carnegie Mellon University
   21  *  Pittsburgh PA 15213-3890
   22  * 
   23  * any improvements or extensions that they make and grant Carnegie Mellon
   24  * the rights to redistribute these changes.
   25  */
   26 /*
   27  * HISTORY
   28  * $Log:        pmap.h,v $
   29  * Revision 2.7  93/11/17  19:19:32  dbg
   30  *      Added ANSI function prototypes.  Include mach/vm_prot.h to
   31  *      get type declarations.
   32  *      [93/09/21  22:09:41  dbg]
   33  * 
   34  * Revision 2.6  91/05/18  14:39:51  rpd
   35  *      Removed pmap_update.
   36  *      [91/04/12            rpd]
   37  *      Removed pmap_bootstrap, pmap_map, pmap_valid_page.
   38  *      Added pmap_startup, pmap_steal_memory, pmap_free_pages,
   39  *      pmap_virtual_space, pmap_next_page.
   40  *      [91/03/22            rpd]
   41  * 
   42  * Revision 2.5  91/05/14  17:48:08  mrt
   43  *      Correcting copyright
   44  * 
   45  * Revision 2.4  91/02/05  17:57:34  mrt
   46  *      Changed to new Mach copyright
   47  *      [91/02/01  16:31:04  mrt]
   48  * 
   49  * Revision 2.3  90/01/22  23:09:05  af
   50  *      Added (optional) pmap_attributes.  This should be implemented
   51  *      just as a macro that evaluates to KERN_INVALID_ARGUMENT for
   52  *      those architectures that do not support any special memory
   53  *      feature in hardware.  NUMA machines and cache-incoherent
   54  *      machines (e.g. mips) should instead implement it as appropriate.
   55  *      [89/12/08            af]
   56  * 
   57  * Revision 2.2  89/11/29  14:16:53  af
   58  *      Carried over the following mods from impure kernel.
   59  *              Added pmap_phys_to_frame as inverse of pmap_phys_address, for use by
   60  *              memory map function in machine-independent pseudo device drivers.
   61  *              The correct thing to do, of course, is to change the device driver map
   62  *              function spec to return a physical address instead of a frame, but
   63  *              this would require changing too many device drivers...
   64  *              [89/09/05  16:45:48  jsb]
   65  * 
   66  *              Removed unused and ugly pmap_redzone() from the list of required
   67  *              pmap functions.  Made more routines implementable as macros.
   68  *              [89/08/05            af]
   69  *      Separate user and kernel cases of PMAP_ACTIVATE and
   70  *      PMAP_DEACTIVATE; supply default definitions.
   71  *      [89/04/28            dbg]
   72  * 
   73  * Revision 2.1  89/08/03  16:44:35  rwd
   74  * Created.
   75  * 
   76  * Revision 2.8  89/04/18  21:24:43  mwyoung
   77  *      Recent history [mwyoung]:
   78  *              Remove pmap_remove_all(), pmap_copy_on_write(), as they're
   79  *               no longer required routines.  The machine-independent code
   80  *               uses pmap_page_protect() instead.
   81  *              Documented interface.  The precise interface specification
   82  *               should be reconstructed from the pmap implementations.
   83  *      History condensation:
   84  *              Added calls for page locking [mwyoung].
   85  *              Added reference bit handling [avie].
   86  *              Created [avie].
   87  *      [89/04/18            mwyoung]
   88  * 
   89  */
   90 /*
   91  *      File:   vm/pmap.h
   92  *      Author: Avadis Tevanian, Jr.
   93  *      Date:   1985
   94  *
   95  *      Machine address mapping definitions -- machine-independent
   96  *      section.  [For machine-dependent section, see "machine/pmap.h".]
   97  */
   98 
   99 #ifndef _VM_PMAP_H_
  100 #define _VM_PMAP_H_
  101 
  102 #include <machine/pmap.h>
  103 #include <mach/machine/vm_types.h>
  104 #include <mach/boolean.h>
  105 #include <mach/vm_prot.h>
  106 
  107 /*
  108  *      The following is a description of the interface to the
  109  *      machine-dependent "physical map" data structure.  The module
  110  *      must provide a "pmap_t" data type that represents the
  111  *      set of valid virtual-to-physical addresses for one user
  112  *      address space.  [The kernel address space is represented
  113  *      by a distinguished "pmap_t".]  The routines described manage
  114  *      this type, install and update virtual-to-physical mappings,
  115  *      and perform operations on physical addresses common to
  116  *      many address spaces.
  117  */
  118 
  119 /*
  120  *      Routines used for initialization.
  121  *      There is traditionally also a pmap_bootstrap,
  122  *      used very early by machine-dependent code,
  123  *      but it is not part of the interface.
  124  */
  125 
  126 extern vm_offset_t      pmap_steal_memory(
  127                 vm_size_t       size);          /* During VM initialization,
  128                                                  * steal a chunk of memory.
  129                                                  */
  130 
  131 extern unsigned int     pmap_free_pages(void);  /* During VM initialization,
  132                                                  * report remaining unused
  133                                                  * physical pages.
  134                                                  */
  135 extern void             pmap_startup(
  136                 vm_offset_t     *startp,
  137                 vm_offset_t     *endp);         /* During VM initialization,
  138                                                  * use remaining physical pages
  139                                                  * to allocate page frames.
  140                                                  */
  141 
  142 extern void             pmap_init(void);        /* Initialization,
  143                                                  * after kernel runs
  144                                                  * in virtual memory.
  145                                                  */
  146 
  147 #ifndef MACHINE_PAGES
  148 /*
  149  *      If machine/pmap.h defines MACHINE_PAGES, it must implement
  150  *      the above functions.  The pmap module has complete control.
  151  *      Otherwise, it must implement
  152  *              pmap_free_pages
  153  *              pmap_virtual_space
  154  *              pmap_next_page
  155  *              pmap_init
  156  *      and vm/vm_resident.c implements pmap_steal_memory and pmap_startup
  157  *      using pmap_free_pages, pmap_next_page, pmap_virtual_space,
  158  *      and pmap_enter.  pmap_free_pages may over-estimate the number
  159  *      of unused physical pages, and pmap_next_page may return FALSE
  160  *      to indicate that there are no more unused pages to return.
  161  *      However, for best performance pmap_free_pages should be accurate.
  162  */
  163 
  164 extern boolean_t        pmap_next_page(
  165                 vm_offset_t     *addrp);        /* During VM initialization,
  166                                                  * return the next unused
  167                                                  * physical page.
  168                                                  */
  169 extern void             pmap_virtual_space(
  170                 vm_offset_t     *startp,
  171                 vm_offset_t     *endp);         /* During VM initialization,
  172                                                  * report virtual space
  173                                                  * available for the kernel.
  174                                                  */
  175 #endif  /* MACHINE_PAGES */
  176 
  177 /*
  178  *      Routines to manage the physical map data structure.
  179  */
  180 extern pmap_t           pmap_create(vm_size_t); /* Create a pmap_t. */
  181 #ifndef pmap_kernel
  182 extern pmap_t           pmap_kernel(void);      /* Return the kernel's pmap_t. */
  183 #endif
  184 extern void             pmap_reference(pmap_t); /* Gain a reference. */
  185 extern void             pmap_destroy(pmap_t);   /* Release a reference. */
  186 
  187 extern void             pmap_enter(             /* Enter a mapping */
  188                 pmap_t          pmap,
  189                 vm_offset_t     va,
  190                 vm_offset_t     pa,
  191                 vm_prot_t       prot,
  192                 boolean_t       wired);
  193 
  194 /*
  195  *      Routines that operate on ranges of virtual addresses.
  196  */
  197 extern void             pmap_remove(            /* Remove mappings. */
  198                 pmap_t          pmap,
  199                 vm_offset_t     start,
  200                 vm_offset_t     end);
  201 extern void             pmap_protect(           /* Change protections. */
  202                 pmap_t          pmap,
  203                 vm_offset_t     start,
  204                 vm_offset_t     end,
  205                 vm_prot_t       prot);
  206 
  207 /*
  208  *      Routines to set up hardware state for physical maps to be used.
  209  */
  210 extern void             pmap_activate();        /* Prepare pmap_t to run
  211                                                  * on a given processor.
  212                                                  */
  213 extern void             pmap_deactivate();      /* Release pmap_t from
  214                                                  * use on processor.
  215                                                  */
  216 
  217 
  218 /*
  219  *      Routines that operate on physical addresses.
  220  */
  221 extern void             pmap_page_protect(      /* Restrict access to page. */
  222                 vm_offset_t     phys_addr,
  223                 vm_prot_t       prot);
  224 
  225 /*
  226  *      Routines to manage reference/modify bits based on
  227  *      physical addresses, simulating them if not provided
  228  *      by the hardware.
  229  */
  230 extern void             pmap_clear_reference(   /* Clear reference bit */
  231                 vm_offset_t     phys_addr);
  232 #ifndef pmap_is_referenced
  233 extern boolean_t        pmap_is_referenced(     /* Return reference bit */
  234                 vm_offset_t     phys_addr);
  235 #endif
  236 extern void             pmap_clear_modify(      /* Clear modify bit */
  237                 vm_offset_t     phys_addr);
  238 extern boolean_t        pmap_is_modified(       /* Return modify bit */
  239                 vm_offset_t     phys_addr);
  240 
  241 
  242 /*
  243  *      Routines to copy and clear physical pages
  244  */
  245 extern void             pmap_copy_page(         /* copy a physical page */
  246                 vm_offset_t     src_phys_addr,
  247                 vm_offset_t     dest_phys_addr);
  248 
  249 extern void             pmap_zero_page(         /* zero a physical page */
  250                 vm_offset_t     phys_addr);
  251 
  252 /*
  253  *      Statistics routines
  254  */
  255 extern void             pmap_statistics();      /* Return statistics */
  256 
  257 #ifndef pmap_resident_count
  258 extern int              pmap_resident_count(pmap_t);
  259 #endif
  260 
  261 /*
  262  *      Sundry required routines
  263  */
  264 extern vm_offset_t      pmap_extract(
  265                 pmap_t          pmap,
  266                 vm_offset_t     va);            /* Return a virtual-to-physical
  267                                                  * mapping, if possible.
  268                                                  */
  269 
  270 extern void             pmap_collect(pmap_t);   /* Perform garbage
  271                                                  * collection, if any
  272                                                  */
  273 
  274 extern void             pmap_change_wiring(     /* Specify pageability */
  275                 pmap_t          pmap,
  276                 vm_offset_t     va,
  277                 boolean_t       wired);
  278 
  279 #ifndef pmap_phys_address
  280 extern vm_offset_t      pmap_phys_address(
  281                 vm_offset_t);                   /* Transform address
  282                                                  * returned by device
  283                                                  * driver mapping function
  284                                                  * to physical address
  285                                                  * known to this module.
  286                                                  */
  287 #endif
  288 #ifndef pmap_phys_to_frame
  289 extern int              pmap_phys_to_frame(     
  290                 vm_offset_t);                   /* Inverse of
  291                                                  * pmap_phys_address,
  292                                                  * for use by device driver
  293                                                  * mapping function in
  294                                                  * machine-independent
  295                                                  * pseudo-devices.
  296                                                  */
  297 #endif
  298 
  299 /*
  300  *      Optional routines
  301  */
  302 #ifndef pmap_copy
  303 extern void             pmap_copy();            /* Copy range of
  304                                                  * mappings, if desired.
  305                                                  */
  306 #endif
  307 #ifndef pmap_attribute
  308 extern kern_return_t    pmap_attribute();       /* Get/Set special
  309                                                  * memory attributes
  310                                                  */
  311 #endif
  312 
  313 /*
  314  * Routines defined as macros.
  315  */
  316 #ifndef PMAP_ACTIVATE_USER
  317 #define PMAP_ACTIVATE_USER(pmap, thread, cpu) {         \
  318         if ((pmap) != kernel_pmap)                      \
  319             PMAP_ACTIVATE(pmap, thread, cpu);           \
  320 }
  321 #endif
  322 
  323 #ifndef PMAP_DEACTIVATE_USER
  324 #define PMAP_DEACTIVATE_USER(pmap, thread, cpu) {       \
  325         if ((pmap) != kernel_pmap)                      \
  326             PMAP_DEACTIVATE(pmap, thread, cpu);         \
  327 }
  328 #endif
  329 
  330 #ifndef PMAP_ACTIVATE_KERNEL
  331 #define PMAP_ACTIVATE_KERNEL(cpu)                       \
  332                 PMAP_ACTIVATE(kernel_pmap, THREAD_NULL, cpu)
  333 #endif
  334 
  335 #ifndef PMAP_DEACTIVATE_KERNEL
  336 #define PMAP_DEACTIVATE_KERNEL(cpu)                     \
  337                 PMAP_DEACTIVATE(kernel_pmap, THREAD_NULL, cpu)
  338 #endif
  339 
  340 /*
  341  *      Exported data structures
  342  */
  343 
  344 extern pmap_t   kernel_pmap;                    /* The kernel's map */
  345 
  346 #endif  /* _VM_PMAP_H_ */

Cache object: c703e47f0b354988060177e5449a9dc6


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.