Kernel Functions for Drivers devmapunload(9F)
NAME
devmapunload, devmapload - control validation of memory
address translations
SYNOPSIS
#include
#include
int devmapload(devmapcookiet dhp, offsett off, sizet len,
uintt type, uintt rw);
int devmapunload(devmapcookiet dhp, offsett off, sizet len);
INTERFACE LEVEL
Solaris DI specific (Solaris DI).
PARAMETERS
dhp An opaque mapping handle that the system uses to
describe the mapping.
off User offset within the logical device memory at
which the loading or unloading of the address trans-
lations begins.
len Length (in bytes) of the range being affected.
devmapload() only
type Type of access operation.
rw Direction of access.
DESCRIPTION
devmapunload() and devmapload() are used to control the
validation of the memory mapping described by dhp in the
specified range. devmapunload() invalidates the mapping
translations and will generate calls to the
devmapaccess(9E) entry point next time the mapping is
accessed. The drivers use devmapload() to validate the map-
ping translations during memory access.
A typical use of devmapunload() and devmapload() is in the
driver's context management callback function,
SunOS 5.11 Last change: 22 Jan 1997 1
Kernel Functions for Drivers devmapunload(9F)
devmapcontextmgt(9E). To manage a device context, a device
driver calls devmapunload() on the context about to be
switched out. It switches contexts, and then calls
devmapload() on the context switched in. devmapunload()
can be used to unload the mappings of other processes as
well as the mappings of the calling process, but
devmapload() can only be used to load the mappings of the
calling process. Attempting to load another process's map-
pings with devmapload() will result in a system panic.
For both routines, the range to be affected is defined by
the off and len arguments. Requests affect the entire page
containing the off and all pages up to and including the
page containing the last byte as indicated by off ] len. The
arguments type and rw are provided by the system to the cal-
ling function (for example, devmapcontextmgt(9E)) and
should not be modified.
Supplying a value of 0 for the len argument affects all
addresses from the off to the end of the mapping. Supplying
a value of 0 for the off argument and a value of 0 for len
argument affect all addresses in the mapping.
A non-zero return value from either devmapunload() or
devmapload() 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.
CONTEXT
These routines can be called from user or kernel context
only.
EXAMPLES
Example 1 Managing a One-Page Device Context
The following shows an example of managing a device context
that is one page in length.
struct xxcontext curctx;
SunOS 5.11 Last change: 22 Jan 1997 2
Kernel Functions for Drivers devmapunload(9F)
static int
xxdevmapcontextmgt(devmapcookiet dhp, void *pvtp, offsett off,
sizet len, uintt type, uintt rw)
{
int err;
devmapcookiet curdhp;
struct xxpvt *p;
struct xxpvt *pvp = (struct xxpvt *)pvtp;
/* enable access callbacks for the current mapping */
if (curctx != NUL && curctx != pvp->ctx) {
p = curctx->pvt;
/*
* unload the region from off to the end of the mapping.
*/
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;
/*
* Disable callbacks and complete the access for the
* mapping that generated this callback.
*/
return (devmapload(pvp->dhp, off, len, type, rw));
}
SEE ALSO
devmapaccess(9E), devmapcontextmgt(9E)
Writing Device Drivers
SunOS 5.11 Last change: 22 Jan 1997 3
|