Stefan Reinauer 28190ce4de malloc/memalign: Remove unneeded linker check
This check got in the code when some Linux distros shipped broken linkers
around 1999.
Since then, the code around that check was changed, and it does not make
sense anymore to have this check.

Change-Id: I37c6b690d72f55c18ba4c34e8541a6a441e5e67a
Signed-off-by: Stefan Reinauer <reinauer@google.com>
Reviewed-on: http://review.coreboot.org/1275
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2012-07-24 02:39:20 +02:00

54 lines
1.2 KiB
C

#include <stdlib.h>
#include <console/console.h>
#if CONFIG_DEBUG_MALLOC
#define MALLOCDBG(x...) printk(BIOS_SPEW, x)
#else
#define MALLOCDBG(x...)
#endif
extern unsigned char _heap, _eheap;
static void *free_mem_ptr = &_heap; /* Start of heap */
static void *free_mem_end_ptr = &_eheap; /* End of heap */
/* We don't restrict the boundary. This is firmware,
* you are supposed to know what you are doing.
*/
void *memalign(size_t boundary, size_t size)
{
void *p;
MALLOCDBG("%s Enter, boundary %zu, size %zu, free_mem_ptr %p\n",
__func__, boundary, size, free_mem_ptr);
free_mem_ptr = (void *)ALIGN((unsigned long)free_mem_ptr, boundary);
p = free_mem_ptr;
free_mem_ptr += size;
if (free_mem_ptr >= free_mem_end_ptr) {
printk(BIOS_ERR, "memalign(boundary=%zu, size=%zu): failed: ",
boundary, size);
printk(BIOS_ERR, "Tried to round up free_mem_ptr %p to %p\n",
p, free_mem_ptr);
printk(BIOS_ERR, "but free_mem_end_ptr is %p\n",
free_mem_end_ptr);
die("Error! memalign: Out of memory (free_mem_ptr >= free_mem_end_ptr)");
}
MALLOCDBG("memalign %p\n", p);
return p;
}
void *malloc(size_t size)
{
return memalign(sizeof(u64), size);
}
void free(void *where)
{
/* Don't care */
MALLOCDBG("free %p\n", where);
}