Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Jan 1997 09:06:28 -0800
From:      "Jin Guojun[ITG]" <jin@george.lbl.gov>
To:        jpt@msc.edu, se@freebsd.org
Cc:        erich@lodgenet.com, hackers@freebsd.org
Subject:   Re: Q for loadable network driver
Message-ID:  <199701151706.JAA22306@george.lbl.gov>

next in thread | raw e-mail | index | archive | help
>         We have a suite of loadable drivers which support an ATM
> research platform. They're available for limited release supporting
> SunOS 4.1.x and the FORE SBA200/SBA200E adapters. Our current task
> has been porting this suite to FreeBSD using the FORE PCA200E PCI
> card and thus we're "experienced" the lack of support for PCI LKMs.
> 
> Not that I'm offering to implement this (yet), but why not think along
> the lines of SunOS and the SBus? SunOS uses an indetify() routine in
> the driver which receives an ascii device identifier (from the SBus
> device PROM) and the driver says "yes - I want it" or "No - it's somebody
> elses device". If say an identify() entry point were non-NULL, FreeBSD
> could call the entry for either: every device in the PCI table (claimed
> and unclaimed) or just those devices not assigned. This leaves the
> configuration upto the device driver and doesn't require a user to run
> around pointing to where drivers might be and what tag's/ID's they're
> assigned to. My gut instinct is to cringe really bad when someone suggests
> user level configuration of what ought only be kernel level info (ie. the
> PCI bus).
> 
> Comments?
> 
> -- 
> Joseph Thomas                           E/Mail:  jpt@msc.edu

identify() is named xxx_probe() in FreeBSD. The "xxx" is your device name,
or something is related to the maker name.
It returns either an ascii string pointer in successfully probing (identifying),
or NULL pointer if this is someone else device.

STefan has made progress on LKM PCI module, and I have used it successfully
for our ATM driver which is submitted to a commercial BETA release this week.
For LKM driver and non LKM driver (for FreeBSD 2.1.x or earlier),
there is only one line difference in the xxx_attach() routine. That is,
in a LKM driver, the line

DATA_SET(pcidevice_set, xxxdevice); 

is deleted because this line is for pci_bus scanner knowing what driver has
been compiled in the kernel during booting up.
In a LKM driver, this is the parameter passed to LKM module.

Here is my ATM LKM module (completed for load/unload, but no status) which is
simple enough and I think there is no need to argue for an alternative.

-Jin

--------------------------- zatm_mod.c ---------------

/*      zatm_mod.c
 #
 %      Copyright (c)   1996, 1997 Jin Guojun   - All rights reserved
 *
 * THIS SOFTWARE IS PROVIDED BY TERRENCE R. LAMBERT ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE TERRENCE R. LAMBERT BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 */

#include <sys/errno.h>
#include <sys/param.h>
#include <sys/sysent.h>
#include <sys/ioctl.h>
#include <sys/conf.h>
#include <sys/exec.h>
#include <sys/lkm.h>
#include <sys/systm.h>

MOD_MISC(zatm);

zatm_mod(lkmtp, cmd, ver)
struct lkm_table*       lkmtp;
int                     cmd, ver;
{
        DISPATCH(lkmtp,cmd,ver, zatm_load,zatm_unload,zatm_stat);
}

#include "commNdep.h"
#include <pci/pci_ioctl.h>

extern struct pci_device zpadevice;

zatm_stat(struct lkm_table* lkmtp, int cmd)
{
        printf("\nChecking zatm status\n");
return  0;
}

static
zatm_load(struct lkm_table*     lkmtp, int cmd)
{
        return  pci_register_lkm(&zpadevice);
}
static
zatm_unload(struct lkm_table* lkmtp, int cmd)
{
        printf("unloading znatm\n");
	return  pci_unregister_lkm(&zpadevice);
}




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