1// Copyright 2015-2020 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 .section .text 16 17 .global esp_shared_stack_invoke_function 18 .type esp_shared_stack_invoke_function, @function 19esp_shared_stack_invoke_function: 20 /* save current stack and return address */ 21 mv t0, sp 22 mv t1, ra 23 24 /* Set shared stack as new stack pointer */ 25 mv sp, a1 26 27 /* store the ra and previous stack pointer in a safe place 28 stack pointer for riscv should always be 16 byte aligned */ 29 addi sp,sp,-16 30 sw t0, 0(sp) 31 sw t1, 4(sp) 32 33 /* call the subroutine */ 34 jalr a0, 0 35 36 /* gets the ra and stack pointer saved previously */ 37 lw t0, 0(sp) 38 lw t1, 4(sp) 39 addi sp, sp, 16 40 41 /* restore both ra and real stack pointer of current task */ 42 mv ra, t1 43 mv sp, t0 44 ret 45