modules: cmsis: Add consistency checks

This change adds checks to validate consistency between Zephyr’s Kconfig
settings and cmsis configuration defined in SiP’s sdk provided headers.

This change also introduces a config to enable cmsis’ own checks which
emits warnings if a parameter relies on auto-populated default values.

Signed-off-by: Wilfried Chauveau <wilfried.chauveau@arm.com>
This commit is contained in:
Wilfried Chauveau 2023-11-06 14:23:19 +00:00 committed by Fabio Baltieri
parent 8d91ba200f
commit 3599fb47e1
2 changed files with 56 additions and 0 deletions

View file

@ -21,4 +21,11 @@ config HAS_CMSIS_CORE_R
config HAS_CMSIS_CORE_M
bool
config CMSIS_M_CHECK_DEVICE_DEFINES
bool "Check device defines"
default n
depends on HAS_CMSIS_CORE_M
help
This options enables the validation of CMSIS configuration flags.
endif

View file

@ -15,8 +15,57 @@
#ifndef ZEPHYR_MODULES_CMSIS_CMSIS_M_H_
#define ZEPHYR_MODULES_CMSIS_CMSIS_M_H_
#if defined(CONFIG_CMSIS_M_CHECK_DEVICE_DEFINES) && CONFIG_CMSIS_M_CHECK_DEVICE_DEFINES == 1U
#define __CHECK_DEVICE_DEFINES 1U
#endif
#include <zephyr/arch/arm/cortex_m/nvic.h>
#include <soc.h>
#if __NVIC_PRIO_BITS != NUM_IRQ_PRIO_BITS
#error "NUM_IRQ_PRIO_BITS and __NVIC_PRIO_BITS are not set to the same value"
#endif
#if __MPU_PRESENT != CONFIG_CPU_HAS_ARM_MPU
#error "__MPU_PRESENT and CONFIG_CPU_HAS_ARM_MPU are not set to the same value"
#endif
#if __FPU_PRESENT != CONFIG_CPU_HAS_FPU
#error "__FPU_PRESENT and CONFIG_CPU_HAS_FPU are not set to the same value"
#endif
/* VTOR is only optional on armv6-m and armv8-m baseline. __VTOR_PRESENT is often
* left undefined on platform where it is not optional.
*/
#if defined(CONFIG_ARMV6_M_ARMV8_M_BASELINE) && \
(__VTOR_PRESENT != CONFIG_CPU_CORTEX_M_HAS_VTOR)
#error "__VTOR_PRESENT and CONFIG_CPU_CORTEX_M_HAS_VTOR are not set to the same value."
#endif
/* Some platforms sdk incorrectly define __DSP_PRESENT for Cortex-M4 & Cortex-M7
* DSP extension. __ARM_FEATURE_DSP is set by the compiler for these. So ignore
* __DSP_PRESENT discrepancy when __ARM_FEATURE_DSP is defined.
*/
#if !defined(__ARM_FEATURE_DSP) && (__DSP_PRESENT != CONFIG_ARMV8_M_DSP)
#error "__DSP_PRESENT and CONFIG_ARMV8_M_DSP are not set to the same value"
#endif
#if __ICACHE_PRESENT != CONFIG_CPU_HAS_ICACHE
#error "__ICACHE_PRESENT and CONFIG_CPU_HAS_ICACHE are not set to the same value"
#endif
#if __DCACHE_PRESENT != CONFIG_CPU_HAS_DCACHE
#error "__DCACHE_PRESENT and CONFIG_CPU_HAS_DCACHE are not set to the same value"
#endif
#if __MVE_PRESENT != CONFIG_ARMV8_1_M_MVEI
#error "__MVE_PRESENT and CONFIG_ARMV8_1_M_MVEI are not set to the same value"
#endif
#if __SAUREGION_PRESENT != CONFIG_CPU_HAS_ARM_SAU
#error "__SAUREGION_PRESENT and CONFIG_CPU_HAS_ARM_SAU are not set to the same value"
#endif
#endif /* ZEPHYR_MODULES_CMSIS_CMSIS_M_H_ */