/*
* CDDL HEADER START
*
* 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
* 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]
*
* CDDL HEADER END
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Clone Driver.
*/
NULL };
NULL };
/*
* Module linkage information for the kernel.
*/
&mod_driverops, /* Type of module. This one is a pseudo driver */
"Clone Pseudodriver 'clone'",
&clone_ops, /* driver ops */
};
(void *)&modldrv,
};
int
_init(void)
{
return (mod_install(&modlinkage));
}
int
_fini(void)
{
/*
* Since the clone driver's reference count is unreliable,
* make sure we are never unloaded.
*/
return (EBUSY);
}
int
{
}
/* ARGSUSED */
static int
{
return (DDI_SUCCESS);
}
/* ARGSUSED */
static int
void **result)
{
int error;
switch (infocmd) {
case DDI_INFO_DEVT2DEVINFO:
error = DDI_FAILURE;
} else {
error = DDI_SUCCESS;
}
break;
case DDI_INFO_DEVT2INSTANCE:
*result = (void *)0;
error = DDI_SUCCESS;
break;
default:
error = DDI_FAILURE;
}
return (error);
}
/*
* Clone open. Maj is the major device number of the streams
* device to open. Look up the device in the cdevsw[]. Attach
* its qinit structures to the read and write queues and call its
* open with the sflag set to CLONEOPEN. Swap in a new vnode with
* the real device number constructed from either
* a) for old-style drivers:
* maj and the minor returned by the device open, or
* b) for new-style drivers:
* the whole dev passed back as a reference parameter
* from the device open.
*/
int
{
int error = 0;
if (sflag)
return (ENXIO);
/*
* Get the device to open.
*/
return (ENXIO);
/*
* NOTE We call ddi_hold_installed_driver() here to attach
* all instances of the driver, since we do not know
* a priori which instance the Stream is associated with.
*
* For Style-2 network drivers, we know that the association
* happens at DL_ATTACH time. For other types of drivers,
* open probably requires attaching instance 0 (pseudo dip).
*
* To eliminate ddi_hold_installed_driver(), the following
* should happen:
*
* - GLD be modified to include gld_init(). The driver will
* register information for gld_open() to succeed. It will
* also inform framework if driver assigns instance=PPA.
* - ddi_hold_devi_by_instance() be modified to actively
* attach the instance via top-down enumeration.
*/
return (ENXIO);
return (ENXIO);
}
/*
* Check for security here. For DLPI style 2 network
* drivers, we need to apply the default network policy.
* Clone is weird in that the network driver isn't loaded
* and attached at spec_open() time, we need to load the
* driver to see if it is a network driver. Hence, we
* check security here (after ddi_hold_installed_driver
* call above).
*/
if (error) {
return (error);
}
/*
* Save so that we can restore the q on failure.
*/
/* create perdm_t if needed */
/*
* Set the syncq state what qattach started off with. This is safe
* since no other thread can access this queue at this point
* (stream open, close, push, and pop are single threaded
* by the framework.)
*/
/*
* Substitute the real qinit values for the current ones.
*/
/* setq might sleep in kmem_alloc - avoid holding locks. */
/*
* Open the attached module or driver.
*
* If there is an outer perimeter get exclusive access during
* the open procedure.
* Bump up the reference count on the queue.
*/
/*
* Call the device open with the stream flag CLONEOPEN. The device
* will either fail this or return the device number.
*/
if (error != 0)
goto failed;
goto bad_major;
return (0);
/*
* Close the device
*/
#ifdef DEBUG
#endif
/*
* open failed; pretty up to look like original
* queue.
*/
/* setq might sleep in kmem_alloc - avoid holding locks. */
B_FALSE);
/* Restore back to what qattach will expect */
return (error);
}