[U-Boot] [PATCH v6] [RFC] early_malloc for DM added.

Graeme Russ graeme.russ at gmail.com
Sun Sep 23 15:06:29 CEST 2012


On Sep 23, 2012 8:09 AM, "Tomas Hlavacek" <tmshlvck at gmail.com> wrote:
>
> early_malloc for DM with support for more heaps and lightweight
> first heap in the same memory as an early stack.
>
> Adaptation layer for seamless calling of early_malloc or dlmalloc from
> DM based on init stage added (dmmalloc() and related functions).
>
> Signed-off-by: Tomas Hlavacek <tmshlvck at gmail.com>
> ---

[snip]

> +#ifdef CONFIG_SYS_EARLY_MALLOC
> +__weak struct early_heap_header *early_brk(size_t size)
> +{
> +       struct early_heap_header *h =
> +               (struct early_heap_header *)CONFIG_SYS_EARLY_HEAP_ADDR;
> +       struct early_heap_header *ehp = gd->early_heap_first;
> +
> +       while (ehp != NULL) {
> +               if (ehp == h)
> +                       return NULL;
> +
> +               ehp = ehp->next_early_heap;
> +       }

if (g->early_heap_first == NULL)
    h = CONFIF_SYS_EARLY_HEAP_ADDR);
else
    return NULL;

> +
> +       h->free_space_pointer = (void *)(roundup(
> +                               (phys_addr_t)CONFIG_SYS_EARLY_HEAP_ADDR +
> +                               sizeof(struct early_heap_header),
> +                               sizeof(phys_addr_t)));
> +       h->free_bytes = size - roundup(sizeof(struct early_heap_header),
> +                               sizeof(phys_addr_t));
> +       h->next_early_heap = NULL;
> +
> +       return h;
> +}

Regards,

Graeme


More information about the U-Boot mailing list