Ignore:
File:
1 edited

Legend:

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

    r9d58539 ra17cced  
    121121        backend_data.base = phys;
    122122        backend_data.frames = pages;
     123        backend_data.anonymous = false;
    123124       
    124125        /*
     
    314315
    315316NO_TRACE static int dmamem_map(uintptr_t virt, size_t size, unsigned int map_flags,
    316     unsigned int flags, void **phys)
     317    unsigned int flags, uintptr_t *phys)
    317318{
    318319        ASSERT(TASK);
     
    322323}
    323324
    324 NO_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)
     325NO_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)
    326328{
    327329        ASSERT(TASK);
    328330       
    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)
     331        size_t frames = SIZE2FRAMES(size);
     332        *phys = frame_alloc(frames, FRAME_ATOMIC, constraint);
     333        if (*phys == 0)
    340334                return ENOMEM;
    341335       
    342336        mem_backend_data_t backend_data;
    343         backend_data.base = (uintptr_t) *phys;
    344         backend_data.frames = pages;
     337        backend_data.base = *phys;
     338        backend_data.frames = frames;
     339        backend_data.anonymous = true;
    345340       
    346341        if (!as_area_create(TASK->as, map_flags, size,
    347342            AS_AREA_ATTR_NONE, &phys_backend, &backend_data, virt, bound)) {
    348                 frame_free_noreserve((uintptr_t) *phys);
     343                frame_free(*phys, frames);
    349344                return ENOMEM;
    350345        }
     
    361356NO_TRACE static int dmamem_unmap_anonymous(uintptr_t virt)
    362357{
    363         // TODO: implement unlocking & unmap
    364         return EOK;
     358        return as_area_destroy(TASK->as, virt);
    365359}
    366360
     
    373367                 */
    374368               
    375                 void *phys;
     369                uintptr_t phys;
    376370                int rc = dmamem_map((uintptr_t) virt_ptr, size, map_flags,
    377371                    flags, &phys);
     
    390384                 */
    391385               
    392                 void *phys;
     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;
    393393                uintptr_t virt = (uintptr_t) -1;
    394                 int rc = dmamem_map_anonymous(size, map_flags, flags,
     394                rc = dmamem_map_anonymous(size, constraint, map_flags, flags,
    395395                    &phys, &virt, bound);
    396396                if (rc != EOK)
Note: See TracChangeset for help on using the changeset viewer.