xref: /titanic_52/usr/src/man/man9e/devmap_dup.9e (revision 1a5e258f5471356ca102c7176637cdce45bac147)
te
Copyright (c) 1996, Sun Microsystems, Inc. All Rights Reserved
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
DEVMAP_DUP 9E "Jan 21, 1997"
NAME
devmap_dup - device mapping duplication entry point
SYNOPSIS

#include <sys/ddi.h>
#include <sys/sunddi.h



 int prefixdevmap_dup(devmap_cookie_t dhp, void *pvtp,
 devmap_cookie_t new_dhp, void **new_pvtp);
INTERFACE LEVEL

Solaris DDI specific (Solaris DDI).

ARGUMENTS
dhp

An opaque mapping handle that the system uses to describe the mapping currently being duplicated.

pvtp

Driver private mapping data for the mapping currently being duplicated.

new_dhp

An opaque data structure that the system uses to describe the duplicated device mapping.

new_pvtp

A pointer to be filled in by device drivers with the driver private mapping data for the duplicated device mapping.

DESCRIPTION

The system calls devmap_dup() when a device mapping is duplicated, such as during the execution of the fork(2) system call. The system expects devmap_dup() to generate new driver private data for the new mapping, and to set new_pvtp to point to it. new_dhp is the handle of the new mapped object.

A non-zero return value from devmap_dup() will cause a corresponding operation such as fork() to fail.

RETURN VALUES

devmap_dup() returns the following values: 0

Successful completion.

Non-zero

An error occurred.

EXAMPLES
static int
xxdevmap_dup(devmap_cookie_t dhp, void *pvtp, \e
 devmap_cookie_t new_dhp,
 void **new_pvtp)
{
 struct xxpvtdata *prvtdata;
 struct xxpvtdata *p = (struct xxpvtdata *)pvtp;
 struct xx_softc *softc = p->softc;
 mutex_enter(&softc->mutex);
 /* Allocate a new private data structure */
 prvtdata = kmem_alloc(sizeof (struct xxpvtdata), KM_SLEEP);
 /* Return the new data */
 prvtdata->off = p->off;
 prvtdata->len = p->len;
 prvtdata->ctx = p->ctx;
 prvtdata->dhp = new_dhp;
 prvtdata->softc = p->softc;
 *new_pvtp = prvtdata;
 mutex_exit(&softc->mutex);
 return (0);
}
SEE ALSO

fork(2), devmap_callback_ctl(9S)

Writing Device Drivers