/*
* 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 <ctype.h>
#include <string.h>
#include <limits.h>
#include <fm/topo_mod.h>
#include <fm/fmd_fmri.h>
#include <topo_alloc.h>
#include <topo_error.h>
#include <topo_hc.h>
#include <topo_method.h>
#include <topo_subr.h>
#include <topo_string.h>
/*
* Topology node properties and method operations may be accessed by FMRI.
* The FMRI used to perform property look-ups and method operations is
* the FMRI contained in the matching topology node's protocol property
* grouping for the resource property. The full range of fmd(1M)
* scheme plugin operations are supported as long as a backend method is
* supplied by a scheme-specific enumerator or the enumerator module that
* created the matching topology node. Support for fmd scheme operations
* include:
*
* - expand
* - presence_state
* - contains
* - service_state
* - nvl2str
* - retire
* - unretire
*
* In addition, the following operations are supported per-FMRI:
*
* - str2nvl: convert string-based FMRI to nvlist
* - asru: lookup associated ASRU property by FMRI
* - fru: lookup associated FRU by FMRI
* - create: an FMRI nvlist by scheme type
* - propery lookup
*
* These routines may only be called by consumers of a topology snapshot.
* They may not be called by libtopo enumerator or method modules.
*/
/*ARGSUSED*/
static int
{
return (-1);
}
/*ARGSUSED*/
static nvlist_t *
{
return (NULL);
}
int
{
TOPO_METH_NVL2STR, out));
TOPO_METH_NVL2STR, out));
TOPO_METH_NVL2STR, out));
TOPO_METH_NVL2STR, out));
return (0);
}
int
int *err)
{
TOPO_METH_STR2NVL, in));
*f = '\0'; /* strip trailing FMRI path */
TOPO_METH_STR2NVL, in));
in));
in));
}
TOPO_METH_STR2NVL, out));
return (0);
}
int
{
char *scheme;
TOPO_METH_PRESENT, out));
TOPO_METH_PRESENT, out));
return (present);
}
return (present);
}
int
{
char *scheme;
out));
return (presence_state);
}
int
{
char *scheme;
NULL));
in));
return (contains);
}
int
{
char *scheme;
return (unusable);
}
int
{
char *scheme;
TOPO_METH_RETIRE, out));
TOPO_METH_RETIRE, out));
TOPO_METH_RETIRE, out));
return (status);
}
int
{
char *scheme;
}
return (status);
}
int
{
char *scheme;
out));
return (service_state);
}
int
{
char *scheme;
TOPO_METH_EXPAND, out));
TOPO_METH_EXPAND, out));
return (0);
}
static int
int *err)
{
int rv;
char *scheme;
TOPO_METH_PROP_GET, in));
TOPO_METH_PROP_GET, in));
TOPO_METH_PROP_GET, in));
if (rv != 0)
TOPO_METH_PROP_GET, in));
if (rv != 0)
return (-1); /* *err is set for us */
return (0);
}
int
{
prop));
prop));
return (0);
}
int
{
prop));
prop));
return (0);
}
int
{
char *lp;
prop));
prop));
return (0);
}
int
{
char *sp;
/*
* If the serial number is in the resource fmri, then use that.
* Otherwise fall back to looking for the serial number property
* in the protocol group. Look for both version 1 and version 0.
*/
"topo_fmri_serial", prop));
else
return (0);
}
prop));
"topo_fmri_serial", prop));
return (0);
}
int *err)
{
}
{
int rv;
char *scheme;
TOPO_METH_PROP_SET, in));
TOPO_METH_PROP_SET, in));
TOPO_METH_PROP_SET, in));
if (rv != 0)
TOPO_METH_PROP_SET, in));
/* no return values */
if (rv)
return (-1);
return (0);
}
int
{
int rv;
char *scheme;
TOPO_METH_PROP_GET, in));
TOPO_METH_PROP_GET, in));
TOPO_METH_PROP_GET, in));
if (rv != 0)
TOPO_METH_PROP_GET, in));
if (rv != 0)
return (-1); /* *err is set for us */
return (0);
}
int
{
return (0);
NULL));
in));
return (compare);
}
/*
* topo_fmri_create
*
* If possible, creates an FMRI of the requested version in the
* requested scheme. Args are passed as part of the inputs to the
* fmri-create method of the scheme.
*/
nvlist_t *
{
TOPO_METH_FMRI, NULL));
TOPO_METH_FMRI, NULL));
TOPO_METH_FMRI, ins));
}
TOPO_METH_FMRI, ins));
}
if (topo_method_invoke(rnode,
}
return (out);
}
{
ulong_t g, h = 0;
size_t i;
for (i = 0; i < len; i++) {
h = (h << 4) + fmri[i];
if ((g = (h & 0xf0000000)) != 0) {
h ^= (g >> 24);
h ^= g;
}
}
return (h);
}
/*ARGSUSED*/
static ulong_t
{
int err;
*f = '\0'; /* strip trailing FMRI path */
return (rval);
}
/*ARGSUSED*/
{
}
/*ARGSUSED*/
{
}
/*
* Note that for performance reasons we skip the usual encapsulation
* of "in" and "out" within nvlists, and instead just pass the two strings
* to be compared as "in" and "out" respectively, and return the return value
* directly as the return value of the method.
*/
/*ARGSUSED*/
static boolean_t
char *type)
{
int err;
int rc;
return (strcmp(a, b) == 0);
return (B_FALSE);
return (B_FALSE);
return (strcmp(a, b) == 0);
if (rc < 0)
return (strcmp(a, b) == 0);
else
return (rc);
}
/*ARGSUSED*/
{
return (B_FALSE);
}
/*ARGSUSED*/
{
}
{
}
int
int *err)
{
int rv;
char *scheme;
TOPO_METH_PROP_GET, in));
if (rv != 0)
return (-1); /* *err is set for us */
return (0);
}
return (0);
}
int
{
int rv;
char *scheme;
TOPO_METH_PROP_GET, in));
TOPO_METH_PROP_GET, in));
TOPO_METH_PROP_GET, in));
#ifdef _LP64
#else
#endif
if (rv != 0)
TOPO_METH_PROP_GET, in));
if (rv != 0)
return (-1); /* *err is set for us */
return (0);
}