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/uvm/uvm_param.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 /*      $NetBSD: uvm_param.h,v 1.19 2004/04/04 18:21:49 pk Exp $        */
    2 
    3 /*
    4  * Copyright (c) 1991, 1993
    5  *      The Regents of the University of California.  All rights reserved.
    6  *
    7  * This code is derived from software contributed to Berkeley by
    8  * The Mach Operating System project at Carnegie-Mellon University.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  * 3. Neither the name of the University nor the names of its contributors
   19  *    may be used to endorse or promote products derived from this software
   20  *    without specific prior written permission.
   21  *
   22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   32  * SUCH DAMAGE.
   33  *
   34  *      @(#)vm_param.h  8.2 (Berkeley) 1/9/95
   35  *
   36  *
   37  * Copyright (c) 1987, 1990 Carnegie-Mellon University.
   38  * All rights reserved.
   39  *
   40  * Authors: Avadis Tevanian, Jr., Michael Wayne Young
   41  *
   42  * Permission to use, copy, modify and distribute this software and
   43  * its documentation is hereby granted, provided that both the copyright
   44  * notice and this permission notice appear in all copies of the
   45  * software, derivative works or modified versions, and any portions
   46  * thereof, and that both notices appear in supporting documentation.
   47  *
   48  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   49  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
   50  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   51  *
   52  * Carnegie Mellon requests users of this software to return to
   53  *
   54  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   55  *  School of Computer Science
   56  *  Carnegie Mellon University
   57  *  Pittsburgh PA 15213-3890
   58  *
   59  * any improvements or extensions that they make and grant Carnegie the
   60  * rights to redistribute these changes.
   61  */
   62 
   63 /*
   64  *      Machine independent virtual memory parameters.
   65  */
   66 
   67 #ifndef _VM_PARAM_
   68 #define _VM_PARAM_
   69 
   70 #ifdef _KERNEL_OPT
   71 #include "opt_uvm.h"
   72 #endif
   73 #ifdef _KERNEL
   74 #include <machine/vmparam.h>
   75 #include <sys/resourcevar.h>
   76 #endif
   77 
   78 #if defined(_KERNEL)
   79 
   80 #if defined(PAGE_SIZE)
   81 
   82 /*
   83  * If PAGE_SIZE is defined at this stage, it must be a constant.
   84  */
   85 
   86 #if PAGE_SIZE == 0
   87 #error Invalid PAGE_SIZE definition
   88 #endif
   89 
   90 /*
   91  * If the platform does not need to support a variable PAGE_SIZE,
   92  * then provide default values for MIN_PAGE_SIZE and MAX_PAGE_SIZE.
   93  */
   94 
   95 #if !defined(MIN_PAGE_SIZE)
   96 #define MIN_PAGE_SIZE   PAGE_SIZE
   97 #endif /* ! MIN_PAGE_SIZE */
   98 
   99 #if !defined(MAX_PAGE_SIZE)
  100 #define MAX_PAGE_SIZE   PAGE_SIZE
  101 #endif /* ! MAX_PAGE_SIZE */
  102 
  103 #else /* ! PAGE_SIZE */
  104 
  105 /*
  106  * PAGE_SIZE is not a constant; MIN_PAGE_SIZE and MAX_PAGE_SIZE must
  107  * be defined.
  108  */
  109 
  110 #if !defined(MIN_PAGE_SIZE)
  111 #error MIN_PAGE_SIZE not defined
  112 #endif
  113 
  114 #if !defined(MAX_PAGE_SIZE)
  115 #error MAX_PAGE_SIZE not defined
  116 #endif
  117 
  118 #endif /* PAGE_SIZE */
  119 
  120 /*
  121  * MIN_PAGE_SIZE and MAX_PAGE_SIZE must be constants.
  122  */
  123 
  124 #if MIN_PAGE_SIZE == 0
  125 #error Invalid MIN_PAGE_SIZE definition
  126 #endif
  127 
  128 #if MAX_PAGE_SIZE == 0
  129 #error Invalid MAX_PAGE_SIZE definition
  130 #endif
  131 
  132 /*
  133  * If MIN_PAGE_SIZE and MAX_PAGE_SIZE are not equal, then we must use
  134  * non-constant PAGE_SIZE, et al for LKMs.
  135  */
  136 #if (MIN_PAGE_SIZE != MAX_PAGE_SIZE) && defined(_LKM)
  137 #undef PAGE_SIZE
  138 #undef PAGE_MASK
  139 #undef PAGE_SHIFT
  140 #endif
  141 
  142 /*
  143  * Now provide PAGE_SIZE, PAGE_MASK, and PAGE_SHIFT if we do not
  144  * have ones that are compile-time constants.
  145  */
  146 #if !defined(PAGE_SIZE)
  147 #define PAGE_SIZE       uvmexp.pagesize         /* size of page */
  148 #define PAGE_MASK       uvmexp.pagemask         /* size of page - 1 */
  149 #define PAGE_SHIFT      uvmexp.pageshift        /* bits to shift for pages */
  150 #endif /* PAGE_SIZE */
  151 
  152 #endif /* _KERNEL */
  153 
  154 /*
  155  * CTL_VM identifiers
  156  */
  157 #define VM_METER        1               /* struct vmmeter */
  158 #define VM_LOADAVG      2               /* struct loadavg */
  159 #define VM_UVMEXP       3               /* struct uvmexp */
  160 #define VM_NKMEMPAGES   4               /* kmem_map pages */
  161 #define VM_UVMEXP2      5               /* struct uvmexp_sysctl */
  162 #define VM_ANONMIN      6
  163 #define VM_EXECMIN      7
  164 #define VM_FILEMIN      8
  165 #define VM_MAXSLP       9
  166 #define VM_USPACE       10
  167 #define VM_ANONMAX      11
  168 #define VM_EXECMAX      12
  169 #define VM_FILEMAX      13
  170 
  171 #define VM_MAXID        14              /* number of valid vm ids */
  172 
  173 #define CTL_VM_NAMES { \
  174         { 0, 0 }, \
  175         { "vmmeter", CTLTYPE_STRUCT }, \
  176         { "loadavg", CTLTYPE_STRUCT }, \
  177         { "uvmexp", CTLTYPE_STRUCT }, \
  178         { "nkmempages", CTLTYPE_INT }, \
  179         { "uvmexp2", CTLTYPE_STRUCT }, \
  180         { "anonmin", CTLTYPE_INT }, \
  181         { "execmin", CTLTYPE_INT }, \
  182         { "filemin", CTLTYPE_INT }, \
  183         { "maxslp", CTLTYPE_INT }, \
  184         { "uspace", CTLTYPE_INT }, \
  185         { "anonmax", CTLTYPE_INT }, \
  186         { "execmax", CTLTYPE_INT }, \
  187         { "filemax", CTLTYPE_INT }, \
  188 }
  189 
  190 #ifndef ASSEMBLER
  191 /*
  192  *      Convert addresses to pages and vice versa.
  193  *      No rounding is used.
  194  */
  195 #ifdef _KERNEL
  196 #define atop(x)         (((paddr_t)(x)) >> PAGE_SHIFT)
  197 #define ptoa(x)         ((vaddr_t)((vaddr_t)(x) << PAGE_SHIFT))
  198 
  199 /*
  200  * Round off or truncate to the nearest page.  These will work
  201  * for either addresses or counts (i.e., 1 byte rounds to 1 page).
  202  */
  203 #define round_page(x)   (((x) + PAGE_MASK) & ~PAGE_MASK)
  204 #define trunc_page(x)   ((x) & ~PAGE_MASK)
  205 
  206 /*
  207  * Set up the default mapping address (VM_DEFAULT_ADDRESS) according to:
  208  *
  209  * USE_TOPDOWN_VM:      a kernel option to enable on a per-kernel basis
  210  *                      which only be used on ports that define...
  211  * __HAVE_TOPDOWN_VM:   a per-port option to offer the topdown option
  212  *
  213  * __USE_TOPDOWN_VM:    a per-port option to unconditionally use it
  214  *
  215  * if __USE_TOPDOWN_VM is defined, the port can specify a default vm
  216  * address, or we will use the topdown default from below.  If it is
  217  * NOT defined, then the port can offer topdown as an option, but it
  218  * MUST define the VM_DEFAULT_ADDRESS macro itself.
  219  */
  220 #if defined(USE_TOPDOWN_VM) || defined(__USE_TOPDOWN_VM)
  221 # if !defined(__HAVE_TOPDOWN_VM) && !defined(__USE_TOPDOWN_VM)
  222 #  error "Top down memory allocation not enabled for this system"
  223 # else /* !__HAVE_TOPDOWN_VM && !__USE_TOPDOWN_VM */
  224 #  define __USING_TOPDOWN_VM
  225 #  if !defined(VM_DEFAULT_ADDRESS)
  226 #   if !defined(__USE_TOPDOWN_VM)
  227 #    error "Top down memory allocation not configured for this system"
  228 #   else /* !__USE_TOPDOWN_VM */
  229 #    define VM_DEFAULT_ADDRESS(da, sz) \
  230         trunc_page(VM_MAXUSER_ADDRESS - MAXSSIZ - (sz))
  231 #   endif /* !__USE_TOPDOWN_VM */
  232 #  endif /* !VM_DEFAULT_ADDRESS */
  233 # endif /* !__HAVE_TOPDOWN_VM && !__USE_TOPDOWN_VM */
  234 #endif /* USE_TOPDOWN_VM || __USE_TOPDOWN_VM */
  235 
  236 #if !defined(__USING_TOPDOWN_VM)
  237 # if defined(VM_DEFAULT_ADDRESS)
  238 #  error "Default vm address should not be defined here"
  239 # else /* VM_DEFAULT_ADDRESS */
  240 #  define VM_DEFAULT_ADDRESS(da, sz) round_page((vaddr_t)(da) + (vsize_t)maxdmap)
  241 # endif /* VM_DEFAULT_ADDRESS */
  242 #endif /* !__USING_TOPDOWN_VM */
  243 
  244 extern int              ubc_nwins;      /* number of UBC mapping windows */
  245 extern int              ubc_winshift;   /* shift for a UBC mapping window */
  246 
  247 #else
  248 /* out-of-kernel versions of round_page and trunc_page */
  249 #define round_page(x) \
  250         ((((vaddr_t)(x) + (vm_page_size - 1)) / vm_page_size) * \
  251             vm_page_size)
  252 #define trunc_page(x) \
  253         ((((vaddr_t)(x)) / vm_page_size) * vm_page_size)
  254 
  255 #endif /* _KERNEL */
  256 #endif /* ASSEMBLER */
  257 #endif /* _VM_PARAM_ */

Cache object: c62982e73e7f23b1c3f05158a32db7a8


[ 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.