Changeset a33f0a6 in mainline for kernel/generic/src/mm/page.c


Ignore:
Timestamp:
2011-08-03T17:34:57Z (14 years ago)
Author:
Oleg Romanenko <romanenko.oleg@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1940326
Parents:
52a79081 (diff), 3fab770 (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 mainline

File:
1 edited

Legend:

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

    r52a79081 ra33f0a6  
    6060
    6161#include <mm/page.h>
     62#include <genarch/mm/page_ht.h>
     63#include <genarch/mm/page_pt.h>
    6264#include <arch/mm/page.h>
    6365#include <arch/mm/asid.h>
     
    7072#include <debug.h>
    7173#include <arch.h>
     74#include <syscall/copy.h>
     75#include <errno.h>
    7276
    7377/** Virtual operations for page subsystem. */
     
    108112 * using flags. Allocate and setup any missing page tables.
    109113 *
    110  * @param as    Address space to wich page belongs.
     114 * @param as    Address space to which page belongs.
    111115 * @param page  Virtual address of the page to be mapped.
    112116 * @param frame Physical address of memory frame to which the mapping is
     
    135139 * this call visible.
    136140 *
    137  * @param as   Address space to wich page belongs.
     141 * @param as   Address space to which page belongs.
    138142 * @param page Virtual address of the page to be demapped.
    139143 *
     
    152156}
    153157
    154 /** Find mapping for virtual page
    155  *
    156  * Find mapping for virtual page.
    157  *
    158  * @param as   Address space to wich page belongs.
    159  * @param page Virtual page.
     158/** Find mapping for virtual page.
     159 *
     160 * @param as     Address space to which page belongs.
     161 * @param page   Virtual page.
     162 * @param nolock True if the page tables need not be locked.
    160163 *
    161164 * @return NULL if there is no such mapping; requested mapping
     
    163166 *
    164167 */
    165 NO_TRACE pte_t *page_mapping_find(as_t *as, uintptr_t page)
    166 {
    167         ASSERT(page_table_locked(as));
     168NO_TRACE pte_t *page_mapping_find(as_t *as, uintptr_t page, bool nolock)
     169{
     170        ASSERT(nolock || page_table_locked(as));
    168171       
    169172        ASSERT(page_mapping_operations);
    170173        ASSERT(page_mapping_operations->mapping_find);
    171174       
    172         return page_mapping_operations->mapping_find(as, page);
     175        return page_mapping_operations->mapping_find(as, page, nolock);
     176}
     177
     178/** Syscall wrapper for getting mapping of a virtual page.
     179 *
     180 * @retval EOK Everything went find, @p uspace_frame and @p uspace_node
     181 *             contains correct values.
     182 * @retval ENOENT Virtual address has no mapping.
     183 */
     184sysarg_t sys_page_find_mapping(uintptr_t virt_address,
     185    uintptr_t *uspace_frame)
     186{
     187        mutex_lock(&AS->lock);
     188       
     189        pte_t *pte = page_mapping_find(AS, virt_address, false);
     190        if (!PTE_VALID(pte) || !PTE_PRESENT(pte)) {
     191                mutex_unlock(&AS->lock);
     192               
     193                return (sysarg_t) ENOENT;
     194        }
     195       
     196        uintptr_t phys_address = PTE_GET_FRAME(pte);
     197       
     198        mutex_unlock(&AS->lock);
     199       
     200        int rc = copy_to_uspace(uspace_frame,
     201            &phys_address, sizeof(phys_address));
     202        if (rc != EOK) {
     203                return (sysarg_t) rc;
     204        }
     205       
     206        return EOK;
    173207}
    174208
Note: See TracChangeset for help on using the changeset viewer.