/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* sun4v machine description driver
*/
#include <sys/mach_descrip.h>
/*
* Operational state flags
*/
static void *mdesc_state_head;
static int mdesc_attached = 0;
struct mdesc_state {
int instance;
int flags;
};
mdesc_open, /* cb_open */
mdesc_close, /* cb_close */
nodev, /* cb_strategy */
nodev, /* cb_print */
nodev, /* cb_dump */
mdesc_read, /* cb_read */
nodev, /* cb_write */
mdesc_ioctl, /* cb_ioctl */
nodev, /* cb_devmap */
nodev, /* cb_mmap */
nodev, /* cb_segmap */
nochpoll, /* cb_chpoll */
ddi_prop_op, /* cb_prop_op */
CB_REV, /* cb_rev */
nodev, /* cb_aread */
nodev /* cb_awrite */
};
DEVO_REV, /* devo_rev */
0, /* devo_refcnt */
mdesc_getinfo, /* devo_getinfo */
nulldev, /* devo_identify */
nulldev, /* devo_probe */
mdesc_attach, /* devo_attach */
mdesc_detach, /* devo_detach */
nodev, /* devo_reset */
&mdesc_cb_ops, /* devo_cb_ops */
nulldev, /* devo_power */
ddi_quiesce_not_needed, /* quiesce */
};
"Machine Description Driver",
(void *)&modldrv,
};
int
_init(void)
{
int retval;
sizeof (struct mdesc_state), mdesc_max_opens)) != 0)
return (retval);
return (retval);
}
return (retval);
}
int
{
}
int
_fini(void)
{
int retval;
return (retval);
return (retval);
}
/*ARGSUSED*/
static int
{
switch (cmd) {
case DDI_INFO_DEVT2DEVINFO:
*resultp = mdesc_devi;
} else
break;
case DDI_INFO_DEVT2INSTANCE:
break;
}
return (retval);
}
static int
{
switch (cmd) {
case DDI_ATTACH:
DDI_PSEUDO, 0) != DDI_SUCCESS) {
return (DDI_FAILURE);
}
mdesc_devi = dip;
mdesc_attached = 1;
return (DDI_SUCCESS);
case DDI_RESUME:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
}
/*ARGSUSED*/
static int
{
switch (cmd) {
case DDI_DETACH:
mdesc_attached = 0;
return (DDI_SUCCESS);
case DDI_SUSPEND:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
}
static void
{
}
static mdesc_state_t *
{
VM_BESTFIT | VM_SLEEP);
DDI_SUCCESS) {
MDESC_NAME, minor);
return (NULL);
}
} else {
}
return (NULL);
}
}
return (mdsp);
}
/*ARGSUSED*/
static int
{
return (EINVAL);
if (!mdesc_attached)
return (ENXIO);
if (mdesc_opens >= mdesc_max_opens) {
return (ENXIO);
}
return (ENXIO);
}
mdesc_opens++;
return (0);
}
/*ARGSUSED*/
static int
{
return (EINVAL);
if (mdesc_opens == 0) {
return (0);
}
return (ENXIO);
mdesc_opens--;
return (0);
}
/*ARGSUSED*/
static int
{
}
/*ARGSUSED*/
static int
{
return (ENXIO); /* This driver version does not allow updates */
}
static int
{
int retval;
return (ENXIO);
if (len == 0)
return (0);
return (EINTR);
}
}
return (EINVAL);
}
/* already checked that offset<mdesc_len above */
if (len == 0) {
}
return (ENXIO);
return (retval);
}
/*ARGSUSED*/
static int
int *rvalp)
{
return (ENXIO);
switch (cmd) {
case MDESCIOCGSZ: {
/*
* We are not guaranteed that ddi_copyout(9F) will read
* atomically anything larger than a byte. Therefore we
* must duplicate the size before copying it out to the user.
*/
return (EACCES);
#ifdef _MULTI_DATAMODEL
case DDI_MODEL_ILP32: {
mode) != 0)
return (EFAULT);
return (0);
}
case DDI_MODEL_NONE:
mode) != 0)
return (EFAULT);
return (0);
default:
"mdesc: Invalid data model %d in ioctl\n",
return (ENOTSUP);
}
#else /* ! _MULTI_DATAMODEL */
return (EFAULT);
return (0);
#endif /* _MULTI_DATAMODEL */
}
default:
return (ENOTTY);
}
}