908f1e1388f616898b4e515d343c0414f2a6472esd/*
908f1e1388f616898b4e515d343c0414f2a6472esd * CDDL HEADER START
908f1e1388f616898b4e515d343c0414f2a6472esd *
908f1e1388f616898b4e515d343c0414f2a6472esd * The contents of this file are subject to the terms of the
908f1e1388f616898b4e515d343c0414f2a6472esd * Common Development and Distribution License (the "License").
908f1e1388f616898b4e515d343c0414f2a6472esd * You may not use this file except in compliance with the License.
908f1e1388f616898b4e515d343c0414f2a6472esd *
908f1e1388f616898b4e515d343c0414f2a6472esd * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
908f1e1388f616898b4e515d343c0414f2a6472esd * or http://www.opensolaris.org/os/licensing.
908f1e1388f616898b4e515d343c0414f2a6472esd * See the License for the specific language governing permissions
908f1e1388f616898b4e515d343c0414f2a6472esd * and limitations under the License.
908f1e1388f616898b4e515d343c0414f2a6472esd *
908f1e1388f616898b4e515d343c0414f2a6472esd * When distributing Covered Code, include this CDDL HEADER in each
908f1e1388f616898b4e515d343c0414f2a6472esd * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
908f1e1388f616898b4e515d343c0414f2a6472esd * If applicable, add the following below this CDDL HEADER, with the
908f1e1388f616898b4e515d343c0414f2a6472esd * fields enclosed by brackets "[]" replaced with your own identifying
908f1e1388f616898b4e515d343c0414f2a6472esd * information: Portions Copyright [yyyy] [name of copyright owner]
908f1e1388f616898b4e515d343c0414f2a6472esd *
908f1e1388f616898b4e515d343c0414f2a6472esd * CDDL HEADER END
908f1e1388f616898b4e515d343c0414f2a6472esd */
908f1e1388f616898b4e515d343c0414f2a6472esd
908f1e1388f616898b4e515d343c0414f2a6472esd/*
908f1e1388f616898b4e515d343c0414f2a6472esd * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
908f1e1388f616898b4e515d343c0414f2a6472esd * Use is subject to license terms.
908f1e1388f616898b4e515d343c0414f2a6472esd */
908f1e1388f616898b4e515d343c0414f2a6472esd
908f1e1388f616898b4e515d343c0414f2a6472esd#pragma ident "%Z%%M% %I% %E% SMI"
908f1e1388f616898b4e515d343c0414f2a6472esd
908f1e1388f616898b4e515d343c0414f2a6472esd/*
908f1e1388f616898b4e515d343c0414f2a6472esd * Create a topology node for a PRI node of type 'niu'
908f1e1388f616898b4e515d343c0414f2a6472esd */
908f1e1388f616898b4e515d343c0414f2a6472esd#include <sys/types.h>
908f1e1388f616898b4e515d343c0414f2a6472esd#include <strings.h>
908f1e1388f616898b4e515d343c0414f2a6472esd#include <sys/fm/protocol.h>
908f1e1388f616898b4e515d343c0414f2a6472esd#include <fm/topo_mod.h>
908f1e1388f616898b4e515d343c0414f2a6472esd#include <fm/topo_hc.h>
908f1e1388f616898b4e515d343c0414f2a6472esd#include "pi_impl.h"
908f1e1388f616898b4e515d343c0414f2a6472esd
908f1e1388f616898b4e515d343c0414f2a6472esd#define _ENUM_NAME "enum_niu"
908f1e1388f616898b4e515d343c0414f2a6472esd
908f1e1388f616898b4e515d343c0414f2a6472esd
908f1e1388f616898b4e515d343c0414f2a6472esd/* ARGSUSED */
908f1e1388f616898b4e515d343c0414f2a6472esdint
908f1e1388f616898b4e515d343c0414f2a6472esdpi_enum_niu(topo_mod_t *mod, md_t *mdp, mde_cookie_t mde_node,
908f1e1388f616898b4e515d343c0414f2a6472esd topo_instance_t inst, tnode_t *t_parent, const char *hc_name,
908f1e1388f616898b4e515d343c0414f2a6472esd tnode_t **t_node)
908f1e1388f616898b4e515d343c0414f2a6472esd{
908f1e1388f616898b4e515d343c0414f2a6472esd int result;
908f1e1388f616898b4e515d343c0414f2a6472esd
908f1e1388f616898b4e515d343c0414f2a6472esd *t_node = NULL;
908f1e1388f616898b4e515d343c0414f2a6472esd
908f1e1388f616898b4e515d343c0414f2a6472esd topo_mod_dprintf(mod,
908f1e1388f616898b4e515d343c0414f2a6472esd "%s node_0x%llx enumeration starting\n", _ENUM_NAME,
908f1e1388f616898b4e515d343c0414f2a6472esd (uint64_t)mde_node);
908f1e1388f616898b4e515d343c0414f2a6472esd
908f1e1388f616898b4e515d343c0414f2a6472esd /* Make sure our dependent modules are loaded */
908f1e1388f616898b4e515d343c0414f2a6472esd if (topo_mod_load(mod, NIU, TOPO_VERSION) == NULL) {
908f1e1388f616898b4e515d343c0414f2a6472esd topo_mod_dprintf(mod, "%s could not load %s module: %s\n",
908f1e1388f616898b4e515d343c0414f2a6472esd _ENUM_NAME, NIU, topo_strerror(topo_mod_errno(mod)));
908f1e1388f616898b4e515d343c0414f2a6472esd return (-1);
908f1e1388f616898b4e515d343c0414f2a6472esd }
908f1e1388f616898b4e515d343c0414f2a6472esd
908f1e1388f616898b4e515d343c0414f2a6472esd /*
908f1e1388f616898b4e515d343c0414f2a6472esd * Invoke the niu enumerator for this node.
908f1e1388f616898b4e515d343c0414f2a6472esd */
908f1e1388f616898b4e515d343c0414f2a6472esd result = topo_mod_enumerate(mod, t_parent, NIU, hc_name, inst, inst,
908f1e1388f616898b4e515d343c0414f2a6472esd NULL);
908f1e1388f616898b4e515d343c0414f2a6472esd if (result != 0) {
908f1e1388f616898b4e515d343c0414f2a6472esd topo_mod_dprintf(mod,
908f1e1388f616898b4e515d343c0414f2a6472esd "%s node_0x%llx enumeration failed: %s\n", _ENUM_NAME,
908f1e1388f616898b4e515d343c0414f2a6472esd (uint64_t)mde_node, topo_strerror(topo_mod_errno(mod)));
908f1e1388f616898b4e515d343c0414f2a6472esd return (-1);
908f1e1388f616898b4e515d343c0414f2a6472esd }
908f1e1388f616898b4e515d343c0414f2a6472esd
908f1e1388f616898b4e515d343c0414f2a6472esd topo_mod_dprintf(mod, "%s added node_0x%llx type %s\n",
908f1e1388f616898b4e515d343c0414f2a6472esd _ENUM_NAME, (uint64_t)mde_node, hc_name);
908f1e1388f616898b4e515d343c0414f2a6472esd
908f1e1388f616898b4e515d343c0414f2a6472esd return (0);
908f1e1388f616898b4e515d343c0414f2a6472esd}