# HG changeset patch # User vae # Date 1339012199 0 # Node ID bded287767e97a85802e17ed91b885c01b3c5782 # Parent c8f21fa3180054e0154931551d272514013e8b2f Provide for cache enablement in RAM startup mode [Bugzilla 1001606] diff --git a/packages/hal/cortexm/kinetis/var/current/ChangeLog b/packages/hal/cortexm/kinetis/var/current/ChangeLog --- a/packages/hal/cortexm/kinetis/var/current/ChangeLog +++ b/packages/hal/cortexm/kinetis/var/current/ChangeLog @@ -1,3 +1,8 @@ +2012-05-18 Ilija Kocho + + * include/hal_cache.h, src/kinetis_misc.c: Provide for cache + enablement in RAM startup mode [Bugzilla 1001606] + 2012-05-19 John Dallaway * doc/kinetis.sgml: Close and blocks. diff --git a/packages/hal/cortexm/kinetis/var/current/include/hal_cache.h b/packages/hal/cortexm/kinetis/var/current/include/hal_cache.h --- a/packages/hal/cortexm/kinetis/var/current/include/hal_cache.h +++ b/packages/hal/cortexm/kinetis/var/current/include/hal_cache.h @@ -66,12 +66,12 @@ // Data cache #define HAL_DCACHE_SIZE (8192*2) // Size of data cache in bytes #define HAL_DCACHE_LINE_SIZE 16 // Size of a data cache line -#define HAL_DCACHE_WAYS 2*2 // Associativity of the cache +#define HAL_DCACHE_WAYS (2*2) // Associativity of the cache // Instruction cache -#define HAL_ICACHE_SIZE 8192*2 // Size of cache in bytes +#define HAL_ICACHE_SIZE (8192*2) // Size of cache in bytes #define HAL_ICACHE_LINE_SIZE 16 // Size of a cache line -#define HAL_ICACHE_WAYS 2*2 // Associativity of the cache +#define HAL_ICACHE_WAYS (2*2) // Associativity of the cache #define HAL_DCACHE_SETS (HAL_DCACHE_SIZE/(HAL_DCACHE_LINE_SIZE*HAL_DCACHE_WAYS)) #define HAL_ICACHE_SETS (HAL_ICACHE_SIZE/(HAL_ICACHE_LINE_SIZE*HAL_ICACHE_WAYS)) @@ -109,8 +109,8 @@ // Query the state of the data cache (does not affect the caching) #define HAL_DCACHE_IS_ENABLED(_state_) \ CYG_MACRO_START \ - (_state_) = HAL_CORTEXM_KINETIS_CACHE_PS_IS_ENABLED() && \ - HAL_CORTEXM_KINETIS_CACHE_PC_IS_ENABLED(); \ + (_state_) = (HAL_CORTEXM_KINETIS_CACHE_PS_IS_ENABLED() && \ + HAL_CORTEXM_KINETIS_CACHE_PC_IS_ENABLED()); \ CYG_MACRO_END // Invalidate cache lines in the given range without writing to memory. diff --git a/packages/hal/cortexm/kinetis/var/current/src/kinetis_misc.c b/packages/hal/cortexm/kinetis/var/current/src/kinetis_misc.c --- a/packages/hal/cortexm/kinetis/var/current/src/kinetis_misc.c +++ b/packages/hal/cortexm/kinetis/var/current/src/kinetis_misc.c @@ -111,10 +111,10 @@ hal_kinetis_flash_conf_p( void ) //=== KINETIS FLASH security configuration END. ============================ -#if defined CYG_HAL_STARTUP_ROM && defined CYGPKG_HAL_KINETIS_CACHE +#if defined CYGPKG_HAL_KINETIS_CACHE +# ifndef CYG_HAL_STARTUP_RAM // Function for demotion of caching memory regions - static void hal_cortexm_kinetis_conf_cache_regions(cyghwr_hal_kinetis_lmem_t* lmem_p, cyg_uint32 reg_n, const cyg_uint32 *reg_mode_p) @@ -134,6 +134,7 @@ hal_cortexm_kinetis_conf_cache_regions(c } lmem_p->rmr = regval; } +# endif // ndef CYG_HAL_STARTUP_RAM const cyg_uint32 cache_reg_modes[] = { (CYGHWR_HAL_KINETIS_LMEM_DRAM_7000 << 16) | @@ -149,7 +150,7 @@ const cyg_uint32 cache_reg_modes[] = { CYGHWR_HAL_KINETIS_LMEM_CRMR_REGION_NC_M }; -#endif // defined CYG_HAL_STARTUP_ROM && defined CYGPKG_HAL_KINETIS_CACHE +#endif // defined CYGPKG_HAL_KINETIS_CACHE //========================================================================== // Setup variant specific hardware @@ -158,18 +159,20 @@ const cyg_uint32 cache_reg_modes[] = { void hal_variant_init( void ) { hal_update_clock_var(); -#if defined CYG_HAL_STARTUP_ROM && defined CYGPKG_HAL_KINETIS_CACHE +#if defined CYGPKG_HAL_KINETIS_CACHE +# ifndef CYG_HAL_STARTUP_RAM hal_cortexm_kinetis_conf_cache_regions(CYGHWR_HAL_KINETIS_LMEM_PS_P, sizeof(cache_reg_modes)/sizeof(cache_reg_modes[0]), cache_reg_modes); hal_cortexm_kinetis_conf_cache_regions(CYGHWR_HAL_KINETIS_LMEM_PC_P, sizeof(cache_reg_modes)/sizeof(cache_reg_modes[0]), cache_reg_modes); +# endif # ifdef ENABLE_CACHE_ON_STARTUP HAL_DCACHE_ENABLE(); HAL_ICACHE_ENABLE(); # endif -#endif // defined CYG_HAL_STARTUP_ROM && defined CYGPKG_HAL_KINETIS_CACHE +#endif // defined CYGPKG_HAL_KINETIS_CACHE #ifdef CYGSEM_HAL_VIRTUAL_VECTOR_SUPPORT hal_if_init(); #endif