add an LKM for "wi at pcmcia" as an example for the new MOD_DRV LKM type

This commit is contained in:
drochner 2004-08-18 13:12:07 +00:00
parent 0c34f6cd99
commit b1a9bed356
3 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,21 @@
# $NetBSD: Makefile,v 1.1 2004/08/18 13:12:07 drochner Exp $
S= ${.CURDIR}/../../../..
KMOD= wi_pcmcia
SRCS= wi_pcmcia_lkm.c
NOMAN= #yes
WARNS= 2
#CPPFLAGS+= -DDIAGNOSTIC -DLOCKDEBUG
CPPFLAGS+= -DDIAGNOSTIC -DDEBUG
.PATH: $S/dev/pcmcia $S/dev/ic
SRCS+= if_wi_pcmcia.c
# if the "wi" driver backend is already in the
# kernel (as "wi at pci"), comment out / uncomment
SRCS+= wi.c
#CPPFLAGS+= -DWI_DRIVER_IS_PRESENT
.include <bsd.kmod.mk>

View File

@ -0,0 +1,5 @@
/* $NetBSD: bpfilter.h,v 1.1 2004/08/18 13:12:07 drochner Exp $ */
/* This is a hack. */
#define NBPFILTER 0

View File

@ -0,0 +1,47 @@
/* $NetBSD: wi_pcmcia_lkm.c,v 1.1 2004/08/18 13:12:07 drochner Exp $ */
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/lkm.h>
#ifndef WI_DRIVER_IS_PRESENT
CFDRIVER_DECL(wi, DV_DULL, NULL);
#endif
extern struct cfdriver wi_cd;
extern struct cfattach wi_pcmcia_ca;
static int pcmcialoc[] = { -1, -1 }; /* function, irq */
static struct cfparent pcmciaparent = {
"pcmcia", "pcmcia", DVUNIT_ANY
};
static struct cfdata wi_pcmcia_cfdata[] = {
{"wi", "wi_pcmcia", 0, FSTATE_STAR, pcmcialoc, 0, &pcmciaparent, 0},
{ 0 }
};
static struct cfdriver *wi_pcmcia_cfdrivers[] = {
&wi_cd,
NULL
};
static struct cfattach *wi_pcmcia_cfattachs[] = {
&wi_pcmcia_ca,
NULL
};
static const struct cfattachlkminit wi_pcmcia_cfattachinit[] = {
{ "wi", wi_pcmcia_cfattachs },
{ NULL }
};
int wi_pcmcia_lkmentry(struct lkm_table *, int, int);
MOD_DRV("wi_pcmcia", wi_pcmcia_cfdrivers, wi_pcmcia_cfattachinit,
wi_pcmcia_cfdata);
int
wi_pcmcia_lkmentry(struct lkm_table *lkmtp, int cmd, int ver)
{
DISPATCH(lkmtp, cmd, ver, lkm_nofunc, lkm_nofunc, lkm_nofunc);
}