Changeset 567807b1 in mainline for generic/src/mm/as.c
- Timestamp:
- 2006-05-24T17:03:29Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8d6bc2d5
- Parents:
- 82da5f5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/src/mm/as.c
r82da5f5 r567807b1 376 376 __address base; 377 377 ipl_t ipl; 378 bool cond; 378 379 379 380 ipl = interrupts_disable(); … … 388 389 389 390 base = area->base; 390 if (!(area->flags & AS_AREA_DEVICE)) { 391 bool cond; 392 393 /* 394 * Releasing physical memory. 395 * Areas mapping memory-mapped devices are treated differently than 396 * areas backing frame_alloc()'ed memory. 397 */ 398 399 /* 400 * Visit only the pages mapped by used_space B+tree. 401 * Note that we must be very careful when walking the tree 402 * leaf list and removing used space as the leaf list changes 403 * unpredictibly after each remove. The solution is to actually 404 * not walk the tree at all, but to remove items from the head 405 * of the leaf list until there are some keys left. 406 */ 407 for (cond = true; cond;) { 408 btree_node_t *node; 391 392 /* 393 * Visit only the pages mapped by used_space B+tree. 394 * Note that we must be very careful when walking the tree 395 * leaf list and removing used space as the leaf list changes 396 * unpredictibly after each remove. The solution is to actually 397 * not walk the tree at all, but to remove items from the head 398 * of the leaf list until there are some keys left. 399 */ 400 for (cond = true; cond;) { 401 btree_node_t *node; 409 402 410 411 412 413 414 415 403 ASSERT(!list_empty(&area->used_space.leaf_head)); 404 node = list_get_instance(area->used_space.leaf_head.next, btree_node_t, leaf_link); 405 if ((cond = (bool) node->keys)) { 406 __address b = node->key[0]; 407 count_t i; 408 pte_t *pte; 416 409 417 for (i = 0; i < (count_t) node->value[0]; i++) { 418 page_table_lock(as, false); 419 pte = page_mapping_find(as, b + i*PAGE_SIZE); 420 ASSERT(pte && PTE_VALID(pte) && PTE_PRESENT(pte)); 421 if (area->backend && area->backend->backend_frame_free) { 422 area->backend->backend_frame_free(area, 423 b + i*PAGE_SIZE, PTE_GET_FRAME(pte)); 424 } 425 page_mapping_remove(as, b + i*PAGE_SIZE); 426 page_table_unlock(as, false); 410 for (i = 0; i < (count_t) node->value[0]; i++) { 411 page_table_lock(as, false); 412 pte = page_mapping_find(as, b + i*PAGE_SIZE); 413 ASSERT(pte && PTE_VALID(pte) && PTE_PRESENT(pte)); 414 if (area->backend && area->backend->backend_frame_free) { 415 area->backend->backend_frame_free(area, 416 b + i*PAGE_SIZE, PTE_GET_FRAME(pte)); 427 417 } 428 if (!used_space_remove(area, b, i))429 panic("Could not remove used space.\n");418 page_mapping_remove(as, b + i*PAGE_SIZE); 419 page_table_unlock(as, false); 430 420 } 421 if (!used_space_remove(area, b, i)) 422 panic("Could not remove used space.\n"); 431 423 } 432 424 } … … 624 616 * 625 617 * @param page Faulting page. 618 * @param access Access mode that caused the fault (i.e. read/write/exec). 626 619 * @param istate Pointer to interrupted state. 627 620 * … … 629 622 * fault was caused by copy_to_uspace() or copy_from_uspace(). 630 623 */ 631 int as_page_fault(__address page, istate_t *istate)624 int as_page_fault(__address page, pf_access_t access, istate_t *istate) 632 625 { 633 626 pte_t *pte; … … 689 682 * Resort to the backend page fault handler. 690 683 */ 691 if (area->backend->backend_page_fault(area, page ) != AS_PF_OK) {684 if (area->backend->backend_page_fault(area, page, access) != AS_PF_OK) { 692 685 page_table_unlock(AS, false); 693 686 mutex_unlock(&area->lock); … … 1451 1444 } 1452 1445 1453 static int anon_page_fault(as_area_t *area, __address addr );1446 static int anon_page_fault(as_area_t *area, __address addr, pf_access_t access); 1454 1447 static void anon_frame_free(as_area_t *area, __address page, __address frame); 1455 1448 … … 1468 1461 * @param area Pointer to the address space area. 1469 1462 * @param addr Faulting virtual address. 1463 * @param access Access mode that caused the fault (i.e. read/write/exec). 1470 1464 * 1471 1465 * @return AS_PF_FAULT on failure (i.e. page fault) or AS_PF_OK on success (i.e. serviced). 1472 1466 */ 1473 int anon_page_fault(as_area_t *area, __address addr )1467 int anon_page_fault(as_area_t *area, __address addr, pf_access_t access) 1474 1468 { 1475 1469 __address frame;
Note:
See TracChangeset
for help on using the changeset viewer.