Changeset 04803bf in mainline for boot/generic/src/balloc.c


Ignore:
Timestamp:
2011-03-21T22:00:17Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
143932e3
Parents:
b50b5af2 (diff), 7308e84 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes (needs fixes).

File:
1 moved

Legend:

Unmodified
Added
Removed
  • boot/generic/src/balloc.c

    rb50b5af2 r04803bf  
    2828
    2929#include <balloc.h>
    30 #include <asm.h>
    31 #include <types.h>
     30#include <typedefs.h>
    3231#include <align.h>
    3332
    3433static ballocs_t *ballocs;
    3534static uintptr_t phys_base;
     35static size_t max_size;
    3636
    37 void balloc_init(ballocs_t *ball, uintptr_t base, uintptr_t kernel_base)
     37void balloc_init(ballocs_t *ball, void *base, uintptr_t kernel_base,
     38    size_t size)
    3839{
    3940        ballocs = ball;
    40         phys_base = base;
     41        phys_base = (uintptr_t) base;
     42        max_size = size;
    4143        ballocs->base = kernel_base;
    4244        ballocs->size = 0;
     
    4547void *balloc(size_t size, size_t alignment)
    4648{
     49        if (alignment == 0)
     50                return NULL;
     51       
    4752        /* Enforce minimal alignment. */
    4853        alignment = ALIGN_UP(alignment, 4);
     
    5055        uintptr_t addr = phys_base + ALIGN_UP(ballocs->size, alignment);
    5156       
    52         if (ALIGN_UP(ballocs->size, alignment) + size > BALLOC_MAX_SIZE)
     57        if (ALIGN_UP(ballocs->size, alignment) + size >= max_size)
    5358                return NULL;
    5459       
     
    6065void *balloc_rebase(void *ptr)
    6166{
    62         return (void *) ((uintptr_t) ptr - phys_base + ballocs->base);
     67        return (void *) (((uintptr_t) ptr - phys_base) + ballocs->base);
    6368}
Note: See TracChangeset for help on using the changeset viewer.