arch: arc: fix the bug in _firq_enter
* In ARC, pop reg ==> sp=sp-4; *sp= b; The original codes have bug that the save of ilink (st ilink [sp]) will crash the interruptted stack's content. This commit fixes this bug and makes the codes easier to understand Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
This commit is contained in:
parent
698898098b
commit
c5c3fdd67b
2 changed files with 23 additions and 6 deletions
|
@ -101,20 +101,25 @@ firq_nest:
|
||||||
* save original value of _ARC_V2_USER_SP and ilink into
|
* save original value of _ARC_V2_USER_SP and ilink into
|
||||||
* the stack of interrupted context first, then restore them later
|
* the stack of interrupted context first, then restore them later
|
||||||
*/
|
*/
|
||||||
st ilink, [sp]
|
push ilink
|
||||||
lr ilink, [_ARC_V2_USER_SP]
|
PUSHAX ilink, _ARC_V2_USER_SP
|
||||||
st ilink, [sp, -4]
|
|
||||||
/* sp here is the sp of interrupted context */
|
/* sp here is the sp of interrupted context */
|
||||||
sr sp, [_ARC_V2_USER_SP]
|
sr sp, [_ARC_V2_USER_SP]
|
||||||
|
/* here, bank 0 sp must go back to the value before push and
|
||||||
|
* PUSHAX as we will switch to bank1, the pop and POPAX later will
|
||||||
|
* change bank1's sp, not bank0's sp
|
||||||
|
*/
|
||||||
|
add sp, sp, 8
|
||||||
|
|
||||||
/* switch back to banked reg, only ilink can be used */
|
/* switch back to banked reg, only ilink can be used */
|
||||||
lr ilink, [_ARC_V2_STATUS32]
|
lr ilink, [_ARC_V2_STATUS32]
|
||||||
or ilink, ilink, _ARC_V2_STATUS32_RB(1)
|
or ilink, ilink, _ARC_V2_STATUS32_RB(1)
|
||||||
kflag ilink
|
kflag ilink
|
||||||
lr sp, [_ARC_V2_USER_SP]
|
lr sp, [_ARC_V2_USER_SP]
|
||||||
ld ilink, [sp, -4]
|
|
||||||
sr ilink, [_ARC_V2_USER_SP]
|
POPAX ilink, _ARC_V2_USER_SP
|
||||||
ld ilink, [sp]
|
pop ilink
|
||||||
firq_nest_1:
|
firq_nest_1:
|
||||||
#else
|
#else
|
||||||
firq_nest:
|
firq_nest:
|
||||||
|
|
|
@ -365,6 +365,18 @@
|
||||||
#endif
|
#endif
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
|
/* macro to push aux reg through reg */
|
||||||
|
.macro PUSHAX reg aux
|
||||||
|
lr \reg, [\aux]
|
||||||
|
st.a \reg, [sp, -4]
|
||||||
|
.endm
|
||||||
|
|
||||||
|
/* macro to pop aux reg through reg */
|
||||||
|
.macro POPAX reg aux
|
||||||
|
ld.ab \reg, [sp, 4]
|
||||||
|
sr \reg, [\aux]
|
||||||
|
.endm
|
||||||
|
|
||||||
#endif /* _ASMLANGUAGE */
|
#endif /* _ASMLANGUAGE */
|
||||||
|
|
||||||
#endif /* ZEPHYR_ARCH_ARC_INCLUDE_SWAP_MACROS_H_ */
|
#endif /* ZEPHYR_ARCH_ARC_INCLUDE_SWAP_MACROS_H_ */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue