Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

add_drv(1M)

mod_info(9F)

mod_install(9F)

mod_remove(9F)

modldrv(9S)

modlinkage(9S)

modlstrmod(9S)

_fini(9E)

NAME

_fini, _info, _init − loadable module configuration entry points

SYNOPSIS

#include <sys/modctl.h>
int _fini(void);

int _info(struct modinfo ∗modinfop);

int _init(void);

ARGUMENTS

_info()

modinfop A pointer to an opaque modinfo structure. 

INTERFACE LEVEL

SPARC architecture specific (SPARC DDI).  These entry points are required.  You must write them. 

DESCRIPTION

_init() initializes a loadable module.  It is called before any other routine in a loadable module.  _init() returns the value returned by mod_install(9F).  The module may optionally perform some other work before the mod_install(9F) call is performed.  If the module has done some setup before the mod_install(9F) function is called, then it should be prepared to undo that setup if mod_install(9F) returns an error. 

_info() returns information about a loadable module.  _info() returns the value returned by mod_info(9F). 

_fini() prepares a loadable module for unloading.  It is called when the system wants to unload a module.  If the module determines that it can be unloaded, then _fini() returns the value returned by mod_remove(9F).  Upon successful return from _fini() no other routine in the module will be called before _init() is called. 

RETURN VALUES

_init() should return the appropriate error number if there is an error, else it should return the return value from mod_install(9F). 

_info() should return the return value from mod_info(9F)

_fini() should return the return value from mod_remove(9F). 

EXAMPLES

#include <sys/modctl.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>
 static struct dev_ops  drv_ops;
 /∗
 ∗ Module linkage information for the kernel.
 ∗/
static struct modldrv modldrv = {
&mod_driverops,/∗ Type of module.  This one is a driver ∗/
"Sample Driver",
&drv_ops/∗ driver ops ∗/
};
 static struct modlinkage modlinkage = {
MODREV_1,
&modldrv,
NULL
};
  int
_init(void)
{
return (mod_install(&modlinkage));
}
 int
_info(struct modinfo ∗modinfop)
{
return (mod_info(&modlinkage, modinfop));
}
 int
_fini(void)
{
return (mod_remove(&modlinkage));
}

SEE ALSO

add_drv(1M), mod_info(9F), mod_install(9F), mod_remove(9F), modldrv(9S), modlinkage(9S), modlstrmod(9S)

SunOS 5.3 Writing Device Drivers

WARNINGS

Do not change the structures referred to by the modlinkage structure after the call to mod_install(), as the system may copy or change them. 

NOTES

Even though the identifiers _fini(), _info(), and _init() appear to be declared as globals, their scope is restricted by the kernel to the module that they are defined in.

BUGS

On some implementations _info() may be called before _init().

Sun Microsystems  —  Last change: 27 Jan 1993

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026