From owner-freebsd-hackers Fri Apr 10 11:32:46 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id LAA01372 for freebsd-hackers-outgoing; Fri, 10 Apr 1998 11:32:46 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from whistle.com (s205m131.whistle.com [207.76.205.131]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id LAA01163 for ; Fri, 10 Apr 1998 11:31:28 -0700 (PDT) (envelope-from archie@whistle.com) Received: (from smap@localhost) by whistle.com (8.7.5/8.6.12) id LAA10563; Fri, 10 Apr 1998 11:30:43 -0700 (PDT) Received: from bubba.whistle.com(207.76.205.7) by whistle.com via smap (V1.3) id sma010561; Fri Apr 10 11:30:19 1998 Received: (from archie@localhost) by bubba.whistle.com (8.8.7/8.6.12) id LAA05807; Fri, 10 Apr 1998 11:30:19 -0700 (PDT) From: Archie Cobbs Message-Id: <199804101830.LAA05807@bubba.whistle.com> Subject: Re: PnP driver question In-Reply-To: <199804100522.HAA07607@labinfo.iet.unipi.it> from Luigi Rizzo at "Apr 10, 98 07:22:26 am" To: luigi@labinfo.iet.unipi.it (Luigi Rizzo) Date: Fri, 10 Apr 1998 11:30:19 -0700 (PDT) Cc: freebsd-hackers@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL31 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Luigi Rizzo writes: > > Need a little help understanding how to write a PnP aware device driver. > > > > Suppose I have a PnP card that I want to do a self-test on before > > claiming that it's been officially detected. Since the attach() routine > > in struct pnp_device returns NULL, then this has to be done in the > > probe routine, right? > > > > In order to talk to the card to do the self-test, I have to set > > the PnP params and enable the card during the probe routine... > > > > My question is.. is this safe? Is this this right way to proceed? > > > > I'm wondering because in Luigi's paper "PnP support in FreeBSD", > > the example has a very simple probe routine (which just compares the > > unqiue identifiers), while the attach routine does all the initialization > > work. > > i am not quite sure if mine is the correct way. However, after some > thinking, i took the following decisions: > - the probe routines should avoid changing the configuration of > PnP devices, since this belongs elsewhere. Pragmatically, > I do not enable anything, but allow a driver to disable resources > that the driver does not use (e.g. in the case of audio driver, all > the synth/midi stuff for which i currently have no support. > > - the probe routine, for non-pnp devices, just tries to figure out if > the device is there and it is properly configured. Since PnP tells > you all of this, there is little to be done in the probe routine, > so the only thing is to check the PnP id > > - the attach routine does all the initialization. Unfortunately > there is no check on the return code from the isa attach routine, > so you cannot report up if the attach fails... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This is precisely the problem. Luigi Rizzo writes later on: > i am not sure if it is safe... i'd postpone all self test to the attach > routine. It can still fail by returning some value (forget which one) > in the struct isa_device set appropriately (like ports=0 or -1, etc.); > look at isa.c what is done after the attach routine. I looked at isa.c and after calling (*dp->attach)(isdp) all it does is check the interrupt value and register the interrupt handler. So there doesn't seem to be any way for "attach" to indicate failure. Here's a propsal (don't know how hard this would be to do): - Have BOTH the PnP and ISA attach routines be defined to return an int value (the ISA attach already does, but it's currently ignored). - Let device drivers' attach routines indicate failure by returning a non-zero value. Basically, since "probe" is only intended to only detect devices in a non-obtrusive way, only "attach" can be used for things like self-test, etc. Therefore, "attach" must be allowed to return non-zero to indicate failure -- in both ISA and PnP cases. If I'm misunderstanding the paradigm, please help clarify.. Thanks, -Archie ___________________________________________________________________________ Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message