File tree Expand file tree Collapse file tree 4 files changed +63
-0
lines changed
Expand file tree Collapse file tree 4 files changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -526,3 +526,29 @@ void hal_prepare_boot(void)
526526 led_unsecure ();
527527#endif
528528}
529+
530+ void hal_cache_enable (int way )
531+ {
532+ ICACHE_CR |= (way ? ICACHE_CR_2WAYS : ICACHE_CR_1WAY );
533+ ICACHE_CR |= ICACHE_CR_CEN ;
534+ }
535+
536+ void hal_cache_disable (void )
537+ {
538+ ICACHE_CR &= ~ICACHE_CR_CEN ;
539+ }
540+
541+ void hal_cache_invalidate (void )
542+ {
543+ /* Check if no ongoing operation */
544+ if ((ICACHE_SR & ICACHE_SR_BUSYF ) == 0 ) {
545+ /* Launch cache invalidation */
546+ ICACHE_CR |= ICACHE_CR_CACHEINV ;
547+ }
548+
549+ if (ICACHE_SR & ICACHE_SR_BUSYF ) {
550+ while ((ICACHE_SR & ICACHE_SR_BSYENDF ) == 0 );
551+ }
552+ /* Clear BSYENDF */
553+ ICACHE_SR |= ICACHE_SR_BSYENDF ;
554+ }
Original file line number Diff line number Diff line change 263263#define AIRCR_VKEY (0x05FA << 16)
264264#define AIRCR_SYSRESETREQ (1 << 2)
265265
266+ /* Cache */
267+ #if (TZ_SECURE ())
268+ #define ICACHE_BASE (0x50030400) /* RM0456 - Table 4 */
269+ #else
270+ #define ICACHE_BASE (0x40030400) /* RM0456 - Table 4 */
271+ #endif
272+ #define ICACHE_CR *(volatile uint32_t *)(ICACHE_BASE + 0x00)
273+ #define ICACHE_CR_WAYSEL (1 << 2)
274+ #define ICACHE_CR_1WAY 0U /* 1-way cache (direct mapped cache) */
275+ #define ICACHE_CR_2WAYS ICACHE_CR_WAYSEL /* 2-ways set associative cache */
276+
277+ #define ICACHE_CR_CACHEINV (1 << 1)
278+ #define ICACHE_CR_CEN (1 << 0)
279+
280+ #define ICACHE_SR *(volatile uint32_t *)(ICACHE_BASE + 0x04)
281+ #define ICACHE_SR_BUSYF (1 << 0) /* busy flag */
282+ #define ICACHE_SR_BSYENDF (1 << 1) /* busy end flag */
283+ #define ICACHE_SR_ERRF (1 << 2) /* cache error flag */
284+
285+ void hal_cache_invalidate (void );
286+ void hal_cache_enable (int way );
287+ void hal_cache_disable (void );
Original file line number Diff line number Diff line change @@ -58,6 +58,14 @@ int wolfBot_get_dts_size(void *dts_addr);
5858#endif
5959#endif
6060
61+ #ifndef WEAKFUNCTION
62+ # if defined(__GNUC__ ) || defined(__CC_ARM )
63+ # define WEAKFUNCTION __attribute__((weak))
64+ # else
65+ # define WEAKFUNCTION
66+ # endif
67+ #endif
68+
6169
6270#ifndef WOLFBOOT_FLAGS_INVERT
6371#define SECT_FLAG_NEW 0x0F
Original file line number Diff line number Diff line change @@ -189,6 +189,11 @@ static uint8_t get_base_offset(uint8_t *base, uintptr_t off)
189189 #pragma GCC diagnostic pop
190190#endif
191191
192+ void WEAKFUNCTION hal_cache_invalidate (void )
193+ {
194+ /* if cache flushing is required implement in hal */
195+ }
196+
192197static int RAMFUNCTION nvm_select_fresh_sector (int part )
193198{
194199 int sel ;
@@ -198,6 +203,8 @@ static int RAMFUNCTION nvm_select_fresh_sector(int part)
198203 uint32_t word_0 ;
199204 uint32_t word_1 ;
200205
206+ hal_cache_invalidate ();
207+
201208 /* if FLAGS_HOME check both boot and update for changes */
202209#ifdef FLAGS_HOME
203210 base = (uint8_t * )PART_BOOT_ENDFLAGS ;
You can’t perform that action at this time.
0 commit comments