diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c index 0599c57..a825e9f 100644 --- a/arch/arm/cpu/start-pbl.c +++ b/arch/arm/cpu/start-pbl.c @@ -32,7 +32,7 @@ #include #include -#include "mmu.h" +#include "mmu-early.h" unsigned long free_mem_ptr; unsigned long free_mem_end_ptr; @@ -83,6 +83,12 @@ setup_c(); + if (IS_ENABLED(CONFIG_MMU_EARLY)) { + endmem &= ~0x3fff; + endmem -= SZ_16K; /* ttb */ + mmu_early_enable(membase, memsize, endmem); + } + endmem -= SZ_128K; /* early malloc */ free_mem_ptr = endmem; free_mem_end_ptr = free_mem_ptr + SZ_128K; diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c index a621161..d90b244 100644 --- a/arch/arm/cpu/start.c +++ b/arch/arm/cpu/start.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -26,6 +27,8 @@ #include #include +#include "mmu-early.h" + unsigned long arm_stack_top; static noinline __noreturn void __start(uint32_t membase, uint32_t memsize, @@ -38,6 +41,15 @@ arm_stack_top = endmem; endmem -= STACK_SIZE; /* Stack */ + if (IS_ENABLED(CONFIG_MMU_EARLY)) { + + endmem &= ~0x3fff; + endmem -= SZ_16K; /* ttb */ + + if (!IS_ENABLED(CONFIG_PBL_IMAGE)) + mmu_early_enable(membase, memsize, endmem); + } + start_barebox(); } diff --git a/common/Kconfig b/common/Kconfig index 595e91f..3f6c11e 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -114,6 +114,15 @@ to enable the data cache which depends on the MMU. See Documentation/mmu.txt for further information. +config MMU_EARLY + bool "Enable MMU early" + depends on ARM + depends on MMU + default y + help + 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_CONFIGURABLE_TEXT_BASE bool