2.11.5. __user_setup_stackheap()
__user_setup_stackheap() returns the locations of the initial stack and heap in the same way as __user_initial_stackheap() (see __user_initial_stackheap()). You can re‑implement either one of these functions as necessary.
__user_setup_stackheap() returns the:
heap base in r0
stack base in sp
heap limit in r2
stack limit in r3.
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.
Note
__user_setup_stackheap() must be re‑implemented in assembler.