/*
* 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
*/
/*
*/
#include <fcntl.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include "libdevice.h"
static int _libdevice_debug = 0;
/*
* devctl_hdl structures are allocated by the devctl_XX_acquire()
* interfaces and passed to the remaining interfaces in this library.
*/
struct devctl_hdl {
};
#pragma init(_libdevice_init)
void
{
}
/*
* release a devctl_hdl structure
*/
void
{
if (_libdevice_debug)
return;
}
/*
* construct a handle suitable for devctl_bus_*() operations
*/
{
if (_libdevice_debug)
(void) printf("devctl_bus_acquire: %s (%d)\n",
return (NULL);
}
}
/*
* construct a handle suitable for devctl_bus_*() and
* devctl_device_*() operations.
*/
{
if (_libdevice_debug)
(void) printf("devctl_device_acquire: %s (%d)\n",
return (NULL);
}
}
/*
* given a devfs (/devices) pathname to an attachment point device,
* access the device and return a handle to be passed to the
* devctl_ap_XXX() functions.
*/
{
if (_libdevice_debug)
(void) printf("devctl_ap_acquire: %s (%d)\n",
if ((devfs_path == NULL) ||
return (NULL);
}
}
/*
* given a devfs (/devices) pathname access the device and return
* a handle to be passed to the devctl_pm_XXX() functions.
* The minor name ":devctl" is appended.
*/
{
if (_libdevice_debug)
(void) printf("devctl_pm_bus_acquire: %s (%d)\n",
return (NULL);
}
}
/*
* given a devfs (/devices) pathname access the device and return
* a handle to be passed to the devctl_pm_XXX() functions.
* The minor name is derived from the device name.
*/
{
if (_libdevice_debug)
(void) printf("devctl_pm_dev_acquire: %s (%d)\n",
return (NULL);
}
}
/*
* allocate and initalize the devctl_hdl structure for the
* particular handle type.
*/
static devctl_hdl_t
{
char *minorname;
char *iocpath_dup;
char *tok;
return (NULL);
}
/*
* allocate handle and make a copy of the original path
*/
return (NULL);
}
return (NULL);
}
/*
* break apart the pathname according to the type handle
*/
switch (type) {
case DEVCTL_PM_BUS:
/*
* chop off any minor name and concatenate the
* ":devctl" minor node name string.
*/
*chop = '\0';
MAXPATHLEN) {
return (NULL);
} else if (_libdevice_debug) {
}
break;
case DEVCTL_PM_DEV:
/*
* Chop up the last device component in the pathname.
* Concatenate either the device name itself, or the
* "a,raw" string, as the minor node name, to the iocpath.
*/
return (NULL);
}
return (NULL);
}
*chop = '\0';
/*
* remove the "@0,0" string
*/
if (_libdevice_debug)
(void) printf("DEVCTL_PM_DEV: failed malloc for"
" minorname\n");
return (NULL);
}
if (_libdevice_debug) {
(void) printf("DEVCTL_PM_DEV: minorname %s\n",
}
/*
* construct the name of the ioctl device
* by concatenating either ":a,raw" or ":"minorname
*/
} else {
}
if (strlcpy_size >= MAXPATHLEN) {
return (NULL);
} else if (_libdevice_debug) {
(void) printf("DEVCTL_PM_DEV: iocpath %s\n",
iocpath);
}
break;
case DEVCTL_AP:
/*
* take the pathname as provided.
*/
break;
case DEVCTL_BUS:
/*
* chop off any minor name and concatenate the
* ":devctl" minor node name string.
*/
*chop = '\0';
MAXPATHLEN) {
return (NULL);
}
break;
case DEVCTL_CLONE:
/*
* create a device handle for a new device created
* from a call to devctl_bus_dev_create()
*/
/* FALLTHRU */
case DEVCTL_DEVICE:
/*
* Chop up the last device component in the pathname.
* The components are passed as nodename and unitaddr
* in the IOCTL data for DEVCTL ops on devices.
*/
return (NULL);
}
*chop = '\0';
return (NULL);
}
/*
* copy the nodename and unit address
*/
return (NULL);
}
*unitsep = '\0';
*minorsep = '\0';
/*
* construct the name of the ioctl device
*/
MAXPATHLEN) {
return (NULL);
}
break;
default:
return (NULL);
}
if (_libdevice_debug)
/*
* verify the devctl or ap device exists and is a
* character device interface.
*/
if (_libdevice_debug)
(void) printf(" - not character device\n");
return (NULL);
}
} else {
/*
* return failure with errno value set by stat
*/
if (_libdevice_debug)
(void) printf(" - stat failed\n");
return (NULL);
}
/*
* if this was a new device, dup the parents handle, otherwise
* just open the device.
*/
if (type == DEVCTL_CLONE)
else
if (_libdevice_debug)
/*
*/
return (NULL);
}
if (_libdevice_debug)
(void) printf(" - open success\n");
return ((devctl_hdl_t)dcp);
}
/*
* Power up component 0, to level MAXPWR, via a pm_raise_power() call
*/
int
{
int rv;
return (-1);
}
if (_libdevice_debug)
return (rv);
}
/*
* Power up component 0, to level MAXPWR, via a power_has_changed() call
*/
int
{
int rv;
return (-1);
}
if (_libdevice_debug)
return (rv);
}
/*
* Power down component 0, to level 0, via a pm_change_power() call
*/
int
{
int rv;
return (-1);
}
if (_libdevice_debug)
return (rv);
}
/*
* mark component 0 idle
*/
int
{
int rv;
return (-1);
}
if (_libdevice_debug)
return (rv);
}
/*
* mark component 0 busy
*/
int
{
int rv;
return (-1);
}
if (_libdevice_debug)
return (rv);
}
/*
* test pm busy state
*/
int
{
int rv;
return (-1);
}
return (-1);
}
(void *)&busy_state);
if (rv == -1)
*busystate = 0;
else
*busystate = busy_state;
if (_libdevice_debug)
(void) printf("devctl_pm_bus_testbusy: rv %d busystate %x\n",
return (rv);
}
/*
* set flag to fail DDI_SUSPEND
*/
int
{
int rv;
return (-1);
}
if (_libdevice_debug)
return (rv);
}
int
{
int rv;
return (-1);
}
return (-1);
}
(void *)&strict_state);
if (rv == -1)
*strict = 0;
else
*strict = strict_state;
if (_libdevice_debug)
(void) printf("devctl_pm_bus_teststrict: rv %d strict %x\n",
return (rv);
}
/*
* issue prom_printf() call
*/
int
{
int rv;
return (-1);
}
if (_libdevice_debug)
return (rv);
}
/*
* set flag to power up the device via
* pm_power_has_changed() calls vs.
* pm_raise_power(), during DDI_RESUME
*/
int
{
int rv;
return (-1);
}
if (_libdevice_debug)
return (rv);
}
/*
* issue DEVCTL_PM_NO_LOWER_POWER to clear the LOWER_POWER_FLAG
* flag: pm_lower_power() will not be called on device detach
*/
int
{
int rv;
return (-1);
}
if (_libdevice_debug)
return (rv);
}
/*
* issue DEVCTL_PM_BUS_NO_INVOL ioctl to set the NO_INVOL_FLAG
* flag: parent driver will mark itself idle twice in
* DDI_CTLOPS_DETACH(POST)
*/
int
{
int rv;
return (-1);
}
if (_libdevice_debug)
return (rv);
}
/*
* Place the device ONLINE
*/
int
{
int rv;
return (-1);
}
if (_libdevice_debug)
return (rv);
}
/*
* take device OFFLINE
*/
int
{
int rv;
return (-1);
}
if (_libdevice_debug)
return (rv);
}
/*
* take the device OFFLINE and remove its dev_info node
*/
int
{
int rv;
return (-1);
}
if (_libdevice_debug)
return (rv);
}
/*
* QUIESCE the bus
*/
int
{
int rv;
if (_libdevice_debug)
return (rv);
}
int
{
int rv;
if (_libdevice_debug)
return (rv);
}
int
{
int rv;
if (_libdevice_debug)
return (rv);
}
int
{
int rv;
if (_libdevice_debug)
return (rv);
}
int
{
int rv;
if (_libdevice_debug)
return (rv);
}
int
{
int rv;
return (-1);
}
(void *)&device_state);
if (rv == -1)
*devstate = 0;
else
*devstate = device_state;
if (_libdevice_debug)
(void) printf("devctl_device_getstate: rv %d state %x\n",
return (rv);
}
int
{
int rv;
return (-1);
}
(void *)&device_state);
if (rv == -1)
*devstate = 0;
else
*devstate = device_state;
if (_libdevice_debug)
(void) printf("devctl_bus_getstate: rv %d, state %x\n",
return (rv);
}
int
{
int rv;
if (_libdevice_debug)
return (rv);
}
int
{
int rv;
if (_libdevice_debug)
return (rv);
}
/*
* devctl_bus_dev_create() - create a new child device
* Attempt to construct and attach a new child device below a
* bus nexus (dcp). The device is defined using the devctl_ddef_*()
* routines to specify the set of bus-specific properties required
* to initalize and attach the device.
*/
int
{
int rv = 0;
return (-1);
}
/*
* construct a device handle for the new device
*/
/*
* Take the pathname of the parent device, chop off
* any minor name info, and append the name@addr of
* the new child device.
* Call dc_mkhndl() with this constructed path and
* the CLONE handle type to create a new handle which
* references the new child device.
*/
*lastslash = '\0';
} else {
*minorname = '\0';
}
rv = -1;
}
return (rv);
}
int
{
int rv;
if (_libdevice_debug)
return (rv);
}
int
{
int rv;
if (_libdevice_debug)
return (rv);
}
int
{
int rv;
if (_libdevice_debug)
return (rv);
}
int
{
int rv;
if (_libdevice_debug)
return (rv);
}
int
{
int rv;
if (_libdevice_debug)
return (rv);
}
int
{
int rv;
if (_libdevice_debug)
return (rv);
}
int
{
int rv;
(void *)&ap_state);
if (rv == -1)
else
if (_libdevice_debug)
return (rv);
}
/*
* Allocate a device 'definition' handle, in reality a list of
* nvpair data.
*/
/* ARGSUSED */
{
return (NULL);
}
/*
* allocate nvlist structure which is returned as an
* opaque handle to the caller. If this fails, return
* NULL with errno left set to the value
*/
return (NULL);
}
/*
* add the nodename of the new device to the list
*/
return (NULL);
}
if (_libdevice_debug)
(void *)nvlp);
return ((devctl_ddef_t)nvlp);
}
/*
* free the definition handle
*/
void
{
if (_libdevice_debug)
}
}
/*
* define an integer property
*/
int
{
int rv;
return (-1);
}
if (_libdevice_debug)
(void) printf("devctl_ddef_int: rv %d nvp %p name %s val %d\n",
return (rv);
}
/*
* define an integer array property
*/
int
{
int rv, i;
return (-1);
}
if (_libdevice_debug) {
(void) printf("devctl_ddef_int_array: rv %d nvp %p name %s: ",
for (i = 0; i < nelements; i++)
(void) printf("\n");
}
return (rv);
}
/*
* define a string property
*/
int
{
int rv;
return (-1);
}
if (_libdevice_debug)
(void) printf("devctl_ddef_string: rv %d nvp %p %s=\"%s\"\n",
return (rv);
}
/*
* define a string array property
*/
int
char **value)
{
int rv, i;
return (-1);
}
if (_libdevice_debug) {
(void) printf("devctl_ddef_string_array: rv %d nvp %p "
for (i = 0; i < nelements; i++)
}
return (rv);
}
/*
* define a byte array property
*/
int
{
int rv;
return (-1);
}
return (rv);
}
/*
* return the pathname which was used to acquire the handle
*/
char *
{
return (NULL);
}
return (pathbuf);
}
/*
* execute the IOCTL request
*/
static int
void *retinfo)
{
int rv = 0;
if (_libdevice_debug)
return (-1);
}
/*
* if there was any user supplied data in the form of a nvlist,
* pack the list prior to copyin.
*/
/*
* exit with errno set by nvlist_pack()
*/
goto exit;
}
} else {
iocdata.nvl_usersz = 0;
}
/*
* finish initalizing the request and execute the IOCTL
*/
if (rv < 0 && _libdevice_debug) {
(void) printf("dc_cmd: exited with rv %d, errno(%d):%s\n",
}
exit:
return (rv);
}