2003-02-21 01:16:05 +03:00
|
|
|
/* $NetBSD: uvm_param.h,v 1.14 2003/02/20 22:16:08 atatat 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.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* 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
|
|
|
|
|
|
|
/*
|
|
|
|
* This belongs in types.h, but breaks too many existing programs.
|
|
|
|
*/
|
|
|
|
typedef int boolean_t;
|
1999-04-11 04:59:07 +04:00
|
|
|
#ifndef TRUE
|
1993-03-21 12:45:37 +03:00
|
|
|
#define TRUE 1
|
1999-04-11 04:59:07 +04:00
|
|
|
#endif
|
|
|
|
#ifndef FALSE
|
1993-03-21 12:45:37 +03:00
|
|
|
#define FALSE 0
|
1999-04-11 04:59:07 +04:00
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The machine independent pages are refered to as PAGES. A page
|
|
|
|
* is some number of hardware pages, depending on the target machine.
|
|
|
|
*/
|
1994-04-15 11:04:03 +04:00
|
|
|
#define DEFAULT_PAGE_SIZE 4096
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2000-03-04 11:41:59 +03:00
|
|
|
#if defined(_KERNEL) && !defined(PAGE_SIZE)
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* All references to the size of a page should be done with PAGE_SIZE
|
|
|
|
* or PAGE_SHIFT. The fact they are variables is hidden here so that
|
|
|
|
* we can easily make them constant if we so desire.
|
|
|
|
*/
|
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 */
|
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 */
|
|
|
|
|
1998-08-13 06:10:37 +04:00
|
|
|
extern psize_t mem_size; /* size of physical memory (bytes) */
|
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_ */
|