Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/mm/backend_anon.c

    r9d58539 r55b77d9  
    4444#include <mm/frame.h>
    4545#include <mm/slab.h>
    46 #include <mm/km.h>
    4746#include <synch/mutex.h>
    4847#include <adt/list.h>
     
    156155int anon_page_fault(as_area_t *area, uintptr_t addr, pf_access_t access)
    157156{
    158         uintptr_t upage = ALIGN_DOWN(addr, PAGE_SIZE);
    159         uintptr_t kpage;
    160157        uintptr_t frame;
    161158
     
    178175                mutex_lock(&area->sh_info->lock);
    179176                frame = (uintptr_t) btree_search(&area->sh_info->pagemap,
    180                     upage - area->base, &leaf);
     177                    ALIGN_DOWN(addr, PAGE_SIZE) - area->base, &leaf);
    181178                if (!frame) {
    182179                        bool allocate = true;
     
    188185                         */
    189186                        for (i = 0; i < leaf->keys; i++) {
    190                                 if (leaf->key[i] == upage - area->base) {
     187                                if (leaf->key[i] ==
     188                                    ALIGN_DOWN(addr, PAGE_SIZE) - area->base) {
    191189                                        allocate = false;
    192190                                        break;
     
    194192                        }
    195193                        if (allocate) {
    196                                 kpage = km_temporary_page_get(&frame,
    197                                     FRAME_NO_RESERVE);
    198                                 memsetb((void *) kpage, PAGE_SIZE, 0);
    199                                 km_temporary_page_put(kpage);
     194                                frame = (uintptr_t) frame_alloc_noreserve(
     195                                    ONE_FRAME, 0);
     196                                memsetb((void *) PA2KA(frame), FRAME_SIZE, 0);
    200197                               
    201198                                /*
     
    204201                                 */
    205202                                btree_insert(&area->sh_info->pagemap,
    206                                     upage - area->base, (void *) frame, leaf);
     203                                    ALIGN_DOWN(addr, PAGE_SIZE) - area->base,
     204                                    (void *) frame, leaf);
    207205                        }
    208206                }
     
    225223                 *   the different causes
    226224                 */
    227                 kpage = km_temporary_page_get(&frame, FRAME_NO_RESERVE);
    228                 memsetb((void *) kpage, PAGE_SIZE, 0);
    229                 km_temporary_page_put(kpage);
     225                frame = (uintptr_t) frame_alloc_noreserve(ONE_FRAME, 0);
     226                memsetb((void *) PA2KA(frame), FRAME_SIZE, 0);
    230227        }
    231228       
    232229        /*
    233          * Map 'upage' to 'frame'.
     230         * Map 'page' to 'frame'.
    234231         * Note that TLB shootdown is not attempted as only new information is
    235232         * being inserted into page tables.
    236233         */
    237         page_mapping_insert(AS, upage, frame, as_area_get_flags(area));
    238         if (!used_space_insert(area, upage, 1))
     234        page_mapping_insert(AS, addr, frame, as_area_get_flags(area));
     235        if (!used_space_insert(area, ALIGN_DOWN(addr, PAGE_SIZE), 1))
    239236                panic("Cannot insert used space.");
    240237               
Note: See TracChangeset for help on using the changeset viewer.