DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
SVR5

_load(D2mdi)


_load -- initialize a loadable kernel module

Syntax

See _load(D2) for syntax, context, and general usage information about this entry point routine.

Usage

All MDI drivers must have a _load( ) entry point routine, even for DDI 7. ISA drivers must also have a _verify(D2mdi) entry point routine for DDI 7, or a CFG_VERIFY subfunction for the config(D2mdi) entry point.

Version applicability

mdi: 2, 2.1 running with ddi: 7, 7mp, 8, 8mp.

DLKM example (DDI 7)

MDI drivers written for DDI versions 7 and 7mp must include a wrapper to declare their _load( ) and _unload( ) routines. The following code sample shows how a dynamically loadable DDI 7 driver can be implemented.
   #include <util/mod/moddefs.h>
   

#define DRVNAME "e3B - 3Com EtherLink II series MDI driver" STATIC int e3B_load(), e3B_unload(), e3B_verify(); MOD_ACDRV_WRAPPER(e3B, e3B_load, e3B_unload, NULL, e3B_verify, DRVNAME);

STATIC int e3B_load() { int ret = 0;

if ((ret = e3Binit()) != 0) { e3Buninit(); } return(ret); }

STATIC int e3B_unload() { e3Buninit(); return(0); }

e3Buninit() { register int i;

for (i = 0; i < e3B_nunit && e3Bcookie; i++) { if ((caddr_t)e3Bcookie[i] != (caddr_t)NULL) cm_intr_detach(e3Bcookie[i]); if (e3Bdev[i].tid) { untimeout(e3Bdev[i].tid); /* cancel watchdog routine */ } } if (e3Bcookie) kmem_free((void *)e3Bcookie, (sizeof(void **) * e3B_nunit)); if (e3Bdev) kmem_free((void *)e3Bdev, (sizeof(struct e3Bdevice) * e3B_nunit)); }

DDI 7 MDI drivers must also call mdi_get_unit(D3mdi) from the _load( ) entry point routine to identify the driver instance that has been configured:

           cm_args.cm_key = cm_getbrdkey("e3B", i);
   

if (mdi_get_unit(cm_args.cm_key, &unit) == B_FALSE) { e3Bdev[i].unit = (uint_t) -1; continue; } e3Bdev[i].unit = unit;

For more examples, see HDK code samples in HDK code samples.

References

_load(D2), _verify(D2mdi), mdi_get_unit(D3mdi)
19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 6 and UnixWare (SVR5) HDK - June 2005