示例#1
0
文件: ioboard.c 项目: andreiw/polaris
/*ARGSUSED*/
static int
iob_enum(topo_mod_t *mp, tnode_t *pn, const char *name, topo_instance_t imin,
    topo_instance_t imax, void *notused)
{
	topo_mod_t *hbmod;
	int rv;
	did_hash_t *didhash;
	di_prom_handle_t promtree;

	if (strcmp(name, IOBOARD) != 0) {
		topo_mod_dprintf(mp,
		    "Currently only know how to enumerate %s components.\n",
		    IOBOARD);
		return (0);
	}

	if ((promtree = di_prom_init()) == DI_PROM_HANDLE_NIL) {
		topo_mod_dprintf(mp,
		    "Ioboard enumerator: di_prom_handle_init failed.\n");
		return (-1);
	}

	/*
	 * Load the hostbridge enumerator, we'll soon need it!
	 */
	if ((hbmod = hb_enumr_load(mp, pn)) == NULL) {
		di_prom_fini(promtree);
		return (-1);
	}

	if ((didhash = did_hash_init(mp)) == NULL) {
		topo_mod_dprintf(mp,
		    "Hash initialization for ioboard enumerator failed.\n");
		di_prom_fini(promtree);
		topo_mod_unload(hbmod);
		return (-1);
	}

	rv = platform_iob_enum(pn, imin, imax, didhash, promtree, mp);

	did_hash_fini(didhash);
	di_prom_fini(promtree);
	topo_mod_unload(hbmod);

	if (rv < 0)
		return (topo_mod_seterrno(mp, EMOD_PARTIAL_ENUM));
	else
		return (0);
}
示例#2
0
/*ARGSUSED*/
static int
hb_enum(topo_mod_t *mp, tnode_t *pn, const char *name, topo_instance_t imin,
    topo_instance_t imax, void *notused, void *data)
{
	int rv;
	topo_mod_t *pcimod;

	if (strcmp(name, HOSTBRIDGE) != 0) {
		topo_mod_dprintf(mp,
		    "Currently only know how to enumerate %s components.\n",
		    HOSTBRIDGE);
		return (0);
	}
	/*
	 * Load the pcibus enumerator
	 */
	if ((pcimod = pci_enumr_load(mp)) == NULL)
		return (-1);

	/*
	 * If we're asked to enumerate a whole range of hostbridges, then
	 * we need to find them all.  If we're just asked to enumerate a
	 * single hostbridge, we expect our caller to have passed us linked
	 * did_t structures we can use to enumerate the singled out hostbridge.
	 */
	if (imin != imax) {

		if (did_hash_init(mp) < 0) {
			topo_mod_dprintf(mp,
			    "Hash initialization for hostbridge "
			    "enumerator failed.\n");
			topo_mod_unload(pcimod);
			return (-1);
		}
		rv = platform_hb_enum(mp, pn, name, imin, imax);
		did_hash_fini(mp);
	} else {
		rv = specific_hb_enum(mp, pn, name, imin, imax, data);
	}

	return (rv);
}