From owner-freebsd-hackers Thu Aug 13 19:10:04 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id TAA01323 for freebsd-hackers-outgoing; Thu, 13 Aug 1998 19:10:04 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from allegro.lemis.com (allegro.lemis.com [192.109.197.134]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id TAA01252 for ; Thu, 13 Aug 1998 19:09:54 -0700 (PDT) (envelope-from grog@freebie.lemis.com) Received: from freebie.lemis.com (freebie.lemis.com [192.109.197.137]) by allegro.lemis.com (8.9.1/8.9.0) with ESMTP id LAA03094; Fri, 14 Aug 1998 11:39:10 +0930 (CST) Received: (from grog@localhost) by freebie.lemis.com (8.9.1/8.9.0) id LAA16787; Fri, 14 Aug 1998 11:38:53 +0930 (CST) Message-ID: <19980814113852.J1921@freebie.lemis.com> Date: Fri, 14 Aug 1998 11:38:52 +0930 From: Greg Lehey To: Terry Lambert , hm@kts.org Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: developing device drivers References: <199808132017.NAA14261@usr09.primenet.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.91.1i In-Reply-To: <199808132017.NAA14261@usr09.primenet.com>; from Terry Lambert on Thu, Aug 13, 1998 at 08:17:13PM +0000 WWW-Home-Page: http://www.lemis.com/~grog Organization: LEMIS, PO Box 460, Echunga SA 5153, Australia Phone: +61-8-8388-8286 Fax: +61-8-8388-8725 Mobile: +61-41-739-7062 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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