1139825Simp/*-
21541Srgrimes * Copyright (c) 1991, 1993
31541Srgrimes *	The Regents of the University of California.  All rights reserved.
41541Srgrimes *
51541Srgrimes * Redistribution and use in source and binary forms, with or without
61541Srgrimes * modification, are permitted provided that the following conditions
71541Srgrimes * are met:
81541Srgrimes * 1. Redistributions of source code must retain the above copyright
91541Srgrimes *    notice, this list of conditions and the following disclaimer.
101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111541Srgrimes *    notice, this list of conditions and the following disclaimer in the
121541Srgrimes *    documentation and/or other materials provided with the distribution.
131541Srgrimes * 4. Neither the name of the University nor the names of its contributors
141541Srgrimes *    may be used to endorse or promote products derived from this software
151541Srgrimes *    without specific prior written permission.
161541Srgrimes *
171541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
181541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
211541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271541Srgrimes * SUCH DAMAGE.
281541Srgrimes *
291541Srgrimes *	@(#)vm.h	8.2 (Berkeley) 12/13/93
3052635Sphk *	@(#)vm_prot.h	8.1 (Berkeley) 6/11/93
3152635Sphk *	@(#)vm_inherit.h	8.1 (Berkeley) 6/11/93
3252635Sphk *
3352635Sphk * Copyright (c) 1987, 1990 Carnegie-Mellon University.
3452635Sphk * All rights reserved.
3552635Sphk *
3652635Sphk * Authors: Avadis Tevanian, Jr., Michael Wayne Young
3752635Sphk *
3852635Sphk * Permission to use, copy, modify and distribute this software and
3952635Sphk * its documentation is hereby granted, provided that both the copyright
4052635Sphk * notice and this permission notice appear in all copies of the
4152635Sphk * software, derivative works or modified versions, and any portions
4252635Sphk * thereof, and that both notices appear in supporting documentation.
4352635Sphk *
4452635Sphk * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
4552635Sphk * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
4652635Sphk * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
4752635Sphk *
4852635Sphk * Carnegie Mellon requests users of this software to return to
4952635Sphk *
5052635Sphk *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
5152635Sphk *  School of Computer Science
5252635Sphk *  Carnegie Mellon University
5352635Sphk *  Pittsburgh PA 15213-3890
5452635Sphk *
5552635Sphk * any improvements or extensions that they make and grant Carnegie the
5652635Sphk * rights to redistribute these changes.
5752635Sphk *
5850477Speter * $FreeBSD$
591541Srgrimes */
601541Srgrimes
611541Srgrimes#ifndef VM_H
621541Srgrimes#define VM_H
631541Srgrimes
64195033Salc#include <machine/vm.h>
65195033Salc
6652635Sphktypedef char vm_inherit_t;	/* inheritance codes */
6752635Sphk
6852635Sphk#define	VM_INHERIT_SHARE	((vm_inherit_t) 0)
6952635Sphk#define	VM_INHERIT_COPY		((vm_inherit_t) 1)
7052635Sphk#define	VM_INHERIT_NONE		((vm_inherit_t) 2)
7152635Sphk#define	VM_INHERIT_DEFAULT	VM_INHERIT_COPY
7252635Sphk
7312662Sdgtypedef u_char vm_prot_t;	/* protection codes */
741541Srgrimes
7552635Sphk#define	VM_PROT_NONE		((vm_prot_t) 0x00)
7652635Sphk#define	VM_PROT_READ		((vm_prot_t) 0x01)
7752635Sphk#define	VM_PROT_WRITE		((vm_prot_t) 0x02)
7852635Sphk#define	VM_PROT_EXECUTE		((vm_prot_t) 0x04)
79199819Salc#define	VM_PROT_COPY		((vm_prot_t) 0x08)	/* copy-on-read */
8052635Sphk
8152635Sphk#define	VM_PROT_ALL		(VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE)
82107948Sdillon#define VM_PROT_RW		(VM_PROT_READ|VM_PROT_WRITE)
8352635Sphk#define	VM_PROT_DEFAULT		VM_PROT_ALL
8452635Sphk
85144501Sjhbenum obj_type { OBJT_DEFAULT, OBJT_SWAP, OBJT_VNODE, OBJT_DEVICE, OBJT_PHYS,
86235375Skib		OBJT_DEAD, OBJT_SG, OBJT_MGTDEVICE };
87144501Sjhbtypedef u_char objtype_t;
88144501Sjhb
891541Srgrimesunion vm_map_object;
901541Srgrimestypedef union vm_map_object vm_map_object_t;
911541Srgrimes
921541Srgrimesstruct vm_map_entry;
931541Srgrimestypedef struct vm_map_entry *vm_map_entry_t;
941541Srgrimes
951541Srgrimesstruct vm_map;
961541Srgrimestypedef struct vm_map *vm_map_t;
971541Srgrimes
981541Srgrimesstruct vm_object;
991541Srgrimestypedef struct vm_object *vm_object_t;
1001541Srgrimes
10155206Speter#ifndef _KERNEL
10212642Sbde/*
10312710Sbde * This is defined in <sys/types.h> for the kernel so that non-vm kernel
10412710Sbde * sources (mainly Mach-derived ones such as ddb) don't have to include
10512710Sbde * vm stuff.  Defining it there for applications might break things.
10612710Sbde * Define it here for "applications" that include vm headers (e.g.,
10712710Sbde * genassym).
10812710Sbde */
10912710Sbdetypedef int boolean_t;
11012710Sbde
11112710Sbde/*
112196615Sjhb * The exact set of memory attributes is machine dependent.  However, every
113196615Sjhb * machine is required to define VM_MEMATTR_DEFAULT.
114196615Sjhb */
115196615Sjhbtypedef	char vm_memattr_t;	/* memory attribute codes */
116196615Sjhb
117196615Sjhb/*
11812642Sbde * This is defined in <sys/types.h> for the kernel so that vnode_if.h
11912642Sbde * doesn't have to include <vm/vm.h>.
12012642Sbde */
1211541Srgrimesstruct vm_page;
1225455Sdgtypedef struct vm_page *vm_page_t;
12392029Seivind#endif				/* _KERNEL */
1241541Srgrimes
125174939Salcstruct vm_reserv;
126174939Salctypedef struct vm_reserv *vm_reserv_t;
127174939Salc
12882127Sdillon/*
12982127Sdillon * Information passed from the machine-independant VM initialization code
13082127Sdillon * for use by machine-dependant code (mainly for MMU support)
13182127Sdillon */
13282127Sdillonstruct kva_md_info {
13382127Sdillon	vm_offset_t	buffer_sva;
13482127Sdillon	vm_offset_t	buffer_eva;
13582127Sdillon	vm_offset_t	clean_sva;
13682127Sdillon	vm_offset_t	clean_eva;
13782127Sdillon};
13882127Sdillon
13982127Sdillonextern struct kva_md_info	kmi;
14089802Sdwmaloneextern void vm_ksubmap_init(struct kva_md_info *);
14182127Sdillon
142244384Szontextern int old_mlock;
143244384Szont
144216128Straszstruct ucred;
145194766Skibint swap_reserve(vm_ooffset_t incr);
146216128Straszint swap_reserve_by_cred(vm_ooffset_t incr, struct ucred *cred);
147194766Skibvoid swap_reserve_force(vm_ooffset_t incr);
148194766Skibvoid swap_release(vm_ooffset_t decr);
149216128Straszvoid swap_release_by_cred(vm_ooffset_t decr, struct ucred *cred);
150253604Savgvoid swapper(void);
151194766Skib
1525455Sdg#endif				/* VM_H */
15382127Sdillon
154