- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

# lib/physmem.c

Go to the documentation of this file.

    00001
    00046 #include <physmem.h>
    00047 #include <types.h>
    00048 #include <util.h>
    00049
    00070 phys_addr_t physmem_alloc(struct physmem_pool *pool, phys_size_t size,
    00071                 unsigned int align_order)
    00072 {
    00073         phys_addr_t     addr;
    00074
    00075         addr = round_down(pool->end - size, align_order);
    00076         if (addr >= pool->start)
    00077                 pool->end = addr;
    00078         else
    00079                 addr = PHYSMEM_ALLOC_ERR;
    00080
    00081         return addr;
    00082 }
    00083
    00102 phys_addr_t physmem_alloc_low(struct physmem_pool *pool, phys_size_t size,
    00103                 unsigned int align_order)
    00104 {
    00105         phys_addr_t     addr;
    00106
    00107         addr = round_up(pool->start, align_order);
    00108         if (addr + size <= pool->end)
    00109                 pool->start = addr + size;
    00110         else
    00111                 addr = PHYSMEM_ALLOC_ERR;
    00112
    00113         return addr;
    00114 }