Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Dec 1996 15:22:48 +0100
From:      se@freebsd.org (Stefan Esser)
To:        jin@george.lbl.gov (Jin Guojun[ITG])
Cc:        erich@lodgenet.com, hackers@freebsd.org
Subject:   Re: Q for loadable network driver
Message-ID:  <Mutt.19961218152248.se@x14.mi.uni-koeln.de>
In-Reply-To: <199612162119.NAA29129@george.lbl.gov>; from Jin Guojun[ITG] on Dec 16, 1996 13:19:33 -0800
References:  <199612162119.NAA29129@george.lbl.gov>

next in thread | previous in thread | raw e-mail | index | archive | help
On Dec 16, jin@george.lbl.gov (Jin Guojun[ITG]) wrote:
> Another question is that is necessary to link the newly loaded driver to
> the kernel control block --
> /sys/pci.c:155:static      struct pcicb   *pcicb;
> -------------------------------------------------------------
> pci/pci.c: unmodified: line 704 --
>                         /*    
>                         **  allocate bus descriptor for bus behind the bridge
>                         */      
>                         link = &pcicb->pcicb_down;
>                         while (*link && (*link)->pcicb_bus < secondary)
>                                 link = &(*link)->pcicb_next;
>                                         
>                         this = malloc (sizeof (*this), M_DEVBUF, M_WAITOK);
> 
> 			... ...
> 
>                         /*
>                         **      Link it in chain.
>                         */              
>                         *link=this;
> pci/pci.c: unmodified: line 819 --
> -----------------------------------------------------------------
> Without an interface to get the PCI control block address -- &pcicb -- it is
> hardly to link the new information into the kernel PCI chain.
> Also, is the segment above (pci/pci.c line 704 - 819) necessary for loading
> a loadable device driver?

I've been thinking about PCI LKMs, and my proposed 
solution would work this way:

- Have a user land command retrieve information about
  PCI devices that got no driver assigned (easy, use
  ioctl() on /dev/pci after I apply a simple patch :)

- This user land program will then scan for a file 
  with the correct driver. This will most probably be
  done by having a PCI LKM config file under /etc,
  which contains the LKM name that corresponds to
  some PCI vendor+device ID (or the subvendorid).
  Something along the lines of:

0x00011000	pci_ncr.o
0x000f1000	pci_ncr.o
0x802910ec	pci_ed.o

  Then a modload is performed, which will add the
  driver to the list of known PCI drivers.

  I think the device driver should just be loaded,
  and a PCI bus rescan be initiated, which will find
  the new driver, and will attach all devices it is
  able to support. (This is already prepared for in
  the current PCI code.)

So, all you need (IMHO) is:

- The patch to pci_ioctl(), which puts the information
  whether there was a driver for some device into the
  pciconf struct.

- A function to call from the LKM to register the new
  driver. The PCI code will test drivers on a linked
  list (and prefer them to compiled in code) for this
  to become effective.

- A function that initiates a PCI bus rescan. Possibly
  combined with the previous one, but I would in fact
  prefer to have a separate load, unload and rescan
  function ...
  (Or would having rescan implied by load, and stopping
   the driver before unload be better ??? Possible ...)

What do you think about these changes ?

The result will be, that your PCI LKM is called with the
corresponding PCI tag. The driver must receive the &pcibus 
to be able to call back into the PCI code, and this may 
either be by making pcibus a global variable again, or by 
making it an additional parameter of the attach function.

Would this help ?

Regards, STefan



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