73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier/*
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier * CDDL HEADER START
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier *
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier * The contents of this file are subject to the terms of the
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier * Common Development and Distribution License (the "License").
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier * You may not use this file except in compliance with the License.
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier *
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier * or http://www.opensolaris.org/os/licensing.
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier * See the License for the specific language governing permissions
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier * and limitations under the License.
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier *
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier * When distributing Covered Code, include this CDDL HEADER in each
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier * If applicable, add the following below this CDDL HEADER, with the
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier * fields enclosed by brackets "[]" replaced with your own identifying
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier * information: Portions Copyright [yyyy] [name of copyright owner]
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier *
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier * CDDL HEADER END
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier */
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier/*
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier * Use is subject to license terms.
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier */
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier/*
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier * Create a topology node for a PRI node of type 'hostbridge'
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier */
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier#include <sys/types.h>
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier#include <strings.h>
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier#include <sys/fm/protocol.h>
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier#include <fm/topo_mod.h>
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier#include <fm/topo_hc.h>
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier#include "pi_impl.h"
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier#define _ENUM_NAME "enum_hostbridge"
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier/*
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier * Create a hostbridge topo node.
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier */
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothierint
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothierpi_enum_hostbridge(topo_mod_t *mod, md_t *mdp, mde_cookie_t mde_node,
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier topo_instance_t inst, tnode_t *t_parent, const char *hc_name,
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier tnode_t **t_node)
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier{
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier int result;
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier topo_mod_dprintf(mod, "%s called for node_0x%llx type %s\n",
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier _ENUM_NAME, (uint64_t)mde_node, hc_name);
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier *t_node = NULL;
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier /*
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier * Create the hostbridge topo node. Use the generic enumerator to
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier * do this, and then we will add more attributes below.
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier */
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier result = pi_enum_generic_impl(mod, mdp, mde_node, inst, t_parent,
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier t_parent, hc_name, _ENUM_NAME, t_node, 0);
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier if (result != 0 || *t_node == NULL) {
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier topo_mod_dprintf(mod,
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier "%s node_0x%llx failed to create topo node: %s\n",
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier _ENUM_NAME, (uint64_t)mde_node,
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier topo_strerror(topo_mod_errno(mod)));
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier return (result);
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier }
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier /* Update the topo node with more specific information */
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier result = pi_enum_update(mod, mdp, mde_node, t_parent, *t_node,
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier hc_name);
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier if (result != 0) {
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier topo_mod_dprintf(mod,
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier "%s node_0x%llx failed to create node properites: %s\n",
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier _ENUM_NAME, (uint64_t)mde_node,
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier topo_strerror(topo_mod_errno(mod)));
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier return (result);
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier }
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier topo_mod_dprintf(mod, "%s added node_0x%llx type %s\n",
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier _ENUM_NAME, (uint64_t)mde_node, hc_name);
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier return (result);
73a0bd151c1115bf39cc2caa30c7cbfdd86361c1Tom Pothier}