Linux expects the MMU to be off on boot as does barebox, when being chainloaded. However for running executables or for testing things, booting with the MMU (and thus the caches) on can be nice. Support this, by having architectures define HAVE_MMU_OFF_FOR_BOOT, if they are turning off the MMU. These architectures are then supposed to implement mmu_boot_enabled(), which should disable turning off the MMU on barebox shutdown. A follow-up commit will add a new -m flag to the go command that calls this function. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- This is similiar to the U-Boot go command, but safer. Devices are shut down and cache maintenance is done correctly. The command might not be of much generic use at the moment, but I occasionly found it useful. --- arch/arm/Kconfig | 1 + arch/arm/cpu/cpu.c | 13 +++++++++++-- common/Kconfig | 3 +++ include/mmu.h | 9 +++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 480c6f011797..b312aabacb72 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -4,6 +4,7 @@ config ARM select HAS_CACHE select HAVE_CONFIGURABLE_TEXT_BASE if !RELOCATABLE select HAVE_IMAGE_COMPRESSION + select HAVE_MMU_OFF_FOR_BOOT default y config ARM_LINUX diff --git a/arch/arm/cpu/cpu.c b/arch/arm/cpu/cpu.c index c5daf6c60efe..65566006693e 100644 --- a/arch/arm/cpu/cpu.c +++ b/arch/arm/cpu/cpu.c @@ -25,6 +25,7 @@ #include <init.h> #include <command.h> #include <cache.h> +#include <mmu.h> #include <asm/mmu.h> #include <asm/system.h> #include <asm/memory.h> @@ -90,6 +91,12 @@ static void disable_interrupts(void) #endif } +static bool _mmu_boot_enabled; +void mmu_boot_enabled(void) +{ + _mmu_boot_enabled = true; +} + /** * Disable MMU and D-cache, flush caches * @return 0 (always) @@ -99,9 +106,11 @@ static void disable_interrupts(void) */ static void arch_shutdown(void) { - #ifdef CONFIG_MMU - mmu_disable(); + if (!_mmu_boot_enabled) + mmu_disable(); + else + arm_early_mmu_cache_flush(); #endif icache_invalidate(); diff --git a/common/Kconfig b/common/Kconfig index f5777a304cf5..4628e72c0e3f 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -209,6 +209,9 @@ config MMU_EARLY This enables the MMU during early startup. This speeds up things during startup of barebox, but may lead to harder to debug code. If unsure say yes here. +config HAVE_MMU_OFF_FOR_BOOT + bool + config HAVE_CONFIGURABLE_TEXT_BASE bool diff --git a/include/mmu.h b/include/mmu.h index 66b246f6d270..06939ab97175 100644 --- a/include/mmu.h +++ b/include/mmu.h @@ -38,4 +38,13 @@ static inline int remap_range(void *start, size_t size, unsigned flags) return arch_remap_range(start, size, flags); } +#ifdef CONFIG_HAVE_MMU_OFF_FOR_BOOT +void mmu_boot_enabled(void); +#else +static inline void mmu_boot_enabled(void) +{ +} +#endif + + #endif -- 2.23.0 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox