Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ddi/ddi.c

    ra17cced r9d58539  
    121121        backend_data.base = phys;
    122122        backend_data.frames = pages;
    123         backend_data.anonymous = false;
    124123       
    125124        /*
     
    315314
    316315NO_TRACE static int dmamem_map(uintptr_t virt, size_t size, unsigned int map_flags,
    317     unsigned int flags, uintptr_t *phys)
     316    unsigned int flags, void **phys)
    318317{
    319318        ASSERT(TASK);
     
    323322}
    324323
    325 NO_TRACE static int dmamem_map_anonymous(size_t size, uintptr_t constraint,
    326     unsigned int map_flags, unsigned int flags, uintptr_t *phys,
    327     uintptr_t *virt, uintptr_t bound)
     324NO_TRACE static int dmamem_map_anonymous(size_t size, unsigned int map_flags,
     325    unsigned int flags, void **phys, uintptr_t *virt, uintptr_t bound)
    328326{
    329327        ASSERT(TASK);
    330328       
    331         size_t frames = SIZE2FRAMES(size);
    332         *phys = frame_alloc(frames, FRAME_ATOMIC, constraint);
    333         if (*phys == 0)
     329        size_t pages = SIZE2FRAMES(size);
     330        uint8_t order;
     331       
     332        /* We need the 2^order >= pages */
     333        if (pages == 1)
     334                order = 0;
     335        else
     336                order = fnzb(pages - 1) + 1;
     337       
     338        *phys = frame_alloc_noreserve(order, 0);
     339        if (*phys == NULL)
    334340                return ENOMEM;
    335341       
    336342        mem_backend_data_t backend_data;
    337         backend_data.base = *phys;
    338         backend_data.frames = frames;
    339         backend_data.anonymous = true;
     343        backend_data.base = (uintptr_t) *phys;
     344        backend_data.frames = pages;
    340345       
    341346        if (!as_area_create(TASK->as, map_flags, size,
    342347            AS_AREA_ATTR_NONE, &phys_backend, &backend_data, virt, bound)) {
    343                 frame_free(*phys, frames);
     348                frame_free_noreserve((uintptr_t) *phys);
    344349                return ENOMEM;
    345350        }
     
    356361NO_TRACE static int dmamem_unmap_anonymous(uintptr_t virt)
    357362{
    358         return as_area_destroy(TASK->as, virt);
     363        // TODO: implement unlocking & unmap
     364        return EOK;
    359365}
    360366
     
    367373                 */
    368374               
    369                 uintptr_t phys;
     375                void *phys;
    370376                int rc = dmamem_map((uintptr_t) virt_ptr, size, map_flags,
    371377                    flags, &phys);
     
    384390                 */
    385391               
    386                 uintptr_t constraint;
    387                 int rc = copy_from_uspace(&constraint, phys_ptr,
    388                     sizeof(constraint));
    389                 if (rc != EOK)
    390                         return rc;
    391                
    392                 uintptr_t phys;
     392                void *phys;
    393393                uintptr_t virt = (uintptr_t) -1;
    394                 rc = dmamem_map_anonymous(size, constraint, map_flags, flags,
     394                int rc = dmamem_map_anonymous(size, map_flags, flags,
    395395                    &phys, &virt, bound);
    396396                if (rc != EOK)
Note: See TracChangeset for help on using the changeset viewer.