2003-08-07 20:26:28 +04:00
|
|
|
/* $NetBSD: uvm_param.h,v 1.18 2003/08/07 16:34:50 agc Exp $ */
|
1994-06-29 10:39:25 +04:00
|
|
|
|
2001-05-25 08:06:11 +04:00
|
|
|
/*
|
1994-05-23 07:11:20 +04:00
|
|
|
* Copyright (c) 1991, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* The Mach Operating System project at Carnegie-Mellon University.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2003-08-07 20:26:28 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1993-03-21 12:45:37 +03:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1998-03-01 05:20:01 +03:00
|
|
|
* @(#)vm_param.h 8.2 (Berkeley) 1/9/95
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright (c) 1987, 1990 Carnegie-Mellon University.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Authors: Avadis Tevanian, Jr., Michael Wayne Young
|
2001-05-25 08:06:11 +04:00
|
|
|
*
|
1993-03-21 12:45:37 +03:00
|
|
|
* Permission to use, copy, modify and distribute this software and
|
|
|
|
* its documentation is hereby granted, provided that both the copyright
|
|
|
|
* notice and this permission notice appear in all copies of the
|
|
|
|
* software, derivative works or modified versions, and any portions
|
|
|
|
* thereof, and that both notices appear in supporting documentation.
|
2001-05-25 08:06:11 +04:00
|
|
|
*
|
|
|
|
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
|
|
|
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
1993-03-21 12:45:37 +03:00
|
|
|
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
2001-05-25 08:06:11 +04:00
|
|
|
*
|
1993-03-21 12:45:37 +03:00
|
|
|
* Carnegie Mellon requests users of this software to return to
|
|
|
|
*
|
|
|
|
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
|
|
|
* School of Computer Science
|
|
|
|
* Carnegie Mellon University
|
|
|
|
* Pittsburgh PA 15213-3890
|
|
|
|
*
|
|
|
|
* any improvements or extensions that they make and grant Carnegie the
|
|
|
|
* rights to redistribute these changes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Machine independent virtual memory parameters.
|
|
|
|
*/
|
|
|
|
|
1994-05-23 07:11:20 +04:00
|
|
|
#ifndef _VM_PARAM_
|
|
|
|
#define _VM_PARAM_
|
|
|
|
|
2003-02-21 01:16:05 +03:00
|
|
|
#ifdef _KERNEL_OPT
|
|
|
|
#include "opt_uvm.h"
|
|
|
|
#endif
|
2001-08-05 07:33:15 +04:00
|
|
|
#ifdef _KERNEL
|
1993-03-21 12:45:37 +03:00
|
|
|
#include <machine/vmparam.h>
|
2001-08-05 07:33:15 +04:00
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2003-04-09 20:34:10 +04:00
|
|
|
#if defined(_KERNEL)
|
|
|
|
|
|
|
|
#if defined(PAGE_SIZE)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If PAGE_SIZE is defined at this stage, it must be a constant.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if PAGE_SIZE == 0
|
|
|
|
#error Invalid PAGE_SIZE definition
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the platform does not need to support a variable PAGE_SIZE,
|
|
|
|
* then provide default values for MIN_PAGE_SIZE and MAX_PAGE_SIZE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if !defined(MIN_PAGE_SIZE)
|
|
|
|
#define MIN_PAGE_SIZE PAGE_SIZE
|
|
|
|
#endif /* ! MIN_PAGE_SIZE */
|
|
|
|
|
|
|
|
#if !defined(MAX_PAGE_SIZE)
|
|
|
|
#define MAX_PAGE_SIZE PAGE_SIZE
|
|
|
|
#endif /* ! MAX_PAGE_SIZE */
|
|
|
|
|
|
|
|
#else /* ! PAGE_SIZE */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PAGE_SIZE is not a constant; MIN_PAGE_SIZE and MAX_PAGE_SIZE must
|
|
|
|
* be defined.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if !defined(MIN_PAGE_SIZE)
|
|
|
|
#error MIN_PAGE_SIZE not defined
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(MAX_PAGE_SIZE)
|
|
|
|
#error MAX_PAGE_SIZE not defined
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* PAGE_SIZE */
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
2003-04-09 20:34:10 +04:00
|
|
|
* MIN_PAGE_SIZE and MAX_PAGE_SIZE must be constants.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
|
2003-04-09 20:34:10 +04:00
|
|
|
#if MIN_PAGE_SIZE == 0
|
|
|
|
#error Invalid MIN_PAGE_SIZE definition
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if MAX_PAGE_SIZE == 0
|
|
|
|
#error Invalid MAX_PAGE_SIZE definition
|
|
|
|
#endif
|
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
2003-04-09 20:34:10 +04:00
|
|
|
* If MIN_PAGE_SIZE and MAX_PAGE_SIZE are not equal, then we must use
|
|
|
|
* non-constant PAGE_SIZE, et al for LKMs.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
2003-04-09 20:34:10 +04:00
|
|
|
#if (MIN_PAGE_SIZE != MAX_PAGE_SIZE) && defined(_LKM)
|
|
|
|
#undef PAGE_SIZE
|
|
|
|
#undef PAGE_MASK
|
|
|
|
#undef PAGE_SHIFT
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now provide PAGE_SIZE, PAGE_MASK, and PAGE_SHIFT if we do not
|
|
|
|
* have ones that are compile-time constants.
|
|
|
|
*/
|
|
|
|
#if !defined(PAGE_SIZE)
|
1998-02-06 03:14:43 +03:00
|
|
|
#define PAGE_SIZE uvmexp.pagesize /* size of page */
|
|
|
|
#define PAGE_MASK uvmexp.pagemask /* size of page - 1 */
|
|
|
|
#define PAGE_SHIFT uvmexp.pageshift /* bits to shift for pages */
|
2003-04-09 20:34:10 +04:00
|
|
|
#endif /* PAGE_SIZE */
|
|
|
|
|
1998-03-25 03:45:51 +03:00
|
|
|
#endif /* _KERNEL */
|
1998-02-06 03:14:43 +03:00
|
|
|
|
1994-05-07 02:44:22 +04:00
|
|
|
/*
|
|
|
|
* CTL_VM identifiers
|
|
|
|
*/
|
|
|
|
#define VM_METER 1 /* struct vmmeter */
|
|
|
|
#define VM_LOADAVG 2 /* struct loadavg */
|
2000-11-29 12:52:18 +03:00
|
|
|
#define VM_UVMEXP 3 /* struct uvmexp */
|
2000-02-11 22:22:52 +03:00
|
|
|
#define VM_NKMEMPAGES 4 /* kmem_map pages */
|
2000-11-29 12:52:18 +03:00
|
|
|
#define VM_UVMEXP2 5 /* struct uvmexp_sysctl */
|
2001-03-09 04:02:10 +03:00
|
|
|
#define VM_ANONMIN 6
|
2001-12-09 06:07:19 +03:00
|
|
|
#define VM_EXECMIN 7
|
|
|
|
#define VM_FILEMIN 8
|
2001-07-14 10:36:01 +04:00
|
|
|
#define VM_MAXSLP 9
|
|
|
|
#define VM_USPACE 10
|
2001-12-09 06:07:19 +03:00
|
|
|
#define VM_ANONMAX 11
|
|
|
|
#define VM_EXECMAX 12
|
|
|
|
#define VM_FILEMAX 13
|
2001-03-09 04:02:10 +03:00
|
|
|
|
2001-12-09 06:07:19 +03:00
|
|
|
#define VM_MAXID 14 /* number of valid vm ids */
|
1998-02-06 03:14:43 +03:00
|
|
|
|
|
|
|
#define CTL_VM_NAMES { \
|
|
|
|
{ 0, 0 }, \
|
|
|
|
{ "vmmeter", CTLTYPE_STRUCT }, \
|
|
|
|
{ "loadavg", CTLTYPE_STRUCT }, \
|
|
|
|
{ "uvmexp", CTLTYPE_STRUCT }, \
|
2000-02-11 22:22:52 +03:00
|
|
|
{ "nkmempages", CTLTYPE_INT }, \
|
2000-11-29 12:52:18 +03:00
|
|
|
{ "uvmexp2", CTLTYPE_STRUCT }, \
|
2001-03-09 04:02:10 +03:00
|
|
|
{ "anonmin", CTLTYPE_INT }, \
|
2001-12-09 06:07:19 +03:00
|
|
|
{ "execmin", CTLTYPE_INT }, \
|
|
|
|
{ "filemin", CTLTYPE_INT }, \
|
2001-07-14 10:36:01 +04:00
|
|
|
{ "maxslp", CTLTYPE_INT }, \
|
|
|
|
{ "uspace", CTLTYPE_INT }, \
|
2001-12-09 06:07:19 +03:00
|
|
|
{ "anonmax", CTLTYPE_INT }, \
|
|
|
|
{ "execmax", CTLTYPE_INT }, \
|
|
|
|
{ "filemax", CTLTYPE_INT }, \
|
1998-02-06 03:14:43 +03:00
|
|
|
}
|
|
|
|
|
1994-05-23 07:11:20 +04:00
|
|
|
#ifndef ASSEMBLER
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* Convert addresses to pages and vice versa.
|
|
|
|
* No rounding is used.
|
|
|
|
*/
|
1995-03-27 00:35:13 +04:00
|
|
|
#ifdef _KERNEL
|
2001-01-09 16:55:20 +03:00
|
|
|
#define atop(x) (((paddr_t)(x)) >> PAGE_SHIFT)
|
1999-11-30 22:31:05 +03:00
|
|
|
#define ptoa(x) ((vaddr_t)((vaddr_t)(x) << PAGE_SHIFT))
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/*
|
1994-05-23 07:11:20 +04:00
|
|
|
* Round off or truncate to the nearest page. These will work
|
|
|
|
* for either addresses or counts (i.e., 1 byte rounds to 1 page).
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
2000-04-11 06:30:32 +04:00
|
|
|
#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK)
|
|
|
|
#define trunc_page(x) ((x) & ~PAGE_MASK)
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2003-02-21 01:16:05 +03:00
|
|
|
/*
|
|
|
|
* Set up the default mapping address (VM_DEFAULT_ADDRESS) according to:
|
|
|
|
*
|
|
|
|
* USE_TOPDOWN_VM: a kernel option to enable on a per-kernel basis
|
|
|
|
* which only be used on ports that define...
|
|
|
|
* __HAVE_TOPDOWN_VM: a per-port option to offer the topdown option
|
|
|
|
*
|
|
|
|
* __USE_TOPDOWN_VM: a per-port option to unconditionally use it
|
|
|
|
*
|
|
|
|
* if __USE_TOPDOWN_VM is defined, the port can specify a default vm
|
|
|
|
* address, or we will use the topdown default from below. If it is
|
|
|
|
* NOT defined, then the port can offer topdown as an option, but it
|
|
|
|
* MUST define the VM_DEFAULT_ADDRESS macro itself.
|
|
|
|
*/
|
|
|
|
#if defined(USE_TOPDOWN_VM) || defined(__USE_TOPDOWN_VM)
|
|
|
|
# if !defined(__HAVE_TOPDOWN_VM) && !defined(__USE_TOPDOWN_VM)
|
|
|
|
# error "Top down memory allocation not enabled for this system"
|
|
|
|
# else /* !__HAVE_TOPDOWN_VM && !__USE_TOPDOWN_VM */
|
|
|
|
# define __USING_TOPDOWN_VM
|
|
|
|
# if !defined(VM_DEFAULT_ADDRESS)
|
|
|
|
# if !defined(__USE_TOPDOWN_VM)
|
|
|
|
# error "Top down memory allocation not configured for this system"
|
|
|
|
# else /* !__USE_TOPDOWN_VM */
|
|
|
|
# define VM_DEFAULT_ADDRESS(da, sz) \
|
|
|
|
trunc_page(VM_MAXUSER_ADDRESS - MAXSSIZ - (sz))
|
|
|
|
# endif /* !__USE_TOPDOWN_VM */
|
|
|
|
# endif /* !VM_DEFAULT_ADDRESS */
|
|
|
|
# endif /* !__HAVE_TOPDOWN_VM && !__USE_TOPDOWN_VM */
|
|
|
|
#endif /* USE_TOPDOWN_VM || __USE_TOPDOWN_VM */
|
|
|
|
|
|
|
|
#if !defined(__USING_TOPDOWN_VM)
|
|
|
|
# if defined(VM_DEFAULT_ADDRESS)
|
|
|
|
# error "Default vm address should not be defined here"
|
|
|
|
# else /* VM_DEFAULT_ADDRESS */
|
|
|
|
# define VM_DEFAULT_ADDRESS(da, sz) round_page((vaddr_t)(da) + MAXDSIZ)
|
|
|
|
# endif /* VM_DEFAULT_ADDRESS */
|
|
|
|
#endif /* !__USING_TOPDOWN_VM */
|
|
|
|
|
2000-12-21 03:52:01 +03:00
|
|
|
extern int ubc_nwins; /* number of UBC mapping windows */
|
2001-03-21 06:16:05 +03:00
|
|
|
extern int ubc_winshift; /* shift for a UBC mapping window */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-05-23 07:11:20 +04:00
|
|
|
#else
|
|
|
|
/* out-of-kernel versions of round_page and trunc_page */
|
|
|
|
#define round_page(x) \
|
1998-08-13 06:10:37 +04:00
|
|
|
((((vaddr_t)(x) + (vm_page_size - 1)) / vm_page_size) * \
|
1995-01-09 05:47:23 +03:00
|
|
|
vm_page_size)
|
1994-05-23 07:11:20 +04:00
|
|
|
#define trunc_page(x) \
|
1998-08-13 06:10:37 +04:00
|
|
|
((((vaddr_t)(x)) / vm_page_size) * vm_page_size)
|
1994-05-23 07:11:20 +04:00
|
|
|
|
1995-03-27 00:35:13 +04:00
|
|
|
#endif /* _KERNEL */
|
1994-05-23 07:11:20 +04:00
|
|
|
#endif /* ASSEMBLER */
|
|
|
|
#endif /* _VM_PARAM_ */
|