7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/*
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * CDDL HEADER START
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * The contents of this file are subject to the terms of the
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Common Development and Distribution License (the "License").
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * You may not use this file except in compliance with the License.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * or http://www.opensolaris.org/os/licensing.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * See the License for the specific language governing permissions
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * and limitations under the License.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * When distributing Covered Code, include this CDDL HEADER in each
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * If applicable, add the following below this CDDL HEADER, with the
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * fields enclosed by brackets "[]" replaced with your own identifying
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * information: Portions Copyright [yyyy] [name of copyright owner]
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi *
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * CDDL HEADER END
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/*
186d582bd9dbcd38e0aeea49036d47d3426a3536Surya Prakki * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Use is subject to license terms.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#include <string.h>
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#include <sys/fm/protocol.h>
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#include <fm/topo_mod.h>
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi#include <fm/topo_hc.h>
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#include <libdevinfo.h>
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#include <limits.h>
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#include <sys/param.h>
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi#include <sys/systeminfo.h>
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi#include <hostbridge.h>
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi#include <ioboard.h>
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi#include <did.h>
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi#include <did_props.h>
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi#include <util.h>
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/*
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * ioboard.c
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Generic code shared by all the ioboard enumerators
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindistatic void iob_release(topo_mod_t *, tnode_t *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindistatic int iob_enum(topo_mod_t *, tnode_t *, const char *, topo_instance_t,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi topo_instance_t, void *, void *);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindistatic int iob_label(topo_mod_t *, tnode_t *, topo_version_t, nvlist_t *,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi nvlist_t **);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern int platform_iob_enum(topo_mod_t *, tnode_t *, topo_instance_t,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi topo_instance_t);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiextern int platform_iob_label(topo_mod_t *, tnode_t *, nvlist_t *, nvlist_t **);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern txprop_t IOB_common_props[];
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiextern int IOB_propcnt;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
0eb822a1c0c2bea495647510b75f77f0e57633ebcindistatic const topo_modops_t Iob_ops =
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi { iob_enum, iob_release };
0eb822a1c0c2bea495647510b75f77f0e57633ebcindistatic const topo_modinfo_t Iob_info =
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi { IOBOARD, FM_FMRI_SCHEME_HC, IOB_ENUMR_VERS, &Iob_ops };
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
0eb822a1c0c2bea495647510b75f77f0e57633ebcindistatic const topo_method_t Iob_methods[] = {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi { TOPO_METH_LABEL, TOPO_METH_LABEL_DESC,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi TOPO_METH_LABEL_VERSION, TOPO_STABILITY_INTERNAL, iob_label },
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi { NULL }
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi};
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindivoid
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi_topo_init(topo_mod_t *modhdl)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi{
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi /*
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Turn on module debugging output
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (getenv("TOPOIOBDBG") != NULL)
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi topo_mod_setdebug(modhdl);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi topo_mod_dprintf(modhdl, "initializing ioboard enumerator\n");
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
186d582bd9dbcd38e0aeea49036d47d3426a3536Surya Prakki (void) topo_mod_register(modhdl, &Iob_info, TOPO_VERSION);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi topo_mod_dprintf(modhdl, "Ioboard enumr initd\n");
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi}
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindivoid
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi_topo_fini(topo_mod_t *modhdl)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi{
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi topo_mod_unregister(modhdl);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi}
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindistatic int
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiiob_label(topo_mod_t *mp, tnode_t *node, topo_version_t version,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi nvlist_t *in, nvlist_t **out)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi{
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (version > TOPO_METH_LABEL_VERSION)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (topo_mod_seterrno(mp, EMOD_VER_NEW));
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi return (platform_iob_label(mp, node, in, out));
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi}
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindistatic topo_mod_t *
0eb822a1c0c2bea495647510b75f77f0e57633ebcindihb_enumr_load(topo_mod_t *mp)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi{
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi topo_mod_t *rp = NULL;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if ((rp = topo_mod_load(mp, HOSTBRIDGE, HB_ENUMR_VERS)) == NULL) {
724365f7556fc4201fdb11766ebc6bd918523130sethg topo_mod_dprintf(mp,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi "%s enumerator could not load %s.\n", IOBOARD, HOSTBRIDGE);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi }
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (rp);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi}
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/*ARGSUSED*/
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindistatic int
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiiob_enum(topo_mod_t *mp, tnode_t *pn, const char *name, topo_instance_t imin,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi topo_instance_t imax, void *notused1, void *notused2)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi{
724365f7556fc4201fdb11766ebc6bd918523130sethg topo_mod_t *hbmod;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi int rv;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (strcmp(name, IOBOARD) != 0) {
724365f7556fc4201fdb11766ebc6bd918523130sethg topo_mod_dprintf(mp,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi "Currently only know how to enumerate %s components.\n",
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi IOBOARD);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (0);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi }
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi /*
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * Load the hostbridge enumerator, we'll soon need it!
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if ((hbmod = hb_enumr_load(mp)) == NULL) {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (-1);
724365f7556fc4201fdb11766ebc6bd918523130sethg }
724365f7556fc4201fdb11766ebc6bd918523130sethg
92ba710950bf6ee35de67e1e0b7f20ec9e528106eschrock if (did_hash_init(mp) != 0)
92ba710950bf6ee35de67e1e0b7f20ec9e528106eschrock return (-1);
724365f7556fc4201fdb11766ebc6bd918523130sethg
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi rv = platform_iob_enum(mp, pn, imin, imax);
724365f7556fc4201fdb11766ebc6bd918523130sethg
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi did_hash_fini(mp);
724365f7556fc4201fdb11766ebc6bd918523130sethg topo_mod_unload(hbmod);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (rv < 0)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (topo_mod_seterrno(mp, EMOD_PARTIAL_ENUM));
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi else
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (0);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi}
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi/*ARGSUSED*/
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindistatic void
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindiiob_release(topo_mod_t *mp, tnode_t *node)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi{
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi /*
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * node private data (did_t) for this node is destroyed in
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * did_hash_destroy()
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi topo_method_unregister_all(mp, node);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi}
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindistatic tnode_t *
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiiob_tnode_create(topo_mod_t *mod, tnode_t *parent,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi const char *name, topo_instance_t i, void *priv)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi{
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi nvlist_t *fmri;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi tnode_t *ntn;
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi nvlist_t *auth = topo_mod_auth(mod, parent);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi fmri = topo_mod_hcfmri(mod, parent, FM_HC_SCHEME_VERSION, name, i,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi NULL, auth, NULL, NULL, NULL);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi nvlist_free(auth);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (fmri == NULL) {
724365f7556fc4201fdb11766ebc6bd918523130sethg topo_mod_dprintf(mod,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi "Unable to make nvlist for %s bind.\n", name);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (NULL);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi }
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi ntn = topo_node_bind(mod, parent, name, i, fmri);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (ntn == NULL) {
724365f7556fc4201fdb11766ebc6bd918523130sethg topo_mod_dprintf(mod,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi "topo_node_bind (%s%d/%s%d) failed: %s\n",
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi topo_node_name(parent), topo_node_instance(parent),
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi name, i,
724365f7556fc4201fdb11766ebc6bd918523130sethg topo_strerror(topo_mod_errno(mod)));
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi nvlist_free(fmri);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (NULL);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi }
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi nvlist_free(fmri);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi topo_node_setspecific(ntn, priv);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi
724365f7556fc4201fdb11766ebc6bd918523130sethg if (topo_method_register(mod, ntn, Iob_methods) < 0) {
724365f7556fc4201fdb11766ebc6bd918523130sethg topo_mod_dprintf(mod, "topo_method_register failed: %s\n",
724365f7556fc4201fdb11766ebc6bd918523130sethg topo_strerror(topo_mod_errno(mod)));
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi topo_node_unbind(ntn);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (NULL);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi }
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (ntn);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi}
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecinditnode_t *
0eb822a1c0c2bea495647510b75f77f0e57633ebcindiioboard_declare(topo_mod_t *mod, tnode_t *parent, topo_instance_t i, void *priv)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi{
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi tnode_t *ntn;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if ((ntn = iob_tnode_create(mod, parent, IOBOARD, i, priv)) == NULL)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (NULL);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if (did_props_set(ntn, priv, IOB_common_props, IOB_propcnt) < 0) {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi topo_node_unbind(ntn);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (NULL);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi }
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi /*
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi * We expect to find host bridges beneath the ioboard.
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi */
724365f7556fc4201fdb11766ebc6bd918523130sethg if (child_range_add(mod, ntn, HOSTBRIDGE, 0, MAX_HBS) < 0) {
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi topo_node_unbind(ntn);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (NULL);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi }
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (ntn);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi}
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindidid_t *
0eb822a1c0c2bea495647510b75f77f0e57633ebcindisplit_bus_address(topo_mod_t *mod, di_node_t dp, uint_t baseaddr,
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi uint_t bussep, int minbrd, int maxbrd, int *brd, int *br, int *bus)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi{
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi uint_t bc, ac;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi char *comma;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi char *bac;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi char *ba;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi int e;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if ((ba = di_bus_addr(dp)) == NULL ||
724365f7556fc4201fdb11766ebc6bd918523130sethg (bac = topo_mod_strdup(mod, ba)) == NULL)
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (NULL);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
724365f7556fc4201fdb11766ebc6bd918523130sethg topo_mod_dprintf(mod,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi "Transcribing %s into board, bus, etc.\n", bac);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if ((comma = strchr(bac, ',')) == NULL) {
724365f7556fc4201fdb11766ebc6bd918523130sethg topo_mod_strfree(mod, bac);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (NULL);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi }
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi *comma = '\0';
724365f7556fc4201fdb11766ebc6bd918523130sethg bc = strtonum(mod, bac, &e);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi *comma = ',';
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (e < 0) {
724365f7556fc4201fdb11766ebc6bd918523130sethg topo_mod_dprintf(mod,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi "Trouble interpreting %s before comma.\n", bac);
724365f7556fc4201fdb11766ebc6bd918523130sethg topo_mod_strfree(mod, bac);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (NULL);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi }
724365f7556fc4201fdb11766ebc6bd918523130sethg ac = strtonum(mod, comma + 1, &e);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (e < 0) {
724365f7556fc4201fdb11766ebc6bd918523130sethg topo_mod_dprintf(mod,
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi "Trouble interpreting %s after comma.\n", bac);
724365f7556fc4201fdb11766ebc6bd918523130sethg topo_mod_strfree(mod, bac);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (NULL);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi }
724365f7556fc4201fdb11766ebc6bd918523130sethg topo_mod_strfree(mod, bac);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi *brd = ((bc - baseaddr) / bussep) + minbrd;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi *br = (bc - baseaddr) % bussep;
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi *bus = ((ac == IOB_BUSADDR1) ? 0 : 1);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi if (*brd < minbrd || *brd > maxbrd || (*br != 0 && *br != 1) ||
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi (ac != IOB_BUSADDR1 && ac != IOB_BUSADDR2)) {
724365f7556fc4201fdb11766ebc6bd918523130sethg topo_mod_dprintf(mod, "Trouble with transcription\n");
724365f7556fc4201fdb11766ebc6bd918523130sethg topo_mod_dprintf(mod, "brd=%d br=%d bus=%d bc=%x ac=%x\n",
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi *brd, *br, *bus, bc, ac);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi return (NULL);
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi }
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi return (did_create(mod, dp, *brd, *br, NO_RC, *bus));
7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fecindi}