074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * CDDL HEADER START
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * The contents of this file are subject to the terms of the
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * Common Development and Distribution License (the "License").
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * You may not use this file except in compliance with the License.
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * See the License for the specific language governing permissions
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * and limitations under the License.
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * When distributing Covered Code, include this CDDL HEADER in each
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * If applicable, add the following below this CDDL HEADER, with the
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * fields enclosed by brackets "[]" replaced with your own identifying
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * information: Portions Copyright [yyyy] [name of copyright owner]
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * CDDL HEADER END
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * Use is subject to license terms.
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * Create a generic topology node.
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * Create a generic topo node based on the hcfmri strcuture passed in.
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothierx86pi_enum_generic(topo_mod_t *mod, x86pi_hcfmri_t *hcfmri,
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier tnode_t *t_bindparent, tnode_t *t_fmriparent, tnode_t **t_node, int flag)
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier topo_mod_dprintf(mod, "%s adding entry for type (%s)\n",
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier "%s called with NULL parent for type %s\n",
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier return (-1);
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier /* Create the FMRI for this node */
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier fmri = topo_mod_hcfmri(mod, t_fmriparent, FM_HC_SCHEME_VERSION,
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier hcfmri->part_number, hcfmri->version, hcfmri->serial_number);
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier "%s failed to create %s fmri : %s\n", _ENUM_NAME,
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier hcfmri->hc_name, topo_strerror(topo_mod_errno(mod)));
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier return (-1);
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier rv = topo_node_range_create(mod, t_bindparent, hcfmri->hc_name, 0, 4);
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier if (rv != 0 && topo_mod_errno(mod) != EMOD_NODE_DUP) {
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier topo_mod_dprintf(mod, "%s range create failed for node %s\n",
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier /* Bind this node to the parent */
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier *t_node = x86pi_node_bind(mod, t_bindparent, hcfmri, fmri, flag);
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier "%s failed to bind %s node instance %d: %s\n",
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier return (-1);
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier /* call IPMI facility provider to register fac methods */
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier if (topo_mod_load(mod, _FAC_PROV, TOPO_VERSION) == NULL) {
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier "%s: Failed to load %s module: %s\n", _ENUM_NAME, _FAC_PROV,
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier return (-1);
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier rv = topo_mod_enumerate(mod, *t_node, _FAC_PROV, _FAC_PROV, 0, 0, NULL);
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier return (-1);
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier /* invoke fac_prov_ipmi_enum method */
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier if (topo_method_supported(*t_node, TOPO_METH_FAC_ENUM, 0)) {
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier if (topo_method_invoke(*t_node, TOPO_METH_FAC_ENUM, 0, NULL,
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier /* log the error and drive on */
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier topo_mod_dprintf(mod, "%s added (%s) node\n", _ENUM_NAME,
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothierx86pi_node_bind(topo_mod_t *mod, tnode_t *t_parent, x86pi_hcfmri_t *hcfmri,
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier char *f = "x86pi_node_bind";
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier "%s: NULL parent for %s node instance %d\n",
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier /* Bind this node to the parent */
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier t_node = topo_node_bind(mod, t_parent, hcfmri->hc_name,
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier "%s: failed to bind %s node instance %d: %s\n",
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier topo_mod_dprintf(mod, "%s: bound %s node instance %d type %s\n",
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier f, hcfmri->hc_name, hcfmri->instance, hcfmri->hc_name);
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * We have bound the node. Now decorate it with an appropriate
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * FRU and label (which may be inherited from the parent).
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier result = x86pi_set_frufmri(mod, hcfmri, t_parent, t_node, flag);
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * Though we have failed to set the FRU FMRI we still continue.
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * The module errno is set by the called routine, so we report
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * the problem and move on.
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier "%s: failed to set FRU FMRI for %s node\n",
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier result = x86pi_set_label(mod, hcfmri->location, hcfmri->hc_name,
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * Though we have failed to set the label, we still continue.
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * The module errno is set by the called routine, so we report
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * the problem and move on.
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier topo_mod_dprintf(mod, "%s: no label for %s node\n",
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier result = x86pi_set_auth(mod, hcfmri, t_parent, t_node);
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * Though we have failed to set the authority, we still
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * continue. The module errno is set by the called routine, so
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * we report the problem and move on.
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier "%s: no authority information for %s node\n",
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * Though we have failed to set the system group, we still
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * continue. The module errno is set by the called routine, so
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier * we report the problem and move on.
074bb90d80fdbeb2d04a8450a55ecbc96de28785Tom Pothier "%s: no system information for %s node\n",