1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright (c) 1999-2001 by Sun Microsystems, Inc.
24 * All rights reserved.
25 *
26 * Starfire Platform specific functions.
27 *
28 * called when :
29 * machine_type == MTYPE_STARFIRE
30 *
31 */
32
33 #pragma ident "%Z%%M% %I% %E% SMI"
34
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <unistd.h>
38 #include <ctype.h>
39 #include <string.h>
40 #include <kvm.h>
41 #include <varargs.h>
42 #include <time.h>
43 #include <dirent.h>
44 #include <fcntl.h>
45 #include <sys/param.h>
46 #include <sys/stat.h>
47 #include <sys/types.h>
48 #include <sys/utsname.h>
49 #include <sys/openpromio.h>
50 #include <libintl.h>
51 #include <syslog.h>
52 #include <sys/dkio.h>
53 #include "pdevinfo.h"
54 #include "display.h"
55 #include "pdevinfo_sun4u.h"
56 #include "display_sun4u.h"
57 #include "libprtdiag.h"
58
59 /*
60 * these functions will overlay the symbol table of libprtdiag
61 * at runtime (starfire systems only)
62 */
63 int error_check(Sys_tree *tree, struct system_kstat_data *kstats);
64 void display_memoryconf(Sys_tree *tree, struct grp_info *grps);
65 void display_hp_fail_fault(Sys_tree *tree, struct system_kstat_data *kstats);
66 void display_diaginfo(int flag, Prom_node *root, Sys_tree *tree,
67 struct system_kstat_data *kstats);
68 void display_mid(int mid);
69 void display_pci(Board_node *);
70 Prom_node *find_device(Board_node *, int, char *);
71
72 #if !defined(TEXT_DOMAIN)
73 #define TEXT_DOMAIN "SYS_TEST"
74 #endif
75
76
77 int
error_check(Sys_tree * tree,struct system_kstat_data * kstats)78 error_check(Sys_tree *tree, struct system_kstat_data *kstats)
79 {
80 #ifdef lint
81 tree = tree;
82 kstats = kstats;
83 #endif
84 return (0);
85 }
86
87 void
display_memoryconf(Sys_tree * tree,struct grp_info * grps)88 display_memoryconf(Sys_tree *tree, struct grp_info *grps)
89 {
90 Board_node *bnode;
91 char indent_str[] = " ";
92
93 #ifdef lint
94 grps = grps;
95 #endif
96
97 /* Print the header for the memory section. */
98 log_printf("\n", 0);
99 log_printf("=========================", 0);
100 log_printf(dgettext(TEXT_DOMAIN, " Memory "), 0);
101 log_printf("=========================", 0);
102 log_printf("\n\n", 0);
103
104 /* Print the header for the memory section. */
105 log_printf(indent_str, 0);
106 log_printf("Memory Units: Size \n", 0);
107 log_printf(indent_str, 0);
108 log_printf("0: MB 1: MB 2: MB 3: MB\n", 0);
109 log_printf(indent_str, 0);
110 log_printf("----- ----- ----- ----- \n", 0);
111
112 /* Run thru the board and display its memory if any */
113 bnode = tree->bd_list;
114 while (bnode != NULL) {
115 Prom_node *pnode;
116 unsigned int *memsize;
117 unsigned int mbyte = 1024*1024;
118
119 /*
120 * Find the mem-unit of the board.
121 * If the board has memory, a mem-unit pnode should
122 * be there.
123 */
124 pnode = dev_find_node(bnode->nodes, "mem-unit");
125
126 if (pnode != NULL) {
127 /* there is a mem-unit in the board */
128
129 /* Print the board header */
130 log_printf("Board%2d ", bnode->board_num, 0);
131
132 memsize = get_prop_val(find_prop(pnode, "size"));
133
134 log_printf(" %4d %4d %4d %4d \n",
135 memsize[0]/mbyte, memsize[1]/mbyte,
136 memsize[2]/mbyte, memsize[3]/mbyte, 0);
137 }
138 bnode = bnode->next;
139 }
140 log_printf("\n", 0);
141 }
142
143 void
display_hp_fail_fault(Sys_tree * tree,struct system_kstat_data * kstats)144 display_hp_fail_fault(Sys_tree *tree, struct system_kstat_data *kstats)
145 {
146 #ifdef lint
147 tree = tree;
148 kstats = kstats;
149 #endif
150 }
151
152 void
display_diaginfo(int flag,Prom_node * root,Sys_tree * tree,struct system_kstat_data * kstats)153 display_diaginfo(int flag, Prom_node *root, Sys_tree *tree,
154 struct system_kstat_data *kstats)
155 {
156
157 char hostname[128]; /* used for starfire output */
158 struct utsname uts_buf;
159
160 #ifdef lint
161 flag = flag;
162 root = root;
163 tree = tree;
164 kstats = kstats;
165 #endif
166
167 /*
168 * Get hostname from system Banner
169 */
170 (void) uname(&uts_buf);
171 strcpy(hostname, uts_buf.nodename);
172
173 /*
174 * We can't display diagnostic/env information for starfire.
175 * The diagnostic information may be displayed through
176 * commands in ssp.
177 */
178 log_printf(dgettext(TEXT_DOMAIN,
179 "\nFor diagnostic information,"), 0);
180 log_printf("\n", 0);
181 log_printf(dgettext(TEXT_DOMAIN, "see /var/opt/SUNWssp/adm/%s/messages "
182 "on the SSP."), hostname, 0);
183 log_printf("\n", 0);
184 }
185
186 void
display_mid(int mid)187 display_mid(int mid)
188 {
189 log_printf(" %2d ", mid % 4, 0);
190 }
191
192 /*
193 * display_pci
194 * Call the generic psycho version of this function.
195 */
196 void
display_pci(Board_node * board)197 display_pci(Board_node *board)
198 {
199 display_psycho_pci(board);
200 }
201
202 /*
203 * Find the device on the current board with the requested device ID
204 * and name. If this rountine is passed a NULL pointer, it simply returns
205 * NULL.
206 */
207 Prom_node *
find_device(Board_node * board,int id,char * name)208 find_device(Board_node *board, int id, char *name)
209 {
210 Prom_node *pnode;
211 int mask;
212
213 /* find the first cpu node */
214 pnode = dev_find_node(board->nodes, name);
215
216 mask = 0x7F;
217 while (pnode != NULL) {
218 if ((get_id(pnode) & mask) == id)
219 return (pnode);
220
221 pnode = dev_next_node(pnode, name);
222 }
223 return (NULL);
224 }
225