Kernel Functions for Drivers devmapdoctxmgt(9F)
NAME
devmapdoctxmgt - perform device context switching on a
mapping
SYNOPSIS
#include
#include
int devmapdoctxmgt(devmapcookiet dhp, void *pvtp, offsett off,
sizet len, uintt type,
uintt rw, int (*devmapcontextmgt)devmapcookiet,
void *, offsett, sizet, uintt, uintt);
INTERFACE LEVEL
Solaris DI specific (Solaris DI).
PARAMETERS
dhp An opaque mapping handle that the sys-
tem 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.
devmapcontextmgt The address of driver function that
the system will call to perform con-
text switching on a mapping. See
devmapcontextmgt(9E) for details.
type Type of access operation. Provided by
devmapaccess(9E). Should not be modi-
fied.
rw Direction of access. Provided by
devmapaccess(9E). Should not be modi-
fied.
SunOS 5.11 Last change: 22 Jan 1997 1
Kernel Functions for Drivers devmapdoctxmgt(9F)
DESCRIPTION
Device drivers call devmapdoctxmgt() in the
devmapaccess(9E) entry point to perform device context
switching on a mapping. devmapdoctxmgt() passes a pointer
to a driver supplied callback function,
devmapcontextmgt(9E), to the system that will perform the
actual device context switching. If devmapcontextmgt(9E)
is not a valid driver callback function, the system will
fail the memory access operation which will result in a SIG-
SEGV or SIGBUS signal being delivered to the process.
devmapdoctxmgt() performs context switching on the mapping
object identified by dhp and pvtp in the range specified by
off and len. The arguments dhp, pvtp, type, and rw are pro-
vided by the devmapaccess(9E) entry point and must not be
modified. The range from off to off]len must support context
switching.
The system will pass through dhp, pvtp, off, len, type, and
rw to devmapcontextmgt(9E) in order to perform the actual
device context switching. The return value from
devmapcontextmgt(9E) will be returned directly to
devmapdoctxmgt().
RETURN VALUES
0 Successful completion.
Non-zero An error occurred.
CONTEXT
devmapdoctxmgt() must be called from the driver's
devmapaccess(9E) entry point.
EXAMPLES
Example 1 Using devmapdoctxmgt in the devmapaccess entry
point.
The following shows an example of using devmapdoctxmgt()
in the devmapaccess(9E) entry point.
...
#define OFDOCTXMGT 0x40000000
#define OFNORMAL 0x40100000
#define CTXMGTSIZE 0x100000
#define NORMALSIZE 0x100000
SunOS 5.11 Last change: 22 Jan 1997 2
Kernel Functions for Drivers devmapdoctxmgt(9F)
/*
* Driver devmapcontextmgt(9E) callback function.
*/
static int
xxcontextmgt(devmapcookiet dhp, void *pvtp, offsett offset,
sizet length, uintt type, uintt rw)
{
......
/*
* see devmapcontextmgt(9E) for an example
*/
}
/*
* Driver devmapaccess(9E) entry point
*/
static int
xxdevmapaccess(devmapcookiet dhp, void *pvtp, offsett off,
sizet len, uintt type, uintt rw)
{
offsett diff;
int err;
/*
* check if off is within the range that supports
* context management.
*/
if ((diff = off - OFDOCTXMG) >= 0 && diff < CTXMGTSIZE) {
/*
* calculates the length for context switching
*/
if ((len ] off) > (OFDOCTXMGT ] CTXMGTSIZE))
return (-1);
/*
* perform context switching
*/
err = devmapdoctxmgt(dhp, pvtp, off, len, type,
rw, xxcontextmgt);
/*
* check if off is within the range that does normal
* memory mapping.
*/
} else if ((diff = off - OFNORMAL) >= 0 && diff < NORMALSIZE) {
if ((len ] off) > (OFNORMAL ] NORMALSIZE))
return (-1);
err = devmapdefaultaccess(dhp, pvtp, off, len, type, rw);
} else
return (-1);
return (err);
}
SunOS 5.11 Last change: 22 Jan 1997 3
Kernel Functions for Drivers devmapdoctxmgt(9F)
SEE ALSO
devmapaccess(9E), devmapcontextmgt(9E),
devmapdefaultaccess(9F)
Writing Device Drivers
SunOS 5.11 Last change: 22 Jan 1997 4
|