Changeset b93d637 in mainline


Ignore:
Timestamp:
2011-01-21T13:54:04Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
aa9f0a4, c979591b
Parents:
85d0cf8
Message:

Add syscall for getting physical address

Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/mm/page.h

    r85d0cf8 rb93d637  
    3737
    3838#include <typedefs.h>
     39#include <proc/task.h>
    3940#include <mm/as.h>
    4041#include <memstr.h>
     
    6263extern uintptr_t hw_map(uintptr_t, size_t);
    6364
     65extern sysarg_t sys_page_find_mapping(uintptr_t, uintptr_t *);
     66
    6467#endif
    6568
  • kernel/generic/include/syscall/syscall.h

    r85d0cf8 rb93d637  
    5959        SYS_AS_AREA_DESTROY,
    6060       
     61        SYS_PAGE_FIND_MAPPING,
     62       
    6163        SYS_IPC_CALL_SYNC_FAST,
    6264        SYS_IPC_CALL_SYNC_SLOW,
  • kernel/generic/src/mm/page.c

    r85d0cf8 rb93d637  
    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. */
     
    173177}
    174178
     179/** Syscall wrapper for getting mapping of a virtual page.
     180 *
     181 * @retval EOK Everything went find, @p uspace_frame and @p uspace_node
     182 *             contains correct values.
     183 * @retval ENOENT Virtual address has no mapping.
     184 */
     185sysarg_t sys_page_find_mapping(uintptr_t virt_address,
     186    uintptr_t *uspace_frame)
     187{
     188        mutex_lock(&AS->lock);
     189       
     190        pte_t *pte = page_mapping_find(AS, virt_address);
     191        if (!PTE_VALID(pte) || !PTE_PRESENT(pte)) {
     192                mutex_unlock(&AS->lock);
     193               
     194                return (sysarg_t) ENOENT;
     195        }
     196       
     197        uintptr_t phys_address = PTE_GET_FRAME(pte);
     198       
     199        mutex_unlock(&AS->lock);
     200       
     201        int rc = copy_to_uspace(uspace_frame,
     202            &phys_address, sizeof(phys_address));
     203        if (rc != EOK) {
     204                return (sysarg_t) rc;
     205        }
     206       
     207        return EOK;
     208}
     209
    175210/** @}
    176211 */
  • kernel/generic/src/syscall/syscall.c

    r85d0cf8 rb93d637  
    4141#include <proc/program.h>
    4242#include <mm/as.h>
     43#include <mm/page.h>
    4344#include <print.h>
    4445#include <arch.h>
     
    144145        (syshandler_t) sys_as_area_destroy,
    145146       
     147        /* Page mapping related syscalls. */
     148        (syshandler_t) sys_page_find_mapping,
     149       
    146150        /* IPC related syscalls. */
    147151        (syshandler_t) sys_ipc_call_sync_fast,
  • uspace/app/tester/Makefile

    r85d0cf8 rb93d637  
    5353        loop/loop1.c \
    5454        mm/malloc1.c \
     55        mm/mapping1.c \
    5556        hw/misc/virtchar1.c \
    5657        hw/serial/serial1.c
  • uspace/app/tester/tester.c

    r85d0cf8 rb93d637  
    6262#include "loop/loop1.def"
    6363#include "mm/malloc1.def"
     64#include "mm/mapping1.def"
    6465#include "hw/serial/serial1.def"
    6566#include "adt/usbaddrkeep.def"
  • uspace/app/tester/tester.h

    r85d0cf8 rb93d637  
    7979extern const char *test_loop1(void);
    8080extern const char *test_malloc1(void);
     81extern const char *test_mapping1(void);
    8182extern const char *test_serial1(void);
    8283extern const char *test_usbaddrkeep(void);
  • uspace/lib/c/generic/as.c

    r85d0cf8 rb93d637  
    3535#include <as.h>
    3636#include <libc.h>
     37#include <errno.h>
    3738#include <unistd.h>
    3839#include <align.h>
     
    128129}
    129130
     131/** Find mapping to physical address.
     132 *
     133 * @param address Virtual address in question (virtual).
     134 * @param[out] frame Frame address (physical).
     135 * @return Error code.
     136 * @retval EOK No error, @p frame holds the translation.
     137 * @retval ENOENT Mapping not found.
     138 */
     139int as_get_physical_mapping(void *address, uintptr_t *frame)
     140{
     141        uintptr_t tmp_frame;
     142        uintptr_t virt = (uintptr_t) address;
     143       
     144        int rc = (int) __SYSCALL2(SYS_PAGE_FIND_MAPPING,
     145            (sysarg_t) virt, (sysarg_t) &tmp_frame);
     146        if (rc != EOK) {
     147                return rc;
     148        }
     149       
     150        if (frame != NULL) {
     151                *frame = tmp_frame;
     152        }
     153       
     154        return EOK;
     155}
     156
    130157/** @}
    131158 */
  • uspace/lib/c/include/as.h

    r85d0cf8 rb93d637  
    4747extern void *set_maxheapsize(size_t mhs);
    4848extern void * as_get_mappable_page(size_t sz);
     49extern int as_get_physical_mapping(void *address, uintptr_t *frame);
    4950
    5051#endif
Note: See TracChangeset for help on using the changeset viewer.