int xxdevmap_dup(devmap_cookie_t handle, void *devprivate, devmap_cookie_t new_handle, void **new_devprivate);
This entry point is called when a device mapping is duplicated, for example, by a user process calling fork(2). The driver is expected to generate new driver private data for the new mapping.
Mapping handle of the mapping being duplicated.
Mapping handle of the mapping that was duplicated.
Pointer to the driver private data associated with the mapping being duplicated.
Should be set to point to the new driver private data for the new mapping.
Mappings created with devmap_dup(9E) will, by default, have their mapping translations invalidated. This will force a call to the devmap_access(9E) entry point the first time the mapping is accessed.
Example 13-4 shows a devmap_dup(9E) routine.
static int xxdevmap_dup(devmap_cookie_t handle, void *devprivate, devmap_cookie_t new_handle, void **new_devprivate) { struct xxctx *ctxp = devprivate; struct xxstate *xsp = ctxp->xsp; struct xxctx *newctx; /* Create a new context for the duplicated mapping */ newctx = kmem_alloc(sizeof (struct xxctx), KM_SLEEP); newctx->xsp = xsp; newctx->handle = new_handle; newctx->offset = ctxp->offset; newctx->flags = ctxp->flags; newctx->len = ctxp->len; mutex_enter(&xsp->ctx_lock); if (ctxp->flags & MAP_PRIVATE) { newctx->context = kmem_alloc(XXCTX_SIZE, KM_SLEEP); bcopy(ctxp->context, newctx->context, XXCTX_SIZE); } else { newctx->context = xsp->ctx_shared; } mutex_exit(&xsp->ctx_lock); *new_devprivate = newctx; return(0); }