1998-07-22 08:29:26 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1998 Doug Rabson
|
|
|
|
* 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.
|
|
|
|
*
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1998-07-22 08:29:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/bus.h>
|
1999-04-16 21:22:55 +00:00
|
|
|
#include <machine/bus.h>
|
1998-07-22 08:29:26 +00:00
|
|
|
#include <sys/malloc.h>
|
2000-10-05 23:09:57 +00:00
|
|
|
#include <sys/proc.h>
|
1998-11-15 18:25:17 +00:00
|
|
|
#include <sys/rman.h>
|
2000-10-05 23:09:57 +00:00
|
|
|
#include <sys/interrupt.h>
|
1998-07-22 08:29:26 +00:00
|
|
|
|
|
|
|
#include <isa/isareg.h>
|
|
|
|
#include <isa/isavar.h>
|
1999-05-22 15:18:28 +00:00
|
|
|
#include <isa/isa_common.h>
|
1999-04-16 21:22:55 +00:00
|
|
|
#include <alpha/isa/isavar.h>
|
1998-07-22 08:29:26 +00:00
|
|
|
#include <machine/intr.h>
|
1998-11-28 09:55:16 +00:00
|
|
|
#include <machine/intrcnt.h>
|
1998-11-15 18:25:17 +00:00
|
|
|
#include <machine/resource.h>
|
2000-05-28 02:40:53 +00:00
|
|
|
#include <machine/cpuconf.h>
|
1998-11-15 18:25:17 +00:00
|
|
|
|
|
|
|
static struct rman isa_irq_rman;
|
1999-06-05 13:30:13 +00:00
|
|
|
static struct rman isa_drq_rman;
|
1998-07-22 08:29:26 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
isa_intr_enable(int irq)
|
|
|
|
{
|
|
|
|
int s = splhigh();
|
|
|
|
if (irq < 8)
|
|
|
|
outb(IO_ICU1+1, inb(IO_ICU1+1) & ~(1 << irq));
|
|
|
|
else
|
1998-10-25 01:30:16 +00:00
|
|
|
outb(IO_ICU2+1, inb(IO_ICU2+1) & ~(1 << (irq - 8)));
|
1998-07-22 08:29:26 +00:00
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
isa_intr_disable(int irq)
|
|
|
|
{
|
|
|
|
int s = splhigh();
|
|
|
|
if (irq < 8)
|
|
|
|
outb(IO_ICU1+1, inb(IO_ICU1+1) | (1 << irq));
|
|
|
|
else
|
1998-10-25 01:30:16 +00:00
|
|
|
outb(IO_ICU2+1, inb(IO_ICU2+1) | (1 << (irq - 8)));
|
1998-07-22 08:29:26 +00:00
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
1999-04-21 07:26:30 +00:00
|
|
|
intrmask_t
|
1998-07-22 08:29:26 +00:00
|
|
|
isa_irq_pending(void)
|
|
|
|
{
|
|
|
|
u_char irr1;
|
|
|
|
u_char irr2;
|
|
|
|
|
|
|
|
irr1 = inb(IO_ICU1);
|
|
|
|
irr2 = inb(IO_ICU2);
|
|
|
|
return ((irr2 << 8) | irr1);
|
|
|
|
}
|
|
|
|
|
1999-04-21 07:26:30 +00:00
|
|
|
intrmask_t
|
1998-07-22 08:29:26 +00:00
|
|
|
isa_irq_mask(void)
|
|
|
|
{
|
|
|
|
u_char irr1;
|
|
|
|
u_char irr2;
|
|
|
|
|
|
|
|
irr1 = inb(IO_ICU1+1);
|
|
|
|
irr2 = inb(IO_ICU2+1);
|
|
|
|
return ((irr2 << 8) | irr1);
|
|
|
|
}
|
|
|
|
|
1999-05-22 15:18:28 +00:00
|
|
|
void
|
|
|
|
isa_init(void)
|
1998-07-22 08:29:26 +00:00
|
|
|
{
|
1999-04-16 21:22:55 +00:00
|
|
|
isa_init_intr();
|
1998-11-15 18:25:17 +00:00
|
|
|
}
|
|
|
|
|
1999-05-22 15:18:28 +00:00
|
|
|
void
|
|
|
|
isa_init_intr(void)
|
1999-04-16 21:22:55 +00:00
|
|
|
{
|
|
|
|
static int initted = 0;
|
|
|
|
|
|
|
|
if (initted) return;
|
|
|
|
initted = 1;
|
|
|
|
|
|
|
|
isa_irq_rman.rm_start = 0;
|
|
|
|
isa_irq_rman.rm_end = 15;
|
|
|
|
isa_irq_rman.rm_type = RMAN_ARRAY;
|
|
|
|
isa_irq_rman.rm_descr = "ISA Interrupt request lines";
|
|
|
|
if (rman_init(&isa_irq_rman)
|
|
|
|
|| rman_manage_region(&isa_irq_rman, 0, 1)
|
|
|
|
|| rman_manage_region(&isa_irq_rman, 3, 15))
|
|
|
|
panic("isa_probe isa_irq_rman");
|
|
|
|
|
1999-06-05 13:30:13 +00:00
|
|
|
isa_drq_rman.rm_start = 0;
|
|
|
|
isa_drq_rman.rm_end = 7;
|
|
|
|
isa_drq_rman.rm_type = RMAN_ARRAY;
|
|
|
|
isa_drq_rman.rm_descr = "ISA DMA request lines";
|
|
|
|
if (rman_init(&isa_drq_rman)
|
|
|
|
|| rman_manage_region(&isa_drq_rman, 0, 7))
|
|
|
|
panic("isa_probe isa_drq_rman");
|
|
|
|
|
1999-04-16 21:22:55 +00:00
|
|
|
/* mask all isa interrupts */
|
|
|
|
outb(IO_ICU1+1, 0xff);
|
|
|
|
outb(IO_ICU2+1, 0xff);
|
|
|
|
|
|
|
|
/* make sure chaining irq is enabled */
|
|
|
|
isa_intr_enable(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct resource *
|
|
|
|
isa_alloc_intr(device_t bus, device_t child, int irq)
|
|
|
|
{
|
|
|
|
return rman_reserve_resource(&isa_irq_rman, irq, irq, 1,
|
|
|
|
0, child);
|
|
|
|
}
|
|
|
|
|
2000-05-10 18:54:28 +00:00
|
|
|
struct resource *
|
|
|
|
isa_alloc_intrs(device_t bus, device_t child, u_long start, u_long end)
|
|
|
|
{
|
|
|
|
return rman_reserve_resource(&isa_irq_rman, start, end,
|
|
|
|
end - start + 1, 0, child);
|
|
|
|
}
|
|
|
|
|
1999-04-16 21:22:55 +00:00
|
|
|
int
|
|
|
|
isa_release_intr(device_t bus, device_t child, struct resource *r)
|
|
|
|
{
|
|
|
|
return rman_release_resource(r);
|
|
|
|
}
|
|
|
|
|
1998-11-15 18:25:17 +00:00
|
|
|
/*
|
|
|
|
* This implementation simply passes the request up to the parent
|
|
|
|
* bus, which in our case is the pci chipset device, substituting any
|
|
|
|
* configured values if the caller defaulted. We can get away with
|
|
|
|
* this because there is no special mapping for ISA resources on this
|
|
|
|
* platform. When porting this code to another architecture, it may be
|
|
|
|
* necessary to interpose a mapping layer here.
|
|
|
|
*
|
|
|
|
* We manage our own interrupt resources since ISA interrupts go through
|
|
|
|
* the ISA PIC, not the PCI interrupt controller.
|
|
|
|
*/
|
1999-05-22 15:18:28 +00:00
|
|
|
struct resource *
|
1998-11-15 18:25:17 +00:00
|
|
|
isa_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
|
|
|
u_long start, u_long end, u_long count, u_int flags)
|
|
|
|
{
|
1999-05-22 15:18:28 +00:00
|
|
|
/*
|
|
|
|
* Consider adding a resource definition. We allow rid 0-1 for
|
1999-06-05 13:30:13 +00:00
|
|
|
* irq and drq, 0-3 for memory and 0-7 for ports which is
|
|
|
|
* sufficient for isapnp.
|
1999-05-22 15:18:28 +00:00
|
|
|
*/
|
|
|
|
int passthrough = (device_get_parent(child) != bus);
|
|
|
|
int isdefault = (start == 0UL && end == ~0UL);
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
struct isa_device* idev = DEVTOISA(child);
|
|
|
|
struct resource_list *rl = &idev->id_resources;
|
1999-05-22 15:18:28 +00:00
|
|
|
struct resource_list_entry *rle;
|
|
|
|
struct resource *res;
|
|
|
|
|
|
|
|
if (!passthrough && !isdefault) {
|
|
|
|
rle = resource_list_find(rl, type, *rid);
|
|
|
|
if (!rle) {
|
|
|
|
if (*rid < 0)
|
|
|
|
return 0;
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
switch (type) {
|
|
|
|
case SYS_RES_IRQ:
|
|
|
|
if (*rid >= ISA_NIRQ)
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
case SYS_RES_DRQ:
|
|
|
|
if (*rid >= ISA_NDRQ)
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
case SYS_RES_MEMORY:
|
|
|
|
if (*rid >= ISA_NMEM)
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
case SYS_RES_IOPORT:
|
|
|
|
if (*rid >= ISA_NPORT)
|
|
|
|
return 0;
|
|
|
|
break;
|
|
|
|
default:
|
1999-05-22 15:18:28 +00:00
|
|
|
return 0;
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
}
|
1999-05-22 15:18:28 +00:00
|
|
|
resource_list_add(rl, type, *rid, start, end, count);
|
1998-11-18 23:53:12 +00:00
|
|
|
}
|
1999-05-22 15:18:28 +00:00
|
|
|
}
|
1998-11-15 18:25:17 +00:00
|
|
|
|
1999-06-05 13:30:13 +00:00
|
|
|
if (type != SYS_RES_IRQ && type != SYS_RES_DRQ)
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
return resource_list_alloc(rl, bus, child, type, rid,
|
1999-05-22 15:18:28 +00:00
|
|
|
start, end, count, flags);
|
1998-11-15 18:25:17 +00:00
|
|
|
|
1999-05-22 15:18:28 +00:00
|
|
|
if (!passthrough) {
|
|
|
|
rl = device_get_ivars(child);
|
1999-06-05 13:30:13 +00:00
|
|
|
rle = resource_list_find(rl, type, *rid);
|
1999-05-22 15:18:28 +00:00
|
|
|
if (!rle)
|
|
|
|
return 0;
|
|
|
|
if (rle->res)
|
|
|
|
panic("isa_alloc_resource: resource entry is busy");
|
|
|
|
if (isdefault) {
|
|
|
|
start = end = rle->start;
|
|
|
|
count = 1;
|
|
|
|
}
|
1998-07-22 08:29:26 +00:00
|
|
|
}
|
1998-11-15 18:25:17 +00:00
|
|
|
|
1999-06-05 13:30:13 +00:00
|
|
|
if (type == SYS_RES_IRQ)
|
|
|
|
res = rman_reserve_resource(&isa_irq_rman, start, start, 1,
|
|
|
|
0, child);
|
|
|
|
else
|
|
|
|
res = rman_reserve_resource(&isa_drq_rman, start, start, 1,
|
|
|
|
0, child);
|
|
|
|
|
1999-05-22 15:18:28 +00:00
|
|
|
if (res && !passthrough) {
|
1999-06-05 13:30:13 +00:00
|
|
|
rle = resource_list_find(rl, type, *rid);
|
1999-05-22 15:18:28 +00:00
|
|
|
rle->start = rman_get_start(res);
|
|
|
|
rle->end = rman_get_end(res);
|
|
|
|
rle->count = 1;
|
|
|
|
rle->res = res;
|
1998-11-15 18:25:17 +00:00
|
|
|
}
|
1999-05-22 15:18:28 +00:00
|
|
|
|
|
|
|
return res;
|
1998-11-15 18:25:17 +00:00
|
|
|
}
|
|
|
|
|
1999-05-22 15:18:28 +00:00
|
|
|
int
|
1998-11-15 18:25:17 +00:00
|
|
|
isa_release_resource(device_t bus, device_t child, int type, int rid,
|
1999-05-22 15:18:28 +00:00
|
|
|
struct resource *res)
|
1998-11-15 18:25:17 +00:00
|
|
|
{
|
1999-05-22 15:18:28 +00:00
|
|
|
int passthrough = (device_get_parent(child) != bus);
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
struct isa_device* idev = DEVTOISA(child);
|
|
|
|
struct resource_list *rl = &idev->id_resources;
|
1999-05-22 15:18:28 +00:00
|
|
|
struct resource_list_entry *rle;
|
|
|
|
int error;
|
1998-11-15 18:25:17 +00:00
|
|
|
|
1999-05-22 15:18:28 +00:00
|
|
|
if (type != SYS_RES_IRQ)
|
* Add struct resource_list* argument to resource_list_alloc and
resource_list_release. This removes the dependancy on the
layout of ivars.
* Move set_resource, get_resource and delete_resource from
isa_if.m to bus_if.m.
* Simplify driver code by providing wrappers to those methods:
bus_set_resource(dev, type, rid, start, count);
bus_get_resource(dev, type, rid, startp, countp);
bus_get_resource_start(dev, type, rid);
bus_get_resource_count(dev, type, rid);
bus_delete_resource(dev, type, rid);
* Delete isa_get_rsrc and use bus_get_resource_start instead.
* Fix a stupid typo in isa_alloc_resource reported by Takahashi
Yoshihiro <nyan@FreeBSD.org>.
* Print a diagnostic message if we can't assign resources to a PnP
device.
* Change device_print_prettyname() so that it doesn't print
"(no driver assigned)-1" for anonymous devices.
1999-10-12 21:35:51 +00:00
|
|
|
return resource_list_release(rl, bus, child, type, rid, res);
|
1999-05-22 15:18:28 +00:00
|
|
|
|
|
|
|
error = rman_release_resource(res);
|
|
|
|
|
|
|
|
if (!passthrough && !error) {
|
|
|
|
rle = resource_list_find(rl, SYS_RES_IRQ, rid);
|
|
|
|
if (rle)
|
|
|
|
rle->res = NULL;
|
|
|
|
else
|
|
|
|
error = ENOENT;
|
1998-11-15 18:25:17 +00:00
|
|
|
}
|
|
|
|
|
1999-05-22 15:18:28 +00:00
|
|
|
return error;
|
1998-07-22 08:29:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct isa_intr {
|
|
|
|
void *ih;
|
|
|
|
driver_intr_t *intr;
|
|
|
|
void *arg;
|
|
|
|
int irq;
|
|
|
|
};
|
|
|
|
|
Lots of changes, including:
* Support for AlphaStation 200, 250, 255, 400
* Untested support for UDB, Multia, AXPpci33 (Noname)
* Support for Personal Workstation 433a/433au, 500a/500au, 600a/600au (Miata)
* Some minor fixes and improvements to interrupt handling.
Submitted by: Andrew Gallatin <gallatin@cs.duke.edu> (AS200, Miata)
Obtained from: NetBSD (some code for AS200, Miata, Noname)
1998-08-10 07:53:59 +00:00
|
|
|
/*
|
|
|
|
* Wrap ISA interrupt routines so that we can feed non-specific
|
|
|
|
* EOI to the PICs.
|
|
|
|
*/
|
|
|
|
|
1998-07-22 08:29:26 +00:00
|
|
|
static void
|
2000-12-01 22:28:04 +00:00
|
|
|
isa_handle_fast_intr(void *arg)
|
1998-07-22 08:29:26 +00:00
|
|
|
{
|
|
|
|
struct isa_intr *ii = arg;
|
|
|
|
int irq = ii->irq;
|
|
|
|
|
|
|
|
ii->intr(ii->arg);
|
|
|
|
|
2000-12-01 22:28:04 +00:00
|
|
|
if (irq > 7)
|
1998-07-22 08:29:26 +00:00
|
|
|
outb(IO_ICU2, 0x20 | (irq & 7));
|
|
|
|
outb(IO_ICU1, 0x20 | (irq > 7 ? 2 : irq));
|
|
|
|
}
|
|
|
|
|
2000-12-01 22:28:04 +00:00
|
|
|
static void
|
|
|
|
isa_handle_intr(void *arg)
|
|
|
|
{
|
|
|
|
struct isa_intr *ii = arg;
|
|
|
|
|
|
|
|
ii->intr(ii->arg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send a non-specific EIO early, then disable the source
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void
|
|
|
|
isa_disable_intr(int vector)
|
|
|
|
{
|
|
|
|
int irq = (vector - 0x800) >> 4;
|
|
|
|
|
|
|
|
if (irq > 7)
|
|
|
|
outb(IO_ICU2, 0x20 | (irq & 7));
|
|
|
|
outb(IO_ICU1, 0x20 | (irq > 7 ? 2 : irq));
|
|
|
|
|
|
|
|
isa_intr_disable(irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
isa_enable_intr(int vector)
|
|
|
|
{
|
|
|
|
int irq = (vector - 0x800) >> 4;
|
|
|
|
isa_intr_enable(irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-04-16 21:22:55 +00:00
|
|
|
int
|
1998-11-15 18:25:17 +00:00
|
|
|
isa_setup_intr(device_t dev, device_t child,
|
1999-05-08 21:59:43 +00:00
|
|
|
struct resource *irq, int flags,
|
1998-11-15 18:25:17 +00:00
|
|
|
driver_intr_t *intr, void *arg, void **cookiep)
|
1998-07-22 08:29:26 +00:00
|
|
|
{
|
|
|
|
struct isa_intr *ii;
|
1998-11-15 18:25:17 +00:00
|
|
|
int error;
|
2000-05-28 02:40:53 +00:00
|
|
|
|
|
|
|
if (platform.isa_setup_intr)
|
|
|
|
return platform.isa_setup_intr(dev, child, irq, flags,
|
|
|
|
intr, arg, cookiep);
|
|
|
|
|
1998-11-15 18:25:17 +00:00
|
|
|
error = rman_activate_resource(irq);
|
|
|
|
if (error)
|
|
|
|
return error;
|
1998-07-22 08:29:26 +00:00
|
|
|
|
|
|
|
ii = malloc(sizeof(struct isa_intr), M_DEVBUF, M_NOWAIT);
|
|
|
|
if (!ii)
|
1998-11-15 18:25:17 +00:00
|
|
|
return ENOMEM;
|
1998-07-22 08:29:26 +00:00
|
|
|
ii->intr = intr;
|
|
|
|
ii->arg = arg;
|
1998-11-15 18:25:17 +00:00
|
|
|
ii->irq = irq->r_start;
|
|
|
|
|
2000-10-05 23:09:57 +00:00
|
|
|
error = alpha_setup_intr(
|
|
|
|
device_get_nameunit(child ? child : dev),
|
2000-12-01 22:28:04 +00:00
|
|
|
0x800 + (irq->r_start << 4),
|
|
|
|
((flags & INTR_FAST) ? isa_handle_fast_intr :
|
2001-02-09 17:53:23 +00:00
|
|
|
isa_handle_intr), ii, flags, &ii->ih,
|
2000-10-05 23:09:57 +00:00
|
|
|
&intrcnt[INTRCNT_ISA_IRQ + irq->r_start],
|
2000-12-01 22:28:04 +00:00
|
|
|
isa_disable_intr, isa_enable_intr);
|
1998-11-15 18:25:17 +00:00
|
|
|
if (error) {
|
1998-07-22 08:29:26 +00:00
|
|
|
free(ii, M_DEVBUF);
|
1998-11-15 18:25:17 +00:00
|
|
|
return error;
|
1998-07-22 08:29:26 +00:00
|
|
|
}
|
1998-11-15 18:25:17 +00:00
|
|
|
isa_intr_enable(irq->r_start);
|
1998-07-22 08:29:26 +00:00
|
|
|
|
1998-11-15 18:25:17 +00:00
|
|
|
*cookiep = ii;
|
1999-04-16 21:22:55 +00:00
|
|
|
|
|
|
|
if (child)
|
|
|
|
device_printf(child, "interrupting at ISA irq %d\n",
|
|
|
|
(int)irq->r_start);
|
|
|
|
|
1998-11-15 18:25:17 +00:00
|
|
|
return 0;
|
1998-07-22 08:29:26 +00:00
|
|
|
}
|
|
|
|
|
1999-04-16 21:22:55 +00:00
|
|
|
int
|
1998-11-15 18:25:17 +00:00
|
|
|
isa_teardown_intr(device_t dev, device_t child,
|
|
|
|
struct resource *irq, void *cookie)
|
1998-07-22 08:29:26 +00:00
|
|
|
{
|
1998-11-15 18:25:17 +00:00
|
|
|
struct isa_intr *ii = cookie;
|
1998-07-22 08:29:26 +00:00
|
|
|
|
2000-05-28 02:40:53 +00:00
|
|
|
if (platform.isa_teardown_intr) {
|
|
|
|
platform.isa_teardown_intr(dev, child, irq, cookie);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1998-11-15 18:25:17 +00:00
|
|
|
alpha_teardown_intr(ii->ih);
|
|
|
|
isa_intr_disable(irq->r_start);
|
|
|
|
|
|
|
|
return 0;
|
1998-07-22 08:29:26 +00:00
|
|
|
}
|