[PATCH rtems-libbsd] rtemsbsd: Use a separate header for test devices

Kinsey Moore kinsey.moore at oarcorp.com
Tue Jul 6 19:44:54 UTC 2021


Devices used specifically for testing are now contained in a separate
nexus-test-devices.h so as not to pollute default hardware
configurations with test-specific information. This header is currently
only used for network tests.
---
 rtemsbsd/include/bsp/nexus-devices.h          | 24 --------
 rtemsbsd/include/bsp/nexus-test-devices.h     | 59 +++++++++++++++++++
 .../rtems/bsd/test/default-network-init.h     |  3 +
 3 files changed, 62 insertions(+), 24 deletions(-)
 create mode 100644 rtemsbsd/include/bsp/nexus-test-devices.h

diff --git a/rtemsbsd/include/bsp/nexus-devices.h b/rtemsbsd/include/bsp/nexus-devices.h
index cbb3f48b..3a5f9155 100644
--- a/rtemsbsd/include/bsp/nexus-devices.h
+++ b/rtemsbsd/include/bsp/nexus-devices.h
@@ -38,7 +38,6 @@
 
 #include <rtems/bsd/bsd.h>
 #include <rtems/bsd/modules.h>
-#include <rtems/bsd/test/network-config.h>
 #include <machine/rtems-bsd-nexus-bus.h>
 
 
@@ -106,30 +105,7 @@ RTEMS_BSD_DRIVER_MMC;
 
 #elif defined(LIBBSP_AARCH64_XILINX_ZYNQMP_BSP_H)
 
-#include <bsp/irq.h>
-
 RTEMS_BSD_DRIVER_XILINX_ZYNQMP_SLCR;
-/* Qemu only applies user-mode networking to the first interface by default, so
- * all 4 CGEM instances must be configured in the Qemu arguments using
- * "-nic user,model=cadence_gem" for each nic.
- *
- * CGEM3 is used for LibBSD because all Zynq Ultrascale+ MPSoC dev boards treat
- * the highest-mapped CGEM as the primary interface.
- */
-#if NET_CFG_ZYNQMP_USE_CGEM0 == '1'
-RTEMS_BSD_DRIVER_XILINX_ZYNQMP_CGEM0(ZYNQMP_IRQ_ETHERNET_0);
-#endif
-#if NET_CFG_ZYNQMP_USE_CGEM1 == '1'
-RTEMS_BSD_DRIVER_XILINX_ZYNQMP_CGEM1(ZYNQMP_IRQ_ETHERNET_1);
-#endif
-#if NET_CFG_ZYNQMP_USE_CGEM2 == '1'
-RTEMS_BSD_DRIVER_XILINX_ZYNQMP_CGEM2(ZYNQMP_IRQ_ETHERNET_2);
-#endif
-#if NET_CFG_ZYNQMP_USE_CGEM3 == '1'
-RTEMS_BSD_DRIVER_XILINX_ZYNQMP_CGEM3(ZYNQMP_IRQ_ETHERNET_3);
-#endif
-RTEMS_BSD_DRIVER_E1000PHY;
-RTEMS_BSD_DRIVER_UKPHY;
 
 #elif defined(LIBBSP_ARM_ATSAM_BSP_H)
 
diff --git a/rtemsbsd/include/bsp/nexus-test-devices.h b/rtemsbsd/include/bsp/nexus-test-devices.h
new file mode 100644
index 00000000..798d9eef
--- /dev/null
+++ b/rtemsbsd/include/bsp/nexus-test-devices.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2021 On-Line Applications Research
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if !defined(BSP_NEXUS_TEST_DEVICES_h)
+#define BSP_NEXUS_TEST_DEVICES_h
+
+#include <rtems/bsd/test/network-config.h>
+
+#if defined(LIBBSP_AARCH64_XILINX_ZYNQMP_BSP_H)
+
+#include <bsp/irq.h>
+
+/* Qemu only applies user-mode networking to the first interface by default, so
+ * all 4 CGEM instances must be configured in the Qemu arguments using
+ * "-nic user,model=cadence_gem" for each nic.
+ *
+ * CGEM3 is used for LibBSD because all Zynq Ultrascale+ MPSoC dev boards treat
+ * the highest-mapped CGEM as the primary interface.
+ */
+#if NET_CFG_ZYNQMP_USE_CGEM0 == '1'
+RTEMS_BSD_DRIVER_XILINX_ZYNQMP_CGEM0(ZYNQMP_IRQ_ETHERNET_0);
+#endif
+#if NET_CFG_ZYNQMP_USE_CGEM1 == '1'
+RTEMS_BSD_DRIVER_XILINX_ZYNQMP_CGEM1(ZYNQMP_IRQ_ETHERNET_1);
+#endif
+#if NET_CFG_ZYNQMP_USE_CGEM2 == '1'
+RTEMS_BSD_DRIVER_XILINX_ZYNQMP_CGEM2(ZYNQMP_IRQ_ETHERNET_2);
+#endif
+#if NET_CFG_ZYNQMP_USE_CGEM3 == '1'
+RTEMS_BSD_DRIVER_XILINX_ZYNQMP_CGEM3(ZYNQMP_IRQ_ETHERNET_3);
+#endif
+RTEMS_BSD_DRIVER_E1000PHY;
+RTEMS_BSD_DRIVER_UKPHY;
+
+#endif /* LIBBSP_AARCH64_XILINX_ZYNQMP_BSP_H */
+
+#endif
diff --git a/testsuite/include/rtems/bsd/test/default-network-init.h b/testsuite/include/rtems/bsd/test/default-network-init.h
index ce1fc015..3bd59f42 100644
--- a/testsuite/include/rtems/bsd/test/default-network-init.h
+++ b/testsuite/include/rtems/bsd/test/default-network-init.h
@@ -268,6 +268,9 @@ Init(rtems_task_argument arg)
 
 #include <machine/rtems-bsd-config.h>
 
+/* Include additional devices that may be required for network tests */
+#include <bsp/nexus-test-devices.h>
+
 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
 #define CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER
-- 
2.20.1



More information about the devel mailing list