diff --git a/components/freertos/xt_asm_utils.h b/components/freertos/xt_asm_utils.h index b3caad1cb6..eccf7aa87b 100644 --- a/components/freertos/xt_asm_utils.h +++ b/components/freertos/xt_asm_utils.h @@ -1,3 +1,28 @@ +/* Copyright 2015-2018 Espressif Systems (Shanghai) PTE LTD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* File adapted to use on IDF FreeRTOS component, extracted + * originally from zephyr RTOS code base + */ + +/* + * Copyright (c) 2017, Intel Corporation + * + * SPDX-License-Identifier: Apache-2.0 + */ + #ifndef __XT_ASM_UTILS_H #define __XT_ASM_UTILS_H @@ -59,5 +84,4 @@ #endif .endm - #endif \ No newline at end of file diff --git a/components/freertos/xtensa_context.S b/components/freertos/xtensa_context.S index db6dee3c50..b0490c5e68 100644 --- a/components/freertos/xtensa_context.S +++ b/components/freertos/xtensa_context.S @@ -169,25 +169,25 @@ _xt_context_save: s32i a9, sp, XT_STK_OVLY /* save overlay state */ #endif - rsr a2, PS - movi a3, PS_INTLEVEL_MASK + rsr a2, PS /* We need to enable window execptions to */ + movi a3, PS_INTLEVEL_MASK /* perform spill registers*/ and a2, a2, a3 bnez a2, _not_l1 rsr a2, PS - movi a3, PS_INTLEVEL(1) - or a2, a2, a3 - wsr a2, PS + movi a3, PS_INTLEVEL(1) /* For some curious reason the level 1 interrupts */ + or a2, a2, a3 /* dont set the intlevel correctly on PS, we need to */ + wsr a2, PS /* do this manually */ _not_l1: - rsr a2, PS + rsr a2, PS /* finally umask the window exceptions */ movi a3, ~(PS_EXCM_MASK) and a2, a2, a3 wsr a2, PS rsync - addi sp, sp, XT_STK_FRMSZ /* restore the interruptee's SP */ - SPILL_ALL_WINDOWS - addi sp, sp, -XT_STK_FRMSZ + addi sp, sp, XT_STK_FRMSZ /* go back to spill register region */ + SPILL_ALL_WINDOWS /* place the live register windows there */ + addi sp, sp, -XT_STK_FRMSZ /* return the current stack pointer and proceed with conext save*/ #endif l32i a12, sp, XT_STK_TMP0 /* temp. save stuff in stack frame */