summaryrefslogtreecommitdiff
path: root/util/extensions/legacybios/kernel/malloc.c
blob: 782b5162224707c4f886a42c5185d9072e626a6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

// 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 */
}