[PATCH v2 6/9] ARM: add CONFIG_SCRATCH_SIZE

Michael Tretter m.tretter at pengutronix.de
Wed May 28 07:11:24 PDT 2025


CONFIG_SCRATCH_SIZE allows to configure the size of the scratch area for
passing data from the PBL to barebox proper.

It may be also used to pass data from the PBL to other firmware or use
it for passing data back to barebox, the size should be configurable.
Since this may be more than 32K, the size should be configurable.

Since other sizes in the memory layout are configurable as well, the
memory layout isn't static.

Signed-off-by: Michael Tretter <m.tretter at pengutronix.de>
---
Changes in v2:
- new patch
---
 arch/arm/include/asm/barebox-arm.h  | 4 ++--
 common/Kconfig                      | 5 +++++
 include/asm-generic/memory_layout.h | 1 +
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index 7d35e88c812393d45e331f238baecfa91cbbe299..1ad863681a04b3172be5ecd3f7fbc5ca11f3c3d7 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -61,7 +61,7 @@ void *barebox_arm_boot_dtb(void);
  *                                   ↓
  *  ---------- arm_mem_optee() / arm_mem_barebox_image_end() ----------
  *                                   ↑
- *                                 SZ_32K
+ *                              SCRATCH_SIZE
  *                                   ↓
  *  ------------------------ arm_mem_scratch() ------------------------
  *                                   ↑
@@ -105,7 +105,7 @@ static inline unsigned long arm_mem_barebox_image_end(unsigned long endmem)
 
 static inline unsigned long arm_mem_scratch(unsigned long endmem)
 {
-	return arm_mem_optee(endmem) - SZ_32K;
+	return arm_mem_optee(endmem) - SCRATCH_SIZE;
 }
 
 static inline unsigned long arm_mem_stack(unsigned long endmem)
diff --git a/common/Kconfig b/common/Kconfig
index fe50da8f3084a9d4f3b659b8a5db049b3324ce0a..4186c499b3a9012ce2ba8c7a0909c7b2bffa42bd 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -300,6 +300,11 @@ config MALLOC_SIZE
 	default 0x400000
 	prompt "malloc area size"
 
+config SCRATCH_SIZE
+	hex
+	default 0x8000
+	prompt "Scratch size"
+
 config MALLOC_ALIGNMENT
 	hex
 	default 8
diff --git a/include/asm-generic/memory_layout.h b/include/asm-generic/memory_layout.h
index 6af1db8113f2226bc30710cee35e2aecf290b15c..39af73849796fd1954521f0b53bf38fcb0984cef 100644
--- a/include/asm-generic/memory_layout.h
+++ b/include/asm-generic/memory_layout.h
@@ -28,6 +28,7 @@
 #define HEAD_TEXT_BASE MALLOC_BASE
 #define MALLOC_SIZE CONFIG_MALLOC_SIZE
 #define STACK_SIZE  CONFIG_STACK_SIZE
+#define SCRATCH_SIZE	CONFIG_SCRATCH_SIZE
 
 /*
  * This generates a useless load from the specified symbol

-- 
2.39.5




More information about the barebox mailing list