[PATCH 3/4] arm/raspberrypi: add cmdline support for rpi bsp

Pavel Pisa ppisa4lists at pikron.com
Thu Apr 28 11:27:53 UTC 2016


From: YANG Qiao <yangqiao0505 at me.com>
Date: Thu, 13 Aug 2015 00:05:52 +0200

---
 c/src/lib/libbsp/arm/raspberrypi/Makefile.am       |  1 +
 c/src/lib/libbsp/arm/raspberrypi/include/bsp.h     |  5 +++
 .../lib/libbsp/arm/raspberrypi/startup/bspstart.c  |  1 +
 .../libbsp/arm/raspberrypi/startup/bspstarthooks.c |  2 ++
 c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c | 40 ++++++++++++++++++++++
 5 files changed, 49 insertions(+)
 create mode 100644 c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c

diff --git a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
index 91f327e..258f8a0 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
+++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
@@ -95,6 +95,7 @@ libbsp_a_SOURCES += ../shared/arm-cp15-set-ttb-entries.c
 # Startup
 libbsp_a_SOURCES += ../../shared/bspreset_loop.c
 libbsp_a_SOURCES += startup/bspstart.c
+libbsp_a_SOURCES += startup/cmdline.c
 
 # IRQ
 libbsp_a_SOURCES += ../shared/arm-cp15-set-exception-handler.c
diff --git a/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h b/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h
index 0abeed6..d8319c6 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h
+++ b/c/src/lib/libbsp/arm/raspberrypi/include/bsp.h
@@ -7,6 +7,7 @@
  */
 
 /*
+ * Copyright (c) 2015 Yang Qiao
  * Copyright (c) 2013 Alan Cudmore
  *
  *  The license and distribution terms for this file may be
@@ -35,6 +36,10 @@ extern "C" {
 #define BSP_GPIO_PINS_PER_BANK 32
 #define BSP_GPIO_PINS_PER_SELECT_BANK 10
 
+void rpi_init_cmdline(void);
+const char* rpi_cmdline(void);
+const char* rpi_cmdline_arg(const char* arg);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/bspstart.c b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstart.c
index c5786bf..884d5ef 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/startup/bspstart.c
+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstart.c
@@ -26,4 +26,5 @@
 void bsp_start(void)
 {
     bsp_interrupt_initialize();
+    rpi_init_cmdline();
 }
diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c 
b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c
index 047c8ad..7d72fe7 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c
+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c
@@ -7,6 +7,7 @@
  */
 
 /*
+ * Copyright (c) 2015 Yang Qiao
  * Copyright (c) 2013. Hesham AL-Matary
  * Copyright (c) 2013 by Alan Cudmore
  * based on work by:
@@ -29,6 +30,7 @@
 
 void BSP_START_TEXT_SECTION bsp_start_hook_0(void)
 {
+  rpi_init_cmdline();
 }
 
 
diff --git a/c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c b/c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c
new file mode 100644
index 0000000..c1ed29a
--- /dev/null
+++ b/c/src/lib/libbsp/arm/raspberrypi/startup/cmdline.c
@@ -0,0 +1,40 @@
+/**
+ * @file
+ *
+ * @ingroup raspberrypi
+ *
+ * @brief mailbox support.
+ */
+/*
+ * Copyright (c) 2015 Yang Qiao
+ *
+ *  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/vc.h>
+
+#define MAX_CMDLINE_LENGTH 1024
+static char* _rpi_cmdline;
+static bcm2835_get_cmdline_entries get_cmdline_entries;
+
+void rpi_init_cmdline(void)
+{
+  bcm2835_get_cmdline_entries get_cmdline_entries;
+  bcm2835_mailbox_get_cmdline(&get_cmdline_entries);
+  _rpi_cmdline = get_cmdline_entries.cmdline;
+}
+
+const char* rpi_cmdline(void)
+{
+  return _rpi_cmdline;
+}
+
+const char* rpi_cmdline_arg(const char* arg)
+{
+  return strstr (rpi_cmdline (), arg);
+}
-- 
1.9.1




More information about the devel mailing list