coreboot/src/lib/malloc.c
Ronald G. Minnich e44595d970 K7SEM is fixed. The problem was that you need
option USE_DOC_MIL=1
now, not just
option USE_DOC_MIL

The latter usage led to empty streams struct.

This is a real problem, though: you can no streams for reading and the linker
will happily create an empty streams structure. Which sucks, since you don't know
why your system won't boot.
2002-02-05 00:06:20 +00:00

53 lines
1.1 KiB
C

#include <stdlib.h>
#include <printk.h>
#include <subr.h>
#if 0
#define MALLOCDBG(x)
#else
#define MALLOCDBG(x) printk_spew x
#endif
extern unsigned char _heap, _eheap;
static size_t free_mem_ptr = (size_t)&_heap; /* Start of heap */
static size_t free_mem_end_ptr = (size_t)&_eheap; /* End of heap */
void malloc_mark(malloc_mark_t *place)
{
*place = free_mem_ptr;
printk_spew("malloc_mark 0x%08lx\n", (unsigned long)free_mem_ptr);
}
void malloc_release(malloc_mark_t *ptr)
{
free_mem_ptr = *ptr;
printk_spew("malloc_release 0x%08lx\n", (unsigned long)free_mem_ptr);
}
void *malloc(size_t size)
{
void *p;
MALLOCDBG((__FUNCTION__ " Enter, size %d, free_mem_ptr %p\n", size, free_mem_ptr));
if (size < 0)
error("Error! malloc: Size < 0");
if (free_mem_ptr <= 0)
error("Error! malloc: Free_mem_ptr <= 0");
free_mem_ptr = (free_mem_ptr + 3) & ~3; /* Align */
p = (void *) free_mem_ptr;
free_mem_ptr += size;
if (free_mem_ptr >= free_mem_end_ptr)
error("Error! malloc: Free_mem_ptr >= free_mem_end_ptr");
MALLOCDBG(("malloc 0x%08lx\n", (unsigned long)p));
return p;
}
void free(void *where)
{
/* Don't care */
}