Changeset 2a2fbc8 in mainline for kernel/genarch/src/mm/page_ht.c
- Timestamp:
- 2016-09-01T17:05:13Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 42d08592
- Parents:
- f126c87 (diff), fb63c06 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/mm/page_ht.c
rf126c87 r2a2fbc8 59 59 static void ht_mapping_insert(as_t *, uintptr_t, uintptr_t, unsigned int); 60 60 static void ht_mapping_remove(as_t *, uintptr_t); 61 static pte_t *ht_mapping_find(as_t *, uintptr_t, bool); 61 static bool ht_mapping_find(as_t *, uintptr_t, bool, pte_t *); 62 static void ht_mapping_update(as_t *, uintptr_t, bool, pte_t *); 62 63 static void ht_mapping_make_global(uintptr_t, size_t); 63 64 … … 70 71 * 71 72 */ 72 mutex_t page_ht_lock;73 IRQ_SPINLOCK_STATIC_INITIALIZE(page_ht_lock); 73 74 74 75 /** Page hash table. … … 91 92 .mapping_remove = ht_mapping_remove, 92 93 .mapping_find = ht_mapping_find, 94 .mapping_update = ht_mapping_update, 93 95 .mapping_make_global = ht_mapping_make_global 94 96 }; … … 191 193 192 194 ASSERT(page_table_locked(as)); 195 196 irq_spinlock_lock(&page_ht_lock, true); 193 197 194 198 if (!hash_table_find(&page_ht, key)) { … … 217 221 hash_table_insert(&page_ht, key, &pte->link); 218 222 } 223 224 irq_spinlock_unlock(&page_ht_lock, true); 219 225 } 220 226 … … 238 244 ASSERT(page_table_locked(as)); 239 245 246 irq_spinlock_lock(&page_ht_lock, true); 247 240 248 /* 241 249 * Note that removed PTE's will be freed … … 243 251 */ 244 252 hash_table_remove(&page_ht, key, 2); 245 } 246 247 248 /** Find mapping for virtual page in page hash table. 249 * 250 * @param as Address space to which page belongs. 251 * @param page Virtual page. 252 * @param nolock True if the page tables need not be locked. 253 * 254 * @return NULL if there is no such mapping; requested mapping otherwise. 255 * 256 */ 257 pte_t *ht_mapping_find(as_t *as, uintptr_t page, bool nolock) 253 254 irq_spinlock_unlock(&page_ht_lock, true); 255 } 256 257 static pte_t *ht_mapping_find_internal(as_t *as, uintptr_t page, bool nolock) 258 258 { 259 259 sysarg_t key[2] = { … … 263 263 264 264 ASSERT(nolock || page_table_locked(as)); 265 265 266 266 link_t *cur = hash_table_find(&page_ht, key); 267 267 if (cur) … … 271 271 } 272 272 273 /** Find mapping for virtual page in page hash table. 274 * 275 * @param as Address space to which page belongs. 276 * @param page Virtual page. 277 * @param nolock True if the page tables need not be locked. 278 * @param[out] pte Structure that will receive a copy of the found PTE. 279 * 280 * @return True if the mapping was found, false otherwise. 281 */ 282 bool ht_mapping_find(as_t *as, uintptr_t page, bool nolock, pte_t *pte) 283 { 284 irq_spinlock_lock(&page_ht_lock, true); 285 286 pte_t *t = ht_mapping_find_internal(as, page, nolock); 287 if (t) 288 *pte = *t; 289 290 irq_spinlock_unlock(&page_ht_lock, true); 291 292 return t != NULL; 293 } 294 295 /** Update mapping for virtual page in page hash table. 296 * 297 * @param as Address space to which page belongs. 298 * @param page Virtual page. 299 * @param nolock True if the page tables need not be locked. 300 * @param pte New PTE. 301 */ 302 void ht_mapping_update(as_t *as, uintptr_t page, bool nolock, pte_t *pte) 303 { 304 irq_spinlock_lock(&page_ht_lock, true); 305 306 pte_t *t = ht_mapping_find_internal(as, page, nolock); 307 if (!t) 308 panic("Updating non-existent PTE"); 309 310 ASSERT(pte->as == t->as); 311 ASSERT(pte->page == t->page); 312 ASSERT(pte->frame == t->frame); 313 ASSERT(pte->g == t->g); 314 ASSERT(pte->x == t->x); 315 ASSERT(pte->w == t->w); 316 ASSERT(pte->k == t->k); 317 ASSERT(pte->c == t->c); 318 ASSERT(pte->p == t->p); 319 320 t->a = pte->a; 321 t->d = pte->d; 322 323 irq_spinlock_unlock(&page_ht_lock, true); 324 } 325 273 326 void ht_mapping_make_global(uintptr_t base, size_t size) 274 327 {
Note:
See TracChangeset
for help on using the changeset viewer.