[rtems commit] bsp/riscv: Add device tree support

Sebastian Huber sebh at rtems.org
Fri Jun 29 09:57:00 UTC 2018


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Jun 22 08:01:48 2018 +0200

bsp/riscv: Add device tree support

Update #3433.

---

 bsps/riscv/riscv/include/bsp.h            |  2 ++
 bsps/riscv/riscv/start/start.S            | 18 ++++++++++++------
 c/src/lib/libbsp/riscv/riscv/Makefile.am  |  1 +
 c/src/lib/libbsp/riscv/riscv/configure.ac | 12 ++++++++++++
 4 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/bsps/riscv/riscv/include/bsp.h b/bsps/riscv/riscv/include/bsp.h
index 79f359a..6298966 100644
--- a/bsps/riscv/riscv/include/bsp.h
+++ b/bsps/riscv/riscv/include/bsp.h
@@ -44,6 +44,8 @@
 extern "C" {
 #endif
 
+#define BSP_FDT_IS_SUPPORTED
+
 /**
   * @defgroup riscv_generic Register Definitions
   *
diff --git a/bsps/riscv/riscv/start/start.S b/bsps/riscv/riscv/start/start.S
index 1d0bde1..f40ceef 100644
--- a/bsps/riscv/riscv/start/start.S
+++ b/bsps/riscv/riscv/start/start.S
@@ -27,10 +27,11 @@
  * SUCH DAMAGE.
  */
 
-#include <bsp/linker-symbols.h>
-#include <rtems/score/riscv-utility.h>
-#include <rtems/score/cpu.h>
 #include <rtems/asm.h>
+#include <rtems/score/cpu.h>
+#include <rtems/score/riscv-utility.h>
+#include <bsp/linker-symbols.h>
+#include <bspopts.h>
 
 EXTERN(bsp_section_bss_begin)
 EXTERN(bsp_section_bss_end)
@@ -57,12 +58,17 @@ SYM(_start):
 	bnez	s0, .Lloop_forever
 #endif
 
-	la	t0, ISR_Handler
-	csrw	mtvec, t0
-
 	/* load stack and frame pointers */
 	la	sp, _Configuration_Interrupt_stack_area_end
 
+#ifdef BSP_START_COPY_FDT_FROM_U_BOOT
+	mv	a0, a1
+	call	bsp_fdt_copy
+#endif
+
+	la	t0, ISR_Handler
+	csrw	mtvec, t0
+
 	/* Clear .bss */
 	la	a0, bsp_section_bss_begin
 	li	a1, 0
diff --git a/c/src/lib/libbsp/riscv/riscv/Makefile.am b/c/src/lib/libbsp/riscv/riscv/Makefile.am
index 0830b4f..bc5355f 100644
--- a/c/src/lib/libbsp/riscv/riscv/Makefile.am
+++ b/c/src/lib/libbsp/riscv/riscv/Makefile.am
@@ -39,6 +39,7 @@ librtemsbsp_a_SOURCES += ../../../../../../bsps/riscv/riscv/start/bsp_fatal_halt
 # Shared
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/bspfatal-default.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/dev/getentropy/getentropy-cpucounter.c
+librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/bsp-fdt.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/stackalloc.c
 librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/bspgetworkarea-default.c
 
diff --git a/c/src/lib/libbsp/riscv/riscv/configure.ac b/c/src/lib/libbsp/riscv/riscv/configure.ac
index b699a8b..9d13210 100644
--- a/c/src/lib/libbsp/riscv/riscv/configure.ac
+++ b/c/src/lib/libbsp/riscv/riscv/configure.ac
@@ -15,6 +15,18 @@ RTEMS_CANONICAL_TARGET_CPU
 AM_INIT_AUTOMAKE([no-define nostdinc foreign 1.12.2])
 RTEMS_BSP_CONFIGURE
 
+RTEMS_BSPOPTS_SET([BSP_START_COPY_FDT_FROM_U_BOOT],[*],[1])
+RTEMS_BSPOPTS_HELP([BSP_START_COPY_FDT_FROM_U_BOOT],[copy the U-Boot provided FDT to an internal storage])
+
+RTEMS_BSPOPTS_SET([BSP_FDT_BLOB_SIZE_MAX],[*],[65536])
+RTEMS_BSPOPTS_HELP([BSP_FDT_BLOB_SIZE_MAX],[maximum size of the FDT blob in bytes])
+
+RTEMS_BSPOPTS_SET([BSP_FDT_BLOB_READ_ONLY],[*],[1])
+RTEMS_BSPOPTS_HELP([BSP_FDT_BLOB_READ_ONLY],[place the FDT blob into the read-only data area])
+
+RTEMS_BSPOPTS_SET([BSP_FDT_BLOB_COPY_TO_READ_ONLY_LOAD_AREA],[*],[1])
+RTEMS_BSPOPTS_HELP([BSP_FDT_BLOB_COPY_TO_READ_ONLY_LOAD_AREA],[copy the FDT blob into the read-only load area via bsp_fdt_copy()])
+
 RTEMS_BSP_CLEANUP_OPTIONS
 
 case "${RTEMS_BSP}" in




More information about the vc mailing list