mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
xtensa: coproc: modify coproc_save/restore to macro
As coproc_save/restore only used in context_restore/save. Use macro instead of function. Some register use optimize. Unify with arm/riscv. Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>
This commit is contained in:
committed by
Masayuki Ishikawa
parent
4896623be2
commit
0e478e559f
@@ -68,6 +68,7 @@
|
|||||||
|
|
||||||
#include "syscall.h"
|
#include "syscall.h"
|
||||||
#include "xtensa_asm_utils.h"
|
#include "xtensa_asm_utils.h"
|
||||||
|
#include "xtensa_coproc.S"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
@@ -201,12 +202,7 @@ _xtensa_context_save:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if XCHAL_CP_NUM > 0
|
#if XCHAL_CP_NUM > 0
|
||||||
s32i a0, sp, (4 * REG_TMP0) /* Save return address */
|
xtensa_coproc_savestate
|
||||||
|
|
||||||
mov a2, sp
|
|
||||||
call0 _xtensa_coproc_savestate
|
|
||||||
|
|
||||||
l32i a0, sp, (4 * REG_TMP0) /* Restore return address */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ret
|
ret
|
||||||
@@ -249,11 +245,7 @@ _xtensa_context_save:
|
|||||||
_xtensa_context_restore:
|
_xtensa_context_restore:
|
||||||
|
|
||||||
#if XCHAL_CP_NUM > 0
|
#if XCHAL_CP_NUM > 0
|
||||||
s32i a0, a2, (4 * REG_TMP0) /* Save return address */
|
xtensa_coproc_restorestate
|
||||||
|
|
||||||
call0 _xtensa_coproc_restorestate
|
|
||||||
|
|
||||||
l32i a0, a2, (4 * REG_TMP0) /* Restore return address */
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if XCHAL_HAVE_LOOPS != 0
|
#if XCHAL_HAVE_LOOPS != 0
|
||||||
|
|||||||
@@ -48,8 +48,6 @@
|
|||||||
#include <arch/chip/tie.h>
|
#include <arch/chip/tie.h>
|
||||||
#include <arch/chip/tie-asm.h>
|
#include <arch/chip/tie-asm.h>
|
||||||
|
|
||||||
#if XCHAL_CP_NUM > 0
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -70,13 +68,11 @@ _xtensa_coproc_saoffsets:
|
|||||||
.size _xtensa_coproc_saoffsets, . - _xtensa_coproc_saoffsets
|
.size _xtensa_coproc_saoffsets, . - _xtensa_coproc_saoffsets
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
.text
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: _xtensa_coproc_savestate
|
* Macro: xtensa_coproc_savestate
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* If there is a current thread and it has a coprocessor state save area,
|
* If there is a current thread and it has a coprocessor state save area,
|
||||||
@@ -89,31 +85,17 @@ _xtensa_coproc_saoffsets:
|
|||||||
* around the assembly language call to _xtensa_coproc_savestate.
|
* around the assembly language call to _xtensa_coproc_savestate.
|
||||||
*
|
*
|
||||||
* Entry Conditions:
|
* Entry Conditions:
|
||||||
* - A2 holds the address of current interrupt stack pointer.
|
|
||||||
* - Registers have been saved/spilled already.
|
* - Registers have been saved/spilled already.
|
||||||
*
|
*
|
||||||
* Exit conditions:
|
* Exit conditions:
|
||||||
* - All necessary CP callee-saved state has been saved.
|
* - All necessary CP callee-saved state has been saved.
|
||||||
* - Registers a2-a7, a13-a15 have been trashed.
|
* - Registers a2-a7, a13-a14 have been trashed.
|
||||||
*
|
|
||||||
* Must be called from assembly code only, using CALL0.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
.global _xtensa_coproc_savestate
|
.macro xtensa_coproc_savestate
|
||||||
.type _xtensa_coproc_savestate, @function
|
|
||||||
|
|
||||||
.align 4
|
/* The stack when interrupt happened
|
||||||
.literal_position
|
|
||||||
.align 4
|
|
||||||
|
|
||||||
_xtensa_coproc_savestate:
|
|
||||||
|
|
||||||
/* Move the address of the thread state save area to R15 */
|
|
||||||
|
|
||||||
mov a3, a2 /* A3 is now the address of the save area */
|
|
||||||
|
|
||||||
/* The stack when interrupt happened (the register a2)
|
|
||||||
* ----------------------------------------------------
|
* ----------------------------------------------------
|
||||||
* | Reserve area (0x20) |
|
* | Reserve area (0x20) |
|
||||||
* ----------------------------------------------------
|
* ----------------------------------------------------
|
||||||
@@ -123,12 +105,12 @@ _xtensa_coproc_savestate:
|
|||||||
* ---------------------------------------------------| <- SP
|
* ---------------------------------------------------| <- SP
|
||||||
*/
|
*/
|
||||||
|
|
||||||
addi a3, a3, (4 * XCPTCONTEXT_REGS)
|
addi a3, sp, (4 * XCPTCONTEXT_REGS)
|
||||||
|
|
||||||
/* CPENABLE should show which CPs are enabled. */
|
/* CPENABLE should show which CPs are enabled. */
|
||||||
|
|
||||||
rsr a2, CPENABLE /* a2 = which CPs are enabled */
|
rsr a2, CPENABLE /* a2 = which CPs are enabled */
|
||||||
beqz a2, .Ldone1 /* Quick exit if none */
|
beqz a2, Ldone1 /* Quick exit if none */
|
||||||
|
|
||||||
movi a13, _xtensa_coproc_saoffsets /* Array of CP save offsets */
|
movi a13, _xtensa_coproc_saoffsets /* Array of CP save offsets */
|
||||||
|
|
||||||
@@ -196,13 +178,12 @@ _xtensa_coproc_savestate:
|
|||||||
2:
|
2:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
.Ldone1:
|
Ldone1:
|
||||||
ret
|
|
||||||
|
|
||||||
.size _xtensa_coproc_savestate, . - _xtensa_coproc_savestate
|
.endm
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: _xtensa_coproc_restorestate
|
* Macro: xtensa_coproc_restorestate
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Restore any callee-saved coprocessor state for the incoming thread.
|
* Restore any callee-saved coprocessor state for the incoming thread.
|
||||||
@@ -216,28 +197,14 @@ _xtensa_coproc_savestate:
|
|||||||
* around the assembly language call to _xtensa_coproc_restorestate.
|
* around the assembly language call to _xtensa_coproc_restorestate.
|
||||||
*
|
*
|
||||||
* Entry Conditions:
|
* Entry Conditions:
|
||||||
* - A2 holds the address of the current interrupt stack pointer.
|
|
||||||
*
|
*
|
||||||
* Exit conditions:
|
* Exit conditions:
|
||||||
* - All necessary CP callee-saved state has been restored.
|
* - All necessary CP callee-saved state has been restored.
|
||||||
* - Registers a2-a7, a13-a15 have been trashed.
|
* - Registers a3-a8, a13-a14 have been trashed.
|
||||||
*
|
|
||||||
* Must be called from assembly code only, using CALL0.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
.global _xtensa_coproc_restorestate
|
.macro xtensa_coproc_restorestate
|
||||||
.type _xtensa_coproc_restorestate, @function
|
|
||||||
|
|
||||||
.align 4
|
|
||||||
.literal_position
|
|
||||||
.align 4
|
|
||||||
|
|
||||||
_xtensa_coproc_restorestate:
|
|
||||||
|
|
||||||
/* Move the address of the thread state save area to R15 */
|
|
||||||
|
|
||||||
mov a3, a2 /* A3 is now the address of the save area */
|
|
||||||
|
|
||||||
/* The stack when interrupt happened (the register A2)
|
/* The stack when interrupt happened (the register A2)
|
||||||
* ----------------------------------------------------
|
* ----------------------------------------------------
|
||||||
@@ -249,10 +216,10 @@ _xtensa_coproc_restorestate:
|
|||||||
* ---------------------------------------------------| <- SP
|
* ---------------------------------------------------| <- SP
|
||||||
*/
|
*/
|
||||||
|
|
||||||
addi a3, a3, (4 * XCPTCONTEXT_REGS)
|
addi a3, a2, (4 * XCPTCONTEXT_REGS)
|
||||||
|
|
||||||
rsr a8, CPENABLE /* Set CPENABLE correctly for this thread */
|
rsr a8, CPENABLE /* a8 = which CPs are enabled */
|
||||||
beqz a8, .Ldone1 /* Quick exit if none */
|
beqz a8, Ldone2 /* Quick exit if none */
|
||||||
|
|
||||||
movi a13, _xtensa_coproc_saoffsets /* Array of CP save offsets */
|
movi a13, _xtensa_coproc_saoffsets /* Array of CP save offsets */
|
||||||
|
|
||||||
@@ -322,8 +289,7 @@ _xtensa_coproc_restorestate:
|
|||||||
/* Ensure wsr.CPENABLE has completed. */
|
/* Ensure wsr.CPENABLE has completed. */
|
||||||
|
|
||||||
rsync
|
rsync
|
||||||
ret
|
|
||||||
|
|
||||||
.size _xtensa_coproc_restorestate, . - _xtensa_coproc_restorestate
|
Ldone2:
|
||||||
|
|
||||||
#endif /* XCHAL_CP_NUM > 0 */
|
.endm
|
||||||
|
|||||||
Reference in New Issue
Block a user