| |||
| Home > The C and C++ Libraries > Tailoring the runtime memory model > __user_setup_stackheap() | |||
__user_setup_stackheap() sets up and
returns the locations of the initial stack and heap.
Unlike __user_initial_stackheap(), __user_setup_stackheap() works
with systems where the application starts with a value of sp (r13)
that is already correct, for example, Cortex-M3. To make use of sp,
implement __user_setup_stackheap() to set up r0, r2, and r3 (for
a two-region model) and return. For a one-region model, set only r0.
When __user_setup_stackheap() is called, sp has
the same value it had on entry to the application. If this value
is not valid then __user_setup_stackheap() must
change the value of sp before using any stack.
Using __user_setup_stackheap() rather
than __user_initial_stackheap() improves code
size because there is no requirement for a temporary stack.
__user_setup_stackheap() returns the:
heap base in r0
stack base in sp
heap limit in r2
stack limit in r3.
__user_setup_stackheap() must be reimplemented
in assembler.