From 407e5714792cf9280eeea1a60e66db69924f114c Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sun, 16 Aug 2015 08:33:01 +0000 Subject: Moved cache initialization into startup files. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8220 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/common/ports/ARMCMx/compilers/GCC/crt0_v6m.s | 12 +++++++++ os/common/ports/ARMCMx/compilers/GCC/crt0_v7m.s | 36 ++++++++++++++++--------- os/common/ports/ARMCMx/compilers/GCC/crt1.c | 26 +++++++++++++++--- 3 files changed, 59 insertions(+), 15 deletions(-) (limited to 'os/common/ports') diff --git a/os/common/ports/ARMCMx/compilers/GCC/crt0_v6m.s b/os/common/ports/ARMCMx/compilers/GCC/crt0_v6m.s index 38b4513b7..824538215 100644 --- a/os/common/ports/ARMCMx/compilers/GCC/crt0_v6m.s +++ b/os/common/ports/ARMCMx/compilers/GCC/crt0_v6m.s @@ -56,6 +56,13 @@ CONTROL_MODE_PRIVILEGED) #endif +/** + * @brief Core initialization switch. + */ +#if !defined(CRT0_INIT_CORE) || defined(__DOXYGEN__) +#define CRT0_INIT_CORE TRUE +#endif + /** * @brief Stack segments initialization switch. */ @@ -129,6 +136,11 @@ Reset_Handler: msr CONTROL, r0 isb +#if CRT0_INIT_CORE == TRUE + /* Core initialization.*/ + bl __core_init +#endif + /* Early initialization..*/ bl __early_init diff --git a/os/common/ports/ARMCMx/compilers/GCC/crt0_v7m.s b/os/common/ports/ARMCMx/compilers/GCC/crt0_v7m.s index fcfa4decd..029713227 100644 --- a/os/common/ports/ARMCMx/compilers/GCC/crt0_v7m.s +++ b/os/common/ports/ARMCMx/compilers/GCC/crt0_v7m.s @@ -54,6 +54,17 @@ /* Module pre-compile time settings. */ /*===========================================================================*/ +/** + * @brief FPU initialization switch. + */ +#if !defined(CRT0_INIT_FPU) || defined(__DOXYGEN__) +#if defined(CORTEX_USE_FPU) || defined(__DOXYGEN__) +#define CRT0_INIT_FPU CORTEX_USE_FPU +#else +#define CRT0_INIT_FPU FALSE +#endif +#endif + /** * @brief Control special register initialization value. * @details The system is setup to run in privileged mode using the PSP @@ -64,6 +75,13 @@ CONTROL_MODE_PRIVILEGED) #endif +/** + * @brief Core initialization switch. + */ +#if !defined(CRT0_INIT_CORE) || defined(__DOXYGEN__) +#define CRT0_INIT_CORE TRUE +#endif + /** * @brief Stack segments initialization switch. */ @@ -106,17 +124,6 @@ #define CRT0_CALL_DESTRUCTORS TRUE #endif -/** - * @brief FPU initialization switch. - */ -#if !defined(CRT0_INIT_FPU) || defined(__DOXYGEN__) -#if defined(CORTEX_USE_FPU) || defined(__DOXYGEN__) -#define CRT0_INIT_FPU CORTEX_USE_FPU -#else -#define CRT0_INIT_FPU FALSE -#endif -#endif - /** * @brief FPU FPCCR register initialization value. * @note Only used if @p CRT0_INIT_FPU is equal to @p TRUE. @@ -199,7 +206,12 @@ Reset_Handler: msr CONTROL, r0 isb - /* Early initialization..*/ +#if CRT0_INIT_CORE == TRUE + /* Core initialization.*/ + bl __core_init +#endif + + /* Early initialization.*/ bl __early_init #if CRT0_INIT_STACKS == TRUE diff --git a/os/common/ports/ARMCMx/compilers/GCC/crt1.c b/os/common/ports/ARMCMx/compilers/GCC/crt1.c index 68e22b95a..b20c3ba9a 100644 --- a/os/common/ports/ARMCMx/compilers/GCC/crt1.c +++ b/os/common/ports/ARMCMx/compilers/GCC/crt1.c @@ -27,11 +27,31 @@ #include +#include "cmparams.h" + /** - * @brief Early initialization. + * @brief Architecture-dependent core initialization. * @details This hook is invoked immediately after the stack initialization - * and before the DATA and BSS segments initialization. The - * default behavior is to do nothing. + * and before the DATA and BSS segments initialization. + * @note This function is a weak symbol. + */ +#if !defined(__DOXYGEN__) +__attribute__((weak)) +#endif +/*lint -save -e9075 [8.4] All symbols are invoked from asm context.*/ +void __core_init(void) { + +#if __CORTEX_M == 7 + SCB_EnableICache(); + SCB_EnableDCache(); +#endif +} + +/** + * @brief Early initialization. + * @details This hook is invoked immediately after the stack and core + * initialization and before the DATA and BSS segments + * initialization. * @note This function is a weak symbol. */ #if !defined(__DOXYGEN__) -- cgit v1.2.3