Date: Tue, 20 Oct 1998 16:17:42 +1000 From: Bruce Evans <bde@zeta.org.au> To: gibbs@narnia.plutotech.com, mike@smith.net.au Cc: current@FreeBSD.ORG Subject: Re: vote:? reversion of BDE change please? Message-ID: <199810200617.QAA00889@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>> The change is actually in the right direction, as the goal is to remove
>> the prototypes from global scope completely. Instead, ISA device
>> drivers should register their interrupt handlers at attach time. I
>> don't know if there's an example of this at the present time.
>
>The CAM ISA SCSI drivers set their own vectors and thus do not need
>entries in isa_devices.h.
Examples for doing it not-quite-right are trivial. For old drivers, it
it essentially takes a 1 line assignment:
diff -c2 syscons.c~ syscons.c
*** syscons.c~ Fri Oct 2 14:44:31 1998
--- syscons.c Tue Oct 20 15:53:49 1998
***************
*** 240,243 ****
--- 240,244 ----
/* prototypes */
static int scattach(struct isa_device *dev);
+ static ointhand2_t scintr;
static int scparam(struct tty *tp, struct termios *t);
static int scprobe(struct isa_device *dev);
***************
*** 646,649 ****
--- 647,651 ----
#endif
+ dev->id_intr = (inthand2_t *)scintr;
scinit();
sc_flags = dev->id_flags;
***************
*** 852,856 ****
}
! void
scintr(int unit)
{
--- 854,858 ----
}
! static void
scintr(int unit)
{
Also, the declaration of scintr() must be changed to `#define scintr NULL'
in isa_device.h so that old config files don't break. For new drivers,
just don't put interrupt vectors in config files or declarations for
interrupt handlers in isa_device.h.
I have converted about 50 drivers as above.
New drivers should also use `inthand2_t' interrupt handlers and not
cast to (inthand2_t *). There is not enough infrastructure for doing
this cleanly - it currently takes larger, uglier code than assigning
to id_intr.
I have converted about 5 drivers to use a NetBSDish interrupt attach
function. The larger, uglier code goes away, something like this:
diff -c2 bt_isa.c~ bt_isa.c
*** bt_isa.c~ Tue Oct 13 19:42:04 1998
--- bt_isa.c Tue Oct 13 19:42:20 1998
***************
*** 43,47 ****
static int bt_isa_probe __P((struct isa_device *dev));
static int bt_isa_attach __P((struct isa_device *dev));
- static void bt_isa_intr __P((void *unit));
static bus_dma_filter_t btvlbouncefilter;
--- 43,46 ----
***************
*** 196,199 ****
--- 208,212 ----
void *filter_arg;
bus_addr_t lowaddr;
+ int result;
bt = bt_softcs[dev->id_unit];
***************
*** 282,298 ****
}
! return (bt_attach(bt));
! }
!
! /*
! * Handle an ISA interrupt.
! * XXX should go away as soon as ISA interrupt handlers
! * take a (void *) arg.
! */
! static void
! bt_isa_intr(void *unit)
! {
! struct bt_softc* arg = bt_softcs[(int)unit];
! bt_intr((void *)arg);
}
--- 295,301 ----
}
! result = bt_attach(bt);
! isa_intr_establish(dev, &bio_imask, bt_intr, bt);
! return (result);
}
However, I think this doesn't actually work for drivers that that hack
on dev->id_intr (pnp and maybe pccard drivers).
Bruce
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199810200617.QAA00889>
