ChorusOS 5.0 Board Support Package Developer's Guide

call_and_switch_stack() routine

Code Example 5-8 is the call_and_switch_stack() routine source code provided in source_dir/nucleus/bsp/src/boot_tools/call_and_switch_stack.s.


Example 5-8 call_and_switch_stack() Routine

			/*
			 *     void
			 * call_and_switch_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.