]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/vm/vm_map_store.h
2 * Copyright (c) 2009 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifndef _VM_VM_MAP_STORE_H
30 #define _VM_VM_MAP_STORE_H
33 #ifndef VM_MAP_STORE_USE_LL
34 #define VM_MAP_STORE_USE_LL
37 #ifndef VM_MAP_STORE_USE_RB
38 #define VM_MAP_STORE_USE_RB
41 #include <libkern/tree.h>
49 #ifdef VM_MAP_STORE_USE_RB
50 RB_ENTRY(vm_map_store
) entry
;
54 #ifdef VM_MAP_STORE_USE_RB
55 RB_HEAD( rb_head
, vm_map_store
);
58 #include <vm/vm_map.h>
59 #include <vm/vm_map_store_ll.h>
60 #include <vm/vm_map_store_rb.h>
62 #define UPDATE_HIGHEST_ENTRY_END(map, highest_entry) \
64 struct _vm_map* UHEE_map; \
65 struct vm_map_entry* UHEE_entry; \
67 UHEE_entry = (highest_entry); \
68 if( UHEE_map->highest_entry_end < UHEE_entry->vme_end) { \
69 UHEE_map->highest_entry_end = UHEE_entry->vme_end; \
73 #define VM_MAP_HIGHEST_ENTRY(map, entry, start) \
75 struct _vm_map* VMHE_map; \
76 struct vm_map_entry* tmp_entry; \
77 vm_map_offset_t VMHE_start; \
79 VMHE_start= VMHE_map->highest_entry_end + PAGE_SIZE_64; \
80 while(vm_map_lookup_entry(VMHE_map, VMHE_start, &tmp_entry)){ \
81 VMHE_map->highest_entry_end = tmp_entry->vme_end; \
82 VMHE_start = VMHE_map->highest_entry_end + PAGE_SIZE_64; \
91 * Saves the specified entry as the hint for
92 * future lookups. only a read lock is held on map,
93 * so make sure the store is atomic... OSCompareAndSwap
94 * guarantees this... also, we don't care if we collide
95 * and someone else wins and stores their 'hint'
97 #define SAVE_HINT_MAP_READ(map,value) \
99 OSCompareAndSwapPtr((map)->hint, value, &(map)->hint); \
104 * SAVE_HINT_MAP_WRITE:
106 * Saves the specified entry as the hint for
107 * future lookups. write lock held on map,
108 * so no one else can be writing or looking
109 * until the lock is dropped, so it's safe
110 * to just do an assignment
112 #define SAVE_HINT_MAP_WRITE(map,value) \
114 (map)->hint = (value); \
117 #define VM_MAP_ENTRY_CREATE 1
118 #define VM_MAP_ENTRY_DELETE 2
120 void vm_map_store_init( struct vm_map_header
* );
121 boolean_t
vm_map_store_lookup_entry( struct _vm_map
*, vm_map_offset_t
, struct vm_map_entry
**);
122 void vm_map_store_update( struct _vm_map
*, struct vm_map_entry
*, int);
123 void _vm_map_store_entry_link( struct vm_map_header
*, struct vm_map_entry
*, struct vm_map_entry
*);
124 void vm_map_store_entry_link( struct _vm_map
*, struct vm_map_entry
*, struct vm_map_entry
*);
125 void _vm_map_store_entry_unlink( struct vm_map_header
*, struct vm_map_entry
*);
126 void vm_map_store_entry_unlink( struct _vm_map
*, struct vm_map_entry
*);
127 void vm_map_store_update_first_free( struct _vm_map
*, struct vm_map_entry
*);
128 void vm_map_store_copy_insert( struct _vm_map
*, struct vm_map_entry
*, struct vm_map_copy
*);
129 void vm_map_store_copy_reset( struct vm_map_copy
*, struct vm_map_entry
*);
131 boolean_t
first_free_is_valid_store( struct _vm_map
*);
134 #endif /* _VM_VM_MAP_STORE_H */