From e61549d8b91c069aed09f37609f0f26003c15206 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 19 Dec 2016 13:57:37 -0600 Subject: [PATCH] Xtensa ESP32: Clean-up and fixes from last commits --- arch/xtensa/src/common/xtensa_coproc.S | 90 ++++++++++++-------------- configs/esp32-core/src/Makefile | 2 +- configs/esp32-core/src/esp32_appinit.c | 2 +- 3 files changed, 42 insertions(+), 52 deletions(-) diff --git a/arch/xtensa/src/common/xtensa_coproc.S b/arch/xtensa/src/common/xtensa_coproc.S index c6ae294193..6af4849cee 100644 --- a/arch/xtensa/src/common/xtensa_coproc.S +++ b/arch/xtensa/src/common/xtensa_coproc.S @@ -225,34 +225,14 @@ xtensa_coproc_savestate: #ifdef __XTENSA_CALL0_ABI__ /* Need to preserve a8-11. _xtensa_coproc_savestate modifies a2-a7, - * a13-a15. So no registers need be saved. + * a13-a15. a12-a15 are callee saved registers so a13-a14 must be + * preserved. */ ENTRY(16) - s32i a0, sp, LOCAL_OFFSET(1) /* Save return address */ - - /* Call _xtensa_coproc_savestate() with A2=address of co-processor - * save area. - */ - - call0 _xtensa_coproc_savestate - - l32i a0, sp, LOCAL_OFFSET(1) /* Recover return address */ - RET(16) - -#else - ENTRY(32) - - /* Need to preserve a8-15. _xtensa_coproc_savestate modifies a2-a7, - * a13-a15. So a13-a15 may need to be preserved. - */ - - s32i a0, sp, LOCAL_OFFSET(1) /* Save return address */ -#if 0 - s32i a13, sp, LOCAL_OFFSET(2) /* Save clobbered registers */ - s32i a14, sp, LOCAL_OFFSET(3) - s32i a15, sp, LOCAL_OFFSET(4) -#endif + s32i a13, sp, LOCAL_OFFSET(1) /* Save clobbered registers */ + s32i a14, sp, LOCAL_OFFSET(2) + s32i a15, sp, LOCAL_OFFSET(3) /* Call _xtensa_coproc_savestate() with A2=address of co-processor * save area. @@ -262,14 +242,29 @@ xtensa_coproc_savestate: /* Restore a13-15 and return */ - l32i a0, sp, LOCAL_OFFSET(1) /* Recover return address */ -#if 0 - l32i a13, sp, LOCAL_OFFSET(2) /* Restore clobbered registers */ - l32i a14, sp, LOCAL_OFFSET(3) - l32i a15, sp, LOCAL_OFFSET(4) -#endif + l32i a13, sp, LOCAL_OFFSET(1) /* Restore clobbered registers */ + l32i a14, sp, LOCAL_OFFSET(2) + l32i a15, sp, LOCAL_OFFSET(3) + RET(16) - RET(32) +#else + /* Need to preserve a8-15. _xtensa_coproc_savestate modifies a2-a7, + * a13-a15. So a13-a15 may need to be preserved. + */ + + ENTRY(32 /*16*/) /* REVISIT: Why 32? */ + s32i a0, sp, LOCAL_OFFSET(1) /* Save return address */ + + /* Call _xtensa_coproc_savestate() with A2=address of co-processor + * save area. + */ + + call0 _xtensa_coproc_savestate + + /* Restore a0 and return */ + + l32i a0, sp, LOCAL_OFFSET(1) /* Recover return address */ + RET(32 /*16*/) /* REVISIT: Why 32? */ #endif @@ -429,11 +424,14 @@ xtensa_coproc_restorestate: #ifdef __XTENSA_CALL0_ABI__ /* Need to preserve a8-11. _xtensa_coproc_restorestate modifies a2-a7, - * a13-a15. So no registers need be saved. + * a13-a15. a12-a15 are callee saved registers so a13-a14 must be + * preserved. */ ENTRY(16) - s32i a0, sp, LOCAL_OFFSET(1) /* Save return address */ + s32i a13, sp, LOCAL_OFFSET(1) /* Save clobbered values */ + s32i a14, sp, LOCAL_OFFSET(2) + s32i a15, sp, LOCAL_OFFSET(3) /* Call _xtensa_coproc_restorestate() with A2=address of co-processor * save area. Registers a0, a2-a7, a13-a15 have been trashed. @@ -441,22 +439,20 @@ xtensa_coproc_restorestate: call0 _xtensa_coproc_restorestate - l32i a0, sp, LOCAL_OFFSET(1) /* Recover return address */ + /* Restore a13-a15 and return */ + + l32i a13, sp, LOCAL_OFFSET(1) /* Restore clobbered registers */ + l32i a14, sp, LOCAL_OFFSET(2) + l32i a15, sp, LOCAL_OFFSET(3) RET(16) #else - ENTRY(32) - /* Need to preserve a8-15. _xtensa_coproc_savestate modifies a2-a7, * a13-a15. So a13-a15 may need to be preserved. */ + ENTRY(32 /*16*/) /* REVISIT: Why 32? */ s32i a0, sp, LOCAL_OFFSET(1) /* Save return address */ -#if 0 - s32i a13, sp, LOCAL_OFFSET(2) /* Save clobbered values */ - s32i a14, sp, LOCAL_OFFSET(3) - s32i a15, sp, LOCAL_OFFSET(4) -#endif /* Call _xtensa_coproc_restorestate() with A2=address of co-processor * save area. Registers a0, a2-a7, a13-a15 have been trashed. @@ -464,16 +460,10 @@ xtensa_coproc_restorestate: call0 _xtensa_coproc_restorestate - /* Restore a13-15 and return */ + /* Restore a0 and return */ l32i a0, sp, LOCAL_OFFSET(1) /* Recover return address */ -#if 0 - l32i a13, sp, LOCAL_OFFSET(2) /* Restore clobbered registers */ - l32i a14, sp, LOCAL_OFFSET(3) - l32i a15, sp, LOCAL_OFFSET(4) -#endif - - RET(32) + RET(32 /*16*/) /* REVISIT: Why 32? */ #endif diff --git a/configs/esp32-core/src/Makefile b/configs/esp32-core/src/Makefile index 2e23d2db4b..46ed73e5c3 100644 --- a/configs/esp32-core/src/Makefile +++ b/configs/esp32-core/src/Makefile @@ -42,7 +42,7 @@ ASRCS = CSRCS = esp32_boot.c esp32_bringup.c ifeq ($(CONFIG_LIB_BOARDCTL),y) -CONFIG_CSRCS += esp32_appinit.c +CSRCS += esp32_appinit.c endif SCRIPTIN = $(SCRIPTDIR)$(DELIM)esp32.template diff --git a/configs/esp32-core/src/esp32_appinit.c b/configs/esp32-core/src/esp32_appinit.c index b352aa2fd2..ff8d1eb957 100644 --- a/configs/esp32-core/src/esp32_appinit.c +++ b/configs/esp32-core/src/esp32_appinit.c @@ -42,7 +42,7 @@ #include #include -#include "esp32_core.h" +#include "esp32-core.h" #ifdef CONFIG_LIB_BOARDCTL