define VM_PAGE_INIT as vm_page_init was only used in one place
[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 *
0e24ad83
KM
10 * @(#)vm_map.h 7.3 (Berkeley) %G%
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
66typedef union vm_map_object vm_map_object_t;
67
68/*
69 * Address map entries consist of start and end addresses,
70 * a VM object (or sharing map) and offset into that object,
71 * and user-exported inheritance and protection information.
72 * Also included is control information for virtual copy operations.
73 */
74struct vm_map_entry {
75 struct vm_map_entry *prev; /* previous entry */
76 struct vm_map_entry *next; /* next entry */
77 vm_offset_t start; /* start address */
78 vm_offset_t end; /* end address */
79 union vm_map_object object; /* object I point to */
80 vm_offset_t offset; /* offset into object */
81 boolean_t is_a_map; /* Is "object" a map? */
82 boolean_t is_sub_map; /* Is "object" a submap? */
83 /* Only in sharing maps: */
84 boolean_t copy_on_write; /* is data copy-on-write */
85 boolean_t needs_copy; /* does object need to be copied */
86 /* Only in task maps: */
87 vm_prot_t protection; /* protection code */
88 vm_prot_t max_protection; /* maximum protection */
89 vm_inherit_t inheritance; /* inheritance */
90 int wired_count; /* can be paged if = 0 */
91};
92
93typedef struct vm_map_entry *vm_map_entry_t;
94
175f072e
KM
95/*
96 * Maps are doubly-linked lists of map entries, kept sorted
97 * by address. A single hint is provided to start
98 * searches again from the last successful search,
99 * insertion, or removal.
100 */
101struct vm_map {
ffe0d082 102 struct pmap * pmap; /* Physical map */
175f072e
KM
103 lock_data_t lock; /* Lock for map data */
104 struct vm_map_entry header; /* List of entries */
105 int nentries; /* Number of entries */
175f072e
KM
106 vm_size_t size; /* virtual size */
107 boolean_t is_main_map; /* Am I a main map? */
108 int ref_count; /* Reference count */
109 simple_lock_data_t ref_lock; /* Lock for ref_count field */
110 vm_map_entry_t hint; /* hint for quick lookups */
111 simple_lock_data_t hint_lock; /* lock for hint storage */
112 vm_map_entry_t first_free; /* First free space hint */
113 boolean_t entries_pageable; /* map entries pageable?? */
114 unsigned int timestamp; /* Version number */
115#define min_offset header.start
116#define max_offset header.end
117};
118
119typedef struct vm_map *vm_map_t;
120
175f072e
KM
121/*
122 * Map versions are used to validate a previous lookup attempt.
123 *
124 * Since lookup operations may involve both a main map and
125 * a sharing map, it is necessary to have a timestamp from each.
126 * [If the main map timestamp has changed, the share_map and
127 * associated timestamp are no longer valid; the map version
128 * does not include a reference for the imbedded share_map.]
129 */
130typedef struct {
131 int main_timestamp;
132 vm_map_t share_map;
133 int share_timestamp;
134} vm_map_version_t;
135
136/*
137 * Macros: vm_map_lock, etc.
138 * Function:
139 * Perform locking on the data portion of a map.
140 */
141
142#define vm_map_lock(map) { lock_write(&(map)->lock); (map)->timestamp++; }
143#define vm_map_unlock(map) lock_write_done(&(map)->lock)
144#define vm_map_lock_read(map) lock_read(&(map)->lock)
145#define vm_map_unlock_read(map) lock_read_done(&(map)->lock)
146
147/*
148 * Exported procedures that operate on vm_map_t.
149 */
150
151void vm_map_init();
152vm_map_t vm_map_create();
153void vm_map_deallocate();
154void vm_map_reference();
155int vm_map_find();
156int vm_map_remove();
157int vm_map_lookup();
158void vm_map_lookup_done();
159int vm_map_protect();
160int vm_map_inherit();
161int vm_map_copy();
175f072e
KM
162void vm_map_print();
163void vm_map_copy_entry();
164boolean_t vm_map_verify();
165void vm_map_verify_done();
166
167/*
168 * Functions implemented as macros
169 */
170#define vm_map_min(map) ((map)->min_offset)
171#define vm_map_max(map) ((map)->max_offset)
172#define vm_map_pmap(map) ((map)->pmap)
173
174/* XXX: number of kernel maps and entries to statically allocate */
175#define MAX_KMAP 10
176#define MAX_KMAPENT 500
177
178#endif _VM_MAP_