/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2000-2003 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 <unistd.h>
#include <sys/systeminfo.h>
#include <sys/openpromio.h>
#include <libdevinfo.h>
#include "pdevinfo.h"
#include "pdevinfo_sun4u.h"
#include "display.h"
#include "display_sun4u.h"
#include "libprtdiag.h"
/*
* This file contains the functions that are to be called when
* a platform wants to use libdevinfo for it's device information
* instead of OBP. This will allow prtdiag to support hot-plug
* events on platforms whose OBP doesn't get updated to reflect
* the hot-plug changes to the system.
*/
int prt_flag);
static int match_compatible_name(char *, int, char *);
/*
* Global variables
*/
extern char *progname;
/*
* Used instead of the walk() function when a platform wants to
* walk libdevinfo's device tree instead of walking OBP's
* device tree.
*/
static Prom_node*
{
int board_node = 0;
int *int_val;
int portid;
/* allocate a node for this level */
NULL) {
perror("malloc");
exit(2);
}
/* assign parent Prom_node */
/* read properties for this node */
type = "";
model = "";
/*
* For identifying Schizo nodes we need to check if the
* compatible property contains the string 'pci108e,8001'.
* This property contains an array of strings so we need
* search all strings.
*/
"pci108e,8001"))
is_schizo = 1;
}
else
portid = -1;
#ifdef DEBUG
#endif
if (has_board_num(pnode)) {
board_node = 1;
D_PRINTF("\n---\nnodename = %s [ %s ] \n",
D_PRINTF("ADDED BOARD name=%s type=%s model=%s "
board_node = 1;
D_PRINTF("\n---\nnodename = %s [ %s ] \n",
D_PRINTF("ADDED BOARD name=%s type=%s model=%s\n",
}
} else {
}
}
if (board_node) {
} else {
}
}
/*
* This check is needed in case the "board node" occurs at the
* end of the sibling chain as opposed to the middle or front.
*/
if (board_node)
return (NULL);
return (pnode);
}
/*
* Dump all the devinfo properties and then the obp properties for
* the specified devinfo node into the Prom_node structure.
*/
static void
{
int retval = 0;
int i;
/* clear out pointers in pnode */
D_PRINTF("\n\n ------- Dumping devinfo properties for node ------\n");
/*
* get all the devinfo properties first
*/
di_prop != DI_PROP_NIL;
char *di_name;
void *di_data;
int di_ptype;
continue;
switch (di_ptype) {
int *int_val;
char *char_val;
case DI_PROP_TYPE_INT:
if (retval > 0) {
}
break;
case DI_PROP_TYPE_STRING:
if (retval > 0) {
}
break;
case DI_PROP_TYPE_BYTE:
if (retval > 0) {
}
break;
case DI_PROP_TYPE_UNKNOWN:
if (retval > 0) {
}
break;
case DI_PROP_TYPE_BOOLEAN:
retval = 1;
break;
default:
D_PRINTF(" Skipping property\n");
retval = -1;
}
if (retval <= 0)
continue;
/* allocate space for the property */
perror("malloc");
exit(1);
}
/*
* Given that we're using libdevinfo rather than OBP,
* the chances are that future accesses to di_name and
* di_data will be via temp->name.val_ptr and
* temp->value.val_ptr respectively. However, this may
* not be the case, so we have to suitably fill in
* temp->name.opp and temp->value.opp.
*
* di_name is char * and non-NULL if we've made it to
* here, so we can simply point
* temp->name.opp.oprom_array to temp->name.val_ptr.
*
* di_data could be NULL, char * or int * at this point.
* If it's non-NULL, a 1st char of '\0' indicates int *.
* We thus set temp->value.opp.oprom_node[] (although
* interest in any element other than 0 is rare, all
* elements must be set to ensure compatibility with
* OBP), and holds_array is set to 0.
*
* If di_data is NULL, or the 1st char is not '\0', we set
* temp->value.opp.oprom_array. If di_ptype is
* DI_PROP_TYPE_BOOLEAN, holds_array is set to 0, else it
* is set to 1.
*/
for (i = 0; i < OPROM_NODE_SIZE; i++)
} else {
if (di_ptype == DI_PROP_TYPE_BOOLEAN)
else
}
/* everything worked so link the property list */
}
/*
* Then get all the OBP properties.
*/
char *p_name;
unsigned char *p_data;
retval = -1;
else
if (retval <= 0)
continue;
/* allocate space for the property */
perror("malloc");
exit(1);
}
/*
* As above, p_name is char * and non-NULL if we've made
* it to here, so we can simply point
* temp->name.opp.oprom_array to temp->name.val_ptr.
*
* p_data could be NULL, a character or a number at this
* point. If it's non-NULL, a 1st char of '\0' indicates a
* number, so we set temp->value.opp.oprom_node[] (again
* setting every element to ensure OBP compatibility).
* These assignments create a lint error, hence the LINTED
* comment.
*
* If p_data is NULL, or the 1st char is not '\0', we set
* temp->value.opp.oprom_array.
*/
for (i = 0; i < OPROM_NODE_SIZE; i++)
/* LINTED */
} else {
}
/* everything worked so link the property list */
}
}
}
/*
* Used in place of do_prominfo() when a platform wants to use
* libdevinfo for getting the device tree instead of OBP.
*/
int
{
/* set the global flags */
/* set the the system tree fields */
/*
* create a snapshot of the kernel device tree
* and return a handle to it.
*/
}
/*
* create a handle to the PROM device tree.
*/
}
/*
* walk the devinfo tree and build up a list of all
* nodes and properties.
*/
/* resolve the board types now */
return (retval);
}
/*
* check to see if the name shows up in the compatible array
*/
static int
{
int i, ret = 0;
/* parse the compatible list */
for (i = 0; i < n_names; i++) {
ret = 1;
break;
}
}
return (ret);
}