[PATCH 079/111] LEON: added get_resarray_count() helper routine
Daniel Hellstrom
daniel at gaisler.com
Thu Feb 26 16:39:21 UTC 2015
---
c/src/lib/libbsp/sparc/Makefile.am | 3 ++
c/src/lib/libbsp/sparc/leon2/Makefile.am | 2 +
c/src/lib/libbsp/sparc/leon2/preinstall.am | 4 +++
c/src/lib/libbsp/sparc/leon3/Makefile.am | 2 +
c/src/lib/libbsp/sparc/leon3/preinstall.am | 4 +++
.../sparc/shared/drvmgr/get_resarray_count.c | 20 ++++++++++++++
.../libbsp/sparc/shared/include/drvmgr/bspcommon.h | 28 ++++++++++++++++++++
7 files changed, 63 insertions(+), 0 deletions(-)
create mode 100644 c/src/lib/libbsp/sparc/shared/drvmgr/get_resarray_count.c
create mode 100644 c/src/lib/libbsp/sparc/shared/include/drvmgr/bspcommon.h
diff --git a/c/src/lib/libbsp/sparc/Makefile.am b/c/src/lib/libbsp/sparc/Makefile.am
index e17f03a..af0df0a 100644
--- a/c/src/lib/libbsp/sparc/Makefile.am
+++ b/c/src/lib/libbsp/sparc/Makefile.am
@@ -149,10 +149,13 @@ EXTRA_DIST += shared/drvmgr/ambapp_bus.c
EXTRA_DIST += shared/drvmgr/ambapp_bus_grlib.c
EXTRA_DIST += shared/drvmgr/ambapp_bus_leon2.c
EXTRA_DIST += shared/drvmgr/leon2_amba_bus.c
+EXTRA_DIST += shared/drvmgr/get_resarray_count.c
EXTRA_DIST += shared/include/drvmgr/ambapp_bus_grlib.h
EXTRA_DIST += shared/include/drvmgr/ambapp_bus.h
EXTRA_DIST += shared/include/drvmgr/leon2_amba_bus.h
+EXTRA_DIST += shared/include/drvmgr/bspcommon.h
+
# GR712
EXTRA_DIST += shared/ascs/grascs.c
EXTRA_DIST += shared/include/grascs.h
diff --git a/c/src/lib/libbsp/sparc/leon2/Makefile.am b/c/src/lib/libbsp/sparc/leon2/Makefile.am
index 3f2cd9f..32ca8aa 100644
--- a/c/src/lib/libbsp/sparc/leon2/Makefile.am
+++ b/c/src/lib/libbsp/sparc/leon2/Makefile.am
@@ -200,9 +200,11 @@ libbsp_a_SOURCES += ../../sparc/shared/tmtc/grtm.c
include_drvmgrdir = $(includedir)/drvmgr
include_drvmgr_HEADERS = ../../sparc/shared/include/drvmgr/ambapp_bus.h
include_drvmgr_HEADERS += ../../sparc/shared/include/drvmgr/leon2_amba_bus.h
+include_drvmgr_HEADERS += ../../sparc/shared/include/drvmgr/bspcommon.h
libbsp_a_SOURCES += ../../sparc/shared/drvmgr/ambapp_bus.c
libbsp_a_SOURCES += ../../sparc/shared/drvmgr/ambapp_bus_leon2.c
libbsp_a_SOURCES += ../../sparc/shared/drvmgr/leon2_amba_bus.c
+libbsp_a_SOURCES += ../../sparc/shared/drvmgr/get_resarray_count.c
if HAS_SMP
libbsp_a_SOURCES += ../../shared/bspsmp.c
diff --git a/c/src/lib/libbsp/sparc/leon2/preinstall.am b/c/src/lib/libbsp/sparc/leon2/preinstall.am
index cf5515b..3240720 100644
--- a/c/src/lib/libbsp/sparc/leon2/preinstall.am
+++ b/c/src/lib/libbsp/sparc/leon2/preinstall.am
@@ -262,6 +262,10 @@ $(PROJECT_INCLUDE)/drvmgr/leon2_amba_bus.h: ../../sparc/shared/include/drvmgr/le
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/drvmgr/leon2_amba_bus.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/drvmgr/leon2_amba_bus.h
+$(PROJECT_INCLUDE)/drvmgr/bspcommon.h: ../../sparc/shared/include/drvmgr/bspcommon.h $(PROJECT_INCLUDE)/drvmgr/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/drvmgr/bspcommon.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/drvmgr/bspcommon.h
+
if HAS_NETWORKING
$(PROJECT_INCLUDE)/greth.h: ../../sparc/shared/include/greth.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/greth.h
diff --git a/c/src/lib/libbsp/sparc/leon3/Makefile.am b/c/src/lib/libbsp/sparc/leon3/Makefile.am
index de6a4f8..5fa2d5a 100644
--- a/c/src/lib/libbsp/sparc/leon3/Makefile.am
+++ b/c/src/lib/libbsp/sparc/leon3/Makefile.am
@@ -231,8 +231,10 @@ libbsp_a_SOURCES += ../../sparc/shared/tmtc/grtm.c
include_drvmgrdir = $(includedir)/drvmgr
include_drvmgr_HEADERS = ../../sparc/shared/include/drvmgr/ambapp_bus_grlib.h
include_drvmgr_HEADERS += ../../sparc/shared/include/drvmgr/ambapp_bus.h
+include_drvmgr_HEADERS += ../../sparc/shared/include/drvmgr/bspcommon.h
libbsp_a_SOURCES += ../../sparc/shared/drvmgr/ambapp_bus.c
libbsp_a_SOURCES += ../../sparc/shared/drvmgr/ambapp_bus_grlib.c
+libbsp_a_SOURCES += ../../sparc/shared/drvmgr/get_resarray_count.c
if HAS_SMP
libbsp_a_SOURCES += startup/bspsmp.c
diff --git a/c/src/lib/libbsp/sparc/leon3/preinstall.am b/c/src/lib/libbsp/sparc/leon3/preinstall.am
index 441102f..98d94ab 100644
--- a/c/src/lib/libbsp/sparc/leon3/preinstall.am
+++ b/c/src/lib/libbsp/sparc/leon3/preinstall.am
@@ -310,6 +310,10 @@ $(PROJECT_INCLUDE)/drvmgr/ambapp_bus.h: ../../sparc/shared/include/drvmgr/ambapp
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/drvmgr/ambapp_bus.h
PREINSTALL_FILES += $(PROJECT_INCLUDE)/drvmgr/ambapp_bus.h
+$(PROJECT_INCLUDE)/drvmgr/bspcommon.h: ../../sparc/shared/include/drvmgr/bspcommon.h $(PROJECT_INCLUDE)/drvmgr/$(dirstamp)
+ $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/drvmgr/bspcommon.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/drvmgr/bspcommon.h
+
if HAS_NETWORKING
$(PROJECT_INCLUDE)/greth.h: ../../sparc/shared/include/greth.h $(PROJECT_INCLUDE)/$(dirstamp)
$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/greth.h
diff --git a/c/src/lib/libbsp/sparc/shared/drvmgr/get_resarray_count.c b/c/src/lib/libbsp/sparc/shared/drvmgr/get_resarray_count.c
new file mode 100644
index 0000000..6fb5719
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/shared/drvmgr/get_resarray_count.c
@@ -0,0 +1,20 @@
+/* Common driver configuration routines.
+ *
+ * COPYRIGHT (c) 2015.
+ * Cobham Gaisler.
+ *
+ * The license and distribution terms for this file may be
+ * found in found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <stdlib.h>
+#include <drvmgr/bspcommon.h>
+
+int get_resarray_count(struct drvmgr_bus_res **array)
+{
+ int i = 0;
+ while (array[i] != NULL)
+ i++;
+ return i;
+}
diff --git a/c/src/lib/libbsp/sparc/shared/include/drvmgr/bspcommon.h b/c/src/lib/libbsp/sparc/shared/include/drvmgr/bspcommon.h
new file mode 100644
index 0000000..08c6198
--- /dev/null
+++ b/c/src/lib/libbsp/sparc/shared/include/drvmgr/bspcommon.h
@@ -0,0 +1,28 @@
+/* Common BSP/driver configuration routines.
+ *
+ * COPYRIGHT (c) 2015.
+ * Cobham Gaisler.
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ */
+
+#ifndef __BSPCOMMON_H__
+#define __BSPCOMMON_H__
+
+#include <drvmgr/drvmgr.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Count driver resource array length. Array must be terminated with a NULL */
+int get_resarray_count(struct drvmgr_bus_res **array);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--
1.7.0.4
More information about the devel
mailing list