|
|
1.1 root 1: /*
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: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions
10: * are met:
11: * 1. Redistributions of source code must retain the above copyright
12: * notice, this list of conditions and the following disclaimer.
13: * 2. Redistributions in binary form must reproduce the above copyright
14: * notice, this list of conditions and the following disclaimer in the
15: * documentation and/or other materials provided with the distribution.
16: * 3. All advertising materials mentioning features or use of this software
17: * must display the following acknowledgement:
18: * This product includes software developed by the University of
19: * California, Berkeley and its contributors.
20: * 4. Neither the name of the University nor the names of its contributors
21: * may be used to endorse or promote products derived from this software
22: * without specific prior written permission.
23: *
24: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34: * SUCH DAMAGE.
35: *
1.1.1.3 ! root 36: * from: @(#)vm_map.h 7.3 (Berkeley) 4/21/91
! 37: * vm_map.h,v 1.4 1993/05/20 03:59:31 cgd Exp
1.1 root 38: *
39: *
40: * Copyright (c) 1987, 1990 Carnegie-Mellon University.
41: * All rights reserved.
42: *
43: * Authors: Avadis Tevanian, Jr., Michael Wayne Young
44: *
45: * Permission to use, copy, modify and distribute this software and
46: * its documentation is hereby granted, provided that both the copyright
47: * notice and this permission notice appear in all copies of the
48: * software, derivative works or modified versions, and any portions
49: * thereof, and that both notices appear in supporting documentation.
50: *
51: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
52: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
53: * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
54: *
55: * Carnegie Mellon requests users of this software to return to
56: *
57: * Software Distribution Coordinator or [email protected]
58: * School of Computer Science
59: * Carnegie Mellon University
60: * Pittsburgh PA 15213-3890
61: *
62: * any improvements or extensions that they make and grant Carnegie the
63: * rights to redistribute these changes.
64: */
65:
1.1.1.3 ! root 66: #ifndef _VM_VM_MAP_H_
! 67: #define _VM_VM_MAP_H_
! 68:
1.1 root 69: /*
70: * Virtual memory map module definitions.
71: */
72:
73: /*
74: * Types defined:
75: *
76: * vm_map_t the high-level address map data structure.
77: * vm_map_entry_t an entry in an address map.
78: * vm_map_version_t a timestamp of a map, for use with vm_map_lookup
79: */
80:
81: /*
82: * Objects which live in maps may be either VM objects, or
83: * another map (called a "sharing map") which denotes read-write
84: * sharing with other maps.
85: */
86:
87: union vm_map_object {
88: struct vm_object *vm_object; /* object object */
89: struct vm_map *share_map; /* share map */
90: struct vm_map *sub_map; /* belongs to another map */
91: };
92:
93: typedef union vm_map_object vm_map_object_t;
94:
95: /*
96: * Address map entries consist of start and end addresses,
97: * a VM object (or sharing map) and offset into that object,
98: * and user-exported inheritance and protection information.
99: * Also included is control information for virtual copy operations.
100: */
101: struct vm_map_entry {
102: struct vm_map_entry *prev; /* previous entry */
103: struct vm_map_entry *next; /* next entry */
104: vm_offset_t start; /* start address */
105: vm_offset_t end; /* end address */
106: union vm_map_object object; /* object I point to */
107: vm_offset_t offset; /* offset into object */
108: boolean_t is_a_map; /* Is "object" a map? */
109: boolean_t is_sub_map; /* Is "object" a submap? */
110: /* Only in sharing maps: */
111: boolean_t copy_on_write; /* is data copy-on-write */
112: boolean_t needs_copy; /* does object need to be copied */
113: /* Only in task maps: */
114: vm_prot_t protection; /* protection code */
115: vm_prot_t max_protection; /* maximum protection */
116: vm_inherit_t inheritance; /* inheritance */
117: int wired_count; /* can be paged if = 0 */
118: };
119:
120: typedef struct vm_map_entry *vm_map_entry_t;
121:
122: /*
123: * Maps are doubly-linked lists of map entries, kept sorted
124: * by address. A single hint is provided to start
125: * searches again from the last successful search,
126: * insertion, or removal.
127: */
128: struct vm_map {
129: struct pmap * pmap; /* Physical map */
130: lock_data_t lock; /* Lock for map data */
131: struct vm_map_entry header; /* List of entries */
132: int nentries; /* Number of entries */
133: vm_size_t size; /* virtual size */
134: boolean_t is_main_map; /* Am I a main map? */
135: int ref_count; /* Reference count */
136: simple_lock_data_t ref_lock; /* Lock for ref_count field */
137: vm_map_entry_t hint; /* hint for quick lookups */
138: simple_lock_data_t hint_lock; /* lock for hint storage */
139: vm_map_entry_t first_free; /* First free space hint */
140: boolean_t entries_pageable; /* map entries pageable?? */
141: unsigned int timestamp; /* Version number */
142: #define min_offset header.start
143: #define max_offset header.end
144: };
145:
146: typedef struct vm_map *vm_map_t;
147:
148: /*
149: * Map versions are used to validate a previous lookup attempt.
150: *
151: * Since lookup operations may involve both a main map and
152: * a sharing map, it is necessary to have a timestamp from each.
153: * [If the main map timestamp has changed, the share_map and
154: * associated timestamp are no longer valid; the map version
155: * does not include a reference for the imbedded share_map.]
156: */
157: typedef struct {
158: int main_timestamp;
159: vm_map_t share_map;
160: int share_timestamp;
161: } vm_map_version_t;
162:
163: /*
164: * Macros: vm_map_lock, etc.
165: * Function:
166: * Perform locking on the data portion of a map.
167: */
168:
169: #define vm_map_lock(map) { lock_write(&(map)->lock); (map)->timestamp++; }
170: #define vm_map_unlock(map) lock_write_done(&(map)->lock)
171: #define vm_map_lock_read(map) lock_read(&(map)->lock)
172: #define vm_map_unlock_read(map) lock_read_done(&(map)->lock)
173:
174: /*
175: * Exported procedures that operate on vm_map_t.
176: */
177:
178: void vm_map_init();
179: vm_map_t vm_map_create();
180: void vm_map_deallocate();
181: void vm_map_reference();
182: int vm_map_find();
183: int vm_map_remove();
184: int vm_map_lookup();
185: void vm_map_lookup_done();
186: int vm_map_protect();
187: int vm_map_inherit();
188: int vm_map_copy();
189: void vm_map_print();
190: void vm_map_copy_entry();
191: boolean_t vm_map_verify();
192: void vm_map_verify_done();
193:
194: /*
195: * Functions implemented as macros
196: */
197: #define vm_map_min(map) ((map)->min_offset)
198: #define vm_map_max(map) ((map)->max_offset)
199: #define vm_map_pmap(map) ((map)->pmap)
200:
201: /* XXX: number of kernel maps and entries to statically allocate */
202: #define MAX_KMAP 10
1.1.1.2 root 203:
204: #ifdef OMIT
205: #define MAX_KMAPENT 500
206: #else /* !OMIT*/
207: #define MAX_KMAPENT 1000 /* 15 Aug 92*/
208: #endif /* !OMIT*/
1.1 root 209:
1.1.1.3 ! root 210: #endif /* !_VM_VM_MAP_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.