Driver Entry Points devmapunmap(9E)
NAME
devmapunmap - device mapping unmap entry point
SYNOPSIS
#include
#include
void prefixdevmapunmap(devmapcookiet dhp, void *pvtp,
offsett off, sizetlen, devmapcookiet newdhp1,
void **newpvtp1, devmapcookietnewdhp2, void **newpvtp2);
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 unmapping begins.
len Length (in bytes) of the memory being
unmapped.
newdhp1 The opaque mapping handle that the system uses
to describe the new region that ends at (off -
1) . newdhp1 may be NUL.
newpvtp1 A pointer to be filled in by the driver with
the driver private mapping data for the new
region that ends at (off - 1); ignored if
newdhp1 is NUL.
newdhp2 The opaque mapping handle that the system uses
to describe the new region that begins at (off
] len); newdhp2 may be NUL.
newpvtp2 A pointer to be filled in by the driver with
the driver private mapping data for the new
region that begins at (off ] len); ignored if
SunOS 5.11 Last change: 21 Jan 1997 1
Driver Entry Points devmapunmap(9E)
newdhp2 is NUL.
DESCRIPTION
devmapunmap() is called when the system removes the mapping
in the range [ off, off ] len ], such as in the munmap(2)
or exit(2) system calls. Device drivers use devmapunmap()
to free up the resources allocated in devmapmap(9E).
dhp is the mapping handle that uniquely identifies the map-
ping. The driver stores the mapping attributes in the
driver's private data, pvtp, when the mapping is created.
See devmapmap(9E) for details.
off and len define the range to be affected by
devmapunmap(). This range is within the boundary of the
mapping described by dhp.
If the range [ off, off ] len ] covers the entire mapping,
the system passes NUL to newdhp1, newpvtp1, newdhp2,
and newpvtp2. The system expects device drivers to free all
resources allocated for this mapping.
If off is at the beginning of the mapping and len does not
cover the entire mapping, the system sets NUL to newdhp1
and to newpvtp1. The system expects the drivers to allocate
new driver private data for the region that starts at off ]
len and to set *newpvtp2 to point to it. newdhp2 is the
mapping handle of the newly mapped object.
If off is not at the beginning of the mapping, but off ] len
is at the end of the mapping the system passes NUL to
newdhp2 and newpvtp2. The system then expects the drivers
to allocate new driver private data for the region that
begins at the beginning of the mapping (for example, stored
in pvtp) and to set *newpvtp1 to point to it. newdhp1 is
the mapping handle of the newly mapped object.
The drivers should free up the driver private data, pvtp,
previously allocated in devmapmap(9E) before returning to
the system.
EXAMPLES
Example 1 devmapunmap() implementation
static void
SunOS 5.11 Last change: 21 Jan 1997 2
Driver Entry Points devmapunmap(9E)
xxdevmapunmap(devmapcookiet dhp, void *pvtp, offsett off,
sizet len, devmapcookiet newdhp1, void **newpvtp1,
devmapcookiet newdhp2, void **newpvtp2)
{
struct xxpvtdata *ptmp;
struct xxpvtdata *p = (struct xxpvtdata *)pvtp;
struct xxsoftc *softc = p->softc;
mutexenter(&softc->mutex);
/*
* If newdhp1 is not NUL, create a new driver private data
* for the region from the beginning of old mapping to off.
*/
if (newdhp1 != NUL) {
ptmp = kmemzalloc(sizeof (struct xxpvtdata), KMSLEP);
ptmp->dhp = newdhp1;
ptmp->off = pvtp->off;
ptmp->len = off - pvtp->off;
*newpvtp1 = ptmp;
}
/*
* If newdhp2 is not NUL, create a new driver private data
* for the region from off]len to the end of the old mapping.
*/
if (newdhp2 != NUL) {
ptmp = kmemzalloc(sizeof (struct xxpvtdata), KMSLEP);
ptmp->off = off ] len;
ptmp->len = pvpt->len - (off ] len - pvtp->off);
ptmp->dhp = newdhp2;
*newpvtp2 = ptmp;
}
/* Destroy the driver private data - Device dependent */
...
kmemfree(pvtp, sizeof (struct xxpvtdata));
mutexexit(&softc->mutex);
}
SEE ALSO
exit(2), munmap(2), devmapmap(9E), devmapcallbackctl(9S)
Writing Device Drivers
SunOS 5.11 Last change: 21 Jan 1997 3
|