[PATCH 16/17] bsp/riscv: Add device tree support

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Jun 22 11:59:13 UTC 2018


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 79f359ac34..6298966a8c 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 2c560cea35..2794213307 100644
--- a/bsps/riscv/riscv/start/start.S
+++ b/bsps/riscv/riscv/start/start.S
@@ -29,10 +29,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 0830b4f639..bc5355f585 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 338c0d4dc9..aaad13069c 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
 
 AC_DEFUN([RISCV_LINKCMD],[
-- 
2.13.7




More information about the devel mailing list