Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Feb 1998 22:17:54 +0100
From:      Stefan Esser <se@FreeBSD.ORG>
To:        Amancio Hasty <hasty@rah.star-gate.com>, hackers@FreeBSD.ORG
Cc:        Stefan Esser <se@FreeBSD.ORG>
Subject:   Re: PCI LKM Drivers ?
Message-ID:  <19980216221754.09856@mi.uni-koeln.de>
In-Reply-To: <199802050526.VAA00603@rah.star-gate.com>; from Amancio Hasty on Wed, Feb 04, 1998 at 09:26:55PM -0800
References:  <199802050526.VAA00603@rah.star-gate.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 1998-02-04 21:26 -0800, Amancio Hasty <hasty@rah.star-gate.com> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980216221754.09856>