[PATCH 3/6] add cmdline support for rpi bsp

YANG QIAO yangqiao0505 at me.com
Wed Aug 12 22:08:02 UTC 2015


From: YANG Qiao <yangqiao0505 at me.com>

---
 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 3593e60..e0b4806 100644
--- a/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
+++ b/c/src/lib/libbsp/arm/raspberrypi/Makefile.am
@@ -96,6 +96,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 5379b13..7cb9e70 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
@@ -37,6 +38,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);
+}
-- 
2.1.0




More information about the devel mailing list