RTX5: Cortex-A exception handlers updated (VFP register count detection)

pull/5628/head
Robert Rostohar 2017-10-27 10:44:59 +02:00 committed by TomoYamanaka
parent 4f4b4ddf36
commit 461c215636
3 changed files with 89 additions and 93 deletions

View File

@ -384,19 +384,18 @@ osRtxContextSave
VMRS R2, FPSCR VMRS R2, FPSCR
STMDB R3!, {R2,R12} ; Push FPSCR, maintain 8-byte alignment STMDB R3!, {R2,R12} ; Push FPSCR, maintain 8-byte alignment
IF {TARGET_FEATURE_EXTENSION_REGISTER_COUNT} == 16
VSTMDB R3!, {D0-D15} VSTMDB R3!, {D0-D15} ; Save D0-D15
LDRB R2, [R0, #TCB_SP_FRAME] ; Record in TCB that VFP/D16 state is stacked
ORR R2, R2, #2
STRB R2, [R0, #TCB_SP_FRAME]
ENDIF
IF {TARGET_FEATURE_EXTENSION_REGISTER_COUNT} == 32 IF {TARGET_FEATURE_EXTENSION_REGISTER_COUNT} == 32
VSTMDB R3!, {D0-D15} VSTMDB R3!, {D16-D31} ; Save D16-D31
VSTMDB R3!, {D16-D31}
LDRB R2, [R0, #TCB_SP_FRAME] ; Record in TCB that NEON/D32 state is stacked
ORR R2, R2, #4
STRB R2, [R0, #TCB_SP_FRAME]
ENDIF ENDIF
LDRB R2, [R0, #TCB_SP_FRAME]
IF {TARGET_FEATURE_EXTENSION_REGISTER_COUNT} == 32
ORR R2, R2, #4 ; NEON state
ELSE
ORR R2, R2, #2 ; VFP state
ENDIF
STRB R2, [R0, #TCB_SP_FRAME] ; Record VFP/NEON state
osRtxContextSave1 osRtxContextSave1
STR R3, [R0, #TCB_SP_OFS] ; Store user sp to osRtxInfo.thread.run.curr STR R3, [R0, #TCB_SP_OFS] ; Store user sp to osRtxInfo.thread.run.curr
@ -414,11 +413,11 @@ osRtxContextRestore
BEQ osRtxContextRestore1 ; No VFP BEQ osRtxContextRestore1 ; No VFP
ISB ; Only sync if we enabled VFP, otherwise we will context switch before next VFP instruction anyway ISB ; Only sync if we enabled VFP, otherwise we will context switch before next VFP instruction anyway
IF {TARGET_FEATURE_EXTENSION_REGISTER_COUNT} == 32 IF {TARGET_FEATURE_EXTENSION_REGISTER_COUNT} == 32
VLDMIA R3!, {D16-D31} VLDMIA R3!, {D16-D31} ; Restore D16-D31
ENDIF ENDIF
VLDMIA R3!, {D0-D15} VLDMIA R3!, {D0-D15} ; Restore D0-D15
LDR R2, [R3] LDR R2, [R3]
VMSR FPSCR, R2 VMSR FPSCR, R2 ; Restore FPSCR
ADD R3, R3, #8 ADD R3, R3, #8
osRtxContextRestore1 osRtxContextRestore1

View File

@ -391,19 +391,18 @@ osRtxContextSave:
VMRS R2, FPSCR VMRS R2, FPSCR
STMDB R3!, {R2,R12} // Push FPSCR, maintain 8-byte alignment STMDB R3!, {R2,R12} // Push FPSCR, maintain 8-byte alignment
#if TARGET_FEATURE_EXTENSION_REGISTER_COUNT == 16
VSTMDB R3!, {D0-D15} VSTMDB R3!, {D0-D15} // Save D0-D15
LDRB R2, [R0, #TCB_SP_FRAME] // Record in TCB that VFP/D16 state is stacked #if __ARM_NEON == 1
ORR R2, R2, #2 VSTMDB R3!, {D16-D31} // Save D16-D31
STRB R2, [R0, #TCB_SP_FRAME]
#endif #endif
#if TARGET_FEATURE_EXTENSION_REGISTER_COUNT == 32 LDRB R2, [R0, #TCB_SP_FRAME]
VSTMDB R3!, {D0-D15} #if __ARM_NEON == 1
VSTMDB R3!, {D16-D31} ORR R2, R2, #4 // NEON state
LDRB R2, [R0, #TCB_SP_FRAME] // Record in TCB that NEON/D32 state is stacked #else
ORR R2, R2, #4 ORR R2, R2, #2 // VFP state
STRB R2, [R0, #TCB_SP_FRAME]
#endif #endif
STRB R2, [R0, #TCB_SP_FRAME] // Record VFP/NEON state
osRtxContextSave1: osRtxContextSave1:
STR R3, [R0, #TCB_SP_OFS] // Store user sp to osRtxInfo.thread.run.curr STR R3, [R0, #TCB_SP_OFS] // Store user sp to osRtxInfo.thread.run.curr
@ -420,12 +419,12 @@ osRtxContextRestore:
MCR p15, 0, R2, c1, c0, 2 // Write CPACR MCR p15, 0, R2, c1, c0, 2 // Write CPACR
BEQ osRtxContextRestore1 // No VFP BEQ osRtxContextRestore1 // No VFP
ISB // Only sync if we enabled VFP, otherwise we will context switch before next VFP instruction anyway ISB // Only sync if we enabled VFP, otherwise we will context switch before next VFP instruction anyway
#if TARGET_FEATURE_EXTENSION_REGISTER_COUNT == 32 #if __ARM_NEON == 1
VLDMIA R3!, {D16-D31} VLDMIA R3!, {D16-D31} // Restore D16-D31
#endif #endif
VLDMIA R3!, {D0-D15} VLDMIA R3!, {D0-D15} // Restore D0-D15
LDR R2, [R3] LDR R2, [R3]
VMSR FPSCR, R2 VMSR FPSCR, R2 // Restore FPSCR
ADD R3, R3, #8 ADD R3, R3, #8
osRtxContextRestore1: osRtxContextRestore1:

View File

@ -42,7 +42,6 @@ TCB_SP_OFS EQU 56 ; osRtxThread_t.sp offset
PRESERVE8 PRESERVE8
ARM
SECTION .rodata:DATA:NOROOT(2) SECTION .rodata:DATA:NOROOT(2)
@ -370,19 +369,18 @@ osRtxContextSave
VMRS R2, FPSCR VMRS R2, FPSCR
STMDB R3!, {R2,R12} ; Push FPSCR, maintain 8-byte alignment STMDB R3!, {R2,R12} ; Push FPSCR, maintain 8-byte alignment
IF {TARGET_FEATURE_EXTENSION_REGISTER_COUNT} == 16
VSTMDB R3!, {D0-D15} VSTMDB R3!, {D0-D15} ; Save D0-D15
LDRB R2, [R0, #TCB_SP_FRAME] ; Record in TCB that VFP/D16 state is stacked #ifdef __ARM_ADVANCED_SIMD__
ORR R2, R2, #2 VSTMDB R3!, {D16-D31} ; Save D16-D31
STRB R2, [R0, #TCB_SP_FRAME] #endif
ENDIF LDRB R2, [R0, #TCB_SP_FRAME]
IF {TARGET_FEATURE_EXTENSION_REGISTER_COUNT} == 32 #ifdef __ARM_ADVANCED_SIMD__
VSTMDB R3!, {D0-D15} ORR R2, R2, #4 ; NEON state
VSTMDB R3!, {D16-D31} #else
LDRB R2, [R0, #TCB_SP_FRAME] ; Record in TCB that NEON/D32 state is stacked ORR R2, R2, #2 ; VFP state
ORR R2, R2, #4 #endif
STRB R2, [R0, #TCB_SP_FRAME] STRB R2, [R0, #TCB_SP_FRAME] ; Record VFP/NEON state
ENDIF
osRtxContextSave1 osRtxContextSave1
STR R3, [R0, #TCB_SP_OFS] ; Store user sp to osRtxInfo.thread.run.curr STR R3, [R0, #TCB_SP_OFS] ; Store user sp to osRtxInfo.thread.run.curr
@ -399,12 +397,12 @@ osRtxContextRestore
MCR p15, 0, R2, c1, c0, 2 ; Write CPACR MCR p15, 0, R2, c1, c0, 2 ; Write CPACR
BEQ osRtxContextRestore1 ; No VFP BEQ osRtxContextRestore1 ; No VFP
ISB ; Only sync if we enabled VFP, otherwise we will context switch before next VFP instruction anyway ISB ; Only sync if we enabled VFP, otherwise we will context switch before next VFP instruction anyway
IF {TARGET_FEATURE_EXTENSION_REGISTER_COUNT} == 32 #ifdef __ARM_ADVANCED_SIMD__
VLDMIA R3!, {D16-D31} VLDMIA R3!, {D16-D31} ; Restore D16-D31
ENDIF #endif
VLDMIA R3!, {D0-D15} VLDMIA R3!, {D0-D15} ; Restore D0-D15
LDR R2, [R3] LDR R2, [R3]
VMSR FPSCR, R2 VMSR FPSCR, R2 ; Restore FPSCR
ADD R3, R3, #8 ADD R3, R3, #8
osRtxContextRestore1 osRtxContextRestore1