1 /* switch_contexts.S - setup for multiple contexts */
4 * Copyright (c) 2003-2010 Tensilica Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 #include <xtensa/coreasm.h>
27 #include <xtensa/xtruntime-frames.h>
29 #if XCHAL_NUM_CONTEXTS > 1
33 * void _xtos_setup_context(int context_num, StartInfo *info);
36 .global _xtos_setup_context
37 .type _xtos_setup_context,@function
40 #if XCHAL_HAVE_INTERRUPTS
41 rsil a5, 15 /* disable interrupts so we can use EXCSAVE_1 */
43 rsr a5, PS /* just read PS */
45 wsr a3, EXCSAVE_1 /* save pointer to new context info */
46 s32i a5, a3, INFO_prevps /* save previous PS */
47 movi a4, ~0x01F00000 /* mask out PS.CTXT */
48 slli a2, a2, 20 /* shift up new PS.CTXT value */
50 or a4, a4, a2 /* new PS value */
53 /* We're now in the new context! */
59 rsr a9, EXCSAVE_1 /* get pointer to context info */
60 movi a0, 0 /* terminate call frames */
61 l32i a1, a9, INFO_sp /* get stack pointer */
62 l32i a10, a9, INFO_arg1 /* get start function's arguments... */
63 l32i a8, a9, INFO_funcpc /* get start function's address */
64 /* Okay, now switch back to context zero: */
65 l32i a9, a9, INFO_prevps /* retrieve previous PS */
68 /* Back to original context! */
71 .size _xtos_setup_context, . - _xtos_setup_context
76 * This is the first thing to be executed in the new context
77 * by explicit setting of PC:
80 .global _xtos_start_context
82 #ifdef __XTENSA_CALL0_ABI__
83 Crash the assembler here: I think this is wrong.
89 j 1b /* do nothing until context 0 exits */
90 .size _xtos_start_context, . - _xtos_start_context
93 #endif /* XCHAL_NUM_CONTEXTS > 1 */