Fix cosmetic issues and add some Doxygen comments (trivial).
Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de> Acked-by: Uwe Hermann <uwe@hermann-uwe.de> git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@277 f3766cd6-281f-0410-b1cd-43a5c92072e9
This commit is contained in:
parent
ec52720cec
commit
5303acd696
1 changed files with 29 additions and 13 deletions
42
lib/malloc.c
42
lib/malloc.c
|
|
@ -30,30 +30,40 @@
|
|||
#if 0
|
||||
#define MALLOCDBG(x...)
|
||||
#else
|
||||
#define MALLOCDBG(x...) printk (BIOS_SPEW, x)
|
||||
#define MALLOCDBG(x...) printk(BIOS_SPEW, x)
|
||||
#endif
|
||||
|
||||
/* instead of ldscript magic, just declare an array. The array
|
||||
* will consume no bytes in the image, and it won't run into trouble
|
||||
* the way the V2 allocator could. We do not provide zero'd memory.
|
||||
* note that the execute-in-place code in top of flash is not allowed to call malloc,
|
||||
* since we can't link this in to it. The FLASH-based code should always be dead simple.
|
||||
* (in fact, it's not clear we need malloc at all any more -- we're doing our best to
|
||||
* remove all usage of it -- the only real users were elfboot and lzma, and we have
|
||||
* removed its usage in elfboot, and will try to remove its usage in lzma).
|
||||
/*
|
||||
* Instead of ldscript magic, just declare an array. The array will consume
|
||||
* no bytes in the image, and it won't run into trouble the way the v2
|
||||
* allocator could. We do not provide zero'd memory.
|
||||
*
|
||||
* Note that the execute-in-place (XIP) code in top of flash is not allowed
|
||||
* to call malloc(), since we can't link this in to it. The flash-based code
|
||||
* should always be dead simple (in fact, it's not clear we need malloc() at
|
||||
* all any more -- we're doing our best to remove all usage of it -- the
|
||||
* only real users were elfboot and lzma, and we have removed its usage in
|
||||
* elfboot, and will try to remove its usage in lzma).
|
||||
*/
|
||||
|
||||
#define HEAPSIZE (256*1024)
|
||||
#define HEAPSIZE (256 * 1024)
|
||||
static unsigned char heap[HEAPSIZE];
|
||||
static unsigned char *free_mem_ptr = heap;
|
||||
static unsigned long freebytes = HEAPSIZE;
|
||||
|
||||
/**
|
||||
* Allocate 'size' bytes of memory. The memory is not zero'd.
|
||||
* If not enough memory is available, just die.
|
||||
*
|
||||
* @param size The number of bytes to allocate.
|
||||
* @return A pointer to the allocated memory.
|
||||
*/
|
||||
void *malloc(size_t size)
|
||||
{
|
||||
void *p;
|
||||
|
||||
MALLOCDBG("%s Enter, size %d, free_mem_ptr %p\n",
|
||||
__FUNCTION__, size, free_mem_ptr);
|
||||
MALLOCDBG("%s Enter, size %d, free_mem_ptr %p\n",
|
||||
__FUNCTION__, size, free_mem_ptr);
|
||||
|
||||
if (size > freebytes) {
|
||||
die("Out of memory.\n");
|
||||
|
|
@ -70,7 +80,13 @@ void *malloc(size_t size)
|
|||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Free the specified memory area.
|
||||
* This is a no-op, we don't care about freeing memory.
|
||||
*
|
||||
* @param where A pointer to the memory area to free.
|
||||
*/
|
||||
void free(void *where)
|
||||
{
|
||||
/* Don't care */
|
||||
/* Don't care. */
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue