summaryrefslogtreecommitdiffstats
path: root/sys/pci
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2003-12-02 12:36:00 +0000
committerbde <bde@FreeBSD.org>2003-12-02 12:36:00 +0000
commit68eb4e63a382af4e61862b702bf07805e988f30c (patch)
treece7ecba2fa1f8e3a071025c81902f0430df0e786 /sys/pci
parent3a0af1aae72ca3322637a9d2f7f8b765835748c7 (diff)
downloadFreeBSD-src-68eb4e63a382af4e61862b702bf07805e988f30c.zip
FreeBSD-src-68eb4e63a382af4e61862b702bf07805e988f30c.tar.gz
Fixed breakage of the pci case of the cy driver by the new interrupt
code. Both the driver and the new code were wrong. Driver interrupt handlers are supposed to take "void *vsc" arg, but some including all COMPAT_ISA drivers and the pci part of the cy driver want an "int unit" arg. They got this using bogus casts of function pointers which should have kept working despite their bogusness. However, the new interrupt code doesn't honor requests to pass an arg of ((void *)0), so things are very broken if the arg is actually a representation of unit 0. The fix is to use a normal "void *vsc" arg for the pci case and a wrapper for the COMPAT_ISA case (of the cy driver). This cleans up new-busification of the pci case but takes the COMPAT_ISA case a little further from new-bus. The corresponding bug for the COMPAT_ISA case has already been fixed similarly using a wrapper in compat_isa.c and we need another wrapper just to undo that. Fixed some directly related style bugs (mainly by removing compatibility cruft). cy.c: Fixed an indirectly related old bug in cyattach_common(). A wrong status was returned in the unlikely event that malloc() failed. Approved by: re (scottl)
Diffstat (limited to 'sys/pci')
-rw-r--r--sys/pci/cy_pci.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/sys/pci/cy_pci.c b/sys/pci/cy_pci.c
index ef5cccd..faa660b 100644
--- a/sys/pci/cy_pci.c
+++ b/sys/pci/cy_pci.c
@@ -66,8 +66,8 @@ __FBSDID("$FreeBSD$");
#define PLX_9060 0x0c
#define PLX_9080 0x0d
-extern int cyattach_common(void *, int); /* Not exactly correct */
-extern void cyintr(int);
+void *cyattach_common(u_char volatile *iobase, int cy_align);
+driver_intr_t cyintr;
static int cy_pci_attach(device_t dev);
static int cy_pci_probe(device_t dev);
@@ -110,9 +110,9 @@ cy_pci_attach(dev)
device_t dev;
{
struct resource *ioport_res, *irq_res, *mem_res;
- void *irq_cookie, *vaddr;
+ void *irq_cookie, *vaddr, *vsc;
u_int32_t ioport;
- int adapter, irq_setup, ioport_rid, irq_rid, mem_rid;
+ int irq_setup, ioport_rid, irq_rid, mem_rid;
u_char plx_ver;
ioport_res = NULL;
@@ -137,21 +137,12 @@ cy_pci_attach(dev)
}
vaddr = rman_get_virtual(mem_res);
- adapter = cyattach_common(vaddr, 1);
- if (adapter < 0) {
+ vsc = cyattach_common(vaddr, 1);
+ if (vsc == NULL) {
device_printf(dev, "no ports found!\n");
goto fail;
}
- /*
- * Allocate our interrupt.
- * XXX Using the ISA interrupt handler directly is a bit of a violation
- * since it doesn't actually take the same argument. For PCI, the
- * argument is a void * token, but for ISA it is a unit. Since
- * there is no overlap in PCI/ISA unit numbers for this driver, and
- * since the ISA driver must handle the interrupt anyway, we use
- * the unit number as the token even for PCI.
- */
irq_rid = 0;
irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &irq_rid, 0ul, ~0ul, 0ul,
RF_SHAREABLE | RF_ACTIVE);
@@ -161,13 +152,13 @@ cy_pci_attach(dev)
}
#ifdef CY_PCI_FASTINTR
irq_setup = bus_setup_intr(dev, irq_res, INTR_TYPE_TTY | INTR_FAST,
- (driver_intr_t *)cyintr, (void *)adapter, &irq_cookie);
+ cyintr, vsc, &irq_cookie);
#else
irq_setup = ENXIO;
#endif
if (irq_setup != 0)
irq_setup = bus_setup_intr(dev, irq_res, INTR_TYPE_TTY,
- (driver_intr_t *)cyintr, (void *)adapter, &irq_cookie);
+ cyintr, vsc, &irq_cookie);
if (irq_setup != 0) {
device_printf(dev, "interrupt setup failed\n");
goto fail;
OpenPOWER on IntegriCloud