/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <dirent.h>
#include <varargs.h>
#include <errno.h>
#include <unistd.h>
#include <alloca.h>
#include <sys/systeminfo.h>
#include <sys/openpromio.h>
#include <kstat.h>
#include <libintl.h>
#include "pdevinfo.h"
#include "display.h"
#include "display_sun4v.h"
#include "libprtdiag.h"
#if !defined(TEXT_DOMAIN)
#endif
/*
* Global variables
*/
char *progname;
int logging = 0;
/*
* This file represents the splitting out of some functionality
* of prtdiag due to the port to the sun4v platform. The PROM
* tree-walking functions which contain sun4v specifics were moved
* into this module.
*/
/* Function prototypes */
/*
*
* This is the starting point for all platforms. However, this function
* can be overlayed by writing a do_prominfo() function
* in the libprtdiag_psr for a particular platform.
*
*/
int
{
err = picl_initialize();
if (err != PICL_SUCCESS) {
exit(1);
}
/* set the global flags */
/* set the the system tree fields */
"open failed")));
}
if (is_openprom() == 0) {
"does not support this option of this "
"command.\n"));
return (2);
}
if (next(0) == 0) {
return (2);
}
promclose();
if (err != PICL_SUCCESS) {
exit(1);
}
if (err != PICL_SUCCESS)
return (err);
}
/*
* sun4v_Walk the PROM device tree and build the system tree and root tree.
* Nodes that have a board number property are placed in the board
* structures for easier processing later. Child nodes are placed
* under their parents.
*/
{
register int curnode;
char *name;
char *type;
char *compatible;
int board_node = 0;
/* allocate a node for this level */
NULL) {
perror("malloc");
}
/* assign parent Prom_node */
/* read properties for this node */
/*
* Place a node in a 'board' if it has 'board'-ness. The definition
* is that all nodes that are children of root should have a
* board# property. But the PROM tree does not exactly follow
* this. This is where we start hacking.
*
* PCI to PCI bridges also have the name "pci", but with different
* model property values. They should not be put under 'board'.
*/
#ifdef DEBUG
printf("\n");
#endif
if (compatible == NULL)
compatible = "";
type = "";
if (has_board_num(pnode)) {
board_node = 1;
#ifdef DEBUG
printf("ADDED BOARD name=%s type=%s compatible=%s\n",
#endif
board_node = 1;
#ifdef DEBUG
printf("ADDED BOARD name=%s type=%s compatible=%s\n",
#endif
}
#ifdef DEBUG
else
#endif
}
}
if (board_node) {
} else {
}
}
if (board_node) {
return (NULL);
} else {
return (pnode);
}
}
/*
* search children to get the node by the nodename
*/
{
int err;
char *nodename;
return (PICL_FAILURE);
sizeof (picl_nodehdl_t));
while (err == PICL_SUCCESS) {
if (err != PICL_SUCCESS) {
&childh, sizeof (picl_nodehdl_t));
continue;
}
return (PICL_SUCCESS);
}
&childh, sizeof (picl_nodehdl_t));
}
return (err);
}
int
{
#ifdef lint
#endif
/*
* This function is intentionally empty
*/
return (0);
}