summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJennifer Averett <jennifer.averett@oarcorp.com>2012-07-11 08:49:13 -0500
committerJennifer Averett <jennifer.averett@oarcorp.com>2012-07-11 08:49:13 -0500
commit2f50f0a7a9dac0386ab962c7ba883360451c0b93 (patch)
treec2bee3570df36b467ff7ed6ff44712cae1d3dc04
parentMakefile: Do not install contrib .h files until proven needed (diff)
downloadrtems-libbsd-2f50f0a7a9dac0386ab962c7ba883360451c0b93.tar.bz2
Added nexus_setup_intr support and did some cleanup.
-rwxr-xr-xfreebsd-to-rtems.py1
-rw-r--r--rtemsbsd/freebsd/machine/rtems-bsd-devicet.h73
-rw-r--r--rtemsbsd/src/rtems-bsd-nexus.c72
3 files changed, 135 insertions, 11 deletions
diff --git a/freebsd-to-rtems.py b/freebsd-to-rtems.py
index c5b0916a..245d9525 100755
--- a/freebsd-to-rtems.py
+++ b/freebsd-to-rtems.py
@@ -514,6 +514,7 @@ rtems.addRTEMSHeaderFiles(
'rtems/machine/rtems-bsd-select.h',
'rtems/machine/rtems-bsd-taskqueue.h',
'rtems/machine/rtems-bsd-bus-dma.h',
+ 'rtems/machine/rtems-bsd-bus-devicet.h',
'bsd.h',
]
)
diff --git a/rtemsbsd/freebsd/machine/rtems-bsd-devicet.h b/rtemsbsd/freebsd/machine/rtems-bsd-devicet.h
new file mode 100644
index 00000000..2db95850
--- /dev/null
+++ b/rtemsbsd/freebsd/machine/rtems-bsd-devicet.h
@@ -0,0 +1,73 @@
+/**
+ * @file
+ *
+ * @ingroup rtems_bsd_rtems
+ *
+ * @brief This file describes the divice structure. It was derived
+ * from the libbsdport source.
+ */
+
+/*
+ * COPYRIGHT (c) 2012. On-Line Applications Research Corporation (OAR).
+ * All rights reserved.
+ *
+ * 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.
+ */
+
+#ifndef _RTEMS_BSD_MACHINE_RTEMS_BSD_DEVICET_H_
+#define _RTEMS_BSD_MACHINE_RTEMS_BSD_DEVICET_H_
+
+#include <rtems.h>
+#include <rtems/bspIo.h>
+#include <stdarg.h>
+#include <stdio.h>
+
+#include <freebsd/sys/queue.h>
+
+typedef struct device *device_t;
+
+typedef struct _pcidev_t {
+ unsigned short bus;
+ unsigned char dev;
+ unsigned char fun;
+} pcidev_t;
+
+#define DEVICE_SOFTC_ALIGNMENT 16
+
+struct device {
+ union {
+ pcidev_t pci;
+ } bushdr;
+ int type;
+ STAILQ_ENTRY(device) list;
+ const char *name;
+ char nameunit[16]; /* NEVER use knowledge about the size of this -- we may change it */
+ int unit;
+ char *desc;
+ driver_t *drv;
+ int attached;
+ void *rawmem; /* back pointer */
+ struct rtems_bsdnet_ifconfig *ifconfig;
+ char softc[] __attribute__ ((aligned(DEVICE_SOFTC_ALIGNMENT), may_alias));
+ /* a pointer to back to the device is installed past the 'softc' */
+};
+#endif
diff --git a/rtemsbsd/src/rtems-bsd-nexus.c b/rtemsbsd/src/rtems-bsd-nexus.c
index 6b85207e..fe2e23a8 100644
--- a/rtemsbsd/src/rtems-bsd-nexus.c
+++ b/rtemsbsd/src/rtems-bsd-nexus.c
@@ -49,6 +49,11 @@
#include <freebsd/sys/rman.h>
#include <freebsd/sys/malloc.h>
+#include <bsp.h>
+#include <freebsd/machine/rtems-bsd-devicet.h>
+#include <bsp/irq.h>
+#include <rtems/irq.h>
+
#if defined(__i386__)
#include <freebsd/machine/rtems-bsd-config.h>
#define I386_BUS_SPACE_MEM 0 /* space is mem space */
@@ -108,11 +113,8 @@ nexus_init_resources(void)
* resource manager.
*/
for (irq = 0; irq < NUM_IO_INTS; irq++)
-#ifndef __rtems__
- if (intr_lookup_source(irq) != NULL)
-#endif
- if (rman_manage_region(&irq_rman, irq, irq) != 0)
- panic("nexus_init_resources irq_rmand");
+ if (rman_manage_region(&irq_rman, irq, irq) != 0)
+ panic("nexus_init_resources irq_rmand");
/*
* ISA DMA on PCI systems is implemented in the ISA part of each
@@ -241,22 +243,18 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
switch (type) {
case SYS_RES_IRQ:
-printf( "nexus_alloc_resource: IRQ\n" );
rm = &irq_rman;
break;
case SYS_RES_DRQ:
-printf( "nexus_alloc_resource: DRQ\n" );
rm = &drq_rman;
break;
case SYS_RES_IOPORT:
-printf( "nexus_alloc_resource: IO\n" );
rm = &port_rman;
break;
case SYS_RES_MEMORY:
-printf( "nexus_alloc_resource: Memory\n" );
rm = &mem_rman;
break;
@@ -265,14 +263,12 @@ printf( "nexus_alloc_resource: Memory\n" );
}
rv = rman_reserve_resource(rm, start, end, count, flags, child);
-printf( "nexus_alloc_resource: rman_reserve_resource ==> %d\n", rv );
if (rv == 0)
return 0;
rman_set_rid(rv, *rid);
if (needactivate) {
if (bus_activate_resource(child, type, *rid, rv)) {
-printf( "nexus_alloc_resource: bus_activate_resource failed\n", rv );
rman_release_resource(rv);
return 0;
}
@@ -355,6 +351,59 @@ nexus_release_resource(device_t bus, device_t child, int type, int rid,
return (rman_release_resource(r));
}
+static void noop(const rtems_irq_connect_data *unused) {};
+static int noop1(const rtems_irq_connect_data *unused) { return 0;};
+
+static int
+bspExtInstallSharedISR(int irqLine, void (*isr)(void *), void * uarg, int flags)
+{
+ return rtems_interrupt_handler_install(
+ irqLine,
+ "BSD Interrupt",
+ RTEMS_INTERRUPT_SHARED,
+ isr,
+ uarg
+ );
+}
+
+int
+intr_add_handler(const char *name, int vector, driver_filter_t filter,
+ driver_intr_t handler, void *arg, enum intr_type flags, void **cookiep)
+{
+ int rval;
+
+ rval = bspExtInstallSharedISR(vector, handler, arg, 0);
+ return rval;
+}
+
+static int
+nexus_setup_intr(device_t bus, device_t child, struct resource *irq,
+ int flags, driver_filter_t filter, void (*ihand)(void *),
+ void *arg, void **cookiep)
+{
+ int error;
+
+ /* somebody tried to setup an irq that failed to allocate! */
+ if (irq == NULL)
+ panic("nexus_setup_intr: NULL irq resource!");
+
+ *cookiep = 0;
+ if ((rman_get_flags(irq) & RF_SHAREABLE) == 0)
+ flags |= INTR_EXCL;
+
+ /*
+ * We depend here on rman_activate_resource() being idempotent.
+ */
+ error = rman_activate_resource(irq);
+ if (error)
+ return (error);
+
+ error = intr_add_handler(device_get_nameunit(child),
+ rman_get_start(irq), filter, ihand, arg, flags, cookiep);
+
+ return (error);
+}
+
static device_method_t nexus_methods [] = {
/* Device interface */
@@ -372,6 +421,7 @@ static device_method_t nexus_methods [] = {
DEVMETHOD(bus_release_resource, nexus_release_resource),
DEVMETHOD(bus_activate_resource, nexus_activate_resource),
DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
+ DEVMETHOD(bus_setup_intr, nexus_setup_intr),
{ 0, 0 }
};