mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/4] ARM: start: Fix arm_mem_barebox_image for !CONFIG_RELOCATABLE
@ 2016-06-16 13:18 Sascha Hauer
  2016-06-16 13:18 ` [PATCH 2/4] ARM: start: do not change barebox_boarddata Sascha Hauer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sascha Hauer @ 2016-06-16 13:18 UTC (permalink / raw)
  To: Barebox List

Fixes: 65071bd arm: Clarify memory layout calculation

arm_mem_barebox_image() shall return the beginning of the barebox
image (and thus the end of the malloc region). For relocatable
images we can return a suitable location, but for non relocatable
images we do not have a choice: We must return TEXT_BASE. If TEXT_BASE
happens to be outside the memory region between membase and endmem
we can return the base of the ramoops area.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Markus Pargmann <mpa@pengutronix.de>
---
 arch/arm/include/asm/barebox-arm.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index 8e7b45c..0acdfa3 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -143,9 +143,13 @@ static inline unsigned long arm_mem_barebox_image(unsigned long membase,
 	if (IS_ENABLED(CONFIG_RELOCATABLE)) {
 		endmem -= size;
 		endmem &= ~(SZ_1M - 1);
+		return endmem;
+	} else {
+		if (TEXT_BASE >= membase && TEXT_BASE < endmem)
+			return TEXT_BASE;
+		else
+			return endmem;
 	}
-
-	return endmem;
 }
 
 #define ENTRY_FUNCTION(name, arg0, arg1, arg2)				\
-- 
2.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/4] ARM: start: do not change barebox_boarddata
  2016-06-16 13:18 [PATCH 1/4] ARM: start: Fix arm_mem_barebox_image for !CONFIG_RELOCATABLE Sascha Hauer
@ 2016-06-16 13:18 ` Sascha Hauer
  2016-06-16 13:18 ` [PATCH 3/4] ARM: start: simplify board_data sdram allocation Sascha Hauer
  2016-06-16 13:18 ` [PATCH 4/4] ARM: start: drop unnecessary variable Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2016-06-16 13:18 UTC (permalink / raw)
  To: Barebox List

barebox_boarddata should stay the original boarddata and not
be modified. Keep a local pointer in barebox_arm_boot_dtb()
instead.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/cpu/start.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index e037d91..d6a4c62 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -73,6 +73,10 @@ void *barebox_arm_boot_dtb(void)
 	void *data;
 	int ret;
 	struct barebox_arm_boarddata_compressed_dtb *compressed_dtb;
+	static void *boot_dtb;
+
+	if (boot_dtb)
+		return boot_dtb;
 
 	if (barebox_boarddata && blob_is_fdt(barebox_boarddata)) {
 		pr_debug("%s: using barebox_boarddata\n", __func__);
@@ -101,9 +105,9 @@ void *barebox_arm_boot_dtb(void)
 		return NULL;
 	}
 
-	barebox_boarddata = dtb;
+	boot_dtb = dtb;
 
-	return barebox_boarddata;
+	return boot_dtb;
 }
 
 static inline unsigned long arm_mem_boarddata(unsigned long membase,
-- 
2.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/4] ARM: start: simplify board_data sdram allocation
  2016-06-16 13:18 [PATCH 1/4] ARM: start: Fix arm_mem_barebox_image for !CONFIG_RELOCATABLE Sascha Hauer
  2016-06-16 13:18 ` [PATCH 2/4] ARM: start: do not change barebox_boarddata Sascha Hauer
@ 2016-06-16 13:18 ` Sascha Hauer
  2016-06-16 13:18 ` [PATCH 4/4] ARM: start: drop unnecessary variable Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2016-06-16 13:18 UTC (permalink / raw)
  To: Barebox List

We already have a pointer for barebox_boarddata, so use it to
request the corresponding SDRAM region instead of calculating
it again.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/cpu/start.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index d6a4c62..38f69d5 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -37,6 +37,7 @@ unsigned long arm_stack_top;
 static unsigned long arm_head_bottom;
 static unsigned long arm_barebox_size;
 static void *barebox_boarddata;
+static unsigned long barebox_boarddata_size;
 
 static bool blob_is_fdt(const void *blob)
 {
@@ -130,11 +131,9 @@ EXPORT_SYMBOL_GPL(arm_mem_ramoops_get);
 
 static int barebox_memory_areas_init(void)
 {
-	unsigned long start = arm_head_bottom;
-	unsigned long size = arm_mem_barebox_image(0, arm_stack_top,
-						   arm_barebox_size) -
-			     arm_head_bottom;
-	request_sdram_region("board data", start, size);
+	if(barebox_boarddata)
+		request_sdram_region("board data", (unsigned long)barebox_boarddata,
+				     barebox_boarddata_size);
 
 	return 0;
 }
@@ -201,6 +200,7 @@ __noreturn void barebox_non_pbl_start(unsigned long membase,
 				 name, mem);
 			barebox_boarddata = memcpy((void *)mem, boarddata,
 						   totalsize);
+			barebox_boarddata_size = totalsize;
 			arm_head_bottom = mem;
 		}
 	}
-- 
2.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 4/4] ARM: start: drop unnecessary variable
  2016-06-16 13:18 [PATCH 1/4] ARM: start: Fix arm_mem_barebox_image for !CONFIG_RELOCATABLE Sascha Hauer
  2016-06-16 13:18 ` [PATCH 2/4] ARM: start: do not change barebox_boarddata Sascha Hauer
  2016-06-16 13:18 ` [PATCH 3/4] ARM: start: simplify board_data sdram allocation Sascha Hauer
@ 2016-06-16 13:18 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2016-06-16 13:18 UTC (permalink / raw)
  To: Barebox List

No need anymore to store arm_head_bottom globally as it's only used
in barebox_non_pbl_start(). Also rename the variable to malloc_end
which is more meaningful.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/cpu/start.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index 38f69d5..f25e592 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -34,7 +34,6 @@
 #include "mmu-early.h"
 
 unsigned long arm_stack_top;
-static unsigned long arm_head_bottom;
 static unsigned long arm_barebox_size;
 static void *barebox_boarddata;
 static unsigned long barebox_boarddata_size;
@@ -162,7 +161,7 @@ __noreturn void barebox_non_pbl_start(unsigned long membase,
 
 	arm_stack_top = endmem;
 	arm_barebox_size = barebox_size;
-	arm_head_bottom = arm_mem_barebox_image(membase, endmem,
+	malloc_end = arm_mem_barebox_image(membase, endmem,
 						arm_barebox_size);
 
 	if (IS_ENABLED(CONFIG_MMU_EARLY)) {
@@ -201,12 +200,10 @@ __noreturn void barebox_non_pbl_start(unsigned long membase,
 			barebox_boarddata = memcpy((void *)mem, boarddata,
 						   totalsize);
 			barebox_boarddata_size = totalsize;
-			arm_head_bottom = mem;
+			malloc_end = mem;
 		}
 	}
 
-	malloc_end = arm_head_bottom;
-
 	/*
 	 * Maximum malloc space is the Kconfig value if given
 	 * or 1GB.
-- 
2.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-06-16 13:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-16 13:18 [PATCH 1/4] ARM: start: Fix arm_mem_barebox_image for !CONFIG_RELOCATABLE Sascha Hauer
2016-06-16 13:18 ` [PATCH 2/4] ARM: start: do not change barebox_boarddata Sascha Hauer
2016-06-16 13:18 ` [PATCH 3/4] ARM: start: simplify board_data sdram allocation Sascha Hauer
2016-06-16 13:18 ` [PATCH 4/4] ARM: start: drop unnecessary variable Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox