Changeset b0c2075 in mainline for kernel/generic/src/ddi/ddi.c


Ignore:
Timestamp:
2013-09-10T17:48:57Z (11 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
85147f3
Parents:
86733f3
Message:

new physical memory allocator supporting physical address constrains
the buddy allocator framework is retired and replaced by a two-level bitmap
the allocator can allocate an arbitrary number of frames, not only a power-of-two count

Caution: Change of semantics
The physical memory allocator no longer allocates naturally aligned blocks. If you require an aligned block, specify it as the constraint.

File:
1 edited

Legend:

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

    r86733f3 rb0c2075  
    322322}
    323323
    324 NO_TRACE static int dmamem_map_anonymous(size_t size, unsigned int map_flags,
    325     unsigned int flags, uintptr_t *phys, uintptr_t *virt, uintptr_t bound)
     324NO_TRACE static int dmamem_map_anonymous(size_t size, uintptr_t constraint,
     325    unsigned int map_flags, unsigned int flags, uintptr_t *phys,
     326    uintptr_t *virt, uintptr_t bound)
    326327{
    327328        ASSERT(TASK);
    328329       
    329330        size_t frames = SIZE2FRAMES(size);
    330         uint8_t order;
    331        
    332         /* We need the 2^order >= frames */
    333         if (frames == 1)
    334                 order = 0;
    335         else
    336                 order = fnzb(frames - 1) + 1;
    337        
    338         *phys = frame_alloc_noreserve(order, 0, 0);
     331        *phys = frame_alloc_noreserve(frames, 0, constraint);
    339332        if (*phys == 0)
    340333                return ENOMEM;
     
    390383                 */
    391384               
     385                uintptr_t constraint;
     386                int rc = copy_from_uspace(&constraint, phys_ptr,
     387                    sizeof(constraint));
     388                if (rc != EOK)
     389                        return rc;
     390               
    392391                uintptr_t phys;
    393392                uintptr_t virt = (uintptr_t) -1;
    394                 int rc = dmamem_map_anonymous(size, map_flags, flags,
     393                rc = dmamem_map_anonymous(size, constraint, map_flags, flags,
    395394                    &phys, &virt, bound);
    396395                if (rc != EOK)
Note: See TracChangeset for help on using the changeset viewer.