Date: Fri, 14 Aug 1998 11:38:52 +0930 From: Greg Lehey <grog@lemis.com> To: Terry Lambert <tlambert@primenet.com>, hm@kts.org Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: developing device drivers Message-ID: <19980814113852.J1921@freebie.lemis.com> In-Reply-To: <199808132017.NAA14261@usr09.primenet.com>; from Terry Lambert on Thu, Aug 13, 1998 at 08:17:13PM %2B0000 References: <m0z6u8J-000026C@bert.kts.org> <199808132017.NAA14261@usr09.primenet.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday, 13 August 1998 at 20:17:13 +0000, Terry Lambert wrote: >>> I second this. If you look in /usr/share/examples, you'll find a >>> couple of sample LKMs written by Terry Lambert. I hijacked the syscall >>> example from here and used it a lot to experiment with the XL driver. >> >> I'd really like to write drivers (for ISA cards) as LKM modules, but so >> far i don't know how to assign 1) the IRQ, 2) the iobase and 3) the membase >> ( and perhaps flags and spl) to the LKM at module load time. >> >> Did i miss something ? > > You probe and attach at load time, normally. This means you detect the > IRQ/DRQ/IOBase/MemBase/Etc., not assign it. That means you should write > the probe code first. > > The flags and spl have to be dealt with by unloading, modifying, and > loading. Frankly, I think you'll not need to change the spl you use > since it's pretty much fixed by the kind of device you are driving. > You could also provide an ioctl to diddle the flags, and run a program > in user space that diddles them one the driver is loaded. > > You are doing this under -current, right? If not, it's going to be > hard to unload, since detaching ISA resources wasn't well supported > before the PCMCIA code required it. > > One of the sample drivers used to be an LPT driver, which grabbed IRQ7; > I haven't looked at the hardware part of the codebase for LKM in a > while (well, mostly; I did help someone with loading a line discipline > recently, but that didn't grab and release resources). > > Most -current drivers are capable of dual-mode compilation. > > For specific examples, look in /usr/src/lkm/ for joy, pcic, qcam, > and wcd. I think Hellmuth brought up an important issue which you don't appear to have covered: sure, it's easy enough to probe. But some probes are destructive, and if you don't know what's already been taken, you're liable to kill some other device while messing around looking for your devices. Is there some list which contains information about what resources are already assigned to other drivers? Greg -- See complete headers for address, home page and phone numbers finger grog@lemis.com for PGP public key To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980814113852.J1921>