03831d35f7499c87d51205817c93e9a8d42c4baestevel * CDDL HEADER START
03831d35f7499c87d51205817c93e9a8d42c4baestevel * The contents of this file are subject to the terms of the
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Common Development and Distribution License, Version 1.0 only
03831d35f7499c87d51205817c93e9a8d42c4baestevel * (the "License"). You may not use this file except in compliance
03831d35f7499c87d51205817c93e9a8d42c4baestevel * with the License.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
03831d35f7499c87d51205817c93e9a8d42c4baestevel * See the License for the specific language governing permissions
03831d35f7499c87d51205817c93e9a8d42c4baestevel * and limitations under the License.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * When distributing Covered Code, include this CDDL HEADER in each
03831d35f7499c87d51205817c93e9a8d42c4baestevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * If applicable, add the following below this CDDL HEADER, with the
03831d35f7499c87d51205817c93e9a8d42c4baestevel * fields enclosed by brackets "[]" replaced with your own identifying
03831d35f7499c87d51205817c93e9a8d42c4baestevel * information: Portions Copyright [yyyy] [name of copyright owner]
03831d35f7499c87d51205817c93e9a8d42c4baestevel * CDDL HEADER END
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Copyright 1999-2003 Sun Microsystems, Inc. All rights reserved.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Use is subject to license terms.
03831d35f7499c87d51205817c93e9a8d42c4baestevel#pragma ident "%Z%%M% %I% %E% SMI"
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Global variables
03831d35f7499c87d51205817c93e9a8d42c4baestevel * This file represents the splitting out of some functionality
03831d35f7499c87d51205817c93e9a8d42c4baestevel * of prtdiag due to the port to the sun4u platform. The PROM
03831d35f7499c87d51205817c93e9a8d42c4baestevel * tree-walking functions which contain sun4u specifics were moved
03831d35f7499c87d51205817c93e9a8d42c4baestevel * into this module.
03831d35f7499c87d51205817c93e9a8d42c4baestevel/* Function prototypes */
03831d35f7499c87d51205817c93e9a8d42c4baestevel * do_prominfo() is called from main() in usr/src/cmd/prtdiag/main.c
03831d35f7499c87d51205817c93e9a8d42c4baestevel * This is the starting point for all platforms. However, this function
03831d35f7499c87d51205817c93e9a8d42c4baestevel * can be overlayed by writing a do_prominfo() function
03831d35f7499c87d51205817c93e9a8d42c4baestevel * in the libprtdiag_psr for a particular platform.
03831d35f7499c87d51205817c93e9a8d42c4baesteveldo_prominfo(int syserrlog, char *pgname, int log_flag, int prt_flag)
03831d35f7499c87d51205817c93e9a8d42c4baestevel Prom_node *root_node; /* root node of OBP device tree */
03831d35f7499c87d51205817c93e9a8d42c4baestevel struct system_kstat_data sys_kstat; /* kstats for non-OBP data */
03831d35f7499c87d51205817c93e9a8d42c4baestevel /* set the global flags */
03831d35f7499c87d51205817c93e9a8d42c4baestevel /* set the the system tree fields */
03831d35f7499c87d51205817c93e9a8d42c4baestevel "open failed")));
03831d35f7499c87d51205817c93e9a8d42c4baestevel if (is_openprom() == 0) {
03831d35f7499c87d51205817c93e9a8d42c4baestevel "does not support this option of this "
03831d35f7499c87d51205817c93e9a8d42c4baestevel "command.\n"));
03831d35f7499c87d51205817c93e9a8d42c4baestevel return (2);
03831d35f7499c87d51205817c93e9a8d42c4baestevel if (next(0) == 0) {
03831d35f7499c87d51205817c93e9a8d42c4baestevel return (2);
03831d35f7499c87d51205817c93e9a8d42c4baestevel /* resolve the board types now */
03831d35f7499c87d51205817c93e9a8d42c4baestevel return (display(&sys_tree, root_node, &sys_kstat, syserrlog));
03831d35f7499c87d51205817c93e9a8d42c4baestevel * check for upa-portid on UI and UII systems
03831d35f7499c87d51205817c93e9a8d42c4baestevel if ((value = (int *)get_prop_val(find_prop(node, "upa-portid")))
03831d35f7499c87d51205817c93e9a8d42c4baestevel * check for portid on UIII systems
03831d35f7499c87d51205817c93e9a8d42c4baestevel if ((value = (int *)get_prop_val(find_prop(node, "portid")))
03831d35f7499c87d51205817c93e9a8d42c4baestevel return (-1);
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Walk the PROM device tree and build the system tree and root tree.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Nodes that have a board number property are placed in the board
03831d35f7499c87d51205817c93e9a8d42c4baestevel * structures for easier processing later. Child nodes are placed
03831d35f7499c87d51205817c93e9a8d42c4baestevel * under their parents. ffb (Fusion Frame Buffer) nodes are handled
03831d35f7499c87d51205817c93e9a8d42c4baestevel * specially, because they do not contain board number properties.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * This was requested from OBP, but was not granted. So this code
03831d35f7499c87d51205817c93e9a8d42c4baestevel * must parse the MID of the FFB to find the board#.
03831d35f7499c87d51205817c93e9a8d42c4baestevel /* allocate a node for this level */
03831d35f7499c87d51205817c93e9a8d42c4baestevel if ((pnode = (Prom_node *) malloc(sizeof (struct prom_node))) ==
03831d35f7499c87d51205817c93e9a8d42c4baestevel /* assign parent Prom_node */
03831d35f7499c87d51205817c93e9a8d42c4baestevel /* read properties for this node */
03831d35f7499c87d51205817c93e9a8d42c4baestevel * Place a node in a 'board' if it has 'board'-ness. The definition
03831d35f7499c87d51205817c93e9a8d42c4baestevel * is that all nodes that are children of root should have a
03831d35f7499c87d51205817c93e9a8d42c4baestevel * board# property. But the PROM tree does not exactly follow
03831d35f7499c87d51205817c93e9a8d42c4baestevel * this. This is where we start hacking. The name 'ffb' can
03831d35f7499c87d51205817c93e9a8d42c4baestevel * change, so watch out for this.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * The UltraSPARC, sbus, pci and ffb nodes will exit in
03831d35f7499c87d51205817c93e9a8d42c4baestevel * the desktops and will not have board# properties. These
03831d35f7499c87d51205817c93e9a8d42c4baestevel * cases must be handled here.
03831d35f7499c87d51205817c93e9a8d42c4baestevel * PCI to PCI bridges also have the name "pci", but with different
03831d35f7499c87d51205817c93e9a8d42c4baestevel * model property values. They should not be put under 'board'.
03831d35f7499c87d51205817c93e9a8d42c4baestevel model = (char *)get_prop_val(find_prop(pnode, "model"));
03831d35f7499c87d51205817c93e9a8d42c4baestevel printf("node not added: name=%s type=%s\n", name, type);