1*1708Sstevel /*
2*1708Sstevel * CDDL HEADER START
3*1708Sstevel *
4*1708Sstevel * The contents of this file are subject to the terms of the
5*1708Sstevel * Common Development and Distribution License, Version 1.0 only
6*1708Sstevel * (the "License"). You may not use this file except in compliance
7*1708Sstevel * with the License.
8*1708Sstevel *
9*1708Sstevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*1708Sstevel * or http://www.opensolaris.org/os/licensing.
11*1708Sstevel * See the License for the specific language governing permissions
12*1708Sstevel * and limitations under the License.
13*1708Sstevel *
14*1708Sstevel * When distributing Covered Code, include this CDDL HEADER in each
15*1708Sstevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*1708Sstevel * If applicable, add the following below this CDDL HEADER, with the
17*1708Sstevel * fields enclosed by brackets "[]" replaced with your own identifying
18*1708Sstevel * information: Portions Copyright [yyyy] [name of copyright owner]
19*1708Sstevel *
20*1708Sstevel * CDDL HEADER END
21*1708Sstevel */
22*1708Sstevel /*
23*1708Sstevel * Copyright (c) 1999-2001 by Sun Microsystems, Inc.
24*1708Sstevel * All rights reserved.
25*1708Sstevel */
26*1708Sstevel
27*1708Sstevel #pragma ident "%Z%%M% %I% %E% SMI"
28*1708Sstevel
29*1708Sstevel #include <stdio.h>
30*1708Sstevel #include <stdlib.h>
31*1708Sstevel #include <unistd.h>
32*1708Sstevel #include <ctype.h>
33*1708Sstevel #include <string.h>
34*1708Sstevel #include <kvm.h>
35*1708Sstevel #include <varargs.h>
36*1708Sstevel #include <errno.h>
37*1708Sstevel #include <time.h>
38*1708Sstevel #include <dirent.h>
39*1708Sstevel #include <fcntl.h>
40*1708Sstevel #include <sys/param.h>
41*1708Sstevel #include <sys/stat.h>
42*1708Sstevel #include <sys/types.h>
43*1708Sstevel #include <sys/utsname.h>
44*1708Sstevel #include <sys/openpromio.h>
45*1708Sstevel #include <kstat.h>
46*1708Sstevel #include <libintl.h>
47*1708Sstevel #include <syslog.h>
48*1708Sstevel #include <sys/dkio.h>
49*1708Sstevel #include "pdevinfo.h"
50*1708Sstevel #include "display.h"
51*1708Sstevel #include "pdevinfo_sun4u.h"
52*1708Sstevel #include "display_sun4u.h"
53*1708Sstevel #include "libprtdiag.h"
54*1708Sstevel
55*1708Sstevel #if !defined(TEXT_DOMAIN)
56*1708Sstevel #define TEXT_DOMAIN "SYS_TEST"
57*1708Sstevel #endif
58*1708Sstevel
59*1708Sstevel
60*1708Sstevel void
disp_prom_version(Prom_node * flashprom)61*1708Sstevel disp_prom_version(Prom_node *flashprom)
62*1708Sstevel {
63*1708Sstevel Prop *version;
64*1708Sstevel char *vers; /* OBP version */
65*1708Sstevel char *temp;
66*1708Sstevel
67*1708Sstevel /* Look version */
68*1708Sstevel version = find_prop(flashprom, "version");
69*1708Sstevel
70*1708Sstevel vers = (char *)get_prop_val(version);
71*1708Sstevel
72*1708Sstevel if (vers != NULL) {
73*1708Sstevel log_printf(" %s ", vers, 0);
74*1708Sstevel
75*1708Sstevel /*
76*1708Sstevel * POST string follows the NULL terminated OBP
77*1708Sstevel * version string. Do not attempt to print POST
78*1708Sstevel * string unless node size is larger than the
79*1708Sstevel * length of the OBP version string.
80*1708Sstevel */
81*1708Sstevel if ((strlen(vers) + 1) < version->size) {
82*1708Sstevel temp = vers + strlen(vers) + 1;
83*1708Sstevel log_printf("%s", temp, 0);
84*1708Sstevel }
85*1708Sstevel }
86*1708Sstevel
87*1708Sstevel log_printf("\n", 0);
88*1708Sstevel }
89*1708Sstevel
90*1708Sstevel
91*1708Sstevel void
platform_disp_prom_version(Sys_tree * tree)92*1708Sstevel platform_disp_prom_version(Sys_tree *tree)
93*1708Sstevel {
94*1708Sstevel Board_node *bnode;
95*1708Sstevel Prom_node *pnode;
96*1708Sstevel
97*1708Sstevel bnode = tree->bd_list;
98*1708Sstevel
99*1708Sstevel /* Display Prom revision header */
100*1708Sstevel log_printf(dgettext(TEXT_DOMAIN, "System PROM "
101*1708Sstevel "revisions:\n"), 0);
102*1708Sstevel log_printf("----------------------\n", 0);
103*1708Sstevel
104*1708Sstevel if ((pnode = find_device(bnode, 0x1F, SBUS_NAME)) == NULL) {
105*1708Sstevel pnode = find_pci_bus(bnode->nodes, 0x1F, 1);
106*1708Sstevel }
107*1708Sstevel
108*1708Sstevel /*
109*1708Sstevel * in case of platforms with multiple flashproms, find and
110*1708Sstevel * display all proms with a "version"(OBP) property. bug 4187301
111*1708Sstevel */
112*1708Sstevel for (pnode = dev_find_node(pnode, "flashprom"); pnode != NULL;
113*1708Sstevel pnode = dev_next_node(pnode, "flashprom")) {
114*1708Sstevel if (find_prop(pnode, "version") != NULL) {
115*1708Sstevel disp_prom_version(pnode);
116*1708Sstevel }
117*1708Sstevel }
118*1708Sstevel }
119*1708Sstevel
120*1708Sstevel int
get_pci_class_code_reg(Prom_node * card_node)121*1708Sstevel get_pci_class_code_reg(Prom_node *card_node)
122*1708Sstevel {
123*1708Sstevel void *value;
124*1708Sstevel
125*1708Sstevel /*
126*1708Sstevel * Get the class-code of this node and return it
127*1708Sstevel * if it exists. Otherwise return (-1).
128*1708Sstevel */
129*1708Sstevel value = get_prop_val(find_prop(card_node, "class-code"));
130*1708Sstevel if (value != NULL)
131*1708Sstevel return (*(int *)value);
132*1708Sstevel else
133*1708Sstevel return (-1);
134*1708Sstevel }
135