908f1e1388f616898b4e515d343c0414f2a6472esd * CDDL HEADER START
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 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
908f1e1388f616898b4e515d343c0414f2a6472esd * See the License for the specific language governing permissions
908f1e1388f616898b4e515d343c0414f2a6472esd * and limitations under the License.
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 * CDDL HEADER END
186d582bd9dbcd38e0aeea49036d47d3426a3536Surya Prakki * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
908f1e1388f616898b4e515d343c0414f2a6472esd * Use is subject to license terms.
908f1e1388f616898b4e515d343c0414f2a6472esd * Some topology creation routines may need to defer completing enumeration
908f1e1388f616898b4e515d343c0414f2a6472esd * until after the entire PRI graph has been visited. This file includes
908f1e1388f616898b4e515d343c0414f2a6472esd * the interfaces necessary to permit these routines to do this in a general
908f1e1388f616898b4e515d343c0414f2a6472esd tnode_t *t_node; /* Topo node associated with MDE node */
908f1e1388f616898b4e515d343c0414f2a6472esd pi_deferenum_fn_t *func; /* Defered enumeration routine */
908f1e1388f616898b4e515d343c0414f2a6472esd/* Routines to handle the list of topology parents and mde_nodes */
908f1e1388f616898b4e515d343c0414f2a6472esdstatic int pi_deferlist_compare(const void *, const void *, void *);
908f1e1388f616898b4e515d343c0414f2a6472esd * Add a new routine to the list of deferred enumeration routines
908f1e1388f616898b4e515d343c0414f2a6472esdpi_defer_add(topo_mod_t *mod, mde_cookie_t mde_node, tnode_t *t_parent,
908f1e1388f616898b4e515d343c0414f2a6472esd if (result != 0) {
908f1e1388f616898b4e515d343c0414f2a6472esd * Create a data structure to store information about the node for
908f1e1388f616898b4e515d343c0414f2a6472esd * which to defer enumeration. The defer_pool is created by the
908f1e1388f616898b4e515d343c0414f2a6472esd * list creation routine, above.
908f1e1388f616898b4e515d343c0414f2a6472esd return (-1);
908f1e1388f616898b4e515d343c0414f2a6472esd return (0);
908f1e1388f616898b4e515d343c0414f2a6472esd * Execute the list of deferred enumeration routines, destroying the list as
908f1e1388f616898b4e515d343c0414f2a6472esd topo_mod_dprintf(mod, "beginning deferred enumerator execution\n");
908f1e1388f616898b4e515d343c0414f2a6472esd topo_mod_dprintf(mod, "no deferred enumerators. done.\n");
908f1e1388f616898b4e515d343c0414f2a6472esd return (0);
908f1e1388f616898b4e515d343c0414f2a6472esd /* Extract the necessary information from the defernode_t */
908f1e1388f616898b4e515d343c0414f2a6472esd * Remove the element from the list. Once we are done calling
908f1e1388f616898b4e515d343c0414f2a6472esd * the routine we do not need it any more.
908f1e1388f616898b4e515d343c0414f2a6472esd /* Get the instance value from the mde node */
908f1e1388f616898b4e515d343c0414f2a6472esd /* Move on to the next node */
186d582bd9dbcd38e0aeea49036d47d3426a3536Surya Prakki (void) topo_mod_seterrno(mod, EMOD_PARTIAL_ENUM);
908f1e1388f616898b4e515d343c0414f2a6472esd /* Get the hc name from the mde node */
908f1e1388f616898b4e515d343c0414f2a6472esd "deferred node_0x%llx has invalid NULL hc_name\n",
908f1e1388f616898b4e515d343c0414f2a6472esd /* Move on to the next node */
186d582bd9dbcd38e0aeea49036d47d3426a3536Surya Prakki (void) topo_mod_seterrno(mod, EMOD_PARTIAL_ENUM);
908f1e1388f616898b4e515d343c0414f2a6472esd "calling deferred enumerator for node_0x%llx\n",
908f1e1388f616898b4e515d343c0414f2a6472esd /* Call the deferred enumeration function */
908f1e1388f616898b4e515d343c0414f2a6472esd result = (func)(mod, mdp, mde_node, inst, t_parent, hc_name,
908f1e1388f616898b4e515d343c0414f2a6472esd if (result != 0) {
908f1e1388f616898b4e515d343c0414f2a6472esd "deferred enumeration for node_0x%llx failed\n",
186d582bd9dbcd38e0aeea49036d47d3426a3536Surya Prakki (void) topo_mod_seterrno(mod, EMOD_PARTIAL_ENUM);
908f1e1388f616898b4e515d343c0414f2a6472esd /* Clean up from the deferred call */
908f1e1388f616898b4e515d343c0414f2a6472esd topo_mod_dprintf(mod, "deferred enumeration completed.\n");
908f1e1388f616898b4e515d343c0414f2a6472esd return (0);
908f1e1388f616898b4e515d343c0414f2a6472esd /* Initialize the uutil list structure */
908f1e1388f616898b4e515d343c0414f2a6472esd sizeof (pi_defernode_t), offsetof(pi_defernode_t, defer_node),
908f1e1388f616898b4e515d343c0414f2a6472esd return (-1);
908f1e1388f616898b4e515d343c0414f2a6472esd return (-1);
908f1e1388f616898b4e515d343c0414f2a6472esd return (0);
908f1e1388f616898b4e515d343c0414f2a6472esd/* ARGSUSED */
908f1e1388f616898b4e515d343c0414f2a6472esdpi_deferlist_compare(const void *l_arg, const void *r_arg, void *private)
908f1e1388f616898b4e515d343c0414f2a6472esd return (1);
908f1e1388f616898b4e515d343c0414f2a6472esd return (-1);
908f1e1388f616898b4e515d343c0414f2a6472esd return (0);