[ipxe-devel] question about memory in ipxe

Michael Brown mbrown at fensystems.co.uk
Fri Aug 10 19:24:23 UTC 2012


On Friday 10 Aug 2012 19:54:22 Levente LEVAI wrote:
> I would like to understand memory usage in ipxe (I would like to
> add some more powerful interpreter to ipxe). Studying the code
> I have got the impression that "heap" in ipxe is a rather scarce
> resource (128kB according to core/malloc.c). What are the limitations
> to increasing heap size?

Any memory forming part of the heap, along with the memory used by the iPXE 
image itself, will be permanently lost for the duration of the system boot if 
booting from SAN.

> I also found out that images (the image data proper, that is) are
> stored in a separate area, allocated by umalloc(). What is the exact
> difference between memory allocated by umalloc() and heap memory?

Allocating memory with umalloc() changes the system memory map as reported by 
INT 15,e820.  It is therefore not allowed to allocate memory with umalloc() 
from routines that may be called by external code such as a PXE NBP.

> A third kind of memory can be allocated from the stack (temporary
> strings and arrays are typically allocated this way).
> 
> There is a separate kind of memory used by drivers for io buffers
> (dma-able memory, means perhaps that
>   physical addresses == virtual address?).

malloc_dma() just allocates memory with specified (physical) alignment 
constraints.  The memory pool is the same as that used by malloc(), i.e. the 
internal heap.

> Are there any documents I should look into or the source code is
> the only documentation? What points should I study? What
> are the gotchas?

No documentation exists for this kind of internal aspect of the code, apart 
from comments in the source code itself.

In general, be aware of the size constraints for both code and data.  For 
reference, the TCP stack is 3.1kB, the Realtek driver is 2.8kB, the script 
interpreter is 0.9kB.  Any code you add should be looking at a similar code-
size budget.

Michael



More information about the ipxe-devel mailing list