From owner-freebsd-new-bus Wed Oct 6 15:21:34 1999 Delivered-To: freebsd-new-bus@freebsd.org Received: from rover.village.org (rover.village.org [204.144.255.49]) by hub.freebsd.org (Postfix) with ESMTP id B14E314A2F; Wed, 6 Oct 1999 15:21:26 -0700 (PDT) (envelope-from imp@harmony.village.org) Received: from harmony.village.org (harmony.village.org [10.0.0.6]) by rover.village.org (8.9.3/8.9.3) with ESMTP id QAA13961; Wed, 6 Oct 1999 16:20:39 -0600 (MDT) (envelope-from imp@harmony.village.org) Received: from harmony.village.org (localhost.village.org [127.0.0.1]) by harmony.village.org (8.9.3/8.8.3) with ESMTP id QAA07058; Wed, 6 Oct 1999 16:20:13 -0600 (MDT) Message-Id: <199910062220.QAA07058@harmony.village.org> To: new-bus@freebsd.org Cc: dfr@freebsd.org Subject: Question on loading buses Date: Wed, 06 Oct 1999 16:20:13 -0600 From: Warner Losh Sender: owner-freebsd-new-bus@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG How can I load a bus? I have a simple bus that has device_identify and device_probe methods. Neither of them seems to be called when I kldload it. This is true when it is a isa driver or a nexus driver. Am I doing something wrong? Warner static device_method_t foobus_methods[] = { /* Device interface */ DEVMETHOD(device_identify, foobus_identify), DEVMETHOD(device_probe, foobus_probe), DEVMETHOD(device_attach, foobus_attach), DEVMETHOD(device_detach, foobus_detach), { 0, 0 } }; static driver_t foobus_driver = { "foobus", foobus_methods, 1, }; static devclass_t foobus_devclass; DRIVER_MODULE(foobus, nexus, foobus_driver, foobus_devclass, 0, 0); /*DRIVER_MODULE(foobus, isa, foobus_driver, foobus_devclass, 0, 0);*/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-new-bus" in the body of the message From owner-freebsd-new-bus Wed Oct 6 16:40:19 1999 Delivered-To: freebsd-new-bus@freebsd.org Received: from herring.nlsystems.com (nlsys.demon.co.uk [158.152.125.33]) by hub.freebsd.org (Postfix) with ESMTP id ADB811535D; Wed, 6 Oct 1999 16:40:04 -0700 (PDT) (envelope-from dfr@nlsystems.com) Received: from salmon.nlsystems.com (salmon.nlsystems.com [10.0.0.3]) by herring.nlsystems.com (8.9.3/8.8.8) with ESMTP id AAA45749; Thu, 7 Oct 1999 00:42:11 +0100 (BST) (envelope-from dfr@nlsystems.com) Date: Thu, 7 Oct 1999 00:42:11 +0100 (BST) From: Doug Rabson To: Warner Losh Cc: new-bus@freebsd.org, dfr@freebsd.org Subject: Re: Question on loading buses In-Reply-To: <199910062220.QAA07058@harmony.village.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-new-bus@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wed, 6 Oct 1999, Warner Losh wrote: > > How can I load a bus? I have a simple bus that has device_identify > and device_probe methods. Neither of them seems to be called when I > kldload it. This is true when it is a isa driver or a nexus driver. > Am I doing something wrong? Currently all that happens when a driver is loaded is that the BUS_DRIVER_ADDED method of all instances of the parent bus is called. There is a generic implementation of BUS_DRIVER_ADDED which calls device_probe_and_attach() for any unmatched device instances but the parent probably doesn't have this in its method table. Probably bus_generic_driver_added() should call DEVICE_IDENTIFY for the new driver too. -- Doug Rabson Mail: dfr@nlsystems.com Nonlinear Systems Ltd. Phone: +44 181 442 9037 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-new-bus" in the body of the message From owner-freebsd-new-bus Wed Oct 6 17:19:16 1999 Delivered-To: freebsd-new-bus@freebsd.org Received: from rover.village.org (rover.village.org [204.144.255.49]) by hub.freebsd.org (Postfix) with ESMTP id B689814C39; Wed, 6 Oct 1999 17:18:41 -0700 (PDT) (envelope-from imp@harmony.village.org) Received: from harmony.village.org (harmony.village.org [10.0.0.6]) by rover.village.org (8.9.3/8.9.3) with ESMTP id SAA14289; Wed, 6 Oct 1999 18:18:42 -0600 (MDT) (envelope-from imp@harmony.village.org) Received: from harmony.village.org (localhost.village.org [127.0.0.1]) by harmony.village.org (8.9.3/8.8.3) with ESMTP id SAA07555; Wed, 6 Oct 1999 18:18:17 -0600 (MDT) Message-Id: <199910070018.SAA07555@harmony.village.org> To: Doug Rabson Subject: Re: Question on loading buses Cc: new-bus@FreeBSD.ORG, dfr@FreeBSD.ORG In-reply-to: Your message of "Thu, 07 Oct 1999 00:42:11 BST." References: Date: Wed, 06 Oct 1999 18:18:16 -0600 From: Warner Losh Sender: owner-freebsd-new-bus@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message Doug Rabson writes: : Currently all that happens when a driver is loaded is that the : BUS_DRIVER_ADDED method of all instances of the parent bus is called. : There is a generic implementation of BUS_DRIVER_ADDED which calls : device_probe_and_attach() for any unmatched device instances but the : parent probably doesn't have this in its method table. Probably : bus_generic_driver_added() should call DEVICE_IDENTIFY for the new driver : too. You mean the following? Index: subr_bus.c =================================================================== RCS file: /home/imp/FreeBSD/CVS/src/sys/kern/subr_bus.c,v retrieving revision 1.42 diff -u -r1.42 subr_bus.c --- subr_bus.c 1999/09/10 21:11:23 1.42 +++ subr_bus.c 1999/10/07 00:17:46 @@ -1928,6 +1928,7 @@ child; child = TAILQ_NEXT(child, link)) if (child->state == DS_NOTPRESENT) device_probe_and_attach(child); + DEVICE_IDENTRIFY(dev); } int To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-new-bus" in the body of the message From owner-freebsd-new-bus Wed Oct 6 17:30:23 1999 Delivered-To: freebsd-new-bus@freebsd.org Received: from herring.nlsystems.com (nlsys.demon.co.uk [158.152.125.33]) by hub.freebsd.org (Postfix) with ESMTP id 8044C1579D; Wed, 6 Oct 1999 17:30:04 -0700 (PDT) (envelope-from dfr@nlsystems.com) Received: from salmon.nlsystems.com (salmon.nlsystems.com [10.0.0.3]) by herring.nlsystems.com (8.9.3/8.8.8) with ESMTP id BAA46553; Thu, 7 Oct 1999 01:31:40 +0100 (BST) (envelope-from dfr@nlsystems.com) Date: Thu, 7 Oct 1999 01:31:39 +0100 (BST) From: Doug Rabson To: Warner Losh Cc: new-bus@FreeBSD.ORG, dfr@FreeBSD.ORG Subject: Re: Question on loading buses In-Reply-To: <199910070018.SAA07555@harmony.village.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-new-bus@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wed, 6 Oct 1999, Warner Losh wrote: > In message Doug Rabson writes: > : Currently all that happens when a driver is loaded is that the > : BUS_DRIVER_ADDED method of all instances of the parent bus is called. > : There is a generic implementation of BUS_DRIVER_ADDED which calls > : device_probe_and_attach() for any unmatched device instances but the > : parent probably doesn't have this in its method table. Probably > : bus_generic_driver_added() should call DEVICE_IDENTIFY for the new driver > : too. > > You mean the following? The call should happen before the probe loop otherwise new devices created by the identify method won't be probed. Note that for the isa bus, we really need an isa_driver_added which can allocate pnp resources etc. after the identify creates them. -- Doug Rabson Mail: dfr@nlsystems.com Nonlinear Systems Ltd. Phone: +44 181 442 9037 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-new-bus" in the body of the message From owner-freebsd-new-bus Wed Oct 6 20: 7:23 1999 Delivered-To: freebsd-new-bus@freebsd.org Received: from rover.village.org (rover.village.org [204.144.255.49]) by hub.freebsd.org (Postfix) with ESMTP id 5504D15046; Wed, 6 Oct 1999 20:06:59 -0700 (PDT) (envelope-from imp@harmony.village.org) Received: from harmony.village.org (harmony.village.org [10.0.0.6]) by rover.village.org (8.9.3/8.9.3) with ESMTP id VAA14792; Wed, 6 Oct 1999 21:07:06 -0600 (MDT) (envelope-from imp@harmony.village.org) Received: from harmony.village.org (localhost.village.org [127.0.0.1]) by harmony.village.org (8.9.3/8.8.3) with ESMTP id UAA00348; Wed, 6 Oct 1999 20:41:37 -0600 (MDT) Message-Id: <199910070241.UAA00348@harmony.village.org> To: Doug Rabson Subject: Re: Question on loading buses Cc: new-bus@FreeBSD.ORG, dfr@FreeBSD.ORG In-reply-to: Your message of "Thu, 07 Oct 1999 01:31:39 BST." References: Date: Wed, 06 Oct 1999 20:41:37 -0600 From: Warner Losh Sender: owner-freebsd-new-bus@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message Doug Rabson writes: : The call should happen before the probe loop otherwise new devices created : by the identify method won't be probed. Note that for the isa bus, we : really need an isa_driver_added which can allocate pnp resources etc. : after the identify creates them. OK. For the moment I've not done the isa_driver_added since I don't understand the pnp code. However, the following works. Can you comment on it? Warner Index: kern/bus_if.m =================================================================== RCS file: /home/imp/FreeBSD/CVS/src/sys/kern/bus_if.m,v retrieving revision 1.14 diff -u -r1.14 bus_if.m --- bus_if.m 1999/08/28 00:46:09 1.14 +++ bus_if.m 1999/10/07 02:19:10 @@ -113,7 +113,7 @@ METHOD void driver_added { device_t dev; driver_t *driver; -} +} DEFAULT bus_generic_driver_added; # # For busses which use use drivers supporting DEVICE_IDENTIFY to Index: kern/subr_bus.c =================================================================== RCS file: /home/imp/FreeBSD/CVS/src/sys/kern/subr_bus.c,v retrieving revision 1.42 diff -u -r1.42 subr_bus.c --- subr_bus.c 1999/09/10 21:11:23 1.42 +++ subr_bus.c 1999/10/07 02:34:05 @@ -1924,6 +1924,7 @@ { device_t child; + DEVICE_IDENTIFY(driver, dev); for (child = TAILQ_FIRST(&dev->children); child; child = TAILQ_NEXT(child, link)) if (child->state == DS_NOTPRESENT) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-new-bus" in the body of the message From owner-freebsd-new-bus Wed Oct 6 20: 7:25 1999 Delivered-To: freebsd-new-bus@freebsd.org Received: from rover.village.org (rover.village.org [204.144.255.49]) by hub.freebsd.org (Postfix) with ESMTP id 5E19F150C7; Wed, 6 Oct 1999 20:07:00 -0700 (PDT) (envelope-from imp@harmony.village.org) Received: from harmony.village.org (harmony.village.org [10.0.0.6]) by rover.village.org (8.9.3/8.9.3) with ESMTP id VAA14795; Wed, 6 Oct 1999 21:07:06 -0600 (MDT) (envelope-from imp@harmony.village.org) Received: from harmony.village.org (localhost.village.org [127.0.0.1]) by harmony.village.org (8.9.3/8.8.3) with ESMTP id TAA07777; Wed, 6 Oct 1999 19:19:27 -0600 (MDT) Message-Id: <199910070119.TAA07777@harmony.village.org> To: Doug Rabson Subject: Re: Question on loading buses Cc: new-bus@FreeBSD.ORG, dfr@FreeBSD.ORG In-reply-to: Your message of "Thu, 07 Oct 1999 01:31:39 BST." References: Date: Wed, 06 Oct 1999 19:19:27 -0600 From: Warner Losh Sender: owner-freebsd-new-bus@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message Doug Rabson writes: : The call should happen before the probe loop otherwise new devices created : by the identify method won't be probed. Note that for the isa bus, we : really need an isa_driver_added which can allocate pnp resources etc. : after the identify creates them. OK. I'll give that a shot. Certainly is much easier than having a load/unload lkm handler... Warner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-new-bus" in the body of the message From owner-freebsd-new-bus Thu Oct 7 1:18: 8 1999 Delivered-To: freebsd-new-bus@freebsd.org Received: from herring.nlsystems.com (nlsys.demon.co.uk [158.152.125.33]) by hub.freebsd.org (Postfix) with ESMTP id 9C01614D14; Thu, 7 Oct 1999 01:18:04 -0700 (PDT) (envelope-from dfr@nlsystems.com) Received: from salmon.nlsystems.com (salmon.nlsystems.com [10.0.0.3]) by herring.nlsystems.com (8.9.3/8.8.8) with ESMTP id JAA73909; Thu, 7 Oct 1999 09:20:24 +0100 (BST) (envelope-from dfr@nlsystems.com) Date: Thu, 7 Oct 1999 09:20:24 +0100 (BST) From: Doug Rabson To: Warner Losh Cc: new-bus@FreeBSD.ORG, dfr@FreeBSD.ORG Subject: Re: Question on loading buses In-Reply-To: <199910070241.UAA00348@harmony.village.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-new-bus@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wed, 6 Oct 1999, Warner Losh wrote: > In message Doug Rabson writes: > : The call should happen before the probe loop otherwise new devices created > : by the identify method won't be probed. Note that for the isa bus, we > : really need an isa_driver_added which can allocate pnp resources etc. > : after the identify creates them. > > OK. For the moment I've not done the isa_driver_added since I don't > understand the pnp code. However, the following works. Can you > comment on it? I think its the right thing to do. I will write the isa_driver_added next time I get a change to work on the pnp code (soon). -- Doug Rabson Mail: dfr@nlsystems.com Nonlinear Systems Ltd. Phone: +44 181 442 9037 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-new-bus" in the body of the message From owner-freebsd-new-bus Thu Oct 7 5:47:18 1999 Delivered-To: freebsd-new-bus@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 608) id AA7DF14C2E; Thu, 7 Oct 1999 05:47:15 -0700 (PDT) From: "Jonathan M. Bresler" To: new-bus@FreeBSD.ORG Subject: reported not working Message-Id: <19991007124715.AA7DF14C2E@hub.freebsd.org> Date: Thu, 7 Oct 1999 05:47:15 -0700 (PDT) Sender: owner-freebsd-new-bus@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG grr....reported not working. lets see. jmb To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-new-bus" in the body of the message From owner-freebsd-new-bus Thu Oct 7 7:27:31 1999 Delivered-To: freebsd-new-bus@freebsd.org Received: from peach.ocn.ne.jp (peach.ocn.ne.jp [210.145.254.87]) by hub.freebsd.org (Postfix) with ESMTP id 32EC215202; Thu, 7 Oct 1999 07:27:28 -0700 (PDT) (envelope-from dcs@newsguy.com) Received: from newsguy.com (p16-dn02kiryunisiki.gunma.ocn.ne.jp [210.163.200.113]) by peach.ocn.ne.jp (8.9.1a/OCN) with ESMTP id XAA22491; Thu, 7 Oct 1999 23:26:56 +0900 (JST) Message-ID: <37FCAD4A.6C902C1A@newsguy.com> Date: Thu, 07 Oct 1999 23:25:14 +0900 From: "Daniel C. Sobral" X-Mailer: Mozilla 4.6 [en] (Win98; I) X-Accept-Language: en,pt-BR,ja MIME-Version: 1.0 To: "Jonathan M. Bresler" Cc: new-bus@FreeBSD.ORG Subject: Re: reported not working References: <19991007124715.AA7DF14C2E@hub.freebsd.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Transfer-Encoding: 7bit Sender: owner-freebsd-new-bus@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG "Jonathan M. Bresler" wrote: > > grr....reported not working. > > lets see. Works for me. -- Daniel C. Sobral (8-DCS) dcs@newsguy.com dcs@freebsd.org "I always feel generous when I'm in the inner circle of a conspiracy to subvert the world order and, with a small group of allies, just defeated an alien invasion. Maybe I should value myself a little more?" To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-new-bus" in the body of the message From owner-freebsd-new-bus Fri Oct 8 16:57:58 1999 Delivered-To: freebsd-new-bus@freebsd.org Received: from rover.village.org (rover.village.org [204.144.255.49]) by hub.freebsd.org (Postfix) with ESMTP id CB57314FFC for ; Fri, 8 Oct 1999 16:57:55 -0700 (PDT) (envelope-from imp@harmony.village.org) Received: from harmony.village.org (harmony.village.org [10.0.0.6]) by rover.village.org (8.9.3/8.9.3) with ESMTP id RAA22211 for ; Fri, 8 Oct 1999 17:57:57 -0600 (MDT) (envelope-from imp@harmony.village.org) Received: from harmony.village.org (localhost.village.org [127.0.0.1]) by harmony.village.org (8.9.3/8.8.3) with ESMTP id RAA70840 for ; Fri, 8 Oct 1999 17:57:54 -0600 (MDT) Message-Id: <199910082357.RAA70840@harmony.village.org> To: new-bus@freebsd.org Subject: Question about self identifying devices Date: Fri, 08 Oct 1999 17:57:54 -0600 From: Warner Losh Sender: owner-freebsd-new-bus@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I have a question about self identifying devices. It is for a custom driver for some hardware that we have at work, but I'll describe it in terms of something in the tree already since the problems are identical. Consider the aha driver. There are 6 locations that the aha driver can map itself into. Right now the probe code has a loop over these addresses plus some self-stepping protection. However, this uglifyies the probe code, so I'm tempted to add code like the following to aha_isa.c: static void aha_isa_identify(driver_t *driver, device_t parent) { device_t child; int i; int addr; int ports[] = { 0x330, 0x334, 0x230, 0x234, 0x130, 0x134 }; int nports = sizeof(ports) / sizeof(ports[0]); for (i = 0; i < nports; i++) { addr = ports[i]; child = BUS_ADD_CHILD(parent, 0, "aha", 0); if (child == NULL) panic("aha_identify"); ISA_SET_RESOURCE(parent, child, SYS_RES_IOPORT, i, addr, AHA_NREG); } } However, there are some problems with this. If I make aha a loadable and unloadable module this creates problems. The first time it is loaded, things appears to be good, until, however, probe happens. When the probe happens, I get something like: aha3: <...> panic: resource_list_alloc: resource entry is busy Debugger("panic") Stopped at Debugger+0x37: movl $0,in_Debugger which seems odd to me. What does this mean? Any idea on how to debug this? If I take out the ISA_SET_RESOURCE from the above, then I don't get the panic. ddb doesn't seem to grok the loaded drivers since I get an address of end+....... on the stack traceback. Second, I suspect that this is too odd for most people. They would get aha3 for a card wired to 0x234 rather than the aha0 they have now. Also, it wouldn't be possible to hardwire them. On the plus side, if I have two aha cards in my system and I load the driver I get to see BOTH of them (right now, you'd only see the first one, which is why I got looking into this problem). I'm not sure what a good thing would be here, short of "prerunning" probe. Third, if I load, unload, load the driver, the previous instances of the aha0..aha5 are still around, so I get aha6..11 as well as aha0..5 and the probes for both aha0 and aha6 seem to succeed. Is there a good way to get rid of the children when I unload? Or should I check to make sure that the aha0 is there first... Comments? Warner P.S. This is for a measurement system where we have n foo-measurement cards. We want to load the driver rather than statically link it in. In the past, we constructed an array of isa_driver which we iterate over in the KLD_LOAD case. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-new-bus" in the body of the message