4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <sys/fm/protocol.h>
33 #include <fm/topo_mod.h>
34 #include <fm/topo_hc.h>
35 #include <fm/libtopo.h>
38 child_range_add(topo_mod_t
*mp
, tnode_t
*tn
, const char *cnm
,
39 topo_instance_t imin
, topo_instance_t imax
)
43 e
= topo_node_range_create(mp
, tn
, cnm
, imin
, imax
);
45 topo_mod_dprintf(mp
, "add child range (%s) failed: %s\n",
46 cnm
, topo_strerror(topo_mod_errno(mp
)));
53 topo_strtonum(topo_mod_t
*mp
, char *str
, int *err
)
58 r
= strtoul(str
, &e
, 16);
61 "Trouble converting %s to a number!\n", str
);
70 get_pci_vpd_sn_pn(topo_mod_t
*mp
, di_node_t dn
, char **serial
, char **part
)
72 char *s
= NULL
, *p
= NULL
;
73 di_prom_handle_t promtree
= DI_PROM_HANDLE_NIL
;
75 if ((promtree
= topo_mod_prominfo(mp
)) == DI_PROM_HANDLE_NIL
) {
77 "get vpd data: di_prom_handle_init failed.\n");
81 /* Get Serial Number and Part Number */
82 if ((di_prom_prop_lookup_bytes(promtree
, dn
, "vpd-serial-number",
83 (uchar_t
**)&s
) > 0) && (s
!= NULL
))
84 *serial
= topo_mod_strdup(mp
, s
);
86 if ((di_prom_prop_lookup_bytes(promtree
, dn
, "vpd-part-number",
87 (uchar_t
**)&p
) > 0) && (p
!= NULL
))
88 *part
= topo_mod_strdup(mp
, p
);
94 tnode_create(topo_mod_t
*mp
, tnode_t
*parent
,
95 const char *name
, topo_instance_t i
, void *priv
)
100 char *serial
= NULL
, *part
= NULL
;
102 auth
= topo_mod_auth(mp
, parent
);
104 * Get PCI/PCIEX Device Serial Number and Part Number
107 if ((strcmp(name
, PCI_DEVICE
) == 0) ||
108 (strcmp(name
, PCIEX_DEVICE
) == 0))
109 (void) get_pci_vpd_sn_pn(mp
, priv
, &serial
, &part
);
111 fmri
= topo_mod_hcfmri(mp
, parent
, FM_HC_SCHEME_VERSION
, name
, i
, NULL
,
112 auth
, part
, NULL
, serial
);
114 topo_mod_strfree(mp
, serial
);
115 topo_mod_strfree(mp
, part
);
119 "Unable to make nvlist for %s bind.\n", name
);
123 ntn
= topo_node_bind(mp
, parent
, name
, i
, fmri
);
126 "topo_node_bind (%s%d/%s%d) failed: %s\n",
127 topo_node_name(parent
), topo_node_instance(parent
),
129 topo_strerror(topo_mod_errno(mp
)));
134 topo_node_setspecific(ntn
, priv
);
141 labelmethod_inherit(topo_mod_t
*mp
, tnode_t
*tn
, nvlist_t
*in
, nvlist_t
**out
)
146 * Ignore the input and output nvlists and directly set the
147 * label as inheritance from the parent
150 if (topo_node_label_set(tn
, NULL
, &err
) < 0) {
151 if (err
!= ETOPO_PROP_NOENT
)
152 return (topo_mod_seterrno(mp
, err
));