From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tomas Hlavacek Date: Sun, 23 Sep 2012 17:30:44 +0200 Subject: [U-Boot] [PATCH v6] [RFC] early_malloc for DM added. In-Reply-To: References: <1346069529-27397-1-git-send-email-tmshlvck@gmail.com> <1348351758-7434-1-git-send-email-tmshlvck@gmail.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello! On Sun, Sep 23, 2012 at 3:06 PM, Graeme Russ wrote: > > On Sep 23, 2012 8:09 AM, "Tomas Hlavacek" 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 >> --- > > [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; Yes, I was too paranoid. What about: if (g->early_heap_first != NULL) 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; >> +} > Tomas