1 /* init.c - context initialization */
4 * Copyright (c) 1999-2006 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/config/core.h>
27 #if XCHAL_NUM_CONTEXTS > 1
33 #if 0 /* XCHAL_NUM_CONTEXTS > 1 */
34 extern void _xtos_setup_context(int context_num, SetupInfo *info);
35 extern void _xtos_start_context(void);
38 * Sets up a context for running code.
40 * Returns PC at which to set the new context, or 0 on error.
42 unsigned _xtos_init_context(int context_num, int stack_size,
43 _xtos_handler_func *start_func, int arg1)
49 char *stack = malloc(stack_size);
53 /* Setup stack for call8: */
54 sp = stack + stack_size - 16;
55 *(unsigned*)(sp - 12) = (unsigned)(sp + 32);
57 info.sp = (unsigned)sp;
58 info.funcpc = (unsigned)start_func;
60 _xtos_setup_context(context_num, &info);
61 return (unsigned) &_xtos_start_context;
63 #endif /* multiple contexts */