Rev 3222 | Rev 3384 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3222 | Rev 3240 | ||
---|---|---|---|
Line 80... | Line 80... | ||
80 | 80 | ||
81 | #ifdef CONFIG_VIRT_IDX_DCACHE |
81 | #ifdef CONFIG_VIRT_IDX_DCACHE |
82 | #include <arch/mm/cache.h> |
82 | #include <arch/mm/cache.h> |
83 | #endif /* CONFIG_VIRT_IDX_DCACHE */ |
83 | #endif /* CONFIG_VIRT_IDX_DCACHE */ |
84 | 84 | ||
85 | #ifndef __OBJC__ |
- | |
86 | /** |
85 | /** |
87 | * Each architecture decides what functions will be used to carry out |
86 | * Each architecture decides what functions will be used to carry out |
88 | * address space operations such as creating or locking page tables. |
87 | * address space operations such as creating or locking page tables. |
89 | */ |
88 | */ |
90 | as_operations_t *as_operations = NULL; |
89 | as_operations_t *as_operations = NULL; |
91 | 90 | ||
92 | /** |
91 | /** |
93 | * Slab for as_t objects. |
92 | * Slab for as_t objects. |
94 | */ |
93 | */ |
95 | static slab_cache_t *as_slab; |
94 | static slab_cache_t *as_slab; |
96 | #endif |
- | |
97 | 95 | ||
98 | /** |
96 | /** |
99 | * This lock serializes access to the ASID subsystem. |
97 | * This lock serializes access to the ASID subsystem. |
100 | * It protects: |
98 | * It protects: |
101 | * - inactive_as_with_asid_head list |
99 | * - inactive_as_with_asid_head list |
Line 117... | Line 115... | ||
117 | static as_area_t *find_area_and_lock(as_t *as, uintptr_t va); |
115 | static as_area_t *find_area_and_lock(as_t *as, uintptr_t va); |
118 | static bool check_area_conflicts(as_t *as, uintptr_t va, size_t size, |
116 | static bool check_area_conflicts(as_t *as, uintptr_t va, size_t size, |
119 | as_area_t *avoid_area); |
117 | as_area_t *avoid_area); |
120 | static void sh_info_remove_reference(share_info_t *sh_info); |
118 | static void sh_info_remove_reference(share_info_t *sh_info); |
121 | 119 | ||
122 | #ifndef __OBJC__ |
- | |
123 | static int as_constructor(void *obj, int flags) |
120 | static int as_constructor(void *obj, int flags) |
124 | { |
121 | { |
125 | as_t *as = (as_t *) obj; |
122 | as_t *as = (as_t *) obj; |
126 | int rc; |
123 | int rc; |
127 | 124 | ||
Line 137... | Line 134... | ||
137 | { |
134 | { |
138 | as_t *as = (as_t *) obj; |
135 | as_t *as = (as_t *) obj; |
139 | 136 | ||
140 | return as_destructor_arch(as); |
137 | return as_destructor_arch(as); |
141 | } |
138 | } |
142 | #endif |
- | |
143 | 139 | ||
144 | /** Initialize address space subsystem. */ |
140 | /** Initialize address space subsystem. */ |
145 | void as_init(void) |
141 | void as_init(void) |
146 | { |
142 | { |
147 | as_arch_init(); |
143 | as_arch_init(); |
148 | 144 | ||
149 | #ifndef __OBJC__ |
- | |
150 | as_slab = slab_cache_create("as_slab", sizeof(as_t), 0, |
145 | as_slab = slab_cache_create("as_slab", sizeof(as_t), 0, |
151 | as_constructor, as_destructor, SLAB_CACHE_MAGDEFERRED); |
146 | as_constructor, as_destructor, SLAB_CACHE_MAGDEFERRED); |
152 | #endif |
- | |
153 | 147 | ||
154 | AS_KERNEL = as_create(FLAG_AS_KERNEL); |
148 | AS_KERNEL = as_create(FLAG_AS_KERNEL); |
155 | if (!AS_KERNEL) |
149 | if (!AS_KERNEL) |
156 | panic("can't create kernel address space\n"); |
150 | panic("can't create kernel address space\n"); |
157 | 151 | ||
Line 163... | Line 157... | ||
163 | */ |
157 | */ |
164 | as_t *as_create(int flags) |
158 | as_t *as_create(int flags) |
165 | { |
159 | { |
166 | as_t *as; |
160 | as_t *as; |
167 | 161 | ||
168 | #ifdef __OBJC__ |
- | |
169 | as = [as_t new]; |
- | |
170 | link_initialize(&as->inactive_as_with_asid_link); |
- | |
171 | mutex_initialize(&as->lock, MUTEX_PASSIVE); |
- | |
172 | (void) as_constructor_arch(as, flags); |
- | |
173 | #else |
- | |
174 | as = (as_t *) slab_alloc(as_slab, 0); |
162 | as = (as_t *) slab_alloc(as_slab, 0); |
175 | #endif |
- | |
176 | (void) as_create_arch(as, 0); |
163 | (void) as_create_arch(as, 0); |
177 | 164 | ||
178 | btree_create(&as->as_area_btree); |
165 | btree_create(&as->as_area_btree); |
179 | 166 | ||
180 | if (flags & FLAG_AS_KERNEL) |
167 | if (flags & FLAG_AS_KERNEL) |
Line 261... | Line 248... | ||
261 | page_table_destroy(NULL); |
248 | page_table_destroy(NULL); |
262 | #endif |
249 | #endif |
263 | 250 | ||
264 | interrupts_restore(ipl); |
251 | interrupts_restore(ipl); |
265 | 252 | ||
266 | #ifdef __OBJC__ |
- | |
267 | [as free]; |
- | |
268 | #else |
- | |
269 | slab_free(as_slab, as); |
253 | slab_free(as_slab, as); |
270 | #endif |
- | |
271 | } |
254 | } |
272 | 255 | ||
273 | /** Create address space area of common attributes. |
256 | /** Create address space area of common attributes. |
274 | * |
257 | * |
275 | * The created address space area is added to the target address space. |
258 | * The created address space area is added to the target address space. |
Line 1161... | Line 1144... | ||
1161 | * |
1144 | * |
1162 | * @return First entry of the page table. |
1145 | * @return First entry of the page table. |
1163 | */ |
1146 | */ |
1164 | pte_t *page_table_create(int flags) |
1147 | pte_t *page_table_create(int flags) |
1165 | { |
1148 | { |
1166 | #ifdef __OBJC__ |
- | |
1167 | return [as_t page_table_create: flags]; |
- | |
1168 | #else |
- | |
1169 | ASSERT(as_operations); |
1149 | ASSERT(as_operations); |
1170 | ASSERT(as_operations->page_table_create); |
1150 | ASSERT(as_operations->page_table_create); |
1171 | 1151 | ||
1172 | return as_operations->page_table_create(flags); |
1152 | return as_operations->page_table_create(flags); |
1173 | #endif |
- | |
1174 | } |
1153 | } |
1175 | 1154 | ||
1176 | /** Destroy page table. |
1155 | /** Destroy page table. |
1177 | * |
1156 | * |
1178 | * Destroy page table in architecture specific way. |
1157 | * Destroy page table in architecture specific way. |
1179 | * |
1158 | * |
1180 | * @param page_table Physical address of PTL0. |
1159 | * @param page_table Physical address of PTL0. |
1181 | */ |
1160 | */ |
1182 | void page_table_destroy(pte_t *page_table) |
1161 | void page_table_destroy(pte_t *page_table) |
1183 | { |
1162 | { |
1184 | #ifdef __OBJC__ |
- | |
1185 | return [as_t page_table_destroy: page_table]; |
- | |
1186 | #else |
- | |
1187 | ASSERT(as_operations); |
1163 | ASSERT(as_operations); |
1188 | ASSERT(as_operations->page_table_destroy); |
1164 | ASSERT(as_operations->page_table_destroy); |
1189 | 1165 | ||
1190 | as_operations->page_table_destroy(page_table); |
1166 | as_operations->page_table_destroy(page_table); |
1191 | #endif |
- | |
1192 | } |
1167 | } |
1193 | 1168 | ||
1194 | /** Lock page table. |
1169 | /** Lock page table. |
1195 | * |
1170 | * |
1196 | * This function should be called before any page_mapping_insert(), |
1171 | * This function should be called before any page_mapping_insert(), |
Line 1203... | Line 1178... | ||
1203 | * @param as Address space. |
1178 | * @param as Address space. |
1204 | * @param lock If false, do not attempt to lock as->lock. |
1179 | * @param lock If false, do not attempt to lock as->lock. |
1205 | */ |
1180 | */ |
1206 | void page_table_lock(as_t *as, bool lock) |
1181 | void page_table_lock(as_t *as, bool lock) |
1207 | { |
1182 | { |
1208 | #ifdef __OBJC__ |
- | |
1209 | [as page_table_lock: lock]; |
- | |
1210 | #else |
- | |
1211 | ASSERT(as_operations); |
1183 | ASSERT(as_operations); |
1212 | ASSERT(as_operations->page_table_lock); |
1184 | ASSERT(as_operations->page_table_lock); |
1213 | 1185 | ||
1214 | as_operations->page_table_lock(as, lock); |
1186 | as_operations->page_table_lock(as, lock); |
1215 | #endif |
- | |
1216 | } |
1187 | } |
1217 | 1188 | ||
1218 | /** Unlock page table. |
1189 | /** Unlock page table. |
1219 | * |
1190 | * |
1220 | * @param as Address space. |
1191 | * @param as Address space. |
1221 | * @param unlock If false, do not attempt to unlock as->lock. |
1192 | * @param unlock If false, do not attempt to unlock as->lock. |
1222 | */ |
1193 | */ |
1223 | void page_table_unlock(as_t *as, bool unlock) |
1194 | void page_table_unlock(as_t *as, bool unlock) |
1224 | { |
1195 | { |
1225 | #ifdef __OBJC__ |
- | |
1226 | [as page_table_unlock: unlock]; |
- | |
1227 | #else |
- | |
1228 | ASSERT(as_operations); |
1196 | ASSERT(as_operations); |
1229 | ASSERT(as_operations->page_table_unlock); |
1197 | ASSERT(as_operations->page_table_unlock); |
1230 | 1198 | ||
1231 | as_operations->page_table_unlock(as, unlock); |
1199 | as_operations->page_table_unlock(as, unlock); |
1232 | #endif |
- | |
1233 | } |
1200 | } |
1234 | 1201 | ||
1235 | 1202 | ||
1236 | /** Find address space area and lock it. |
1203 | /** Find address space area and lock it. |
1237 | * |
1204 | * |