From owner-freebsd-hackers Mon Feb 16 13:19:08 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id NAA00357 for freebsd-hackers-outgoing; Mon, 16 Feb 1998 13:19:08 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from Octopussy.MI.Uni-Koeln.DE (Octopussy.MI.Uni-Koeln.DE [134.95.166.20]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id NAA00202; Mon, 16 Feb 1998 13:18:29 -0800 (PST) (envelope-from se@dialup124.zpr.uni-koeln.de) Received: from dialup124.zpr.Uni-Koeln.DE (dialup124.zpr.Uni-Koeln.DE [134.95.219.124]) by Octopussy.MI.Uni-Koeln.DE (8.8.7/8.8.7) with ESMTP id WAA05646; Mon, 16 Feb 1998 22:18:06 +0100 (MET) Received: (from se@localhost) by dialup124.zpr.Uni-Koeln.DE (8.8.8/8.6.9) id WAA00486; Mon, 16 Feb 1998 22:17:54 +0100 (CET) X-Face: " Date: Mon, 16 Feb 1998 22:17:54 +0100 From: Stefan Esser To: Amancio Hasty , hackers@FreeBSD.ORG Cc: Stefan Esser Subject: Re: PCI LKM Drivers ? Mail-Followup-To: Amancio Hasty , hackers@FreeBSD.ORG, Stefan Esser References: <199802050526.VAA00603@rah.star-gate.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89i In-Reply-To: <199802050526.VAA00603@rah.star-gate.com>; from Amancio Hasty on Wed, Feb 04, 1998 at 09:26:55PM -0800 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On 1998-02-04 21:26 -0800, Amancio Hasty wrote: > Curious, what is the correct way to load an LKM PCI driver? You need a version of the PCI code, that was not yet tagged into the -stable tree: pci.c (1.64), pcibus.h (1.8) Check the mail archive for my messages on that topic in the September to December 1996 time frame ... > What I would like to have is a Bt848 LKM . > > Tnks, > Amancio > ----------------------- > > static char* lkm_probe (pcici_t tag, pcidi_t type); > static void lkm_attach (pcici_t tag, int unit); > static u_long lkm_count; > > static struct pci_device lkm_device = { > "lkm", > lkm_probe, > lkm_attach, > &lkm_count, > NULL > }; > > DATA_SET (pcidevice_set, lkm_device); > > static char* > lkm_probe (pcici_t tag, pcidi_t type) > { > /* > ** Not yet! > ** (Should try to load a matching driver) > */ > return ((char*)0); > } > > static void > lkm_attach (pcici_t tag, int unit) > {} What you suggest is to tell the PCI code about the laoding of LKMs. That's not the best approach, IMHO. For the case of the Bt848 driver just replace (with the above mentioned versions of pci.c and pcibus.h compiled into the kernel): DATA_SET (pcidevice_set, bktr_device); by: #ifndef LKM DATA_SET (pcidevice_set, bktr_device); #else bktr_load(struct lkm_table* lkmtp, int cmd) { return pci_register_lkm(&bktr_device, 0) } #endif That's it ... When going multi-user, you want to run the following shell script from /etc/rc: #!/bin/sh for dev in `pciconf -l |cut -f1` do if pciconf -a $dev | grep -q "not attached" then DevVendorID=`pciconf -r $dev 0` LKM=`grep $DevVendorID /etc/pcidevices | cut -f 2` LKMfile=/lkm/pci/$LKM.o echo "$dev Loading $LKMfile for DevVendorID $DevVendorID" modload $LKMfile fi done This expects /etc/pcidevices to contain lines like those: 0x0350109E brkt BrookTree 848 0x802910ec if_ed Realtek 8129 NE2000 compatible Ethernet [Everything beyond the second column is a comment. The script will load /lkm/pci/brkt.o, if the PCI vendor and device ID is matched. The script relies on a feature of the PCI code and the pciconf utility (the -a flag) which is not present in -stable, currently, but this has all been tested and works reliably.] If I reserve some time the next few days, I might be able to add the (long finished) PCI LKM support to -stable. I did not do this, yet, because I expect the changes to the FreeBSD device driver code to require an interface change, and there has not been much demand for the LKM feature ... Regards, STefan To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message