Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/as.c

    rb93d637 r56273bb  
    3535#include <as.h>
    3636#include <libc.h>
    37 #include <errno.h>
    3837#include <unistd.h>
    3938#include <align.h>
     
    4140#include <bitops.h>
    4241#include <malloc.h>
    43 
    44 /** Last position allocated by as_get_mappable_page */
    45 static uintptr_t last_allocated = 0;
     42#include "private/libc.h"
    4643
    4744/** Create address space area.
     
    5451 *
    5552 */
    56 void *as_area_create(void *address, size_t size, int flags)
     53void *as_area_create(void *address, size_t size, unsigned int flags)
    5754{
    5855        return (void *) __SYSCALL3(SYS_AS_AREA_CREATE, (sysarg_t) address,
     
    7067 *
    7168 */
    72 int as_area_resize(void *address, size_t size, int flags)
     69int as_area_resize(void *address, size_t size, unsigned int flags)
    7370{
    7471        return __SYSCALL3(SYS_AS_AREA_RESIZE, (sysarg_t) address,
     
    9895 *
    9996 */
    100 int as_area_change_flags(void *address, int flags)
     97int as_area_change_flags(void *address, unsigned int flags)
    10198{
    10299        return __SYSCALL2(SYS_AS_AREA_CHANGE_FLAGS, (sysarg_t) address,
     
    104101}
    105102
    106 /** Return pointer to some unmapped area, where fits new as_area
     103/** Return pointer to unmapped address space area
    107104 *
    108105 * @param size Requested size of the allocation.
    109106 *
    110  * @return pointer to the beginning
     107 * @return Pointer to the beginning of unmapped address space area.
    111108 *
    112109 */
    113110void *as_get_mappable_page(size_t size)
    114111{
    115         if (size == 0)
    116                 return NULL;
    117        
    118         size_t sz = 1 << (fnzb(size - 1) + 1);
    119         if (last_allocated == 0)
    120                 last_allocated = get_max_heap_addr();
    121        
    122         /*
    123          * Make sure we allocate from naturally aligned address.
    124          */
    125         uintptr_t res = ALIGN_UP(last_allocated, sz);
    126         last_allocated = res + ALIGN_UP(size, PAGE_SIZE);
    127        
    128         return ((void *) res);
    129 }
    130 
    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  */
    139 int 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;
     112        return (void *) __SYSCALL2(SYS_AS_GET_UNMAPPED_AREA,
     113            (sysarg_t) __entry, (sysarg_t) size);
    155114}
    156115
Note: See TracChangeset for help on using the changeset viewer.