/*
* 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 <limits.h>
#include <strings.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <alloca.h>
#include <devid.h>
#include <libnvpair.h>
#include <fm/topo_mod.h>
#include <fm/fmd_fmri.h>
#include <topo_method.h>
#include <topo_subr.h>
#include <dev.h>
topo_instance_t, void *, void *);
{ NULL }
};
{ dev_enum, dev_release };
int
{
if (getenv("TOPOHCDEBUG"))
if (version != DEV_VERSION)
return (-1);
}
return (0);
}
void
{
}
/*ARGSUSED*/
static int
{
/*
* Methods are registered, but there is no enumeration. Should
* enumeration be added be sure to cater for global vs non-global
* zones.
*/
return (0);
}
static void
{
}
static ssize_t
{
int err;
return (-1);
/* Get devid, if present */
return (-1);
/* Get target-port-l0id, if present */
return (-1);
/* There must be a device path present */
return (-1);
/*
* dev:///
*
* The dev scheme does not render fmri authority information
* in the string form of an fmri. It is meaningless to
* transmit a dev scheme fmri outside of the immediate fault
* manager.
*/
/* device-id part, topo_fmristr_build does nothing if devid is NULL */
/* target-port-l0id part */
/*
* device-path part; the devpath should always start with a /
* so you'd think we don't need to add a further / prefix here;
* however past implementation has always added the / if
* there is a devid component so we continue to do that
* so strings match exactly as before. So we can have:
*
* dev:////pci@0,0/...
* dev:///<devid-and-tpl0>//pci@0,0/...
*
* where <devid-and-tpl0> =
* [:devid=<devid>][:target-port-l0id=<tpl0>]
*/
return (size);
}
/*ARGSUSED*/
static int
{
if (version > TOPO_METH_NVL2STR_VERSION)
}
}
return (0);
}
/*ARGSUSED*/
static int
{
char *devpath;
int err;
if (version > TOPO_METH_STR2NVL_VERSION)
/*
* We're expecting a string version of a dev scheme FMRI, and
* no fmri authority information.
*
* The shortest legal string would be "dev:////" (len 8) for a string
* with no FMRI auth info, no devid or target-port-l0id and
* an empty devpath string.
*/
/*
* If the first character after the "/" that terminates the (empty)
* info. They could be in either order.
*
* If not a colon then it must be the / that begins the devpath.
*/
if (*cur == ':') {
int i;
/*
* Look ahead to the "/" that starts the devpath. If not
* found or if straight after the : then we're busted.
*/
/*
* Replace the initial "/" of the devpath with a NUL
* to terminate the string before it. We'll undo this
* before rendering devpath.
*/
*eos = '\0';
/*
* We should now have a NUL-terminated string matching
* foo=<pat1>[:bar=<pat2>] (we stepped over the initial :)
* Look for a second colon; if found there must be space
* after it for the additional component, but no more colons.
*/
return (topo_mod_seterrno(mod,
part[1]++;
}
for (i = 0; i < 2; i++) {
char *eq;
if (!part[i])
continue;
return (topo_mod_seterrno(mod,
*eq = '\0';
else
return (topo_mod_seterrno(mod,
}
} else if (*cur != '/') {
/* the device-path should start with a slash */
} else {
}
/* step over repeated initial / in the devpath */
devpath++;
if (err != 0) {
}
return (0);
}
/*ARGSUSED*/
static int
{
int len;
if (version > TOPO_METH_PRESENT_VERSION)
/*
* stat() the device node in devfs. This will tell us if the device is
* present or not. Don't stat the minor, just the whole device.
* If the device is present and there is a devid, it must also match.
* so di_init that one node. No need for DINFOFORCE.
*/
present = 1;
present = 0;
else {
present = 0;
else
present = 1;
}
} else {
present = 0;
present = 0;
else {
present = 0;
else {
present = 0;
else
present = 1;
}
}
}
nvlist_free(*out);
}
return (0);
}
/*ARGSUSED*/
static int
{
int len;
/*
* stat() the device node in devfs. This will tell us if the device is
* present or not. Don't stat the minor, just the whole device.
* If the device is present and there is a devid, it must also match.
* so di_init that one node. No need for DINFOFORCE.
*/
else {
else
}
} else {
else {
else {
else
}
}
}
nvlist_free(*out);
}
return (0);
}
/*ARGSUSED*/
static int
{
unusable = 1;
} else {
unusable = 1;
else
unusable = 0;
}
nvlist_free(*out);
}
return (0);
}
/*ARGSUSED*/
static int
{
} else {
else if (state & DI_DEVICE_DEGRADED)
else
}
service_state) != 0) {
nvlist_free(*out);
}
return (0);
}
static nvlist_t *
{
int e;
return (NULL);
}
if (e == 0)
return (out);
return (NULL);
}
/*ARGSUSED*/
static int
{
if (version > TOPO_METH_FMRI_VERSION)
}
return (-1);
return (0);
}