[PATCH 4/6] cmdline: Add cmdline support

andreas.koelbl at st.oth-regensburg.de andreas.koelbl at st.oth-regensburg.de
Mon Jul 31 22:27:21 UTC 2017


From: Andreas Kölbl <andreas.koelbl at st.oth-regensburg.de>

---
 c/src/lib/libbsp/arm/jetson-tk1/Makefile.am        |  2 ++
 c/src/lib/libbsp/arm/jetson-tk1/include/cmdline.h  | 17 ++++++++++
 c/src/lib/libbsp/arm/jetson-tk1/misc/cmdline.c     | 38 ++++++++++++++++++++++
 c/src/lib/libbsp/arm/jetson-tk1/start/start.S      |  6 +++-
 .../lib/libbsp/arm/jetson-tk1/startup/linkcmds.in  |  4 ++-
 5 files changed, 65 insertions(+), 2 deletions(-)
 create mode 100644 c/src/lib/libbsp/arm/jetson-tk1/include/cmdline.h
 create mode 100644 c/src/lib/libbsp/arm/jetson-tk1/misc/cmdline.c

diff --git a/c/src/lib/libbsp/arm/jetson-tk1/Makefile.am b/c/src/lib/libbsp/arm/jetson-tk1/Makefile.am
index 9fc1695cba..37d2ca267e 100644
--- a/c/src/lib/libbsp/arm/jetson-tk1/Makefile.am
+++ b/c/src/lib/libbsp/arm/jetson-tk1/Makefile.am
@@ -40,6 +40,7 @@ include_bsp_HEADERS += ../shared/armv467ar-basic-cache/cache_.h
 
 include_bsp_HEADERS += include/car.h
 include_bsp_HEADERS += include/console.h
+include_bsp_HEADERS += include/cmdline.h
 include_bsp_HEADERS += include/irq.h
 include_bsp_HEADERS += include/memory.h
 include_bsp_HEADERS += include/mmu.h
@@ -123,6 +124,7 @@ libbsp_a_SOURCES += startup/mm_config_table.c
 libbsp_a_SOURCES += ../shared/mminit.c
 
 # misc
+libbsp_a_SOURCES += misc/cmdline.c
 libbsp_a_SOURCES += misc/timer.c
 
 ###############################################################################
diff --git a/c/src/lib/libbsp/arm/jetson-tk1/include/cmdline.h b/c/src/lib/libbsp/arm/jetson-tk1/include/cmdline.h
new file mode 100644
index 0000000000..d50bfaaed0
--- /dev/null
+++ b/c/src/lib/libbsp/arm/jetson-tk1/include/cmdline.h
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) OTH Regensburg, 2017
+ *   Author: Andreas Kölbl
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#ifndef LIBBSP_ARM_JETSONTK1_CMDLINE_H
+#define LIBBSP_ARM_JETSONTK1_CMDLINE_H
+
+#include <bspopts.h>
+
+#define BSP_CMDLINE_LOCATION (TEGRA_BASE + MEMORY_SIZE - 0x4000)
+
+#endif /* LIBBSP_ARM_JETSONTK1_CMDLINE_H */
diff --git a/c/src/lib/libbsp/arm/jetson-tk1/misc/cmdline.c b/c/src/lib/libbsp/arm/jetson-tk1/misc/cmdline.c
new file mode 100644
index 0000000000..fae2769ef4
--- /dev/null
+++ b/c/src/lib/libbsp/arm/jetson-tk1/misc/cmdline.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) OTH Regensburg, 2017
+ *   Author: Andreas Kölbl
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#include <bsp.h>
+#include <bsp/cmdline.h>
+#include <rtems/bspcmdline.h>
+#include <rtems/bspIo.h>
+
+#define ARM_MAX_CPU_COUNT 4
+
+#define DEFAULT_BOOT_CPU (1 << 0)
+
+uint8_t bsp_get_boot_cpu( void ) {
+  char boot_cpu_str[32];
+  char c;
+
+  if ( rtems_bsp_cmdline_get_param_rhs("boot_cpu", boot_cpu_str,
+         sizeof(boot_cpu_str)) == NULL ) {
+    printk("No boot cpu argument provided %x\n", BSP_CMDLINE_LOCATION);
+
+    return DEFAULT_BOOT_CPU;
+  }
+
+  c = boot_cpu_str[0];
+  if ( (c >= '0') && (c < '0' + ARM_MAX_CPU_COUNT) ) {
+    return c - '0';
+  }
+
+  printk("Warning: Invalid boot CPU '%c'\n", c == 0 ? '?' : c);
+
+  return DEFAULT_BOOT_CPU;
+}
diff --git a/c/src/lib/libbsp/arm/jetson-tk1/start/start.S b/c/src/lib/libbsp/arm/jetson-tk1/start/start.S
index bb984189ba..af9107188f 100644
--- a/c/src/lib/libbsp/arm/jetson-tk1/start/start.S
+++ b/c/src/lib/libbsp/arm/jetson-tk1/start/start.S
@@ -30,6 +30,7 @@
 	
 #include <bspopts.h>
 #include <bsp/irq.h>
+#include <bsp/cmdline.h>
 #include <bsp/linker-symbols.h>
 
 	/* External symbols */
@@ -363,7 +364,7 @@ bsp_vector_table_copy_done:
 	bl	bsp_start_hook_1
 
 	/* Branch to boot card */
-	mov	r0, #0
+	ldr r0, bsp_cmdline_location
 	bl	boot_card
 
 twiddle:
@@ -373,6 +374,9 @@ twiddle:
 
 	b	twiddle
 
+bsp_cmdline_location:
+	.word BSP_CMDLINE_LOCATION
+
 #elif defined(ARM_MULTILIB_ARCH_V7M)
 
 #include <rtems/score/armv7m.h>
diff --git a/c/src/lib/libbsp/arm/jetson-tk1/startup/linkcmds.in b/c/src/lib/libbsp/arm/jetson-tk1/startup/linkcmds.in
index f37a62faed..ddc19c5097 100644
--- a/c/src/lib/libbsp/arm/jetson-tk1/startup/linkcmds.in
+++ b/c/src/lib/libbsp/arm/jetson-tk1/startup/linkcmds.in
@@ -1,7 +1,9 @@
 bsp_mmu_size = 16k;
+bsp_cmdline_size = 16k;
 
 MEMORY {
-  RAM         (AIW) : ORIGIN = @TEGRA_BASE@, LENGTH = @MEMORY_SIZE@ - bsp_mmu_size
+  RAM         (AIW) : ORIGIN = @TEGRA_BASE@, LENGTH = @MEMORY_SIZE@ - bsp_mmu_size - bsp_cmdline_size
+  CMD         (AR)  : ORIGIN = @TEGRA_BASE@ + @MEMORY_SIZE@ - bsp_mmu_size - bsp_cmdline_size, LENGTH = bsp_cmdline_size
   RAM_MMU     (AIW) : ORIGIN = @TEGRA_BASE@ + @MEMORY_SIZE@ - bsp_mmu_size, LENGTH = bsp_mmu_size
 }
 
-- 
2.13.3




More information about the devel mailing list