1*03831d35Sstevel /*
2*03831d35Sstevel * CDDL HEADER START
3*03831d35Sstevel *
4*03831d35Sstevel * The contents of this file are subject to the terms of the
5*03831d35Sstevel * Common Development and Distribution License, Version 1.0 only
6*03831d35Sstevel * (the "License"). You may not use this file except in compliance
7*03831d35Sstevel * with the License.
8*03831d35Sstevel *
9*03831d35Sstevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*03831d35Sstevel * or http://www.opensolaris.org/os/licensing.
11*03831d35Sstevel * See the License for the specific language governing permissions
12*03831d35Sstevel * and limitations under the License.
13*03831d35Sstevel *
14*03831d35Sstevel * When distributing Covered Code, include this CDDL HEADER in each
15*03831d35Sstevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*03831d35Sstevel * If applicable, add the following below this CDDL HEADER, with the
17*03831d35Sstevel * fields enclosed by brackets "[]" replaced with your own identifying
18*03831d35Sstevel * information: Portions Copyright [yyyy] [name of copyright owner]
19*03831d35Sstevel *
20*03831d35Sstevel * CDDL HEADER END
21*03831d35Sstevel */
22*03831d35Sstevel /*
23*03831d35Sstevel * Copyright 2000-2003 Sun Microsystems, Inc. All rights reserved.
24*03831d35Sstevel * Use is subject to license terms.
25*03831d35Sstevel */
26*03831d35Sstevel
27*03831d35Sstevel #pragma ident "%Z%%M% %I% %E% SMI"
28*03831d35Sstevel
29*03831d35Sstevel #include <stdio.h>
30*03831d35Sstevel #include <stdlib.h>
31*03831d35Sstevel #include <string.h>
32*03831d35Sstevel #include <unistd.h>
33*03831d35Sstevel #include <sys/systeminfo.h>
34*03831d35Sstevel #include <sys/utsname.h>
35*03831d35Sstevel #include <sys/openpromio.h>
36*03831d35Sstevel #include <libdevinfo.h>
37*03831d35Sstevel
38*03831d35Sstevel #include "pdevinfo.h"
39*03831d35Sstevel #include "pdevinfo_sun4u.h"
40*03831d35Sstevel #include "display.h"
41*03831d35Sstevel #include "display_sun4u.h"
42*03831d35Sstevel #include "libprtdiag.h"
43*03831d35Sstevel
44*03831d35Sstevel /*
45*03831d35Sstevel * This file contains the functions that are to be called when
46*03831d35Sstevel * a platform wants to use libdevinfo for it's device information
47*03831d35Sstevel * instead of OBP. This will allow prtdiag to support hot-plug
48*03831d35Sstevel * events on platforms whose OBP doesn't get updated to reflect
49*03831d35Sstevel * the hot-plug changes to the system.
50*03831d35Sstevel */
51*03831d35Sstevel
52*03831d35Sstevel int do_devinfo(int syserrlog, char *pgname, int log_flag,
53*03831d35Sstevel int prt_flag);
54*03831d35Sstevel static void dump_di_node(Prom_node *pnode, di_node_t di_node);
55*03831d35Sstevel static Prom_node *walk_di_tree(Sys_tree *tree, Prom_node *root,
56*03831d35Sstevel di_node_t di_node);
57*03831d35Sstevel static int match_compatible_name(char *, int, char *);
58*03831d35Sstevel
59*03831d35Sstevel /*
60*03831d35Sstevel * Global variables
61*03831d35Sstevel */
62*03831d35Sstevel di_prom_handle_t ph; /* Handle for using di_prom interface */
63*03831d35Sstevel extern char *progname;
64*03831d35Sstevel
65*03831d35Sstevel
66*03831d35Sstevel
67*03831d35Sstevel /*
68*03831d35Sstevel * Used instead of the walk() function when a platform wants to
69*03831d35Sstevel * walk libdevinfo's device tree instead of walking OBP's
70*03831d35Sstevel * device tree.
71*03831d35Sstevel */
72*03831d35Sstevel static Prom_node*
walk_di_tree(Sys_tree * tree,Prom_node * root,di_node_t di_node)73*03831d35Sstevel walk_di_tree(Sys_tree *tree, Prom_node *root, di_node_t di_node)
74*03831d35Sstevel {
75*03831d35Sstevel di_node_t curnode;
76*03831d35Sstevel Prom_node *pnode;
77*03831d35Sstevel char *name, *type, *model, *compatible_array;
78*03831d35Sstevel int board_node = 0;
79*03831d35Sstevel int *int_val;
80*03831d35Sstevel int portid;
81*03831d35Sstevel int is_schizo = 0, n_names;
82*03831d35Sstevel
83*03831d35Sstevel /* allocate a node for this level */
84*03831d35Sstevel if ((pnode = (Prom_node *) malloc(sizeof (struct prom_node))) ==
85*03831d35Sstevel NULL) {
86*03831d35Sstevel perror("malloc");
87*03831d35Sstevel exit(2);
88*03831d35Sstevel }
89*03831d35Sstevel
90*03831d35Sstevel /* assign parent Prom_node */
91*03831d35Sstevel pnode->parent = root;
92*03831d35Sstevel pnode->sibling = NULL;
93*03831d35Sstevel pnode->child = NULL;
94*03831d35Sstevel
95*03831d35Sstevel /* read properties for this node */
96*03831d35Sstevel dump_di_node(pnode, di_node);
97*03831d35Sstevel
98*03831d35Sstevel name = get_node_name(pnode);
99*03831d35Sstevel type = get_node_type(pnode);
100*03831d35Sstevel if (type == NULL)
101*03831d35Sstevel type = "";
102*03831d35Sstevel model = (char *)get_prop_val(find_prop(pnode, "model"));
103*03831d35Sstevel if (model == NULL)
104*03831d35Sstevel model = "";
105*03831d35Sstevel
106*03831d35Sstevel /*
107*03831d35Sstevel * For identifying Schizo nodes we need to check if the
108*03831d35Sstevel * compatible property contains the string 'pci108e,8001'.
109*03831d35Sstevel * This property contains an array of strings so we need
110*03831d35Sstevel * search all strings.
111*03831d35Sstevel */
112*03831d35Sstevel if ((n_names = di_compatible_names(di_node, &compatible_array)) > 0) {
113*03831d35Sstevel if (match_compatible_name(compatible_array, n_names,
114*03831d35Sstevel "pci108e,8001"))
115*03831d35Sstevel is_schizo = 1;
116*03831d35Sstevel }
117*03831d35Sstevel
118*03831d35Sstevel if (int_val = (int *)get_prop_val(find_prop(pnode, "portid")))
119*03831d35Sstevel portid = *int_val;
120*03831d35Sstevel else if ((strcmp(type, "cpu") == 0) &&
121*03831d35Sstevel (int_val = (int *)get_prop_val(find_prop(pnode->parent, "portid"))))
122*03831d35Sstevel portid = *int_val;
123*03831d35Sstevel else
124*03831d35Sstevel portid = -1;
125*03831d35Sstevel
126*03831d35Sstevel #ifdef DEBUG
127*03831d35Sstevel if (name != NULL)
128*03831d35Sstevel printf("name=%s\n", name);
129*03831d35Sstevel if (type != NULL)
130*03831d35Sstevel printf("type=%s\n", type);
131*03831d35Sstevel if (model != NULL)
132*03831d35Sstevel printf("model=%s\n", model);
133*03831d35Sstevel printf("portid=%d\n", portid);
134*03831d35Sstevel #endif
135*03831d35Sstevel
136*03831d35Sstevel if (name != NULL) {
137*03831d35Sstevel if (has_board_num(pnode)) {
138*03831d35Sstevel add_node(tree, pnode);
139*03831d35Sstevel board_node = 1;
140*03831d35Sstevel D_PRINTF("\n---\nnodename = %s [ %s ] \n",
141*03831d35Sstevel di_node_name(di_node), di_devfs_path(di_node));
142*03831d35Sstevel D_PRINTF("ADDED BOARD name=%s type=%s model=%s "
143*03831d35Sstevel "portid =%d\n", name, type, model, portid);
144*03831d35Sstevel } else if ((strcmp(name, FFB_NAME) == 0) ||
145*03831d35Sstevel (strcmp(type, "cpu") == 0) ||
146*03831d35Sstevel
147*03831d35Sstevel ((strcmp(type, "memory-controller") == 0) &&
148*03831d35Sstevel (strcmp(name, "ac") != 0)) ||
149*03831d35Sstevel
150*03831d35Sstevel ((strcmp(name, "pci") == 0) &&
151*03831d35Sstevel (strcmp(model, "SUNW,psycho") == 0)) ||
152*03831d35Sstevel
153*03831d35Sstevel ((strcmp(name, "pci") == 0) &&
154*03831d35Sstevel (strcmp(model, "SUNW,sabre") == 0)) ||
155*03831d35Sstevel
156*03831d35Sstevel ((strcmp(name, "pci") == 0) && (is_schizo)) ||
157*03831d35Sstevel
158*03831d35Sstevel (strcmp(name, "counter-timer") == 0) ||
159*03831d35Sstevel (strcmp(name, "sbus") == 0)) {
160*03831d35Sstevel add_node(tree, pnode);
161*03831d35Sstevel board_node = 1;
162*03831d35Sstevel D_PRINTF("\n---\nnodename = %s [ %s ] \n",
163*03831d35Sstevel di_node_name(di_node), di_devfs_path(di_node));
164*03831d35Sstevel D_PRINTF("ADDED BOARD name=%s type=%s model=%s\n",
165*03831d35Sstevel name, type, model);
166*03831d35Sstevel }
167*03831d35Sstevel } else {
168*03831d35Sstevel D_PRINTF("node not added: type=%s portid =%d\n", type, portid);
169*03831d35Sstevel }
170*03831d35Sstevel
171*03831d35Sstevel if (curnode = di_child_node(di_node)) {
172*03831d35Sstevel pnode->child = walk_di_tree(tree, pnode, curnode);
173*03831d35Sstevel }
174*03831d35Sstevel
175*03831d35Sstevel if (curnode = di_sibling_node(di_node)) {
176*03831d35Sstevel if (board_node) {
177*03831d35Sstevel return (walk_di_tree(tree, root, curnode));
178*03831d35Sstevel } else {
179*03831d35Sstevel pnode->sibling = walk_di_tree(tree, root, curnode);
180*03831d35Sstevel }
181*03831d35Sstevel }
182*03831d35Sstevel
183*03831d35Sstevel /*
184*03831d35Sstevel * This check is needed in case the "board node" occurs at the
185*03831d35Sstevel * end of the sibling chain as opposed to the middle or front.
186*03831d35Sstevel */
187*03831d35Sstevel if (board_node)
188*03831d35Sstevel return (NULL);
189*03831d35Sstevel
190*03831d35Sstevel return (pnode);
191*03831d35Sstevel }
192*03831d35Sstevel
193*03831d35Sstevel /*
194*03831d35Sstevel * Dump all the devinfo properties and then the obp properties for
195*03831d35Sstevel * the specified devinfo node into the Prom_node structure.
196*03831d35Sstevel */
197*03831d35Sstevel static void
dump_di_node(Prom_node * pnode,di_node_t di_node)198*03831d35Sstevel dump_di_node(Prom_node *pnode, di_node_t di_node)
199*03831d35Sstevel {
200*03831d35Sstevel Prop *prop = NULL; /* tail of properties list */
201*03831d35Sstevel
202*03831d35Sstevel Prop *temp; /* newly allocated property */
203*03831d35Sstevel di_prop_t di_prop;
204*03831d35Sstevel di_prom_prop_t p_prop;
205*03831d35Sstevel int retval = 0;
206*03831d35Sstevel int i;
207*03831d35Sstevel
208*03831d35Sstevel /* clear out pointers in pnode */
209*03831d35Sstevel pnode->props = NULL;
210*03831d35Sstevel
211*03831d35Sstevel D_PRINTF("\n\n ------- Dumping devinfo properties for node ------\n");
212*03831d35Sstevel
213*03831d35Sstevel /*
214*03831d35Sstevel * get all the devinfo properties first
215*03831d35Sstevel */
216*03831d35Sstevel for (di_prop = di_prop_next(di_node, DI_PROP_NIL);
217*03831d35Sstevel di_prop != DI_PROP_NIL;
218*03831d35Sstevel di_prop = di_prop_next(di_node, di_prop)) {
219*03831d35Sstevel
220*03831d35Sstevel char *di_name;
221*03831d35Sstevel void *di_data;
222*03831d35Sstevel int di_ptype;
223*03831d35Sstevel
224*03831d35Sstevel di_name = di_prop_name(di_prop);
225*03831d35Sstevel if (di_name == (char *)NULL)
226*03831d35Sstevel continue;
227*03831d35Sstevel
228*03831d35Sstevel di_ptype = di_prop_type(di_prop);
229*03831d35Sstevel D_PRINTF("DEVINFO Properties %s: ", di_name);
230*03831d35Sstevel
231*03831d35Sstevel switch (di_ptype) {
232*03831d35Sstevel int *int_val;
233*03831d35Sstevel char *char_val;
234*03831d35Sstevel case DI_PROP_TYPE_INT:
235*03831d35Sstevel retval = di_prop_lookup_ints(DDI_DEV_T_ANY,
236*03831d35Sstevel di_node, di_name, (int **)&di_data);
237*03831d35Sstevel if (retval > 0) {
238*03831d35Sstevel int_val = (int *)di_data;
239*03831d35Sstevel D_PRINTF("0x%x\n", *int_val);
240*03831d35Sstevel }
241*03831d35Sstevel break;
242*03831d35Sstevel case DI_PROP_TYPE_STRING:
243*03831d35Sstevel retval = di_prop_lookup_strings(DDI_DEV_T_ANY,
244*03831d35Sstevel di_node, di_name, (char **)&di_data);
245*03831d35Sstevel if (retval > 0) {
246*03831d35Sstevel char_val = (char *)di_data;
247*03831d35Sstevel D_PRINTF("%s\n", char_val);
248*03831d35Sstevel }
249*03831d35Sstevel break;
250*03831d35Sstevel case DI_PROP_TYPE_BYTE:
251*03831d35Sstevel retval = di_prop_lookup_bytes(DDI_DEV_T_ANY,
252*03831d35Sstevel di_node, di_name, (uchar_t **)&di_data);
253*03831d35Sstevel if (retval > 0) {
254*03831d35Sstevel char_val = (char *)di_data;
255*03831d35Sstevel D_PRINTF("%s\n", char_val);
256*03831d35Sstevel }
257*03831d35Sstevel break;
258*03831d35Sstevel case DI_PROP_TYPE_UNKNOWN:
259*03831d35Sstevel retval = di_prop_lookup_bytes(DDI_DEV_T_ANY,
260*03831d35Sstevel di_node, di_name, (uchar_t **)&di_data);
261*03831d35Sstevel if (retval > 0) {
262*03831d35Sstevel char_val = (char *)di_data;
263*03831d35Sstevel D_PRINTF("%s\n", char_val);
264*03831d35Sstevel }
265*03831d35Sstevel break;
266*03831d35Sstevel case DI_PROP_TYPE_BOOLEAN:
267*03831d35Sstevel di_data = NULL;
268*03831d35Sstevel retval = 1;
269*03831d35Sstevel break;
270*03831d35Sstevel default:
271*03831d35Sstevel D_PRINTF(" Skipping property\n");
272*03831d35Sstevel retval = -1;
273*03831d35Sstevel }
274*03831d35Sstevel
275*03831d35Sstevel if (retval <= 0)
276*03831d35Sstevel continue;
277*03831d35Sstevel
278*03831d35Sstevel /* allocate space for the property */
279*03831d35Sstevel if ((temp = (Prop *) malloc(sizeof (Prop))) == NULL) {
280*03831d35Sstevel perror("malloc");
281*03831d35Sstevel exit(1);
282*03831d35Sstevel }
283*03831d35Sstevel
284*03831d35Sstevel /*
285*03831d35Sstevel * Given that we're using libdevinfo rather than OBP,
286*03831d35Sstevel * the chances are that future accesses to di_name and
287*03831d35Sstevel * di_data will be via temp->name.val_ptr and
288*03831d35Sstevel * temp->value.val_ptr respectively. However, this may
289*03831d35Sstevel * not be the case, so we have to suitably fill in
290*03831d35Sstevel * temp->name.opp and temp->value.opp.
291*03831d35Sstevel *
292*03831d35Sstevel * di_name is char * and non-NULL if we've made it to
293*03831d35Sstevel * here, so we can simply point
294*03831d35Sstevel * temp->name.opp.oprom_array to temp->name.val_ptr.
295*03831d35Sstevel *
296*03831d35Sstevel * di_data could be NULL, char * or int * at this point.
297*03831d35Sstevel * If it's non-NULL, a 1st char of '\0' indicates int *.
298*03831d35Sstevel * We thus set temp->value.opp.oprom_node[] (although
299*03831d35Sstevel * interest in any element other than 0 is rare, all
300*03831d35Sstevel * elements must be set to ensure compatibility with
301*03831d35Sstevel * OBP), and holds_array is set to 0.
302*03831d35Sstevel *
303*03831d35Sstevel * If di_data is NULL, or the 1st char is not '\0', we set
304*03831d35Sstevel * temp->value.opp.oprom_array. If di_ptype is
305*03831d35Sstevel * DI_PROP_TYPE_BOOLEAN, holds_array is set to 0, else it
306*03831d35Sstevel * is set to 1.
307*03831d35Sstevel */
308*03831d35Sstevel temp->name.val_ptr = (void *)di_name;
309*03831d35Sstevel temp->name.opp.oprom_array = temp->name.val_ptr;
310*03831d35Sstevel temp->name.opp.holds_array = 1;
311*03831d35Sstevel
312*03831d35Sstevel temp->value.val_ptr = (void *)di_data;
313*03831d35Sstevel if ((di_data != NULL) && (*((char *)di_data) == '\0')) {
314*03831d35Sstevel for (i = 0; i < OPROM_NODE_SIZE; i++)
315*03831d35Sstevel temp->value.opp.oprom_node[i] = *((int *)di_data+i);
316*03831d35Sstevel
317*03831d35Sstevel temp->value.opp.holds_array = 0;
318*03831d35Sstevel } else {
319*03831d35Sstevel temp->value.opp.oprom_array = temp->value.val_ptr;
320*03831d35Sstevel if (di_ptype == DI_PROP_TYPE_BOOLEAN)
321*03831d35Sstevel temp->value.opp.holds_array = 0;
322*03831d35Sstevel else
323*03831d35Sstevel temp->value.opp.holds_array = 1;
324*03831d35Sstevel }
325*03831d35Sstevel
326*03831d35Sstevel temp->size = retval;
327*03831d35Sstevel
328*03831d35Sstevel /* everything worked so link the property list */
329*03831d35Sstevel if (pnode->props == NULL)
330*03831d35Sstevel pnode->props = temp;
331*03831d35Sstevel else if (prop != NULL)
332*03831d35Sstevel prop->next = temp;
333*03831d35Sstevel prop = temp;
334*03831d35Sstevel prop->next = NULL;
335*03831d35Sstevel }
336*03831d35Sstevel
337*03831d35Sstevel /*
338*03831d35Sstevel * Then get all the OBP properties.
339*03831d35Sstevel */
340*03831d35Sstevel for (p_prop = di_prom_prop_next(ph, di_node, DI_PROM_PROP_NIL);
341*03831d35Sstevel p_prop != DI_PROM_PROP_NIL;
342*03831d35Sstevel p_prop = di_prom_prop_next(ph, di_node, p_prop)) {
343*03831d35Sstevel
344*03831d35Sstevel char *p_name;
345*03831d35Sstevel unsigned char *p_data;
346*03831d35Sstevel
347*03831d35Sstevel p_name = di_prom_prop_name(p_prop);
348*03831d35Sstevel if (p_name == (char *)NULL)
349*03831d35Sstevel retval = -1;
350*03831d35Sstevel else
351*03831d35Sstevel retval = di_prom_prop_data(p_prop, &p_data);
352*03831d35Sstevel
353*03831d35Sstevel if (retval <= 0)
354*03831d35Sstevel continue;
355*03831d35Sstevel
356*03831d35Sstevel /* allocate space for the property */
357*03831d35Sstevel if ((temp = (Prop *) malloc(sizeof (Prop))) == NULL) {
358*03831d35Sstevel perror("malloc");
359*03831d35Sstevel exit(1);
360*03831d35Sstevel }
361*03831d35Sstevel
362*03831d35Sstevel /*
363*03831d35Sstevel * As above, p_name is char * and non-NULL if we've made
364*03831d35Sstevel * it to here, so we can simply point
365*03831d35Sstevel * temp->name.opp.oprom_array to temp->name.val_ptr.
366*03831d35Sstevel *
367*03831d35Sstevel * p_data could be NULL, a character or a number at this
368*03831d35Sstevel * point. If it's non-NULL, a 1st char of '\0' indicates a
369*03831d35Sstevel * number, so we set temp->value.opp.oprom_node[] (again
370*03831d35Sstevel * setting every element to ensure OBP compatibility).
371*03831d35Sstevel * These assignments create a lint error, hence the LINTED
372*03831d35Sstevel * comment.
373*03831d35Sstevel *
374*03831d35Sstevel * If p_data is NULL, or the 1st char is not '\0', we set
375*03831d35Sstevel * temp->value.opp.oprom_array.
376*03831d35Sstevel */
377*03831d35Sstevel temp->name.val_ptr = (void *)p_name;
378*03831d35Sstevel temp->name.opp.oprom_array = temp->name.val_ptr;
379*03831d35Sstevel temp->name.opp.holds_array = 1;
380*03831d35Sstevel
381*03831d35Sstevel temp->value.val_ptr = (void *)p_data;
382*03831d35Sstevel if ((p_data != NULL) && (*p_data == '\0')) {
383*03831d35Sstevel for (i = 0; i < OPROM_NODE_SIZE; i++)
384*03831d35Sstevel /* LINTED */
385*03831d35Sstevel temp->value.opp.oprom_node[i] = *((int *)p_data+i);
386*03831d35Sstevel
387*03831d35Sstevel temp->value.opp.holds_array = 0;
388*03831d35Sstevel } else {
389*03831d35Sstevel temp->value.opp.oprom_array = temp->value.val_ptr;
390*03831d35Sstevel temp->value.opp.holds_array = 1;
391*03831d35Sstevel }
392*03831d35Sstevel
393*03831d35Sstevel temp->size = retval;
394*03831d35Sstevel
395*03831d35Sstevel /* everything worked so link the property list */
396*03831d35Sstevel if (pnode->props == NULL) {
397*03831d35Sstevel pnode->props = temp;
398*03831d35Sstevel } else if (prop != NULL) {
399*03831d35Sstevel prop->next = temp;
400*03831d35Sstevel }
401*03831d35Sstevel prop = temp;
402*03831d35Sstevel prop->next = NULL;
403*03831d35Sstevel }
404*03831d35Sstevel }
405*03831d35Sstevel
406*03831d35Sstevel /*
407*03831d35Sstevel * Used in place of do_prominfo() when a platform wants to use
408*03831d35Sstevel * libdevinfo for getting the device tree instead of OBP.
409*03831d35Sstevel */
410*03831d35Sstevel int
do_devinfo(int syserrlog,char * pgname,int log_flag,int prt_flag)411*03831d35Sstevel do_devinfo(int syserrlog, char *pgname, int log_flag, int prt_flag)
412*03831d35Sstevel {
413*03831d35Sstevel Sys_tree sys_tree; /* system information */
414*03831d35Sstevel Prom_node *root_node; /* root node of OBP device tree */
415*03831d35Sstevel di_node_t di_root_node; /* root of the devinfo tree */
416*03831d35Sstevel struct system_kstat_data sys_kstat; /* kstats for non-OBP data */
417*03831d35Sstevel int retval = -1;
418*03831d35Sstevel
419*03831d35Sstevel /* set the global flags */
420*03831d35Sstevel progname = pgname;
421*03831d35Sstevel logging = log_flag;
422*03831d35Sstevel print_flag = prt_flag;
423*03831d35Sstevel
424*03831d35Sstevel /* set the the system tree fields */
425*03831d35Sstevel sys_tree.sys_mem = NULL;
426*03831d35Sstevel sys_tree.boards = NULL;
427*03831d35Sstevel sys_tree.bd_list = NULL;
428*03831d35Sstevel sys_tree.board_cnt = 0;
429*03831d35Sstevel
430*03831d35Sstevel /*
431*03831d35Sstevel * create a snapshot of the kernel device tree
432*03831d35Sstevel * and return a handle to it.
433*03831d35Sstevel */
434*03831d35Sstevel if ((di_root_node = di_init("/", DINFOCPYALL)) == DI_NODE_NIL) {
435*03831d35Sstevel exit(_error("di_init() failed"));
436*03831d35Sstevel }
437*03831d35Sstevel
438*03831d35Sstevel /*
439*03831d35Sstevel * create a handle to the PROM device tree.
440*03831d35Sstevel */
441*03831d35Sstevel if ((ph = di_prom_init()) == NULL) {
442*03831d35Sstevel exit(_error("di_prom_init() failed"));
443*03831d35Sstevel }
444*03831d35Sstevel
445*03831d35Sstevel /*
446*03831d35Sstevel * walk the devinfo tree and build up a list of all
447*03831d35Sstevel * nodes and properties.
448*03831d35Sstevel */
449*03831d35Sstevel root_node = walk_di_tree(&sys_tree, NULL, di_root_node);
450*03831d35Sstevel
451*03831d35Sstevel /* resolve the board types now */
452*03831d35Sstevel resolve_board_types(&sys_tree);
453*03831d35Sstevel
454*03831d35Sstevel read_sun4u_kstats(&sys_tree, &sys_kstat);
455*03831d35Sstevel retval = display(&sys_tree, root_node, &sys_kstat, syserrlog);
456*03831d35Sstevel
457*03831d35Sstevel di_fini(di_root_node);
458*03831d35Sstevel di_prom_fini(ph);
459*03831d35Sstevel return (retval);
460*03831d35Sstevel }
461*03831d35Sstevel
462*03831d35Sstevel /*
463*03831d35Sstevel * check to see if the name shows up in the compatible array
464*03831d35Sstevel */
465*03831d35Sstevel static int
match_compatible_name(char * compatible_array,int n_names,char * name)466*03831d35Sstevel match_compatible_name(char *compatible_array, int n_names, char *name)
467*03831d35Sstevel {
468*03831d35Sstevel int i, ret = 0;
469*03831d35Sstevel
470*03831d35Sstevel /* parse the compatible list */
471*03831d35Sstevel for (i = 0; i < n_names; i++) {
472*03831d35Sstevel if (strcmp(compatible_array, name) == 0) {
473*03831d35Sstevel ret = 1;
474*03831d35Sstevel break;
475*03831d35Sstevel }
476*03831d35Sstevel compatible_array += strlen(compatible_array) + 1;
477*03831d35Sstevel }
478*03831d35Sstevel return (ret);
479*03831d35Sstevel }
480