0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * CDDL HEADER START
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * The contents of this file are subject to the terms of the
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * Common Development and Distribution License (the "License").
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * You may not use this file except in compliance with the License.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * See the License for the specific language governing permissions
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * and limitations under the License.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * When distributing Covered Code, include this CDDL HEADER in each
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * If applicable, add the following below this CDDL HEADER, with the
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * fields enclosed by brackets "[]" replaced with your own identifying
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * information: Portions Copyright [yyyy] [name of copyright owner]
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * CDDL HEADER END
9c94f155585ea35e938fea603bc227c685223abdCheng Sean Ye * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * Use is subject to license terms.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * Generic code shared by all the hostbridge enumerators
0eb822a1c0c2bea495647510b75f77f0e57633ebcindistatic int hb_label(topo_mod_t *, tnode_t *, topo_version_t, nvlist_t *,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindistatic int hb_enum(topo_mod_t *, tnode_t *, const char *, topo_instance_t,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi topo_instance_t, void *, void *);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern int platform_hb_label(topo_mod_t *, tnode_t *, nvlist_t *, nvlist_t **);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindistatic int specific_hb_enum(topo_mod_t *, tnode_t *, const char *,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi { HOSTBRIDGE, FM_FMRI_SCHEME_HC, HB_ENUMR_VERS, &Hb_ops };
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi TOPO_METH_LABEL_VERSION, TOPO_STABILITY_INTERNAL, hb_label },
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * Turn on module debugging output
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi topo_mod_dprintf(modhdl, "initializing hostbridge enumerator\n");
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if (topo_mod_register(modhdl, &Hb_info, TOPO_VERSION) < 0) {
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi topo_mod_dprintf(modhdl, "hostbridge registration failed: %s\n",
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi return (0);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindihb_label(topo_mod_t *mp, tnode_t *node, topo_version_t version,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if ((rp = topo_mod_load(mp, PCI_ENUM, PCI_ENUMR_VERS)) == NULL) {
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi "%s enumerator could not load %s.\n", HOSTBRIDGE, PCI_ENUM);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi/*ARGSUSED*/
0eb822a1c0c2bea495647510b75f77f0e57633ebcindihb_enum(topo_mod_t *mp, tnode_t *pn, const char *name, topo_instance_t imin,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi "Currently only know how to enumerate %s components.\n",
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi return (0);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * Load the pcibus enumerator
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi return (-1);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * If we're asked to enumerate a whole range of hostbridges, then
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * we need to find them all. If we're just asked to enumerate a
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * single hostbridge, we expect our caller to have passed us linked
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * did_t structures we can use to enumerate the singled out hostbridge.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi "Hash initialization for hostbridge "
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi "enumerator failed.\n");
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi return (-1);
12cc75c814f0c017004a9bbc96429911e008601bcindi rv = specific_hb_enum(mp, pn, name, imin, imax, data);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi/*ARGSUSED*/
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi fmri = topo_mod_hcfmri(mod, parent, FM_HC_SCHEME_VERSION, name, i,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi "Unable to make nvlist for %s bind: %s.\n",
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi "topo_node_bind (%s%d/%s%d) failed: %s\n",
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if (topo_pgroup_create(ntn, &hb_auth_pgroup, &err) == 0) {
9c94f155585ea35e938fea603bc227c685223abdCheng Sean Ye (void) topo_prop_inherit(ntn, FM_FMRI_AUTHORITY,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi topo_mod_dprintf(mod, "topo_method_register failed: %s\n",
0eb822a1c0c2bea495647510b75f77f0e57633ebcindipcihostbridge_declare(topo_mod_t *mod, tnode_t *parent, di_node_t din,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if ((ntn = hb_tnode_create(mod, parent, HOSTBRIDGE, i, din)) == NULL)
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if (did_props_set(ntn, pd, HB_common_props, HB_propcnt) < 0) {
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * We expect to find pci buses beneath the hostbridge.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if (child_range_add(mod, ntn, PCI_BUS, 0, MAX_HB_BUSES) < 0) {
0eb822a1c0c2bea495647510b75f77f0e57633ebcindipciexhostbridge_declare(topo_mod_t *mod, tnode_t *parent, di_node_t din,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if ((ntn = hb_tnode_create(mod, parent, HOSTBRIDGE, hi, din)) == NULL)
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if (did_props_set(ntn, pd, ExHB_common_props, ExHB_propcnt) < 0) {
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * We expect to find root complexes beneath the hostbridge.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if (child_range_add(mod, ntn, PCIEX_ROOT, 0, MAX_HB_BUSES) < 0) {
0eb822a1c0c2bea495647510b75f77f0e57633ebcindipciexrc_declare(topo_mod_t *mod, tnode_t *parent, di_node_t din,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if ((ntn = hb_tnode_create(mod, parent, PCIEX_ROOT, ri, din)) == NULL)
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if (did_props_set(ntn, pd, RC_common_props, RC_propcnt) < 0) {
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * We expect to find pci-express buses beneath a root complex
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if (child_range_add(mod, ntn, PCIEX_BUS, 0, MAX_HB_BUSES) < 0) {
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi/*ARGSUSED*/
0eb822a1c0c2bea495647510b75f77f0e57633ebcindispecific_hb_enum(topo_mod_t *mod, tnode_t *pn, const char *name,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi topo_instance_t imin, topo_instance_t imax, void *priv)
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * Find the hostbridge of interest
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if ((hb = pcihostbridge_declare(mod, pn, did_dinode(didp), imin))
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi return (-1);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi return (0);