[rtems commit] bsp/qoriq: Fix bsp_restart()

Sebastian Huber sebh at rtems.org
Tue Mar 20 06:42:13 UTC 2018


Module:    rtems
Branch:    master
Commit:    5d44981c2d8891478423af82316576d00f6352ea
Changeset: http://git.rtems.org/rtems/commit/?id=5d44981c2d8891478423af82316576d00f6352ea

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Mar 20 07:34:22 2018 +0100

bsp/qoriq: Fix bsp_restart()

Update #3085.

---

 .../lib/libbsp/powerpc/qoriq/startup/bsprestart.c  | 19 ++++++++-------
 .../lib/libbsp/powerpc/qoriq/startup/mmu-config.c  | 27 +++++++++++-----------
 2 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/c/src/lib/libbsp/powerpc/qoriq/startup/bsprestart.c b/c/src/lib/libbsp/powerpc/qoriq/startup/bsprestart.c
index ac09971..36e751e 100644
--- a/c/src/lib/libbsp/powerpc/qoriq/startup/bsprestart.c
+++ b/c/src/lib/libbsp/powerpc/qoriq/startup/bsprestart.c
@@ -7,7 +7,7 @@
  */
 
 /*
- * Copyright (c) 2016 embedded brains GmbH.  All rights reserved.
+ * Copyright (c) 2016, 2018 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
  *  Dornierstr. 4
@@ -29,22 +29,21 @@
 
 #include <libcpu/powerpc-utility.h>
 
+#include <string.h>
+
+static char fdt_copy[BSP_FDT_BLOB_SIZE_MAX];
+
 static RTEMS_NO_RETURN void do_restart(void *addr)
 {
   void (*restart)(uintptr_t);
-  uintptr_t fdt;
 
   qoriq_reset_qman_and_bman();
 
-  restart = addr;
+  memcpy(fdt_copy, bsp_fdt_get(), sizeof(fdt_copy));
+  rtems_cache_flush_multiple_data_lines(fdt_copy, sizeof(fdt_copy));
 
-  fdt = (uintptr_t) bsp_fdt_get();
-#ifdef BSP_FDT_BLOB_READ_ONLY
-  fdt -= (uintptr_t) bsp_section_rodata_begin;
-  fdt += (uintptr_t) bsp_section_rodata_load_begin;
-#endif
-
-  (*restart)(fdt);
+  restart = addr;
+  (*restart)((uintptr_t) fdt_copy);
   bsp_fatal(QORIQ_FATAL_RESTART_FAILED);
 }
 
diff --git a/c/src/lib/libbsp/powerpc/qoriq/startup/mmu-config.c b/c/src/lib/libbsp/powerpc/qoriq/startup/mmu-config.c
index 91a6240..b59d9c7 100644
--- a/c/src/lib/libbsp/powerpc/qoriq/startup/mmu-config.c
+++ b/c/src/lib/libbsp/powerpc/qoriq/startup/mmu-config.c
@@ -258,33 +258,34 @@ static void TEXT config_fdt_adjust(const void *fdt)
 	if (node >= 0) {
 		int len;
 		const void *val;
-		uint64_t begin;
-		uint64_t size;
+		uint64_t mem_begin;
+		uint64_t mem_size;
 
 		val = fdt_getprop(fdt, node, "reg", &len);
 		if (len == 8) {
-			begin = fdt32_to_cpu(((fdt32_t *) val)[0]);
-			size = fdt32_to_cpu(((fdt32_t *) val)[1]);
+			mem_begin = fdt32_to_cpu(((fdt32_t *) val)[0]);
+			mem_size = fdt32_to_cpu(((fdt32_t *) val)[1]);
 		} else if (len == 16) {
-			begin = fdt64_to_cpu(((fdt64_t *) val)[0]);
-			size = fdt64_to_cpu(((fdt64_t *) val)[1]);
+			mem_begin = fdt64_to_cpu(((fdt64_t *) val)[0]);
+			mem_size = fdt64_to_cpu(((fdt64_t *) val)[1]);
 		} else {
-			begin = 0;
-			size = 0;
+			mem_begin = 0;
+			mem_size = 0;
 		}
 
 #ifndef __powerpc64__
-		size = MIN(size, 0x80000000U);
+		mem_size = MIN(mem_size, 0x80000000U);
 #endif
 
 		if (
-			begin == 0
-				&& size > (uintptr_t) bsp_section_work_end
+			mem_begin == 0
+				&& mem_size > (uintptr_t) bsp_section_work_end
 				&& (uintptr_t) bsp_section_nocache_end
 					< (uintptr_t) bsp_section_work_end
 		) {
-			config[WORKSPACE_ENTRY_INDEX].size += (uintptr_t) size
-				- (uintptr_t) bsp_section_work_end;
+			/* Assign new value to allow a bsp_restart() */
+			config[WORKSPACE_ENTRY_INDEX].size = (uintptr_t) mem_size
+				- (uintptr_t) bsp_section_work_begin;
 		}
 	}
 }



More information about the vc mailing list