Commit | Line | Data |
---|---|---|
175f072e | 1 | /* |
ad0f93d2 KB |
2 | * Copyright (c) 1991, 1993 |
3 | * The Regents of the University of California. All rights reserved. | |
175f072e KM |
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 | * |
ad0f93d2 | 10 | * @(#)vm_object.h 8.1 (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 object module definitions. | |
41 | */ | |
42 | ||
43 | #ifndef _VM_OBJECT_ | |
44 | #define _VM_OBJECT_ | |
45 | ||
175f072e | 46 | #include <vm/vm_pager.h> |
175f072e KM |
47 | |
48 | /* | |
49 | * Types defined: | |
50 | * | |
51 | * vm_object_t Virtual memory object. | |
52 | */ | |
53 | ||
54 | struct vm_object { | |
55 | queue_chain_t memq; /* Resident memory */ | |
56 | queue_chain_t object_list; /* list of all objects */ | |
ac29144a KM |
57 | u_short flags; /* see below */ |
58 | u_short paging_in_progress; /* Paging (in or out) so | |
59 | don't collapse or destroy */ | |
175f072e | 60 | simple_lock_data_t Lock; /* Synchronization */ |
175f072e KM |
61 | int ref_count; /* How many refs?? */ |
62 | vm_size_t size; /* Object size */ | |
63 | int resident_page_count; | |
64 | /* number of resident pages */ | |
65 | struct vm_object *copy; /* Object that holds copies of | |
66 | my changed pages */ | |
67 | vm_pager_t pager; /* Where to get data */ | |
175f072e KM |
68 | vm_offset_t paging_offset; /* Offset into paging space */ |
69 | struct vm_object *shadow; /* My shadow */ | |
70 | vm_offset_t shadow_offset; /* Offset in shadow */ | |
175f072e KM |
71 | queue_chain_t cached_list; /* for persistence */ |
72 | }; | |
ac29144a KM |
73 | /* |
74 | * Flags | |
75 | */ | |
76 | #define OBJ_CANPERSIST 0x0001 /* allow to persist */ | |
77 | #define OBJ_INTERNAL 0x0002 /* internally created object */ | |
78 | #define OBJ_ACTIVE 0x0004 /* used to mark active objects */ | |
175f072e | 79 | |
175f072e KM |
80 | struct vm_object_hash_entry { |
81 | queue_chain_t hash_links; /* hash chain links */ | |
82 | vm_object_t object; /* object we represent */ | |
83 | }; | |
84 | ||
85 | typedef struct vm_object_hash_entry *vm_object_hash_entry_t; | |
86 | ||
87 | #ifdef KERNEL | |
88 | queue_head_t vm_object_cached_list; /* list of objects persisting */ | |
89 | int vm_object_cached; /* size of cached list */ | |
90 | simple_lock_data_t vm_cache_lock; /* lock for object cache */ | |
91 | ||
92 | queue_head_t vm_object_list; /* list of allocated objects */ | |
93 | long vm_object_count; /* count of all objects */ | |
94 | simple_lock_data_t vm_object_list_lock; | |
95 | /* lock for object list and count */ | |
96 | ||
97 | vm_object_t kernel_object; /* the single kernel object */ | |
98 | vm_object_t kmem_object; | |
99 | ||
100 | #define vm_object_cache_lock() simple_lock(&vm_cache_lock) | |
101 | #define vm_object_cache_unlock() simple_unlock(&vm_cache_lock) | |
b73f8487 | 102 | #endif /* KERNEL */ |
175f072e | 103 | |
175f072e KM |
104 | #define vm_object_lock_init(object) simple_lock_init(&(object)->Lock) |
105 | #define vm_object_lock(object) simple_lock(&(object)->Lock) | |
106 | #define vm_object_unlock(object) simple_unlock(&(object)->Lock) | |
107 | #define vm_object_lock_try(object) simple_lock_try(&(object)->Lock) | |
108 | #define vm_object_sleep(event, object, interruptible) \ | |
109 | thread_sleep((event), &(object)->Lock, (interruptible)) | |
175f072e | 110 | |
5fddb4f9 KB |
111 | #ifdef KERNEL |
112 | vm_object_t vm_object_allocate __P((vm_size_t)); | |
113 | void vm_object_cache_clear __P((void)); | |
114 | void vm_object_cache_trim __P((void)); | |
115 | boolean_t vm_object_coalesce __P((vm_object_t, vm_object_t, | |
116 | vm_offset_t, vm_offset_t, vm_offset_t, vm_size_t)); | |
117 | void vm_object_collapse __P((vm_object_t)); | |
118 | void vm_object_copy __P((vm_object_t, vm_offset_t, vm_size_t, | |
119 | vm_object_t *, vm_offset_t *, boolean_t *)); | |
120 | void vm_object_deactivate_pages __P((vm_object_t)); | |
121 | void vm_object_deallocate __P((vm_object_t)); | |
122 | void vm_object_enter __P((vm_object_t, vm_pager_t)); | |
123 | void vm_object_init __P((vm_size_t)); | |
124 | vm_object_t vm_object_lookup __P((vm_pager_t)); | |
125 | void vm_object_page_clean __P((vm_object_t, | |
126 | vm_offset_t, vm_offset_t, boolean_t)); | |
127 | void vm_object_page_remove __P((vm_object_t, | |
128 | vm_offset_t, vm_offset_t)); | |
129 | void vm_object_pmap_copy __P((vm_object_t, | |
130 | vm_offset_t, vm_offset_t)); | |
131 | void vm_object_pmap_remove __P((vm_object_t, | |
132 | vm_offset_t, vm_offset_t)); | |
133 | void vm_object_print __P((vm_object_t, boolean_t)); | |
134 | void vm_object_reference __P((vm_object_t)); | |
135 | void vm_object_remove __P((vm_pager_t)); | |
136 | void vm_object_setpager __P((vm_object_t, | |
137 | vm_pager_t, vm_offset_t, boolean_t)); | |
138 | void vm_object_shadow __P((vm_object_t *, | |
139 | vm_offset_t *, vm_size_t)); | |
140 | void vm_object_shutdown __P((void)); | |
141 | void vm_object_terminate __P((vm_object_t)); | |
142 | #endif | |
b73f8487 | 143 | #endif /* _VM_OBJECT_ */ |