Skip to content

Commit 2e62c25

Browse files
author
GuentherMartin
committed
Core: added define guard __ARM_FEATURE_CMSE (#171)
1 parent e34e38b commit 2e62c25

File tree

4 files changed

+148
-147
lines changed

4 files changed

+148
-147
lines changed

CMSIS/Core/Include/m-profile/cmsis_armclang_m.h

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
#define __VECTOR_TABLE_ATTRIBUTE __attribute__((used, section("RESET")))
5757
#endif
5858

59-
#if (__ARM_FEATURE_CMSE == 3)
59+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)
6060
#ifndef __STACK_SEAL
6161
#define __STACK_SEAL Image$$STACKSEAL$$ZI$$Base
6262
#endif
@@ -69,12 +69,13 @@
6969
#define __TZ_STACK_SEAL_VALUE 0xFEF5EDA5FEF5EDA5ULL
7070
#endif
7171

72-
73-
__STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop) {
72+
__STATIC_FORCEINLINE void __TZ_set_STACKSEAL_S (uint32_t* stackTop)
73+
{
7474
*((uint64_t *)stackTop) = __TZ_STACK_SEAL_VALUE;
75-
}
75+
}
7676
#endif
7777

78+
7879
#if (__ARM_ARCH_ISA_THUMB >= 2)
7980
/**
8081
\brief STRT Unprivileged (8 bit)
@@ -119,7 +120,6 @@ __STATIC_FORCEINLINE void __STRT(uint32_t value, volatile uint32_t *ptr)
119120
@{
120121
*/
121122

122-
123123
/**
124124
\brief Get Control Register
125125
\details Returns the content of the Control Register.
@@ -134,7 +134,7 @@ __STATIC_FORCEINLINE uint32_t __get_CONTROL(void)
134134
}
135135

136136

137-
#if (__ARM_FEATURE_CMSE == 3)
137+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)
138138
/**
139139
\brief Get Control Register (non-secure)
140140
\details Returns the content of the non-secure Control Register when in secure mode.
@@ -162,7 +162,7 @@ __STATIC_FORCEINLINE void __set_CONTROL(uint32_t control)
162162
}
163163

164164

165-
#if (__ARM_FEATURE_CMSE == 3)
165+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)
166166
/**
167167
\brief Set Control Register (non-secure)
168168
\details Writes the given value to the non-secure Control Register when in secure state.
@@ -232,7 +232,7 @@ __STATIC_FORCEINLINE uint32_t __get_PSP(void)
232232
}
233233

234234

235-
#if (__ARM_FEATURE_CMSE == 3)
235+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)
236236
/**
237237
\brief Get Process Stack Pointer (non-secure)
238238
\details Returns the current value of the non-secure Process Stack Pointer (PSP) when in secure state.
@@ -259,7 +259,7 @@ __STATIC_FORCEINLINE void __set_PSP(uint32_t topOfProcStack)
259259
}
260260

261261

262-
#if (__ARM_FEATURE_CMSE == 3)
262+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)
263263
/**
264264
\brief Set Process Stack Pointer (non-secure)
265265
\details Assigns the given value to the non-secure Process Stack Pointer (PSP) when in secure state.
@@ -286,7 +286,7 @@ __STATIC_FORCEINLINE uint32_t __get_MSP(void)
286286
}
287287

288288

289-
#if (__ARM_FEATURE_CMSE == 3)
289+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)
290290
/**
291291
\brief Get Main Stack Pointer (non-secure)
292292
\details Returns the current value of the non-secure Main Stack Pointer (MSP) when in secure state.
@@ -313,7 +313,7 @@ __STATIC_FORCEINLINE void __set_MSP(uint32_t topOfMainStack)
313313
}
314314

315315

316-
#if (__ARM_FEATURE_CMSE == 3)
316+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)
317317
/**
318318
\brief Set Main Stack Pointer (non-secure)
319319
\details Assigns the given value to the non-secure Main Stack Pointer (MSP) when in secure state.
@@ -326,7 +326,7 @@ __STATIC_FORCEINLINE void __TZ_set_MSP_NS(uint32_t topOfMainStack)
326326
#endif
327327

328328

329-
#if (__ARM_FEATURE_CMSE == 3)
329+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)
330330
/**
331331
\brief Get Stack Pointer (non-secure)
332332
\details Returns the current value of the non-secure Stack Pointer (SP) when in secure state.
@@ -367,7 +367,7 @@ __STATIC_FORCEINLINE uint32_t __get_PRIMASK(void)
367367
}
368368

369369

370-
#if (__ARM_FEATURE_CMSE == 3)
370+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)
371371
/**
372372
\brief Get Priority Mask (non-secure)
373373
\details Returns the current state of the non-secure priority mask bit from the Priority Mask Register when in secure state.
@@ -394,7 +394,7 @@ __STATIC_FORCEINLINE void __set_PRIMASK(uint32_t priMask)
394394
}
395395

396396

397-
#if (__ARM_FEATURE_CMSE == 3)
397+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)
398398
/**
399399
\brief Set Priority Mask (non-secure)
400400
\details Assigns the given value to the non-secure Priority Mask Register when in secure state.
@@ -422,7 +422,7 @@ __STATIC_FORCEINLINE uint32_t __get_BASEPRI(void)
422422
}
423423

424424

425-
#if (__ARM_FEATURE_CMSE == 3)
425+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)
426426
/**
427427
\brief Get Base Priority (non-secure)
428428
\details Returns the current value of the non-secure Base Priority register when in secure state.
@@ -449,7 +449,7 @@ __STATIC_FORCEINLINE void __set_BASEPRI(uint32_t basePri)
449449
}
450450

451451

452-
#if (__ARM_FEATURE_CMSE == 3)
452+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)
453453
/**
454454
\brief Set Base Priority (non-secure)
455455
\details Assigns the given value to the non-secure Base Priority register when in secure state.
@@ -488,7 +488,7 @@ __STATIC_FORCEINLINE uint32_t __get_FAULTMASK(void)
488488
}
489489

490490

491-
#if (__ARM_FEATURE_CMSE == 3)
491+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)
492492
/**
493493
\brief Get Fault Mask (non-secure)
494494
\details Returns the current value of the non-secure Fault Mask register when in secure state.
@@ -515,7 +515,7 @@ __STATIC_FORCEINLINE void __set_FAULTMASK(uint32_t faultMask)
515515
}
516516

517517

518-
#if (__ARM_FEATURE_CMSE == 3)
518+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)
519519
/**
520520
\brief Set Fault Mask (non-secure)
521521
\details Assigns the given value to the non-secure Fault Mask register when in secure state.
@@ -542,9 +542,9 @@ __STATIC_FORCEINLINE void __TZ_set_FAULTMASK_NS(uint32_t faultMask)
542542
*/
543543
__STATIC_FORCEINLINE uint32_t __get_PSPLIM(void)
544544
{
545-
#if (((__ARM_ARCH_8M_MAIN__ < 1) && \
546-
(__ARM_ARCH_8_1M_MAIN__ < 1) ) && \
547-
(__ARM_FEATURE_CMSE < 3) )
545+
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
546+
!(defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) && \
547+
(!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
548548
/* without main extensions, the non-secure PSPLIM is RAZ/WI */
549549
return (0U);
550550
#else
@@ -554,7 +554,7 @@ __STATIC_FORCEINLINE uint32_t __get_PSPLIM(void)
554554
#endif
555555
}
556556

557-
#if (__ARM_FEATURE_CMSE == 3)
557+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)
558558
/**
559559
\brief Get Process Stack Pointer Limit (non-secure)
560560
Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
@@ -565,8 +565,8 @@ __STATIC_FORCEINLINE uint32_t __get_PSPLIM(void)
565565
*/
566566
__STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void)
567567
{
568-
#if ((__ARM_ARCH_8M_MAIN__ < 1) && \
569-
(__ARM_ARCH_8_1M_MAIN__ < 1) )
568+
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
569+
!(defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)))
570570
/* without main extensions, the non-secure PSPLIM is RAZ/WI */
571571
return (0U);
572572
#else
@@ -589,9 +589,9 @@ __STATIC_FORCEINLINE uint32_t __TZ_get_PSPLIM_NS(void)
589589
*/
590590
__STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
591591
{
592-
#if (((__ARM_ARCH_8M_MAIN__ < 1) && \
593-
(__ARM_ARCH_8_1M_MAIN__ < 1) ) && \
594-
(__ARM_FEATURE_CMSE < 3) )
592+
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
593+
!(defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) && \
594+
(!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
595595
/* without main extensions, the non-secure PSPLIM is RAZ/WI */
596596
(void)ProcStackPtrLimit;
597597
#else
@@ -600,7 +600,7 @@ __STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
600600
}
601601

602602

603-
#if (__ARM_FEATURE_CMSE == 3)
603+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)
604604
/**
605605
\brief Set Process Stack Pointer (non-secure)
606606
Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
@@ -611,8 +611,8 @@ __STATIC_FORCEINLINE void __set_PSPLIM(uint32_t ProcStackPtrLimit)
611611
*/
612612
__STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
613613
{
614-
#if ((__ARM_ARCH_8M_MAIN__ < 1) && \
615-
(__ARM_ARCH_8_1M_MAIN__ < 1) )
614+
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
615+
!(defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)))
616616
/* without main extensions, the non-secure PSPLIM is RAZ/WI */
617617
(void)ProcStackPtrLimit;
618618
#else
@@ -632,9 +632,9 @@ __STATIC_FORCEINLINE void __TZ_set_PSPLIM_NS(uint32_t ProcStackPtrLimit)
632632
*/
633633
__STATIC_FORCEINLINE uint32_t __get_MSPLIM(void)
634634
{
635-
#if (((__ARM_ARCH_8M_MAIN__ < 1) && \
636-
(__ARM_ARCH_8_1M_MAIN__ < 1) ) && \
637-
(__ARM_FEATURE_CMSE < 3) )
635+
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
636+
!(defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) && \
637+
(!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
638638
/* without main extensions, the non-secure MSPLIM is RAZ/WI */
639639
return (0U);
640640
#else
@@ -645,7 +645,7 @@ __STATIC_FORCEINLINE uint32_t __get_MSPLIM(void)
645645
}
646646

647647

648-
#if (__ARM_FEATURE_CMSE == 3)
648+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)
649649
/**
650650
\brief Get Main Stack Pointer Limit (non-secure)
651651
Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
@@ -656,8 +656,8 @@ __STATIC_FORCEINLINE uint32_t __get_MSPLIM(void)
656656
*/
657657
__STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void)
658658
{
659-
#if ((__ARM_ARCH_8M_MAIN__ < 1) && \
660-
(__ARM_ARCH_8_1M_MAIN__ < 1) )
659+
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
660+
!(defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)))
661661
/* without main extensions, the non-secure MSPLIM is RAZ/WI */
662662
return (0U);
663663
#else
@@ -679,9 +679,9 @@ __STATIC_FORCEINLINE uint32_t __TZ_get_MSPLIM_NS(void)
679679
*/
680680
__STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
681681
{
682-
#if (((__ARM_ARCH_8M_MAIN__ < 1) && \
683-
(__ARM_ARCH_8_1M_MAIN__ < 1) ) && \
684-
(__ARM_FEATURE_CMSE < 3) )
682+
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
683+
!(defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)) && \
684+
(!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
685685
/* without main extensions, the non-secure MSPLIM is RAZ/WI */
686686
(void)MainStackPtrLimit;
687687
#else
@@ -690,7 +690,7 @@ __STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
690690
}
691691

692692

693-
#if (__ARM_FEATURE_CMSE == 3)
693+
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)
694694
/**
695695
\brief Set Main Stack Pointer Limit (non-secure)
696696
Devices without ARMv8-M Main Extensions (i.e. Cortex-M23) lack the non-secure
@@ -701,15 +701,16 @@ __STATIC_FORCEINLINE void __set_MSPLIM(uint32_t MainStackPtrLimit)
701701
*/
702702
__STATIC_FORCEINLINE void __TZ_set_MSPLIM_NS(uint32_t MainStackPtrLimit)
703703
{
704-
#if ((__ARM_ARCH_8M_MAIN__ < 1) && \
705-
(__ARM_ARCH_8_1M_MAIN__ < 1) )
704+
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
705+
!(defined (__ARM_ARCH_8_1M_MAIN__ ) && (__ARM_ARCH_8_1M_MAIN__ == 1)))
706706
/* without main extensions, the non-secure MSPLIM is RAZ/WI */
707707
(void)MainStackPtrLimit;
708708
#else
709709
__ASM volatile ("MSR msplim_ns, %0" : : "r" (MainStackPtrLimit));
710710
#endif
711711
}
712712
#endif
713+
713714
#endif /* (__ARM_ARCH >= 8) */
714715
/** @} end of CMSIS_Core_RegAccFunctions */
715716

@@ -812,7 +813,7 @@ __STATIC_FORCEINLINE int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
812813
return (result);
813814
}
814815
#endif /* (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)) */
815-
/** @} end of group CMSIS_SIMD_intrinsics */
816+
/** @} end of group CMSIS_SIMD_intrinsics */
816817

817818

818819
#endif /* __CMSIS_ARMCLANG_M_H */

0 commit comments

Comments
 (0)