]>
Commit | Line | Data |
---|---|---|
6d2010ae A |
1 | /* |
2 | * Copyright (c) 2009 Apple Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * This file contains Original Code and/or Modifications of Original Code | |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
25 | * | |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
27 | */ | |
28 | ||
29 | #ifndef _VM_VM_MAP_STORE_H | |
30 | #define _VM_VM_MAP_STORE_H | |
31 | ||
32 | /* | |
33 | #ifndef VM_MAP_STORE_USE_LL | |
34 | #define VM_MAP_STORE_USE_LL | |
35 | #endif | |
36 | */ | |
37 | #ifndef VM_MAP_STORE_USE_RB | |
38 | #define VM_MAP_STORE_USE_RB | |
39 | #endif | |
40 | ||
41 | #include <libkern/tree.h> | |
42 | ||
43 | struct _vm_map; | |
44 | struct vm_map_entry; | |
45 | struct vm_map_copy; | |
46 | struct vm_map_header; | |
47 | ||
48 | struct vm_map_store { | |
49 | #ifdef VM_MAP_STORE_USE_RB | |
50 | RB_ENTRY(vm_map_store) entry; | |
51 | #endif | |
52 | }; | |
53 | ||
54 | #ifdef VM_MAP_STORE_USE_RB | |
55 | RB_HEAD( rb_head, vm_map_store ); | |
56 | #endif | |
57 | ||
58 | #include <vm/vm_map.h> | |
59 | #include <vm/vm_map_store_ll.h> | |
60 | #include <vm/vm_map_store_rb.h> | |
61 | ||
39037602 A |
62 | #define UPDATE_HIGHEST_ENTRY_END(map, highest_entry) \ |
63 | MACRO_BEGIN \ | |
64 | struct _vm_map* UHEE_map; \ | |
65 | struct vm_map_entry* UHEE_entry; \ | |
66 | UHEE_map = (map); \ | |
67 | assert(UHEE_map->disable_vmentry_reuse); \ | |
68 | assert(!UHEE_map->is_nested_map); \ | |
69 | UHEE_entry = (highest_entry); \ | |
70 | if( UHEE_map->highest_entry_end < UHEE_entry->vme_end) { \ | |
71 | UHEE_map->highest_entry_end = UHEE_entry->vme_end; \ | |
6d2010ae A |
72 | } \ |
73 | MACRO_END | |
74 | ||
39037602 A |
75 | #define VM_MAP_HIGHEST_ENTRY(map, entry, start) \ |
76 | MACRO_BEGIN \ | |
77 | struct _vm_map* VMHE_map; \ | |
78 | struct vm_map_entry* tmp_entry; \ | |
79 | vm_map_offset_t VMHE_start; \ | |
80 | VMHE_map = (map); \ | |
81 | assert(VMHE_map->disable_vmentry_reuse); \ | |
82 | assert(!VMHE_map->is_nested_map); \ | |
83 | VMHE_start= VMHE_map->highest_entry_end + PAGE_SIZE_64; \ | |
84 | while(vm_map_lookup_entry(VMHE_map, VMHE_start, &tmp_entry)){ \ | |
85 | VMHE_map->highest_entry_end = tmp_entry->vme_end; \ | |
86 | VMHE_start = VMHE_map->highest_entry_end + PAGE_SIZE_64; \ | |
87 | } \ | |
88 | entry = tmp_entry; \ | |
89 | start = VMHE_start; \ | |
6d2010ae A |
90 | MACRO_END |
91 | ||
92 | /* | |
93 | * SAVE_HINT_MAP_READ: | |
94 | * | |
95 | * Saves the specified entry as the hint for | |
96 | * future lookups. only a read lock is held on map, | |
97 | * so make sure the store is atomic... OSCompareAndSwap | |
98 | * guarantees this... also, we don't care if we collide | |
99 | * and someone else wins and stores their 'hint' | |
100 | */ | |
101 | #define SAVE_HINT_MAP_READ(map,value) \ | |
102 | MACRO_BEGIN \ | |
103 | OSCompareAndSwapPtr((map)->hint, value, &(map)->hint); \ | |
104 | MACRO_END | |
105 | ||
106 | ||
107 | /* | |
108 | * SAVE_HINT_MAP_WRITE: | |
109 | * | |
110 | * Saves the specified entry as the hint for | |
111 | * future lookups. write lock held on map, | |
112 | * so no one else can be writing or looking | |
113 | * until the lock is dropped, so it's safe | |
114 | * to just do an assignment | |
115 | */ | |
116 | #define SAVE_HINT_MAP_WRITE(map,value) \ | |
117 | MACRO_BEGIN \ | |
118 | (map)->hint = (value); \ | |
119 | MACRO_END | |
120 | ||
3e170ce0 A |
121 | #define SAVE_HINT_HOLE_WRITE(map,value) \ |
122 | MACRO_BEGIN \ | |
123 | (map)->hole_hint = (value); \ | |
124 | MACRO_END | |
125 | ||
04b8595b A |
126 | #define SKIP_RB_TREE 0xBAADC0D1 |
127 | ||
6d2010ae A |
128 | #define VM_MAP_ENTRY_CREATE 1 |
129 | #define VM_MAP_ENTRY_DELETE 2 | |
130 | ||
131 | void vm_map_store_init( struct vm_map_header* ); | |
132 | boolean_t vm_map_store_lookup_entry( struct _vm_map*, vm_map_offset_t, struct vm_map_entry**); | |
133 | void vm_map_store_update( struct _vm_map*, struct vm_map_entry*, int); | |
134 | void _vm_map_store_entry_link( struct vm_map_header *, struct vm_map_entry*, struct vm_map_entry*); | |
d9a64523 | 135 | void vm_map_store_entry_link( struct _vm_map*, struct vm_map_entry*, struct vm_map_entry*, vm_map_kernel_flags_t); |
6d2010ae A |
136 | void _vm_map_store_entry_unlink( struct vm_map_header *, struct vm_map_entry*); |
137 | void vm_map_store_entry_unlink( struct _vm_map*, struct vm_map_entry*); | |
3e170ce0 | 138 | void vm_map_store_update_first_free( struct _vm_map*, struct vm_map_entry*, boolean_t new_entry_creation); |
6d2010ae A |
139 | void vm_map_store_copy_reset( struct vm_map_copy*, struct vm_map_entry*); |
140 | #if MACH_ASSERT | |
141 | boolean_t first_free_is_valid_store( struct _vm_map*); | |
142 | #endif | |
04b8595b | 143 | boolean_t vm_map_store_has_RB_support( struct vm_map_header *hdr ); |
6d2010ae A |
144 | |
145 | #endif /* _VM_VM_MAP_STORE_H */ | |
146 |