xref: /illumos-gate/usr/src/lib/libprtdiag/common/display_sun4u.c (revision cd61ae21816e53b94bc1673f3f1aa651fc3115e8)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
23  * Copyright (c) 2020 Peter Tribble.
24  */
25 
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <unistd.h>
29 #include <ctype.h>
30 #include <string.h>
31 #include <kvm.h>
32 #include <varargs.h>
33 #include <time.h>
34 #include <dirent.h>
35 #include <fcntl.h>
36 #include <sys/param.h>
37 #include <sys/stat.h>
38 #include <sys/types.h>
39 #include <sys/utsname.h>
40 #include <sys/openpromio.h>
41 #include <libintl.h>
42 #include <syslog.h>
43 #include <sys/dkio.h>
44 #include "pdevinfo.h"
45 #include "display.h"
46 #include "pdevinfo_sun4u.h"
47 #include "display_sun4u.h"
48 #include "libprtdiag.h"
49 
50 
51 #if !defined(TEXT_DOMAIN)
52 #define	TEXT_DOMAIN	"SYS_TEST"
53 #endif
54 
55 extern	int sys_clk;
56 
57 int
58 display(Sys_tree *tree,
59 	Prom_node *root,
60 	struct system_kstat_data *kstats,
61 	int syserrlog)
62 {
63 	int exit_code = 0;	/* init to all OK */
64 	void *value;		/* used for opaque PROM data */
65 	struct mem_total memory_total;	/* Total memory in system */
66 
67 	sys_clk = -1;  /* System clock freq. (in MHz) */
68 
69 	/*
70 	 * silently check for any types of machine errors
71 	 */
72 	exit_code = error_check(tree, kstats);
73 
74 	/*
75 	 * Now display the machine's configuration. We do this if we
76 	 * are not logging or exit_code is set (machine is broke).
77 	 */
78 	if (!logging || exit_code) {
79 		struct utsname uts_buf;
80 
81 		/*
82 		 * Display system banner
83 		 */
84 		(void) uname(&uts_buf);
85 
86 		log_printf(dgettext(TEXT_DOMAIN, "System Configuration:  "
87 		    "Oracle Corporation  %s %s\n"), uts_buf.machine,
88 		    get_prop_val(find_prop(root, "banner-name")), 0);
89 
90 		/* display system clock frequency */
91 		value = get_prop_val(find_prop(root, "clock-frequency"));
92 		if (value != NULL) {
93 			sys_clk = ((*((int *)value)) + 500000) / 1000000;
94 			log_printf(dgettext(TEXT_DOMAIN, "System clock "
95 			    "frequency: %d MHz\n"), sys_clk, 0);
96 		}
97 
98 		/* Display the Memory Size */
99 		display_memorysize(tree, kstats, &memory_total);
100 
101 		/* Display platform specific configuration info */
102 		display_platform_specific_header();
103 
104 		/* Display the CPU devices */
105 		display_cpu_devices(tree);
106 
107 		/* Display the Memory configuration */
108 		display_memoryconf(tree);
109 
110 		/* Display all the IO cards. */
111 		(void) display_io_devices(tree);
112 
113 
114 		/*
115 		 * Display any Hot plugged, disabled and failed board(s)
116 		 * where appropriate.
117 		 */
118 		display_hp_fail_fault(tree, kstats);
119 
120 		display_diaginfo((syserrlog || (logging && exit_code)),
121 		    root, tree, kstats);
122 	}
123 
124 	return (exit_code);
125 }
126 
127 
128 int
129 error_check(Sys_tree *tree, struct system_kstat_data *kstats)
130 {
131 #ifdef	lint
132 	tree = tree;
133 	kstats = kstats;
134 #endif
135 	/*
136 	 * This function is intentionally empty
137 	 */
138 	return (0);
139 }
140 
141 int
142 disp_fail_parts(Sys_tree *tree)
143 {
144 #ifdef	lint
145 	tree = tree;
146 #endif
147 	/*
148 	 * This function is intentionally empty
149 	 */
150 	return (0);
151 }
152 
153 
154 void
155 display_hp_fail_fault(Sys_tree *tree, struct system_kstat_data *kstats)
156 {
157 #ifdef	lint
158 	tree = tree;
159 	kstats = kstats;
160 #endif
161 	/*
162 	 * This function is intentionally empty
163 	 */
164 }
165 
166 void
167 display_diaginfo(int flag, Prom_node *root, Sys_tree *tree,
168 			struct system_kstat_data *kstats)
169 {
170 #ifdef	lint
171 	flag = flag;
172 	root = root;
173 	tree = tree;
174 	kstats = kstats;
175 #endif
176 	/*
177 	 * This function is intentionally empty
178 	 */
179 }
180 
181 
182 void
183 resolve_board_types(Sys_tree *tree)
184 {
185 #ifdef	lint
186 	tree = tree;
187 #endif
188 	/*
189 	 * This function is intentionally empty
190 	 */
191 }
192 
193 void
194 display_boardnum(int num)
195 {
196 	log_printf("%2d   ", num, 0);
197 }
198 
199 
200 /*
201  * The various platforms can over-ride this function to
202  * return any platform specific configuration information
203  * they may wish to return in addition to the generic output.
204  */
205 void
206 display_platform_specific_header(void)
207 {
208 	/*
209 	 * This function is intentionally empty
210 	 */
211 }
212