Example 4-6 is the call_and_switch_stack() routine source code provided in kernel/snippet/nucleus/boot_tools/call_and_switch_stack.s.
/*
* void
* call_and_swithc_stack(void* cookie, void* new_pc, void* new_sp)
*/
GLOBAL(call_and_switch_stack)
call_and_switch_stack:
mr r5, r1 /* sp = new_sp */
mtlr r4, lr /* (*new_pc) (cookie) */
blr
The call_and_switch_stack() routine switches to the stack provided as argument three, new_pc, jumps to the function specified by the second argument, new_pc, passing to that function the first argument, cookie.