Subject: Re: LKM that uses DMA under NetBSD-current x86
To: None <current-users@NetBSD.ORG, netbsd-help@NetBSD.ORG, port-i386@NetBSD.ORG,>
From: Matthias Drochner <drochner@zelux6.zel.kfa-juelich.de>
List: port-i386
Date: 11/17/1997 13:16:41
Excerpts from netbsd: 14-Nov-97 LKM that uses DMA under Net.. Cameron
Elliott@elliott. (853*)

> My problem is this, the isa_dmastart(), and other isa_dma*() routines
> now require a pointer to a 'device *', really a 'isa_softc *'.

There are 2 ways:
a) traverse the "alldevs" list of attached devices:
struct device *d;
struct isa_softc *myisadev;
for (d = alldevs.tqh_first; d; d = d->dv_list.tqe_next)
	if (!strcmp(d->dv_xname, "isa0")
		myisadev = (struct isa_softc*)d;

b) use the ISA driver's list:
extern struct cfdriver isa_cd;
struct isa_softc *myisadev = isa_cd.cd_devs[0]

(assuming there is exactly one ISA bus with unit number 0)

This violates abstraction - it is not desirable to use
other driver's internal data structures -, but there
is no other way.

> I am not sure how to create this data for the device driver,
> and also, I need to know how to uninstall or clean up this data

As far as the ISA softc is concerned, you don't have to
create nor remove it.
For you own driver: If it's a simple one (which doesn't
have child devices), it should be possible to keep it out
of the autoconfig structures. This would save a lot of
trouble. (from own painful experience...)

best regards
Matthias