From 2294da24d78ca55a77938b63c69c786a933a4a7c Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Mon, 8 Jul 2024 16:36:30 -0400 Subject: [PATCH] arc: start mpu in prep_c, do not use SYS_INIT Initialize MPU in prep_c similar to how all other architectures do it, avoid use of SYS_INIT. Signed-off-by: Anas Nashif --- arch/arc/core/mpu/arc_mpu_common_internal.h | 6 +----- arch/arc/core/mpu/arc_mpu_v4_internal.h | 10 ++++------ arch/arc/core/prep_c.c | 5 +++++ 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/arch/arc/core/mpu/arc_mpu_common_internal.h b/arch/arc/core/mpu/arc_mpu_common_internal.h index a9ff5518b2f..15758ed15f6 100644 --- a/arch/arc/core/mpu/arc_mpu_common_internal.h +++ b/arch/arc/core/mpu/arc_mpu_common_internal.h @@ -238,7 +238,7 @@ int arc_core_mpu_buffer_validate(const void *addr, size_t size, int write) * This function provides the default configuration mechanism for the Memory * Protection Unit (MPU). */ -static int arc_mpu_init(void) +void arc_mpu_init(void) { uint32_t num_regions = get_num_regions(); @@ -246,7 +246,6 @@ static int arc_mpu_init(void) if (mpu_config.num_regions > num_regions) { __ASSERT(0, "Request to configure: %u regions (supported: %u)\n", mpu_config.num_regions, num_regions); - return -EINVAL; } /* Disable MPU */ @@ -278,10 +277,7 @@ static int arc_mpu_init(void) /* Enable MPU */ arc_core_mpu_enable(); - - return 0; } -SYS_INIT(arc_mpu_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); #endif /* ZEPHYR_ARCH_ARC_CORE_MPU_ARC_MPU_COMMON_INTERNAL_H_ */ diff --git a/arch/arc/core/mpu/arc_mpu_v4_internal.h b/arch/arc/core/mpu/arc_mpu_v4_internal.h index 3bf6fca6c43..1323f1ebda2 100644 --- a/arch/arc/core/mpu/arc_mpu_v4_internal.h +++ b/arch/arc/core/mpu/arc_mpu_v4_internal.h @@ -814,7 +814,7 @@ int arc_core_mpu_buffer_validate(const void *addr, size_t size, int write) * This function provides the default configuration mechanism for the Memory * Protection Unit (MPU). */ -static int arc_mpu_init(void) +void arc_mpu_init(void) { uint32_t num_regions; uint32_t i; @@ -826,7 +826,7 @@ static int arc_mpu_init(void) __ASSERT(0, "Request to configure: %u regions (supported: %u)\n", mpu_config.num_regions, num_regions); - return -EINVAL; + return; } static_regions_num = 0U; @@ -851,7 +851,7 @@ static int arc_mpu_init(void) MPU_DYNAMIC_REGION_AREAS_NUM) { LOG_ERR("not enough dynamic regions %d", dynamic_regions_num); - return -EINVAL; + return; } dyn_reg_info[dynamic_regions_num].index = i; @@ -886,10 +886,8 @@ static int arc_mpu_init(void) /* Enable MPU */ arc_core_mpu_enable(); - return 0; + return; } -SYS_INIT(arc_mpu_init, PRE_KERNEL_1, - CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); #endif /* ZEPHYR_ARCH_ARC_CORE_MPU_ARC_MPU_V4_INTERNAL_H_ */ diff --git a/arch/arc/core/prep_c.c b/arch/arc/core/prep_c.c index dfe7dad7008..e9b39dc54fc 100644 --- a/arch/arc/core/prep_c.c +++ b/arch/arc/core/prep_c.c @@ -115,6 +115,8 @@ static void dev_state_zero(void) #endif extern FUNC_NORETURN void z_cstart(void); +extern void arc_mpu_init(void); + /** * @brief Prepare to and run C code * @@ -138,6 +140,9 @@ void z_prep_c(void) z_data_copy(); #if CONFIG_ARCH_CACHE arch_cache_init(); +#endif +#ifdef CONFIG_ARC_MPU + arc_mpu_init(); #endif z_cstart(); CODE_UNREACHABLE;