Driver Entry Points devmapcontextmgt(9E)
NAME
devmapcontextmgt - driver callback function for context
management
SYNOPSIS
#include
#include
int devmapcontextmgt(devmapcookiet dhp, void *pvtp,
offsett off, sizet len, uintt type, uintt rw);
INTERFACE LEVEL
Solaris DI specific (Solaris DI).
ARGUMENTS
dhp An opaque mapping handle that the system uses to
describe the mapping.
pvtp Driver private mapping data.
off User offset within the logical device memory at
which the access begins.
len Length (in bytes) of the memory being accessed.
type Type of access operation. Possible values are:
DEVMAPACES Memory access.
DEVMAPLOCK Lock the memory being accessed.
DEVMAPUNLOCK Unlock the memory being accessed.
rw Direction of access. Possible values are:
DEVMAPREAD Read access attempted.
DEVMAPWRITE Write access attempted.
SunOS 5.11 Last change: 16 Jan 1997 1
Driver Entry Points devmapcontextmgt(9E)
DESCRIPTION
devmapcontextmgt() is a driver-supplied function that per-
forms device context switching on a mapping. Device
drivers pass devmapcontextmgt() as an argument to
devmapdoctxmgt(9F) in the devmapaccess(9E) entry point.
The system will call devmapcontextmgt() when memory is
accessed. The system expects devmapcontextmgt() to load
the memory address translations of the mapping by calling
devmapload(9F) before returning.
dhp uniquely identifies the mapping and is used as an argu-
ment to devmapload(9F) to validate the mapping. off and
len define the range to be affected by the operations in
devmapcontextmgt().
The driver must check if there is already a mapping esta-
blished at off that needs to be unloaded. If a mapping
exists at off, devmapcontextmgt() must call
devmapunload(9F) on the current mapping. devmapunload(9F)
must be followed by devmapload() on the mapping that gen-
erated this call to devmapcontextmgt(). devmapunload(9F)
unloads the current mapping so that a call to
devmapaccess(9E), which causes the system to call
devmapcontextmgt(), will be generated the next time the
mapping is accessed.
pvtp is a pointer to the driver's private mapping data that
was allocated and initialized in the devmapmap(9E) entry
point. type defines the type of operation that device
drivers should perform on the memory object. If type is
either DEVMAPLOCK or DEVMAPUNLOCK, the length passed to
either devmapunload(9F) or devmapload(9F) must be same as
len. rw specifies the access direction on the memory object.
A non-zero return value from devmapcontextmgt() will be
returned to devmapaccess(9E) and will cause the
corresponding operation to fail. The failure may result in a
SIGSEGV or SIGBUS signal being delivered to the process.
RETURN VALUES
0 Successful completion.
Non-zero An error occurred.
EXAMPLES
SunOS 5.11 Last change: 16 Jan 1997 2
Driver Entry Points devmapcontextmgt(9E)
Example 1 managing a device context
The following shows an example of managing a device context.
struct xxcontext curctx;
static int
xxdevmapcontextmgt(devmapcookiet dhp, void *pvtp, offsett off,
sizet len, uintt type, uintt rw)
{
devmapcookiet curdhp;
struct xxpvtdata *p;
struct xxpvtdata *pvp = (struct xxpvtdata *)pvtp;
struct xxsoftc *softc = pvp->softc;
int err;
mutexenter(&softc->mutex);
/*
* invalidate the translations of current context before
* switching context.
*/
if (curctx != NUL && curctx != pvp->ctx) {
p = curctx->pvt;
curdhp = p->dhp;
if ((err = devmapunload(curdhp, off, len)) != 0)
return (err);
}
/* Switch device context - device dependent*/
...
/* Make handle the new current mapping */
curctx = pvp->ctx;
/*
* Load the address translations of the calling context.
*/
err = devmapload(pvp->dhp, off, len, type, rw);
mutexexit(&softc->mutex);
return (err);
}
SEE ALSO
devmapaccess(9E), devmapdoctxmgt(9F) devmapload(9F),
devmapunload(9F)
Writing Device Drivers
SunOS 5.11 Last change: 16 Jan 1997 3
|