Changeset 9970a5a in mainline for kernel/generic/src/mm/km.c


Ignore:
Timestamp:
2012-01-27T23:24:27Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7b3b571, fe56c08a
Parents:
d81eaf94 (diff), 221c9ec (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:

Merge from lp:~jakub/helenos/mm.

File:
1 edited

Legend:

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

    rd81eaf94 r9970a5a  
    4646#include <debug.h>
    4747#include <arch.h>
     48#include <align.h>
     49#include <macros.h>
     50#include <bitops.h>
    4851
    4952static ra_arena_t *km_ni_arena;
     
    120123        ra_free(km_ni_arena, page, size);
    121124}
     125
     126uintptr_t km_map(uintptr_t paddr, size_t size, unsigned int flags)
     127{
     128        uintptr_t vaddr;
     129        size_t asize;
     130        size_t align;
     131        uintptr_t offs;
     132
     133        asize = ALIGN_UP(size, PAGE_SIZE);
     134        align = ispwr2(size) ? size : (1U << (fnzb(size) + 1));
     135        vaddr = km_page_alloc(asize, max(PAGE_SIZE, align));
     136
     137        page_table_lock(AS_KERNEL, true);
     138        for (offs = 0; offs < asize; offs += PAGE_SIZE) {
     139                page_mapping_insert(AS_KERNEL, vaddr + offs, paddr + offs,
     140                    flags);
     141        }
     142        page_table_unlock(AS_KERNEL, true);
     143       
     144        return vaddr;
     145}
     146
    122147
    123148/** Unmap kernen non-identity page.
     
    165190            FRAME_HIGHMEM | FRAME_ATOMIC | flags);
    166191        if (frame) {
    167                 page = km_page_alloc(PAGE_SIZE, PAGE_SIZE);
     192                page = km_map(frame, PAGE_SIZE,
     193                    PAGE_READ | PAGE_WRITE | PAGE_CACHEABLE);
    168194                ASSERT(page);   // FIXME
    169                 page_table_lock(AS_KERNEL, true);
    170                 page_mapping_insert(AS_KERNEL, page, frame,
    171                     PAGE_CACHEABLE | PAGE_READ | PAGE_WRITE);
    172                 page_table_unlock(AS_KERNEL, true);
    173195        } else {
    174196                frame = (uintptr_t) frame_alloc_noreserve(ONE_FRAME,
Note: See TracChangeset for help on using the changeset viewer.