[OpenBIOS] Dynamic memory allocation

Segher Boessenkool segher at kernel.crashing.org
Wed Jun 6 19:18:22 CEST 2012


> I couldn't find any documentation on alloc-mem,

See the Open Firmware specification.

> but I think this is how it works. It pops the top number on the  
> stack and tries to allocate that amount of memory. If it succeeds  
> it returns the address of the memory. If it fails, it returns 0. I  
> think I would release the memory using free-mem. Does this sound  
> about right?

alloc-mem ( len -- a-addr )
free-mem ( a-addr len -- )

alloc-mem calls ABORT" if it fails.  Note that free-mem takes the
length as input as well.


Segher




More information about the OpenBIOS mailing list