From 35da1042a40acb74b716e68b777a3605fe5c0076 Mon Sep 17 00:00:00 2001 From: Arnaud Pouliquen Date: Thu, 25 Sep 2025 13:12:57 +0200 Subject: [PATCH 1/2] arch: arm: mmu: introduce NORMAL and STRONGLY_ORDERED flags Add new flag to allow to select normal non-cacheable memory. This is needed for armV7 to be able to configure non cacheable memories with normal attribute instead of "device" attribute. Signed-off-by: Arnaud Pouliquen --- include/zephyr/arch/arm/mmu/arm_mem.h | 17 +++++++++++++++++ include/zephyr/kernel/mm.h | 2 ++ 2 files changed, 19 insertions(+) create mode 100644 include/zephyr/arch/arm/mmu/arm_mem.h diff --git a/include/zephyr/arch/arm/mmu/arm_mem.h b/include/zephyr/arch/arm/mmu/arm_mem.h new file mode 100644 index 0000000000000..55a880cae8b7d --- /dev/null +++ b/include/zephyr/arch/arm/mmu/arm_mem.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2025 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ +#ifndef ZEPHYR_INCLUDE_ARCH_ARM_ARM_MEM_H_ +#define ZEPHYR_INCLUDE_ARCH_ARM_ARM_MEM_H_ + +/* + * Define ARM specific memory flags used by k_mem_map_phys_bare() + * followed public definitions in include/kernel/mm.h. + */ + +/** ARM Specific flags: normal memory with Non-cacheable */ +#define K_MEM_ARM_NORMAL_NC 5 + +#endif /* ZEPHYR_INCLUDE_ARCH_ARM_ARM_MEM_H_ */ diff --git a/include/zephyr/kernel/mm.h b/include/zephyr/kernel/mm.h index 79c3dc4815f97..51eef148040e6 100644 --- a/include/zephyr/kernel/mm.h +++ b/include/zephyr/kernel/mm.h @@ -11,6 +11,8 @@ #include #if defined(CONFIG_ARM_MMU) && defined(CONFIG_ARM64) #include +#elif defined(CONFIG_ARM_AARCH32_MMU) +#include #endif /* CONFIG_ARM_MMU && CONFIG_ARM64 */ #include From dd7db5f7dc929447f4082929c0d7dcaf688a1e95 Mon Sep 17 00:00:00 2001 From: Arnaud Pouliquen Date: Thu, 25 Sep 2025 14:15:44 +0200 Subject: [PATCH 2/2] arch: arm: mmu: allow to select the K_MEM_ARM_NORMAL_NC memory type Allow to configure the MMU for non-cacheable normal memories. This mode is needed for instance by net samples to access to to non word-aligned memory. Signed-off-by: Arnaud Pouliquen --- arch/arm/core/mmu/arm_mmu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/core/mmu/arm_mmu.c b/arch/arm/core/mmu/arm_mmu.c index 62ef1492557c7..cdf099d253b0c 100644 --- a/arch/arm/core/mmu/arm_mmu.c +++ b/arch/arm/core/mmu/arm_mmu.c @@ -890,6 +890,9 @@ static int __arch_mem_map(void *virt, uintptr_t phys, size_t size, uint32_t flag switch (flags & K_MEM_CACHE_MASK) { + case K_MEM_ARM_NORMAL_NC: + conv_flags |= MT_NORMAL; + break; case K_MEM_CACHE_NONE: default: conv_flags |= MT_DEVICE;