Skip to content

Commit 640e1fd

Browse files
bulislaw0xc0170
authored andcommitted
CMSIS/RTX: Pre-processor defines used for assembly
CMSIS repo does not support pre-processor defines, hence multiple assembly files are added for secure/non-secure and floating point tools. Mbed OS tools support assembly file pre-processing, but the build system does not support multiple assembly files for each target, hence updating the assembly files. 1. Patch RTX so irq_cm4f.S files work with no FPU targets 2. Patch RTX so irq_armv8mml.S files to work with and without FPU 2. Patch RTX so irq_armv8mml.S and irq_armv8mbl.S files to work with secure and non-secure builds (cherry picked from commit 96e0689)
1 parent 30597a6 commit 640e1fd

File tree

7 files changed

+37
-11
lines changed

7 files changed

+37
-11
lines changed

rtos/source/TARGET_CORTEX/rtx5/RTX/Source/TOOLCHAIN_ARM/TARGET_M23/irq_armv8mbl.S

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
; */
2525

2626

27-
IF :LNOT::DEF:DOMAIN_NS
28-
DOMAIN_NS EQU 0
29-
ENDIF
27+
#ifndef DOMAIN_NS
28+
DOMAIN_NS EQU 0
29+
#endif
3030

3131
I_T_RUN_OFS EQU 20 ; osRtxInfo.thread.run offset
3232
TCB_SM_OFS EQU 48 ; TCB.stack_mem offset

rtos/source/TARGET_CORTEX/rtx5/RTX/Source/TOOLCHAIN_ARM/TARGET_M33/irq_armv8mml.S

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,16 @@
2424
; */
2525

2626

27-
IF :LNOT::DEF:DOMAIN_NS
28-
DOMAIN_NS EQU 0
29-
ENDIF
27+
#ifndef DOMAIN_NS
28+
DOMAIN_NS EQU 0
29+
#endif
30+
31+
#ifdef __ARM_FP
32+
__FPU_USED EQU 1
33+
#else
34+
__FPU_USED EQU 0
35+
#endif
3036

31-
IF ({FPU}="FPv5-SP") || ({FPU}="FPv5_D16")
32-
FPU_USED EQU 1
33-
ELSE
34-
FPU_USED EQU 0
35-
ENDIF
3637

3738
I_T_RUN_OFS EQU 20 ; osRtxInfo.thread.run offset
3839
TCB_SM_OFS EQU 48 ; TCB.stack_mem offset

rtos/source/TARGET_CORTEX/rtx5/RTX/Source/TOOLCHAIN_ARM/TARGET_RTOS_M4_M7/irq_cm4f.S

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,22 @@ SVC_Context
7474
CBNZ R1,SVC_ContextSave ; Branch if running thread is not deleted
7575
TST LR,#0x10 ; Check if extended stack frame
7676
BNE SVC_ContextSwitch
77+
#ifdef __FPU_PRESENT
7778
LDR R1,=0xE000EF34 ; FPCCR Address
7879
LDR R0,[R1] ; Load FPCCR
7980
BIC R0,R0,#1 ; Clear LSPACT (Lazy state)
8081
STR R0,[R1] ; Store FPCCR
8182
B SVC_ContextSwitch
83+
#endif
8284

8385
SVC_ContextSave
8486
STMDB R12!,{R4-R11} ; Save R4..R11
87+
#ifdef __FPU_PRESENT
8588
TST LR,#0x10 ; Check if extended stack frame
8689
IT EQ
8790
VSTMDBEQ R12!,{S16-S31} ; Save VFP S16.S31
91+
#endif
92+
8893
STR R12,[R1,#TCB_SP_OFS] ; Store SP
8994
STRB LR, [R1,#TCB_SF_OFS] ; Store stack frame information
9095

@@ -103,9 +108,11 @@ SVC_ContextRestore
103108
LDR R0,[R2,#TCB_SP_OFS] ; Load SP
104109
ORR LR,R1,#0xFFFFFF00 ; Set EXC_RETURN
105110

111+
#ifdef __FPU_PRESENT
106112
TST LR,#0x10 ; Check if extended stack frame
107113
IT EQ
108114
VLDMIAEQ R0!,{S16-S31} ; Restore VFP S16..S31
115+
#endif
109116
LDMIA R0!,{R4-R11} ; Restore R4..R11
110117
MSR PSP,R0 ; Set PSP
111118

rtos/source/TARGET_CORTEX/rtx5/RTX/Source/TOOLCHAIN_GCC/TARGET_RTOS_M4_M7/irq_cm4f.S

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,22 @@ SVC_Context:
7373
CBNZ R1,SVC_ContextSave // Branch if running thread is not deleted
7474
TST LR,#0x10 // Check if extended stack frame
7575
BNE SVC_ContextSwitch
76+
#ifdef __FPU_PRESENT
7677
LDR R1,=0xE000EF34 // FPCCR Address
7778
LDR R0,[R1] // Load FPCCR
7879
BIC R0,R0,#1 // Clear LSPACT (Lazy state)
7980
STR R0,[R1] // Store FPCCR
8081
B SVC_ContextSwitch
82+
#endif
8183

8284
SVC_ContextSave:
8385
STMDB R12!,{R4-R11} // Save R4..R11
86+
#ifdef __FPU_PRESENT
8487
TST LR,#0x10 // Check if extended stack frame
8588
IT EQ
8689
VSTMDBEQ R12!,{S16-S31} // Save VFP S16.S31
90+
#endif
91+
8792
STR R12,[R1,#TCB_SP_OFS] // Store SP
8893
STRB LR, [R1,#TCB_SF_OFS] // Store stack frame information
8994

@@ -95,9 +100,11 @@ SVC_ContextRestore:
95100
LDR R0,[R2,#TCB_SP_OFS] // Load SP
96101
ORR LR,R1,#0xFFFFFF00 // Set EXC_RETURN
97102

103+
#ifdef __FPU_PRESENT
98104
TST LR,#0x10 // Check if extended stack frame
99105
IT EQ
100106
VLDMIAEQ R0!,{S16-S31} // Restore VFP S16..S31
107+
#endif
101108
LDMIA R0!,{R4-R11} // Restore R4..R11
102109
MSR PSP,R0 // Set PSP
103110

rtos/source/TARGET_CORTEX/rtx5/RTX/Source/TOOLCHAIN_IAR/TARGET_M23/irq_armv8mbl_common.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,5 @@ Sys_ContextRestore2
299299

300300
Sys_ContextExit
301301
BX LR ; Exit from handler
302+
303+
END

rtos/source/TARGET_CORTEX/rtx5/RTX/Source/TOOLCHAIN_IAR/TARGET_M33/irq_armv8mml_common.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,5 @@ Sys_ContextRestore2
278278

279279
Sys_ContextExit
280280
BX LR ; Exit from handler
281+
282+
END

rtos/source/TARGET_CORTEX/rtx5/RTX/Source/TOOLCHAIN_IAR/TARGET_RTOS_M4_M7/irq_cm4f.S

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,22 @@ SVC_Context
7474
CBNZ R1,SVC_ContextSave ; Branch if running thread is not deleted
7575
TST LR,#0x10 ; Check if extended stack frame
7676
BNE SVC_ContextSwitch
77+
#ifdef __FPU_PRESENT
7778
LDR R1,=0xE000EF34 ; FPCCR Address
7879
LDR R0,[R1] ; Load FPCCR
7980
BIC R0,R0,#1 ; Clear LSPACT (Lazy state)
8081
STR R0,[R1] ; Store FPCCR
8182
B SVC_ContextSwitch
83+
#endif
8284

8385
SVC_ContextSave
8486
STMDB R12!,{R4-R11} ; Save R4..R11
87+
#ifdef __FPU_PRESENT
8588
TST LR,#0x10 ; Check if extended stack frame
8689
IT EQ
8790
VSTMDBEQ R12!,{S16-S31} ; Save VFP S16.S31
91+
#endif
92+
8893
STR R12,[R1,#TCB_SP_OFS] ; Store SP
8994
STRB LR, [R1,#TCB_SF_OFS] ; Store stack frame information
9095

@@ -96,9 +101,11 @@ SVC_ContextRestore
96101
LDR R0,[R2,#TCB_SP_OFS] ; Load SP
97102
ORR LR,R1,#0xFFFFFF00 ; Set EXC_RETURN
98103

104+
#ifdef __FPU_PRESENT
99105
TST LR,#0x10 ; Check if extended stack frame
100106
IT EQ
101107
VLDMIAEQ R0!,{S16-S31} ; Restore VFP S16..S31
108+
#endif
102109
LDMIA R0!,{R4-R11} ; Restore R4..R11
103110
MSR PSP,R0 ; Set PSP
104111

0 commit comments

Comments
 (0)