/*
* 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.
*/
/*
* A simple wrapper around the balloon kernel thread to allow userland
* programs access to the balloon status.
*/
#include <sys/hypervisor.h>
#include <sys/sysmacros.h>
#include <sys/balloon_impl.h>
/*ARGSUSED*/
static int
{
return (DDI_FAILURE);
switch (cmd) {
case DDI_INFO_DEVT2DEVINFO:
*result = balloon_devi;
break;
case DDI_INFO_DEVT2INSTANCE:
*result = 0;
break;
default:
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
static int
{
if (cmd != DDI_ATTACH)
return (DDI_FAILURE);
return (DDI_FAILURE);
balloon_devi = devi;
return (DDI_SUCCESS);
}
static int
{
if (cmd != DDI_DETACH)
return (DDI_FAILURE);
balloon_devi = NULL;
return (DDI_SUCCESS);
}
/*ARGSUSED1*/
static int
{
}
/*
* When asked for one of the balloon values, we simply query the balloon thread.
*/
/*ARGSUSED*/
static int
int *rval_p)
{
int rval = 0;
switch (cmd) {
case BLN_IOCTL_CURRENT:
case BLN_IOCTL_TARGET:
case BLN_IOCTL_LOW:
case BLN_IOCTL_HIGH:
case BLN_IOCTL_LIMIT:
mode))
return (EFAULT);
break;
default:
break;
}
return (rval);
}
nulldev, /* close */
nodev, /* strategy */
nodev, /* print */
nodev, /* dump */
nodev, /* read */
nodev, /* write */
balloon_ioctl, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */
nodev, /* segmap */
nochpoll, /* poll */
NULL,
NULL,
};
0,
nulldev, /* identify */
nulldev, /* probe */
nodev, /* reset */
NULL, /* struct bus_ops */
NULL, /* power */
ddi_quiesce_not_needed, /* quiesce */
};
"balloon driver",
};
{
(void *)&modldrv,
NULL /* null termination */
}
};
int
_init(void)
{
return (mod_install(&modl));
}
int
_fini(void)
{
return (mod_remove(&modl));
}
int
{
}