coreboot-kgpe-d16/util/extensions/legacybios/kernel/malloc.c
Stefan Reinauer dcdbdfb46e first shot of legacybios emulation.
does not work yet.. sorry :-(


git-svn-id: svn://svn.coreboot.org/coreboot/trunk@1119 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
2003-09-18 14:16:08 +00:00

35 lines
638 B
C

// 32k heap
void printk(const char *fmt, ...);
#define error printk
static unsigned long free_mem_ptr = 0x20000; /* Start of heap */
static unsigned long free_mem_end_ptr = 0x28000; /* End of heap */
void *malloc(unsigned int size)
{
void *p;
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");
return p;
}
void free(void *where)
{
/* Don't care */
}