Changeset 948911d in mainline for kernel/generic/src/mm/backend_anon.c


Ignore:
Timestamp:
2012-01-24T02:27:43Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
230385c
Parents:
8afeb04 (diff), 2df6f6fe (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.
Message:

Mainline changes.

File:
1 edited

Legend:

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

    r8afeb04 r948911d  
    4444#include <mm/frame.h>
    4545#include <mm/slab.h>
     46#include <mm/km.h>
    4647#include <synch/mutex.h>
    4748#include <adt/list.h>
     
    155156int anon_page_fault(as_area_t *area, uintptr_t addr, pf_access_t access)
    156157{
     158        uintptr_t upage = ALIGN_DOWN(addr, PAGE_SIZE);
     159        uintptr_t kpage;
    157160        uintptr_t frame;
    158161
     
    175178                mutex_lock(&area->sh_info->lock);
    176179                frame = (uintptr_t) btree_search(&area->sh_info->pagemap,
    177                     ALIGN_DOWN(addr, PAGE_SIZE) - area->base, &leaf);
     180                    upage - area->base, &leaf);
    178181                if (!frame) {
    179182                        bool allocate = true;
     
    185188                         */
    186189                        for (i = 0; i < leaf->keys; i++) {
    187                                 if (leaf->key[i] ==
    188                                     ALIGN_DOWN(addr, PAGE_SIZE) - area->base) {
     190                                if (leaf->key[i] == upage - area->base) {
    189191                                        allocate = false;
    190192                                        break;
     
    192194                        }
    193195                        if (allocate) {
    194                                 frame = (uintptr_t) frame_alloc_noreserve(
    195                                     ONE_FRAME, 0);
    196                                 memsetb((void *) PA2KA(frame), FRAME_SIZE, 0);
     196                                kpage = km_temporary_page_get(&frame,
     197                                    FRAME_NO_RESERVE);
     198                                memsetb((void *) kpage, PAGE_SIZE, 0);
     199                                km_temporary_page_put(kpage);
    197200                               
    198201                                /*
     
    201204                                 */
    202205                                btree_insert(&area->sh_info->pagemap,
    203                                     ALIGN_DOWN(addr, PAGE_SIZE) - area->base,
    204                                     (void *) frame, leaf);
     206                                    upage - area->base, (void *) frame, leaf);
    205207                        }
    206208                }
     
    223225                 *   the different causes
    224226                 */
    225                 frame = (uintptr_t) frame_alloc_noreserve(ONE_FRAME, 0);
    226                 memsetb((void *) PA2KA(frame), FRAME_SIZE, 0);
     227                kpage = km_temporary_page_get(&frame, FRAME_NO_RESERVE);
     228                memsetb((void *) kpage, PAGE_SIZE, 0);
     229                km_temporary_page_put(kpage);
    227230        }
    228231       
    229232        /*
    230          * Map 'page' to 'frame'.
     233         * Map 'upage' to 'frame'.
    231234         * Note that TLB shootdown is not attempted as only new information is
    232235         * being inserted into page tables.
    233236         */
    234         page_mapping_insert(AS, addr, frame, as_area_get_flags(area));
    235         if (!used_space_insert(area, ALIGN_DOWN(addr, PAGE_SIZE), 1))
     237        page_mapping_insert(AS, upage, frame, as_area_get_flags(area));
     238        if (!used_space_insert(area, upage, 1))
    236239                panic("Cannot insert used space.");
    237240               
Note: See TracChangeset for help on using the changeset viewer.