xref: /freebsd/sys/vm/vm.h (revision 98df9218daac2006d7cf5a914544ab8614d31e3b)
160727d8bSWarner Losh /*-
2df8bae1dSRodney W. Grimes  * Copyright (c) 1991, 1993
3df8bae1dSRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
4df8bae1dSRodney W. Grimes  *
5df8bae1dSRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
6df8bae1dSRodney W. Grimes  * modification, are permitted provided that the following conditions
7df8bae1dSRodney W. Grimes  * are met:
8df8bae1dSRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
9df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
10df8bae1dSRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
11df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
12df8bae1dSRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
13df8bae1dSRodney W. Grimes  * 4. Neither the name of the University nor the names of its contributors
14df8bae1dSRodney W. Grimes  *    may be used to endorse or promote products derived from this software
15df8bae1dSRodney W. Grimes  *    without specific prior written permission.
16df8bae1dSRodney W. Grimes  *
17df8bae1dSRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18df8bae1dSRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19df8bae1dSRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20df8bae1dSRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21df8bae1dSRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22df8bae1dSRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23df8bae1dSRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24df8bae1dSRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25df8bae1dSRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26df8bae1dSRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27df8bae1dSRodney W. Grimes  * SUCH DAMAGE.
28df8bae1dSRodney W. Grimes  *
29df8bae1dSRodney W. Grimes  *	@(#)vm.h	8.2 (Berkeley) 12/13/93
30923502ffSPoul-Henning Kamp  *	@(#)vm_prot.h	8.1 (Berkeley) 6/11/93
31923502ffSPoul-Henning Kamp  *	@(#)vm_inherit.h	8.1 (Berkeley) 6/11/93
32923502ffSPoul-Henning Kamp  *
33923502ffSPoul-Henning Kamp  * Copyright (c) 1987, 1990 Carnegie-Mellon University.
34923502ffSPoul-Henning Kamp  * All rights reserved.
35923502ffSPoul-Henning Kamp  *
36923502ffSPoul-Henning Kamp  * Authors: Avadis Tevanian, Jr., Michael Wayne Young
37923502ffSPoul-Henning Kamp  *
38923502ffSPoul-Henning Kamp  * Permission to use, copy, modify and distribute this software and
39923502ffSPoul-Henning Kamp  * its documentation is hereby granted, provided that both the copyright
40923502ffSPoul-Henning Kamp  * notice and this permission notice appear in all copies of the
41923502ffSPoul-Henning Kamp  * software, derivative works or modified versions, and any portions
42923502ffSPoul-Henning Kamp  * thereof, and that both notices appear in supporting documentation.
43923502ffSPoul-Henning Kamp  *
44923502ffSPoul-Henning Kamp  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
45923502ffSPoul-Henning Kamp  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
46923502ffSPoul-Henning Kamp  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
47923502ffSPoul-Henning Kamp  *
48923502ffSPoul-Henning Kamp  * Carnegie Mellon requests users of this software to return to
49923502ffSPoul-Henning Kamp  *
50923502ffSPoul-Henning Kamp  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
51923502ffSPoul-Henning Kamp  *  School of Computer Science
52923502ffSPoul-Henning Kamp  *  Carnegie Mellon University
53923502ffSPoul-Henning Kamp  *  Pittsburgh PA 15213-3890
54923502ffSPoul-Henning Kamp  *
55923502ffSPoul-Henning Kamp  * any improvements or extensions that they make and grant Carnegie the
56923502ffSPoul-Henning Kamp  * rights to redistribute these changes.
57923502ffSPoul-Henning Kamp  *
58c3aac50fSPeter Wemm  * $FreeBSD$
59df8bae1dSRodney W. Grimes  */
60df8bae1dSRodney W. Grimes 
61df8bae1dSRodney W. Grimes #ifndef VM_H
62df8bae1dSRodney W. Grimes #define VM_H
63df8bae1dSRodney W. Grimes 
64923502ffSPoul-Henning Kamp typedef char vm_inherit_t;	/* inheritance codes */
65923502ffSPoul-Henning Kamp 
66923502ffSPoul-Henning Kamp #define	VM_INHERIT_SHARE	((vm_inherit_t) 0)
67923502ffSPoul-Henning Kamp #define	VM_INHERIT_COPY		((vm_inherit_t) 1)
68923502ffSPoul-Henning Kamp #define	VM_INHERIT_NONE		((vm_inherit_t) 2)
69923502ffSPoul-Henning Kamp #define	VM_INHERIT_DEFAULT	VM_INHERIT_COPY
70923502ffSPoul-Henning Kamp 
71efeaf95aSDavid Greenman typedef u_char vm_prot_t;	/* protection codes */
72df8bae1dSRodney W. Grimes 
73923502ffSPoul-Henning Kamp #define	VM_PROT_NONE		((vm_prot_t) 0x00)
74923502ffSPoul-Henning Kamp #define	VM_PROT_READ		((vm_prot_t) 0x01)
75923502ffSPoul-Henning Kamp #define	VM_PROT_WRITE		((vm_prot_t) 0x02)
76923502ffSPoul-Henning Kamp #define	VM_PROT_EXECUTE		((vm_prot_t) 0x04)
77923502ffSPoul-Henning Kamp #define	VM_PROT_OVERRIDE_WRITE	((vm_prot_t) 0x08)	/* copy-on-write */
78923502ffSPoul-Henning Kamp 
79923502ffSPoul-Henning Kamp #define	VM_PROT_ALL		(VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE)
80fa7dd9c5SMatthew Dillon #define VM_PROT_RW		(VM_PROT_READ|VM_PROT_WRITE)
81923502ffSPoul-Henning Kamp #define	VM_PROT_DEFAULT		VM_PROT_ALL
82923502ffSPoul-Henning Kamp 
8398df9218SJohn Baldwin enum obj_type { OBJT_DEFAULT, OBJT_SWAP, OBJT_VNODE, OBJT_DEVICE, OBJT_PHYS,
8498df9218SJohn Baldwin 		OBJT_DEAD };
8598df9218SJohn Baldwin typedef u_char objtype_t;
8698df9218SJohn Baldwin 
87df8bae1dSRodney W. Grimes union vm_map_object;
88df8bae1dSRodney W. Grimes typedef union vm_map_object vm_map_object_t;
89df8bae1dSRodney W. Grimes 
90df8bae1dSRodney W. Grimes struct vm_map_entry;
91df8bae1dSRodney W. Grimes typedef struct vm_map_entry *vm_map_entry_t;
92df8bae1dSRodney W. Grimes 
93df8bae1dSRodney W. Grimes struct vm_map;
94df8bae1dSRodney W. Grimes typedef struct vm_map *vm_map_t;
95df8bae1dSRodney W. Grimes 
96df8bae1dSRodney W. Grimes struct vm_object;
97df8bae1dSRodney W. Grimes typedef struct vm_object *vm_object_t;
98df8bae1dSRodney W. Grimes 
99c4473420SPeter Wemm #ifndef _KERNEL
1000ff89d5bSBruce Evans /*
1015ad9d5a7SBruce Evans  * This is defined in <sys/types.h> for the kernel so that non-vm kernel
1025ad9d5a7SBruce Evans  * sources (mainly Mach-derived ones such as ddb) don't have to include
1035ad9d5a7SBruce Evans  * vm stuff.  Defining it there for applications might break things.
1045ad9d5a7SBruce Evans  * Define it here for "applications" that include vm headers (e.g.,
1055ad9d5a7SBruce Evans  * genassym).
1065ad9d5a7SBruce Evans  */
1075ad9d5a7SBruce Evans typedef int boolean_t;
1085ad9d5a7SBruce Evans 
1095ad9d5a7SBruce Evans /*
1100ff89d5bSBruce Evans  * This is defined in <sys/types.h> for the kernel so that vnode_if.h
1110ff89d5bSBruce Evans  * doesn't have to include <vm/vm.h>.
1120ff89d5bSBruce Evans  */
113df8bae1dSRodney W. Grimes struct vm_page;
114df8bae1dSRodney W. Grimes typedef struct vm_page *vm_page_t;
115a1287949SEivind Eklund #endif				/* _KERNEL */
116df8bae1dSRodney W. Grimes 
117219d632cSMatthew Dillon /*
118c1fbc251SAlan Cox  * Virtual memory MPSAFE temporary workarounds.
119c1fbc251SAlan Cox  */
120c1fbc251SAlan Cox extern int debug_mpsafevm;		/* defined in vm/vm_meter.c */
121c1fbc251SAlan Cox #define	VM_LOCK_GIANT() do {						\
122c1fbc251SAlan Cox 	if (!debug_mpsafevm)						\
123c1fbc251SAlan Cox 		mtx_lock(&Giant);					\
124c1fbc251SAlan Cox } while (0)
125c1fbc251SAlan Cox #define	VM_UNLOCK_GIANT() do {						\
126c1fbc251SAlan Cox 	if (!debug_mpsafevm)						\
127c1fbc251SAlan Cox 		mtx_unlock(&Giant);					\
128c1fbc251SAlan Cox } while (0)
129c1fbc251SAlan Cox 
130c1fbc251SAlan Cox /*
131219d632cSMatthew Dillon  * Information passed from the machine-independant VM initialization code
132219d632cSMatthew Dillon  * for use by machine-dependant code (mainly for MMU support)
133219d632cSMatthew Dillon  */
134219d632cSMatthew Dillon struct kva_md_info {
135219d632cSMatthew Dillon 	vm_offset_t	buffer_sva;
136219d632cSMatthew Dillon 	vm_offset_t	buffer_eva;
137219d632cSMatthew Dillon 	vm_offset_t	clean_sva;
138219d632cSMatthew Dillon 	vm_offset_t	clean_eva;
139219d632cSMatthew Dillon 	vm_offset_t	pager_sva;
140219d632cSMatthew Dillon 	vm_offset_t	pager_eva;
141219d632cSMatthew Dillon };
142219d632cSMatthew Dillon 
143219d632cSMatthew Dillon extern struct kva_md_info	kmi;
144d2979f90SDavid Malone extern void vm_ksubmap_init(struct kva_md_info *);
145219d632cSMatthew Dillon 
146df8bae1dSRodney W. Grimes #endif				/* VM_H */
147219d632cSMatthew Dillon 
148