Add extra argument to VOP_BMAP.
[unix-history] / usr / src / sys / vm / vm_map.h
CommitLineData
175f072e 1/*
175f072e
KM
2 * Copyright (c) 1991 Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * The Mach Operating System project at Carnegie-Mellon University.
7 *
0e24ad83 8 * %sccs.include.redist.c%
175f072e 9 *
9c83b781 10 * @(#)vm_map.h 7.5 (Berkeley) %G%
0e24ad83
KM
11 *
12 *
13 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
14 * All rights reserved.
15 *
16 * Authors: Avadis Tevanian, Jr., Michael Wayne Young
17 *
18 * Permission to use, copy, modify and distribute this software and
19 * its documentation is hereby granted, provided that both the copyright
20 * notice and this permission notice appear in all copies of the
21 * software, derivative works or modified versions, and any portions
22 * thereof, and that both notices appear in supporting documentation.
23 *
24 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
25 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
26 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
27 *
28 * Carnegie Mellon requests users of this software to return to
29 *
30 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
31 * School of Computer Science
32 * Carnegie Mellon University
33 * Pittsburgh PA 15213-3890
34 *
35 * any improvements or extensions that they make and grant Carnegie the
36 * rights to redistribute these changes.
175f072e
KM
37 */
38
39/*
40 * Virtual memory map module definitions.
41 */
42
43#ifndef _VM_MAP_
44#define _VM_MAP_
45
175f072e
KM
46/*
47 * Types defined:
48 *
49 * vm_map_t the high-level address map data structure.
50 * vm_map_entry_t an entry in an address map.
51 * vm_map_version_t a timestamp of a map, for use with vm_map_lookup
52 */
53
54/*
55 * Objects which live in maps may be either VM objects, or
56 * another map (called a "sharing map") which denotes read-write
57 * sharing with other maps.
58 */
59
60union vm_map_object {
61 struct vm_object *vm_object; /* object object */
62 struct vm_map *share_map; /* share map */
63 struct vm_map *sub_map; /* belongs to another map */
64};
65
175f072e
KM
66/*
67 * Address map entries consist of start and end addresses,
68 * a VM object (or sharing map) and offset into that object,
69 * and user-exported inheritance and protection information.
70 * Also included is control information for virtual copy operations.
71 */
72struct vm_map_entry {
73 struct vm_map_entry *prev; /* previous entry */
74 struct vm_map_entry *next; /* next entry */
75 vm_offset_t start; /* start address */
76 vm_offset_t end; /* end address */
77 union vm_map_object object; /* object I point to */
78 vm_offset_t offset; /* offset into object */
79 boolean_t is_a_map; /* Is "object" a map? */
80 boolean_t is_sub_map; /* Is "object" a submap? */
81 /* Only in sharing maps: */
82 boolean_t copy_on_write; /* is data copy-on-write */
83 boolean_t needs_copy; /* does object need to be copied */
84 /* Only in task maps: */
85 vm_prot_t protection; /* protection code */
86 vm_prot_t max_protection; /* maximum protection */
87 vm_inherit_t inheritance; /* inheritance */
88 int wired_count; /* can be paged if = 0 */
89};
90
175f072e
KM
91/*
92 * Maps are doubly-linked lists of map entries, kept sorted
93 * by address. A single hint is provided to start
94 * searches again from the last successful search,
95 * insertion, or removal.
96 */
97struct vm_map {
ffe0d082 98 struct pmap * pmap; /* Physical map */
175f072e
KM
99 lock_data_t lock; /* Lock for map data */
100 struct vm_map_entry header; /* List of entries */
101 int nentries; /* Number of entries */
175f072e
KM
102 vm_size_t size; /* virtual size */
103 boolean_t is_main_map; /* Am I a main map? */
104 int ref_count; /* Reference count */
105 simple_lock_data_t ref_lock; /* Lock for ref_count field */
106 vm_map_entry_t hint; /* hint for quick lookups */
107 simple_lock_data_t hint_lock; /* lock for hint storage */
108 vm_map_entry_t first_free; /* First free space hint */
109 boolean_t entries_pageable; /* map entries pageable?? */
110 unsigned int timestamp; /* Version number */
111#define min_offset header.start
112#define max_offset header.end
113};
114
175f072e
KM
115/*
116 * Map versions are used to validate a previous lookup attempt.
117 *
118 * Since lookup operations may involve both a main map and
119 * a sharing map, it is necessary to have a timestamp from each.
120 * [If the main map timestamp has changed, the share_map and
121 * associated timestamp are no longer valid; the map version
122 * does not include a reference for the imbedded share_map.]
123 */
124typedef struct {
125 int main_timestamp;
126 vm_map_t share_map;
127 int share_timestamp;
128} vm_map_version_t;
129
130/*
131 * Macros: vm_map_lock, etc.
132 * Function:
133 * Perform locking on the data portion of a map.
134 */
135
9c83b781
KB
136#define vm_map_lock(map) { \
137 lock_write(&(map)->lock); \
138 (map)->timestamp++; \
139}
140#define vm_map_unlock(map) lock_write_done(&(map)->lock)
141#define vm_map_lock_read(map) lock_read(&(map)->lock)
142#define vm_map_unlock_read(map) lock_read_done(&(map)->lock)
175f072e
KM
143
144/*
145 * Functions implemented as macros
146 */
147#define vm_map_min(map) ((map)->min_offset)
148#define vm_map_max(map) ((map)->max_offset)
149#define vm_map_pmap(map) ((map)->pmap)
150
151/* XXX: number of kernel maps and entries to statically allocate */
152#define MAX_KMAP 10
153#define MAX_KMAPENT 500
154
9c83b781
KB
155#ifdef KERNEL
156boolean_t vm_map_check_protection __P((vm_map_t,
157 vm_offset_t, vm_offset_t, vm_prot_t));
158int vm_map_copy __P((vm_map_t, vm_map_t, vm_offset_t,
159 vm_size_t, vm_offset_t, boolean_t, boolean_t));
160void vm_map_copy_entry __P((vm_map_t,
161 vm_map_t, vm_map_entry_t, vm_map_entry_t));
162struct pmap;
163vm_map_t vm_map_create __P((struct pmap *,
164 vm_offset_t, vm_offset_t, boolean_t));
165void vm_map_deallocate __P((vm_map_t));
166int vm_map_delete __P((vm_map_t, vm_offset_t, vm_offset_t));
167vm_map_entry_t vm_map_entry_create __P((vm_map_t));
168void vm_map_entry_delete __P((vm_map_t, vm_map_entry_t));
169void vm_map_entry_dispose __P((vm_map_t, vm_map_entry_t));
170void vm_map_entry_unwire __P((vm_map_t, vm_map_entry_t));
171int vm_map_find __P((vm_map_t, vm_object_t,
172 vm_offset_t, vm_offset_t *, vm_size_t, boolean_t));
173int vm_map_findspace __P((vm_map_t,
174 vm_offset_t, vm_size_t, vm_offset_t *));
175int vm_map_inherit __P((vm_map_t,
176 vm_offset_t, vm_offset_t, vm_inherit_t));
177void vm_map_init __P((struct vm_map *,
178 vm_offset_t, vm_offset_t, boolean_t));
179int vm_map_insert __P((vm_map_t,
180 vm_object_t, vm_offset_t, vm_offset_t, vm_offset_t));
181boolean_t vm_map_is_allocated __P((vm_map_t,
182 vm_offset_t, vm_offset_t, boolean_t));
183int vm_map_lookup __P((vm_map_t *, vm_offset_t, vm_prot_t,
184 vm_map_entry_t *, vm_object_t *, vm_offset_t *, vm_prot_t *,
185 boolean_t *, boolean_t *));
186void vm_map_lookup_done __P((vm_map_t, vm_map_entry_t));
187boolean_t vm_map_lookup_entry __P((vm_map_t,
188 vm_offset_t, vm_map_entry_t *));
189int vm_map_pageable __P((vm_map_t,
190 vm_offset_t, vm_offset_t, boolean_t));
191void vm_map_print __P((vm_map_t, boolean_t));
192int vm_map_protect __P((vm_map_t,
193 vm_offset_t, vm_offset_t, vm_prot_t, boolean_t));
194void vm_map_reference __P((vm_map_t));
195int vm_map_remove __P((vm_map_t, vm_offset_t, vm_offset_t));
196void vm_map_simplify __P((vm_map_t, vm_offset_t));
197void vm_map_simplify_entry __P((vm_map_t, vm_map_entry_t));
198void vm_map_startup __P((void));
199int vm_map_submap __P((vm_map_t,
200 vm_offset_t, vm_offset_t, vm_map_t));
201#endif
175f072e 202#endif _VM_MAP_