cache: add new interface arch_cache_init() for initializing cache
Add a new call for initializing cache on architectures that need that. Avoid using SYS_INIT for this and instead call the hook in a fixed place and run if implemented. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
418b1e0e21
commit
6ec74d02b6
17 changed files with 68 additions and 1 deletions
|
|
@ -227,4 +227,8 @@ static int init_dcache(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
SYS_INIT(init_dcache, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
|
||||
|
||||
void arch_cache_init(void)
|
||||
{
|
||||
init_dcache();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include <zephyr/kernel_structs.h>
|
||||
#include <kernel_internal.h>
|
||||
#include <zephyr/platform/hooks.h>
|
||||
#include <zephyr/arch/cache.h>
|
||||
|
||||
/* XXX - keep for future use in full-featured cache APIs */
|
||||
#if 0
|
||||
|
|
@ -135,6 +136,9 @@ void z_prep_c(void)
|
|||
dev_state_zero();
|
||||
#endif
|
||||
z_data_copy();
|
||||
#if CONFIG_ARCH_CACHE
|
||||
arch_cache_init();
|
||||
#endif
|
||||
z_cstart();
|
||||
CODE_UNREACHABLE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -217,3 +217,7 @@ int arch_icache_flush_and_invd_range(void *start_addr, size_t size)
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
void arch_cache_init(void)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include <zephyr/sys/barrier.h>
|
||||
#include <zephyr/arch/arm/cortex_a_r/lib_helpers.h>
|
||||
#include <zephyr/platform/hooks.h>
|
||||
#include <zephyr/arch/cache.h>
|
||||
|
||||
#if defined(CONFIG_ARMV7_R) || defined(CONFIG_ARMV7_A)
|
||||
#include <cortex_a_r/stack.h>
|
||||
|
|
@ -164,6 +165,9 @@ void z_prep_c(void)
|
|||
z_arm_init_stacks();
|
||||
#endif
|
||||
z_arm_interrupt_init();
|
||||
#if CONFIG_ARCH_CACHE
|
||||
arch_cache_init();
|
||||
#endif
|
||||
#ifdef CONFIG_ARM_MPU
|
||||
z_arm_mpu_init();
|
||||
z_arm_configure_static_mpu_regions();
|
||||
|
|
|
|||
|
|
@ -110,3 +110,7 @@ int arch_icache_flush_and_invd_range(void *start_addr, size_t size)
|
|||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
void arch_cache_init(void)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include <zephyr/linker/linker-defs.h>
|
||||
#include <zephyr/sys/barrier.h>
|
||||
#include <zephyr/platform/hooks.h>
|
||||
#include <zephyr/arch/cache.h>
|
||||
|
||||
#if defined(__GNUC__)
|
||||
/*
|
||||
|
|
@ -198,6 +199,9 @@ void z_prep_c(void)
|
|||
#else
|
||||
z_arm_interrupt_init();
|
||||
#endif /* CONFIG_ARM_CUSTOM_INTERRUPT_CONTROLLER */
|
||||
#if CONFIG_ARCH_CACHE
|
||||
arch_cache_init();
|
||||
#endif
|
||||
z_cstart();
|
||||
CODE_UNREACHABLE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
#include <kernel_internal.h>
|
||||
#include <zephyr/linker/linker-defs.h>
|
||||
#include <zephyr/platform/hooks.h>
|
||||
#include <zephyr/arch/cache.h>
|
||||
|
||||
extern void z_arm64_mm_init(bool is_primary_core);
|
||||
|
||||
|
|
@ -57,6 +58,9 @@ extern FUNC_NORETURN void arch_secondary_cpu_init(void);
|
|||
void z_arm64_secondary_prep_c(void)
|
||||
{
|
||||
arch_secondary_cpu_init();
|
||||
#if CONFIG_ARCH_CACHE
|
||||
arch_cache_init();
|
||||
#endif
|
||||
|
||||
CODE_UNREACHABLE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <kernel_internal.h>
|
||||
#include <zephyr/irq.h>
|
||||
#include <zephyr/platform/hooks.h>
|
||||
#include <zephyr/arch/cache.h>
|
||||
|
||||
static void interrupt_init(void)
|
||||
{
|
||||
|
|
@ -51,6 +52,9 @@ void z_prep_c(void)
|
|||
z_bss_zero();
|
||||
|
||||
interrupt_init();
|
||||
#if CONFIG_ARCH_CACHE
|
||||
arch_cache_init();
|
||||
#endif
|
||||
|
||||
z_cstart();
|
||||
CODE_UNREACHABLE;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include <zephyr/kernel_structs.h>
|
||||
#include <kernel_internal.h>
|
||||
#include <zephyr/platform/hooks.h>
|
||||
#include <zephyr/arch/cache.h>
|
||||
|
||||
/**
|
||||
* @brief Prepare to and run C code
|
||||
|
|
@ -49,6 +50,9 @@ void z_prep_c(void)
|
|||
*/
|
||||
z_nios2_dcache_flush_all();
|
||||
#endif
|
||||
#endif
|
||||
#if CONFIG_ARCH_CACHE
|
||||
arch_cache_init();
|
||||
#endif
|
||||
z_cstart();
|
||||
CODE_UNREACHABLE;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
#include <zephyr/kernel_structs.h>
|
||||
#include <kernel_internal.h>
|
||||
#include <zephyr/platform/hooks.h>
|
||||
#include <zephyr/arch/cache.h>
|
||||
|
||||
#if defined(CONFIG_RISCV_SOC_INTERRUPT_INIT)
|
||||
void soc_interrupt_init(void);
|
||||
|
|
@ -42,6 +43,9 @@ void z_prep_c(void)
|
|||
z_data_copy();
|
||||
#if defined(CONFIG_RISCV_SOC_INTERRUPT_INIT)
|
||||
soc_interrupt_init();
|
||||
#endif
|
||||
#if CONFIG_ARCH_CACHE
|
||||
arch_cache_init();
|
||||
#endif
|
||||
z_cstart();
|
||||
CODE_UNREACHABLE;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <kernel_internal.h>
|
||||
#include <zephyr/platform/hooks.h>
|
||||
#include <zephyr/arch/cache.h>
|
||||
|
||||
/**
|
||||
* @brief Prepare to and run C code
|
||||
|
|
@ -24,6 +25,9 @@ void z_prep_c(void)
|
|||
soc_prep_hook();
|
||||
#endif
|
||||
z_data_copy();
|
||||
#if CONFIG_ARCH_CACHE
|
||||
arch_cache_init();
|
||||
#endif
|
||||
z_cstart();
|
||||
CODE_UNREACHABLE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,3 +119,7 @@ int arch_dcache_flush_and_invd_range(void *start_addr, size_t size)
|
|||
{
|
||||
return arch_dcache_flush_range(start_addr, size);
|
||||
}
|
||||
|
||||
void arch_cache_init(void)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include <zephyr/arch/x86/efi.h>
|
||||
#include <x86_mmu.h>
|
||||
#include <zephyr/platform/hooks.h>
|
||||
#include <zephyr/arch/cache.h>
|
||||
|
||||
extern FUNC_NORETURN void z_cstart(void);
|
||||
extern void x86_64_irq_init(void);
|
||||
|
|
@ -76,6 +77,9 @@ FUNC_NORETURN void z_prep_c(void *arg)
|
|||
z_x86_set_stack_guard(z_interrupt_stacks[i]);
|
||||
}
|
||||
#endif
|
||||
#if CONFIG_ARCH_CACHE
|
||||
arch_cache_init();
|
||||
#endif
|
||||
|
||||
z_cstart();
|
||||
CODE_UNREACHABLE;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <zephyr/kernel.h>
|
||||
#include <kernel_internal.h>
|
||||
#include <zephyr/platform/hooks.h>
|
||||
#include <zephyr/arch/cache.h>
|
||||
|
||||
extern FUNC_NORETURN void z_cstart(void);
|
||||
|
||||
|
|
@ -71,6 +72,9 @@ void z_prep_c(void)
|
|||
memset(stack_start, 0xAA, stack_sz);
|
||||
}
|
||||
#endif
|
||||
#if CONFIG_ARCH_CACHE
|
||||
arch_cache_init();
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_XTENSA_MMU
|
||||
xtensa_mmu_init();
|
||||
|
|
|
|||
|
|
@ -236,6 +236,10 @@ static ALWAYS_INLINE void arch_icache_disable(void)
|
|||
|
||||
#endif /* CONFIG_ICACHE */
|
||||
|
||||
static ALWAYS_INLINE void arch_cache_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -349,6 +349,9 @@ void *arch_cache_uncached_ptr_get(void __sparse_cache *ptr);
|
|||
#define cache_uncached_ptr(ptr) arch_cache_uncached_ptr_get(ptr)
|
||||
#endif /* CONFIG_CACHE_DOUBLEMAP */
|
||||
|
||||
|
||||
void arch_cache_init(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -331,6 +331,10 @@ static inline void *arch_cache_uncached_ptr_get(void *ptr)
|
|||
}
|
||||
#endif
|
||||
|
||||
static ALWAYS_INLINE void arch_cache_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
|
|||
Loading…
Reference in a new issue