• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#include <esp_osal/xtensa_context.h>
16
17    .extern xtensa_shared_stack
18    .extern xtensa_shared_stack_callback
19    .extern xtensa_shared_stack_function_done
20    .extern xtensa_shared_stack_env
21    .extern longjmp
22    .text
23
24
25/* extern void esp_shared_stack_invoke_function(void) */
26
27    .globl     esp_shared_stack_invoke_function
28    .type       esp_shared_stack_invoke_function,@function
29    .align      4
30esp_shared_stack_invoke_function:
31
32    #ifndef __XTENSA_CALL0_ABI__
33    movi    a0, 0                   /* must not rotate the window here, */
34                                    /* the state of execution for shared stack */
35                                    /* functions will be completely destroyed at end */
36    movi    a6, xtensa_shared_stack
37    l32i    sp, a6, 0               /* load shared stack pointer */
38    movi    a12, xtensa_shared_stack_callback
39    l32i    a12, a12, 0
40    callx4  a12                     /* call user function */
41    movi    a6, xtensa_shared_stack_function_done
42    movi    a7, 1
43    s32i    a7, a6, 0               /* hint the function was finished */
44    movi    a6, xtensa_shared_stack_env
45    movi    a7, 0
46    movi    a12, longjmp
47    callx4  a12                 /* jump to last clean state previously saved */
48    ret
49    #else
50    #error "this code is written for Window ABI"
51    #endif
52