[rtems commit] bsp/qoriq: Adjust workspace according to FDT

Sebastian Huber sebh at rtems.org
Thu Mar 2 14:27:12 UTC 2017


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Mar  2 15:25:34 2017 +0100

bsp/qoriq: Adjust workspace according to FDT

---

 c/src/lib/libbsp/powerpc/qoriq/Makefile.am         |  1 -
 .../lib/libbsp/powerpc/qoriq/startup/mmu-config.c  | 74 ++++++++++++++++++++--
 2 files changed, 70 insertions(+), 5 deletions(-)

diff --git a/c/src/lib/libbsp/powerpc/qoriq/Makefile.am b/c/src/lib/libbsp/powerpc/qoriq/Makefile.am
index 1416a20..64ef08d 100644
--- a/c/src/lib/libbsp/powerpc/qoriq/Makefile.am
+++ b/c/src/lib/libbsp/powerpc/qoriq/Makefile.am
@@ -57,7 +57,6 @@ libbsp_a_SOURCES += \
 	../../shared/sbrk.c \
 	../../shared/gnatinstallhandler.c \
 	../../shared/bspclean.c \
-	../../shared/bspgetworkarea.c \
 	../../shared/src/bsp-fdt.c \
 	../shared/src/ppc-exc-handler-table.c \
 	../shared/src/tictac.c \
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 414bcb4..def9d52 100644
--- a/c/src/lib/libbsp/powerpc/qoriq/startup/mmu-config.c
+++ b/c/src/lib/libbsp/powerpc/qoriq/startup/mmu-config.c
@@ -7,7 +7,7 @@
  */
 
 /*
- * Copyright (c) 2011-2015 embedded brains GmbH.  All rights reserved.
+ * Copyright (c) 2011, 2017 embedded brains GmbH.  All rights reserved.
  *
  *  embedded brains GmbH
  *  Dornierstr. 4
@@ -21,10 +21,18 @@
  */
 
 #include <bsp.h>
-#include <bsp/mmu.h>
+#include <bsp/bootcard.h>
+#include <bsp/fdt.h>
 #include <bsp/linker-symbols.h>
+#include <bsp/mmu.h>
 #include <bsp/qoriq.h>
 
+#include <sys/param.h>
+
+#include <libfdt.h>
+
+#include <rtems/config.h>
+
 #define TEXT __attribute__((section(".bsp_start_text")))
 #define DATA __attribute__((section(".bsp_start_data")))
 
@@ -95,7 +103,12 @@ typedef struct {
 	.mas7 = QORIQ_MMU_DEVICE_MAS7 \
 }
 
-static const entry DATA config [] = {
+#define WORKSPACE_ENTRY_INDEX 0
+
+static entry DATA config[] = {
+	/* Must be first entry, see WORKSPACE_ENTRY_INDEX */
+	ENTRY_RW(bsp_section_work_begin, bsp_section_work_size),
+
 	#if defined(RTEMS_MULTIPROCESSING) && \
 	    defined(QORIQ_INTERCOM_AREA_BEGIN) && \
 	    defined(QORIQ_INTERCOM_AREA_SIZE)
@@ -119,7 +132,6 @@ static const entry DATA config [] = {
 	ENTRY_RW(bsp_section_sbss_begin, bsp_section_sbss_size),
 	ENTRY_RW(bsp_section_bss_begin, bsp_section_bss_size),
 	ENTRY_RW(bsp_section_rwextra_begin, bsp_section_rwextra_size),
-	ENTRY_RW(bsp_section_work_begin, bsp_section_work_size),
 	ENTRY_RW(bsp_section_stack_begin, bsp_section_stack_size),
 	ENTRY_IO(bsp_section_nocache_begin, bsp_section_nocache_size),
 	ENTRY_IO(bsp_section_nocachenoload_begin, bsp_section_nocachenoload_size),
@@ -134,11 +146,52 @@ static const entry DATA config [] = {
 	ENTRY_DEV(&qoriq, sizeof(qoriq))
 };
 
+static DATA char memory_path[] = "/memory";
+
+static void TEXT config_fdt_adjust(void)
+{
+	const void *fdt = bsp_fdt_get();
+	int node;
+
+	node = fdt_path_offset_namelen(
+		fdt,
+		memory_path,
+		(int) sizeof(memory_path) - 1
+	);
+
+	if (node >= 0) {
+		int len;
+		const void *val;
+		uint64_t begin;
+		uint64_t 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]);
+		} else if (len == 16) {
+			begin = fdt64_to_cpu(((fdt64_t *) val)[0]);
+			size = fdt64_to_cpu(((fdt64_t *) val)[1]);
+		} else {
+			begin = 0;
+			size = 0;
+		}
+
+		size = MAX(size, 0x80000000U);
+
+		if (begin == 0 && size > (uintptr_t) bsp_section_work_end) {
+			config[WORKSPACE_ENTRY_INDEX].size += (uintptr_t) size
+				- (uintptr_t) bsp_section_work_end;
+		}
+	}
+}
+
 void TEXT qoriq_mmu_config(int first_tlb, int scratch_tlb)
 {
 	qoriq_mmu_context context;
 	int i = 0;
 
+	config_fdt_adjust();
 	qoriq_mmu_context_init(&context);
 
 	for (i = 0; i < QORIQ_TLB1_ENTRY_COUNT; ++i) {
@@ -165,3 +218,16 @@ void TEXT qoriq_mmu_config(int first_tlb, int scratch_tlb)
 	qoriq_mmu_partition(&context, (3 * QORIQ_TLB1_ENTRY_COUNT) / 4);
 	qoriq_mmu_write_to_tlb1(&context, first_tlb);
 }
+
+void TEXT bsp_work_area_initialize(void)
+{
+	const entry *we = &config[WORKSPACE_ENTRY_INDEX];
+	uintptr_t begin = we->begin;
+	uintptr_t end = begin + we->size;
+
+#ifdef BSP_INTERRUPT_STACK_AT_WORK_AREA_BEGIN
+	begin += rtems_configuration_get_interrupt_stack_size();
+#endif
+
+	bsp_work_area_initialize_default((void *) begin, end - begin);
+}




More information about the vc mailing list