static topo_mod_t * hb_enumr_load(topo_mod_t *mp, tnode_t *parent) { topo_mod_t *rp = NULL; char *plat, *mach; char *hbpath; char *rootdir; int err; plat = mach = NULL; if (topo_prop_get_string(parent, TOPO_PGROUP_SYSTEM, TOPO_PROP_PLATFORM, &plat, &err) < 0) { (void) topo_mod_seterrno(mp, err); return (NULL); } if (topo_prop_get_string(parent, TOPO_PGROUP_SYSTEM, TOPO_PROP_MACHINE, &mach, &err) < 0) { (void) topo_mod_seterrno(mp, err); return (NULL); } hbpath = topo_mod_alloc(mp, PATH_MAX); rootdir = topo_mod_rootdir(mp); (void) snprintf(hbpath, PATH_MAX, PATH_TO_HB_ENUM, rootdir ? rootdir : "", plat); if ((rp = topo_mod_load(mp, hbpath)) == NULL) { topo_mod_dprintf(mp, "%s enumerator could not load %s.\n", IOBOARD, hbpath); (void) snprintf(hbpath, PATH_MAX, PATH_TO_HB_ENUM, rootdir ? rootdir : "", mach); if ((rp = topo_mod_load(mp, hbpath)) == NULL) { topo_mod_dprintf(mp, "%s enumerator could not load %s.\n", IOBOARD, hbpath); } } topo_mod_strfree(mp, plat); topo_mod_strfree(mp, mach); topo_mod_free(mp, hbpath, PATH_MAX); return (rp); }
static topo_mod_t * xfp_enum_load(topo_mod_t *mp) { topo_mod_t *rp = NULL; if ((rp = topo_mod_load(mp, XFP, TOPO_VERSION)) == NULL) { topo_mod_dprintf(mp, "%s enumerator could not load %s enum.\n", XAUI, XFP); } return (rp); }
static topo_mod_t * pci_enumr_load(topo_mod_t *mp) { topo_mod_t *rp = NULL; if ((rp = topo_mod_load(mp, PCI_ENUM, PCI_ENUMR_VERS)) == NULL) { topo_mod_dprintf(mp, "%s enumerator could not load %s.\n", HOSTBRIDGE, PCI_ENUM); } return (rp); }
static topo_mod_t * module_load(topo_mod_t *mp, tnode_t *parent, const char *name) { topo_mod_t *rp = NULL; char *plat, *mach; char *path; char *rootdir; int err; plat = mach = NULL; if (topo_prop_get_string(parent, TOPO_PGROUP_SYSTEM, TOPO_PROP_PLATFORM, &plat, &err) < 0) { (void) topo_mod_seterrno(mp, err); return (NULL); } if (topo_prop_get_string(parent, TOPO_PGROUP_SYSTEM, TOPO_PROP_MACHINE, &mach, &err) < 0) { (void) topo_mod_seterrno(mp, err); return (NULL); } path = topo_mod_alloc(mp, PATH_MAX); rootdir = topo_mod_rootdir(mp); (void) snprintf(path, PATH_MAX, PATH_TEMPLATE, rootdir ? rootdir : "", plat, name); if ((rp = topo_mod_load(mp, path)) == NULL) { topo_mod_dprintf(mp, "Unable to load %s.\n", path); (void) snprintf(path, PATH_MAX, PATH_TEMPLATE, rootdir ? rootdir : "", mach, name); if ((rp = topo_mod_load(mp, path)) == NULL) topo_mod_dprintf(mp, "Unable to load %s.\n", path); } topo_mod_strfree(mp, plat); topo_mod_strfree(mp, mach); topo_mod_free(mp, path, PATH_MAX); return (rp); }
/* * Create a generic topo node based on the hcfmri strcuture passed in. */ int x86pi_enum_generic(topo_mod_t *mod, x86pi_hcfmri_t *hcfmri, tnode_t *t_bindparent, tnode_t *t_fmriparent, tnode_t **t_node, int flag) { int rv; int err; nvlist_t *out; nvlist_t *fmri; nvlist_t *auth; topo_mod_dprintf(mod, "%s adding entry for type (%s)\n", _ENUM_NAME, hcfmri->hc_name); if (t_bindparent == NULL) { topo_mod_dprintf(mod, "%s called with NULL parent for type %s\n", _ENUM_NAME, hcfmri->hc_name); return (-1); } /* Create the FMRI for this node */ auth = topo_mod_auth(mod, t_bindparent); fmri = topo_mod_hcfmri(mod, t_fmriparent, FM_HC_SCHEME_VERSION, hcfmri->hc_name, hcfmri->instance, NULL, auth, hcfmri->part_number, hcfmri->version, hcfmri->serial_number); nvlist_free(auth); if (fmri == NULL) { topo_mod_dprintf(mod, "%s failed to create %s fmri : %s\n", _ENUM_NAME, hcfmri->hc_name, topo_strerror(topo_mod_errno(mod))); return (-1); } rv = topo_node_range_create(mod, t_bindparent, hcfmri->hc_name, 0, 4); if (rv != 0 && topo_mod_errno(mod) != EMOD_NODE_DUP) { topo_mod_dprintf(mod, "%s range create failed for node %s\n", _ENUM_NAME, hcfmri->hc_name); } /* Bind this node to the parent */ *t_node = x86pi_node_bind(mod, t_bindparent, hcfmri, fmri, flag); nvlist_free(fmri); if (*t_node == NULL) { topo_mod_dprintf(mod, "%s failed to bind %s node instance %d: %s\n", _ENUM_NAME, hcfmri->hc_name, hcfmri->instance, topo_strerror(topo_mod_errno(mod))); return (-1); } /* call IPMI facility provider to register fac methods */ if (topo_mod_load(mod, _FAC_PROV, TOPO_VERSION) == NULL) { topo_mod_dprintf(mod, "%s: Failed to load %s module: %s\n", _ENUM_NAME, _FAC_PROV, topo_mod_errmsg(mod)); return (-1); } rv = topo_mod_enumerate(mod, *t_node, _FAC_PROV, _FAC_PROV, 0, 0, NULL); if (rv != 0) { topo_mod_dprintf(mod, "%s: %s failed: %s\n", _ENUM_NAME, _FAC_PROV, topo_mod_errmsg(mod)); return (-1); } /* invoke fac_prov_ipmi_enum method */ if (topo_method_supported(*t_node, TOPO_METH_FAC_ENUM, 0)) { if (topo_method_invoke(*t_node, TOPO_METH_FAC_ENUM, 0, NULL, &out, &err) != 0) { /* log the error and drive on */ topo_mod_dprintf(mod, "%s: TOPO_METH_FAC_ENUM failed\n", _ENUM_NAME); } else { fac_done = 1; } } topo_mod_dprintf(mod, "%s added (%s) node\n", _ENUM_NAME, topo_node_name(*t_node)); return (0); }
/* * opl_hb_enum gets the ioboard instance passed in, and determines the * hostbridge and root complex instances numbers based on the bus addresses. */ int opl_hb_enum(topo_mod_t *mp, const ioboard_contents_t *iob, tnode_t *ion, int brd) { int hb; int rc; di_node_t p; tnode_t *hbnode; tnode_t *rcnode; topo_mod_t *pcimod; /* Load the pcibus module. We'll need it later. */ pcimod = topo_mod_load(mp, PCI_BUS, PCI_BUS_VERS); if (pcimod == NULL) { topo_mod_dprintf(mp, "can't load pcibus module: %s\n", topo_strerror(topo_mod_errno(mp))); return (-1); } /* For each hostbridge on an ioboard... */ for (hb = 0; hb < OPL_HB_MAX; hb++) { hbnode = NULL; /* For each root complex in a hostbridge... */ for (rc = 0; rc < OPL_RC_MAX; rc++) { p = iob->rcs[hb][rc]; /* If no root complex, continue */ if (p == DI_NODE_NIL) { continue; } /* The root complex exists! */ topo_mod_dprintf(mp, "declaring " "/chassis=0/ioboard=%d/hostbridge=%d/pciexrc=%d\n", brd, hb, rc); /* * If we haven't created a hostbridge node yet, do it * now. */ if (hbnode == NULL) { hbnode = opl_hb_node_create(mp, ion, hb); if (hbnode == NULL) { topo_mod_dprintf(mp, "unable to create hbnode: %s\n", topo_strerror(topo_mod_errno(mp))); topo_mod_unload(pcimod); return (-1); } } /* Create the root complex node */ rcnode = opl_rc_node_create(mp, hbnode, p, rc); if (rcnode == NULL) { topo_mod_dprintf(mp, "unable to create rcnode: %s\n", topo_strerror(topo_mod_errno(mp))); topo_mod_unload(pcimod); return (-1); } /* Enumerate pcibus nodes under the root complex */ if (topo_mod_enumerate(pcimod, rcnode, PCI_BUS, PCIEX_BUS, 0, 255, NULL) != 0) { topo_mod_dprintf(mp, "error enumerating pcibus: %s\n", topo_strerror(topo_mod_errno(mp))); topo_mod_unload(pcimod); return (-1); } } } topo_mod_unload(pcimod); return (0); }
/* * Enumerate hostbridge on the cpuboard. Hostbridge and root complex instances * match the cpuboard instance. */ int cpuboard_hb_enum(topo_mod_t *mp, di_node_t dnode, char *rcpath, tnode_t *cpubn, int brd) { int hb; int rc; tnode_t *hbnode; tnode_t *rcnode; topo_mod_t *pcimod; topo_mod_dprintf(mp, "cpuboard_hb_enum: brd: %d, cpubn=%p\n", brd, cpubn); /* Load the pcibus module. We'll need it later. */ pcimod = topo_mod_load(mp, PCI_BUS, PCI_BUS_VERS); if (pcimod == NULL) { topo_mod_dprintf(mp, "can't load pcibus module: %s\n", topo_strerror(topo_mod_errno(mp))); return (-1); } hb = rc = brd; /* The root complex exists! */ topo_mod_dprintf(mp, "declaring " "/motherboard=0/cpuboard=%d/hostbridge=%d/" "pciexrc=%d\n", brd, hb, rc); /* Create the hostbridge node */ hbnode = cpuboard_hb_node_create(mp, cpubn, hb); if (hbnode == NULL) { topo_mod_dprintf(mp, "unable to create hbnode: %s\n", topo_strerror(topo_mod_errno(mp))); topo_mod_unload(pcimod); return (-1); } /* Create the root complex node */ rcnode = cpuboard_rc_node_create(mp, hbnode, dnode, rcpath, rc); if (rcnode == NULL) { topo_mod_dprintf(mp, "unable to create rcnode: %s\n", topo_strerror(topo_mod_errno(mp))); topo_mod_unload(pcimod); return (-1); } /* * If dnode not NULL, enumerate pcibus nodes under the root complex. * If dnode NULL, skip enumeration. Condition could occur if the RC * is assigned to non-control domain. */ if ((dnode != NULL) && topo_mod_enumerate(pcimod, rcnode, PCI_BUS, PCIEX_BUS, 0, 255, NULL) != 0) { topo_mod_dprintf(mp, "error enumerating pcibus: %s\n", topo_strerror(topo_mod_errno(mp))); topo_mod_unload(pcimod); return (-1); } topo_mod_unload(pcimod); return (0); }