vm_param.h revision 5455
15455Sdg/* 21541Srgrimes * Copyright (c) 1991, 1993 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * 51541Srgrimes * This code is derived from software contributed to Berkeley by 61541Srgrimes * The Mach Operating System project at Carnegie-Mellon University. 71541Srgrimes * 81541Srgrimes * Redistribution and use in source and binary forms, with or without 91541Srgrimes * modification, are permitted provided that the following conditions 101541Srgrimes * are met: 111541Srgrimes * 1. Redistributions of source code must retain the above copyright 121541Srgrimes * notice, this list of conditions and the following disclaimer. 131541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 141541Srgrimes * notice, this list of conditions and the following disclaimer in the 151541Srgrimes * documentation and/or other materials provided with the distribution. 161541Srgrimes * 3. All advertising materials mentioning features or use of this software 171541Srgrimes * must display the following acknowledgement: 181541Srgrimes * This product includes software developed by the University of 191541Srgrimes * California, Berkeley and its contributors. 201541Srgrimes * 4. Neither the name of the University nor the names of its contributors 211541Srgrimes * may be used to endorse or promote products derived from this software 221541Srgrimes * without specific prior written permission. 231541Srgrimes * 241541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 251541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 261541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 271541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 281541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 291541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 301541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 311541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 321541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 331541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 341541Srgrimes * SUCH DAMAGE. 351541Srgrimes * 361817Sdg * from: @(#)vm_param.h 8.1 (Berkeley) 6/11/93 371541Srgrimes * 381541Srgrimes * 391541Srgrimes * Copyright (c) 1987, 1990 Carnegie-Mellon University. 401541Srgrimes * All rights reserved. 411541Srgrimes * 421541Srgrimes * Authors: Avadis Tevanian, Jr., Michael Wayne Young 435455Sdg * 441541Srgrimes * Permission to use, copy, modify and distribute this software and 451541Srgrimes * its documentation is hereby granted, provided that both the copyright 461541Srgrimes * notice and this permission notice appear in all copies of the 471541Srgrimes * software, derivative works or modified versions, and any portions 481541Srgrimes * thereof, and that both notices appear in supporting documentation. 495455Sdg * 505455Sdg * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 515455Sdg * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 521541Srgrimes * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 535455Sdg * 541541Srgrimes * Carnegie Mellon requests users of this software to return to 551541Srgrimes * 561541Srgrimes * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 571541Srgrimes * School of Computer Science 581541Srgrimes * Carnegie Mellon University 591541Srgrimes * Pittsburgh PA 15213-3890 601541Srgrimes * 611541Srgrimes * any improvements or extensions that they make and grant Carnegie the 621541Srgrimes * rights to redistribute these changes. 631817Sdg * 645455Sdg * $Id: vm_param.h,v 1.3 1994/08/02 07:55:37 davidg Exp $ 651541Srgrimes */ 661541Srgrimes 671541Srgrimes/* 681541Srgrimes * Machine independent virtual memory parameters. 691541Srgrimes */ 701541Srgrimes 711541Srgrimes#ifndef _VM_PARAM_ 721541Srgrimes#define _VM_PARAM_ 731541Srgrimes 741541Srgrimes#include <machine/vmparam.h> 751541Srgrimes 761541Srgrimes/* 771541Srgrimes * This belongs in types.h, but breaks too many existing programs. 781541Srgrimes */ 795455Sdgtypedef int boolean_t; 805455Sdg 811541Srgrimes#define TRUE 1 821541Srgrimes#define FALSE 0 831541Srgrimes 841541Srgrimes/* 851541Srgrimes * The machine independent pages are refered to as PAGES. A page 861541Srgrimes * is some number of hardware pages, depending on the target machine. 871541Srgrimes */ 881541Srgrimes#define DEFAULT_PAGE_SIZE 4096 891541Srgrimes 901549Srgrimes#if 0 911549Srgrimes 921541Srgrimes/* 931541Srgrimes * All references to the size of a page should be done with PAGE_SIZE 941541Srgrimes * or PAGE_SHIFT. The fact they are variables is hidden here so that 951541Srgrimes * we can easily make them constant if we so desire. 961541Srgrimes */ 971549Srgrimes#ifndef PAGE_SIZE 985455Sdg#define PAGE_SIZE cnt.v_page_size /* size of page */ 991549Srgrimes#endif 1001549Srgrimes#ifndef PAGE_MASK 1015455Sdg#define PAGE_MASK page_mask /* size of page - 1 */ 1021549Srgrimes#endif 1031549Srgrimes#ifndef PAGE_SHIFT 1045455Sdg#define PAGE_SHIFT page_shift /* bits to shift for pages */ 1051549Srgrimes#endif 1061549Srgrimes 1071549Srgrimes#endif 1081549Srgrimes 1091541Srgrimes#ifdef KERNEL 1105455Sdgextern vm_size_t page_mask; 1115455Sdgextern int page_shift; 1125455Sdg 1131541Srgrimes#endif 1141541Srgrimes 1151541Srgrimes/* 1161541Srgrimes * CTL_VM identifiers 1171541Srgrimes */ 1185455Sdg#define VM_METER 1 /* struct vmmeter */ 1195455Sdg#define VM_LOADAVG 2 /* struct loadavg */ 1205455Sdg#define VM_V_FREE_MIN 3 /* cnt.v_free_min */ 1215455Sdg#define VM_V_FREE_TARGET 4 /* cnt.v_free_target */ 1225455Sdg#define VM_V_FREE_RESERVED 5 /* cnt.v_free_reserved */ 1235455Sdg#define VM_V_INACTIVE_TARGET 6 /* cnt.v_inactive_target */ 1245455Sdg#define VM_V_CACHE_MIN 7 /* cnt.v_cache_max */ 1255455Sdg#define VM_V_CACHE_MAX 8 /* cnt.v_cache_min */ 1265455Sdg#define VM_V_PAGEOUT_FREE_MIN 9 /* cnt.v_pageout_free_min */ 1275455Sdg#define VM_MAXID 10 /* number of valid vm ids */ 1281541Srgrimes 1291541Srgrimes#define CTL_VM_NAMES { \ 1301541Srgrimes { 0, 0 }, \ 1311541Srgrimes { "vmmeter", CTLTYPE_STRUCT }, \ 1321541Srgrimes { "loadavg", CTLTYPE_STRUCT }, \ 1335455Sdg { "v_free_min", CTLTYPE_INT }, \ 1345455Sdg { "v_free_target", CTLTYPE_INT }, \ 1355455Sdg { "v_free_reserved", CTLTYPE_INT }, \ 1365455Sdg { "v_inactive_target", CTLTYPE_INT }, \ 1375455Sdg { "v_cache_min", CTLTYPE_INT }, \ 1385455Sdg { "v_cache_max", CTLTYPE_INT }, \ 1395455Sdg { "v_pageout_free_min", CTLTYPE_INT}, \ 1401541Srgrimes} 1411541Srgrimes 1425455Sdg/* 1431541Srgrimes * Return values from the VM routines. 1441541Srgrimes */ 1451541Srgrimes#define KERN_SUCCESS 0 1461541Srgrimes#define KERN_INVALID_ADDRESS 1 1471541Srgrimes#define KERN_PROTECTION_FAILURE 2 1481541Srgrimes#define KERN_NO_SPACE 3 1491541Srgrimes#define KERN_INVALID_ARGUMENT 4 1501541Srgrimes#define KERN_FAILURE 5 1511541Srgrimes#define KERN_RESOURCE_SHORTAGE 6 1521541Srgrimes#define KERN_NOT_RECEIVER 7 1531541Srgrimes#define KERN_NO_ACCESS 8 1541541Srgrimes 1551541Srgrimes#ifndef ASSEMBLER 1561541Srgrimes/* 1571541Srgrimes * Convert addresses to pages and vice versa. 1581541Srgrimes * No rounding is used. 1591541Srgrimes */ 1601541Srgrimes#ifdef KERNEL 1611541Srgrimes#define num_pages(x) \ 1621541Srgrimes ((vm_offset_t)((((vm_offset_t)(x)) + PAGE_MASK) >> PAGE_SHIFT)) 1631541Srgrimes 1645455Sdgextern vm_size_t mem_size; /* size of physical memory (bytes) */ 1655455Sdgextern vm_offset_t first_addr; /* first physical page */ 1665455Sdgextern vm_offset_t last_addr; /* last physical page */ 1675455Sdg#endif /* KERNEL */ 1685455Sdg#endif /* ASSEMBLER */ 1695455Sdg#endif /* _VM_PARAM_ */ 170