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