summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rwxr-xr-xfreebsd-to-rtems.py1
-rw-r--r--rtemsbsd/include/bsp/nexus-devices.h (renamed from rtemsbsd/bsp/bsp-bsd-nexus-devices.c)35
-rw-r--r--rtemsbsd/include/rtems/bsd/bsd.h17
-rw-r--r--rtemsbsd/rtems/rtems-bsd-nexus.c18
-rw-r--r--testsuite/include/rtems/bsd/test/default-network-init.h2
-rw-r--r--testsuite/swi01/init.c5
-rw-r--r--testsuite/timeout01/init.c5
8 files changed, 28 insertions, 56 deletions
diff --git a/Makefile b/Makefile
index e79cc74d..4f82d460 100644
--- a/Makefile
+++ b/Makefile
@@ -109,7 +109,6 @@ LIB_C_FILES += rtemsbsd/telnetd/check_passwd.c
LIB_C_FILES += rtemsbsd/telnetd/des.c
LIB_C_FILES += rtemsbsd/telnetd/pty.c
LIB_C_FILES += rtemsbsd/telnetd/telnetd.c
-LIB_C_FILES += rtemsbsd/bsp/bsp-bsd-nexus-devices.c
LIB_GEN_FILES += rtemsbsd/rtems/rtems-kvm-symbols.c
LIB_C_FILES += rtemsbsd/rtems/rtems-kvm-symbols.c
rtemsbsd/rtems/rtems-kvm-symbols.c: rtemsbsd/rtems/generate_kvm_symbols
diff --git a/freebsd-to-rtems.py b/freebsd-to-rtems.py
index 64eb4751..5b747fea 100755
--- a/freebsd-to-rtems.py
+++ b/freebsd-to-rtems.py
@@ -707,7 +707,6 @@ rtems.addRTEMSSourceFiles(
'telnetd/des.c',
'telnetd/pty.c',
'telnetd/telnetd.c',
- 'bsp/bsp-bsd-nexus-devices.c',
]
)
diff --git a/rtemsbsd/bsp/bsp-bsd-nexus-devices.c b/rtemsbsd/include/bsp/nexus-devices.h
index bf8aeefc..6fae2e92 100644
--- a/rtemsbsd/bsp/bsp-bsd-nexus-devices.c
+++ b/rtemsbsd/include/bsp/nexus-devices.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
@@ -31,8 +31,6 @@
#include <rtems/bsd/bsd.h>
-#include <machine/rtems-bsd-sysinit.h>
-
#include <bsp.h>
#if defined(LIBBSP_ARM_REALVIEW_PBX_A9_BSP_H)
@@ -51,36 +49,13 @@ static const rtems_bsd_device_resource smc0_res[] = {
}
};
-const rtems_bsd_device rtems_bsd_nexus_devices[] = {
- {
- .name = "smc",
- .unit = 0,
- .resource_count = RTEMS_ARRAY_SIZE(smc0_res),
- .resources = &smc0_res[0]
- }
-};
-
-SYSINIT_DRIVER_REFERENCE(smc, nexus);
+RTEMS_BSD_DEFINE_NEXUS_DEVICE(smc, 0, RTEMS_ARRAY_SIZE(smc0_res),
+ &smc0_res[0]);
#elif defined(__GENMCF548X_BSP_H)
-const rtems_bsd_device rtems_bsd_nexus_devices[] = {
- {
- .name = "fec",
- .unit = 0
- }, {
- .name = "fec",
- .unit = 1
- }
-};
-
-SYSINIT_DRIVER_REFERENCE(fec, nexus);
-
-#else
+RTEMS_BSD_DEFINE_NEXUS_DEVICE(fec, 0, 0, NULL);
-const rtems_bsd_device rtems_bsd_nexus_devices[0];
+RTEMS_BSD_DEFINE_NEXUS_DEVICE(fec, 1, 0, NULL);
#endif
-
-const size_t rtems_bsd_nexus_device_count =
- RTEMS_ARRAY_SIZE(rtems_bsd_nexus_devices);
diff --git a/rtemsbsd/include/rtems/bsd/bsd.h b/rtemsbsd/include/rtems/bsd/bsd.h
index af03b443..a9118ecc 100644
--- a/rtemsbsd/include/rtems/bsd/bsd.h
+++ b/rtemsbsd/include/rtems/bsd/bsd.h
@@ -40,12 +40,16 @@
#ifndef _RTEMS_BSD_BSD_H_
#define _RTEMS_BSD_BSD_H_
+#include <sys/cdefs.h>
+#include <sys/queue.h>
+#include <sys/kernel.h>
+
+#include <rtems.h>
+
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-#include <rtems.h>
-
typedef enum {
RTEMS_BSD_RES_IRQ = 1,
RTEMS_BSD_RES_MEMORY = 3
@@ -62,11 +66,14 @@ typedef struct {
int unit;
size_t resource_count;
const rtems_bsd_device_resource *resources;
+ const struct sysinit *driver_reference;
} rtems_bsd_device;
-extern const rtems_bsd_device rtems_bsd_nexus_devices[];
-
-extern const size_t rtems_bsd_nexus_device_count;
+#define RTEMS_BSD_DEFINE_NEXUS_DEVICE(name, unit, resource_count, resources) \
+ extern struct sysinit SYSINIT_ENTRY_NAME(name##_nexusmodule); \
+ RTEMS_BSD_DEFINE_SET_ITEM(nexus, name##unit, rtems_bsd_device) = \
+ { #name, unit, (resource_count), (resources), \
+ &SYSINIT_ENTRY_NAME(name##_nexusmodule) }
rtems_status_code rtems_bsd_initialize(void);
diff --git a/rtemsbsd/rtems/rtems-bsd-nexus.c b/rtemsbsd/rtems/rtems-bsd-nexus.c
index ce8f646b..60cc8cd0 100644
--- a/rtemsbsd/rtems/rtems-bsd-nexus.c
+++ b/rtemsbsd/rtems/rtems-bsd-nexus.c
@@ -7,7 +7,7 @@
*/
/*
- * Copyright (c) 2009-2013 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2009-2014 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
@@ -54,6 +54,10 @@
/* #define DISABLE_INTERRUPT_EXTENSION */
+RTEMS_BSD_DECLARE_SET(nexus, rtems_bsd_device);
+
+RTEMS_BSD_DEFINE_SET(nexus, rtems_bsd_device);
+
RTEMS_STATIC_ASSERT(SYS_RES_MEMORY == RTEMS_BSD_RES_MEMORY, RTEMS_BSD_RES_MEMORY);
RTEMS_STATIC_ASSERT(SYS_RES_IRQ == RTEMS_BSD_RES_IRQ, RTEMS_BSD_RES_IRQ);
@@ -67,7 +71,7 @@ nexus_probe(device_t dev)
{
rtems_status_code status;
int err;
- size_t i;
+ const rtems_bsd_device *nd;
device_set_desc(dev, "RTEMS Nexus device");
@@ -100,9 +104,7 @@ nexus_probe(device_t dev)
err = rman_manage_region(&irq_rman, irq_rman.rm_start, irq_rman.rm_end);
BSD_ASSERT(err == 0);
- for (i = 0; i < rtems_bsd_nexus_device_count; ++i) {
- const rtems_bsd_device *nd = &rtems_bsd_nexus_devices[i];
-
+ SET_FOREACH(nd, nexus) {
device_add_child(dev, nd->name, nd->unit);
}
@@ -133,7 +135,7 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
u_long start, u_long end, u_long count, u_int flags)
{
struct rman *rm;
- size_t i;
+ const rtems_bsd_device *nd;
switch (type) {
case SYS_RES_MEMORY:
@@ -146,9 +148,7 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
return (NULL);
}
- for (i = 0; i < rtems_bsd_nexus_device_count; ++i) {
- const rtems_bsd_device *nd = &rtems_bsd_nexus_devices[i];
-
+ SET_FOREACH(nd, nexus) {
if (strcmp(device_get_name(child), nd->name) == 0
&& device_get_unit(child) == nd->unit) {
struct resource *res = NULL;
diff --git a/testsuite/include/rtems/bsd/test/default-network-init.h b/testsuite/include/rtems/bsd/test/default-network-init.h
index 5643308e..fb4aa704 100644
--- a/testsuite/include/rtems/bsd/test/default-network-init.h
+++ b/testsuite/include/rtems/bsd/test/default-network-init.h
@@ -272,6 +272,8 @@ Init(rtems_task_argument arg)
SYSINIT_NEED_NET_PF_UNIX;
+#include <bsp/nexus-devices.h>
+
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER
diff --git a/testsuite/swi01/init.c b/testsuite/swi01/init.c
index 0108f6ce..ec5ae2b9 100644
--- a/testsuite/swi01/init.c
+++ b/testsuite/swi01/init.c
@@ -39,11 +39,6 @@
#include "swi_test.h"
-const rtems_bsd_device rtems_bsd_nexus_devices[0];
-
-const size_t rtems_bsd_nexus_device_count =
- RTEMS_ARRAY_SIZE(rtems_bsd_nexus_devices);
-
static void Init(rtems_task_argument arg)
{
rtems_status_code sc;
diff --git a/testsuite/timeout01/init.c b/testsuite/timeout01/init.c
index efab0757..92385e57 100644
--- a/testsuite/timeout01/init.c
+++ b/testsuite/timeout01/init.c
@@ -39,11 +39,6 @@
#include "timeout_test.h"
-const rtems_bsd_device rtems_bsd_nexus_devices[0];
-
-const size_t rtems_bsd_nexus_device_count =
- RTEMS_ARRAY_SIZE(rtems_bsd_nexus_devices);
-
static void Init(rtems_task_argument arg)
{
rtems_status_code sc;