Enhancements and Bug Fixes for F1Kx Port (#1169)

Fix FPU stack order issue and Improve FPU checking flow
Fix Interrupt depth comparison logic
Fix parameter mismatch in portmacro.h file
Add comment to explain assembly code
This commit is contained in:
Trong Nguyen 2024-11-05 15:09:50 +07:00 committed by GitHub
parent f0d79459d6
commit d0d55f3031
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 35 additions and 29 deletions

View file

@ -84,6 +84,10 @@ portSAVE_CONTEXT .macro
stsr FPEPC, r19
pushsp r18, r19
; Save EIPSW register to stack
; Due to the syntax of the pushsp instruction, using r14 as dummy value
pushsp r14, r15
; Get current TCB, the return value is stored in r10 (CCRH compiler)
jarl _pvPortGetCurrentTCB, lp
st.w sp, 0[r10]
@ -101,14 +105,15 @@ portRESTORE_CONTEXT .macro
; Restore FPU registers if FPU is enabled
mov FPU_MSK, r19
stsr PSW, r18
tst r18, r19
; Jump over next 3 instructions: stsr (4 bytes)*2 + popsp (4 bytes)
; Restore EIPSW register to check FPU
; Due to the syntax of the popsp instruction, using r14 as dummy value
popsp r14, r15
tst r15, r19
; Jump over next 3 instructions: stsr (4 bytes)*2 + popsp (4 bytes)
bz 12
popsp r18, r19
ldsr r18, FPEPC
ldsr r19, FPSR
ldsr r19, FPEPC
ldsr r18, FPSR
;Restore general-purpose registers and EIPSW, EIPC, EIIC, CTPSW, CTPC
popsp r15, r19
@ -146,14 +151,15 @@ SAVE_REGISTER .macro
mov ep, r15
stsr CTPSW, r14
stsr CTPC, r13
pushsp r13, r19
pushsp r13, r18
mov FPU_MSK, r16
tst r16, r19
bz 12
stsr FPSR, r18
stsr FPEPC, r19
pushsp r18, r19
bz 8
stsr FPSR, r17
stsr FPEPC, r18
pushsp r17, r19
.endm
;------------------------------------------------------------------------------
@ -161,15 +167,14 @@ SAVE_REGISTER .macro
;------------------------------------------------------------------------------
RESTORE_REGISTER .macro
mov FPU_MSK, r16
stsr PSW, r18
tst r18, r19
bz 12
popsp r18, r19
mov FPU_MSK, r15
popsp r17, r19
tst r19, r15
bz 8
ldsr r18, FPEPC
ldsr r19, FPSR
ldsr r17, FPSR
popsp r13, r19
popsp r13, r18
ldsr r13, CTPC
ldsr r14, CTPSW
mov r15, ep
@ -268,9 +273,10 @@ _vIrq_Handler:
; Do not enable interrupt for nesting. Stackover flow may occurs if the
; depth of nesting interrupt is exceeded.
mov #_uxPortMaxInterruptDepth, r15
cmp r16, r15
be 4 ; Jump over ei instruction
mov #_uxPortMaxInterruptDepth, r19
ld.w 0[r19], r15
cmp r15, r16
bge 4 ; Jump over ei instruction
ei
jarl _vCommonISRHandler, lp
di