103831d35Sstevel /*
203831d35Sstevel  * CDDL HEADER START
303831d35Sstevel  *
403831d35Sstevel  * The contents of this file are subject to the terms of the
52983dda7SMichael Bergknoff  * Common Development and Distribution License (the "License").
62983dda7SMichael Bergknoff  * You may not use this file except in compliance with the License.
703831d35Sstevel  *
803831d35Sstevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
903831d35Sstevel  * or http://www.opensolaris.org/os/licensing.
1003831d35Sstevel  * See the License for the specific language governing permissions
1103831d35Sstevel  * and limitations under the License.
1203831d35Sstevel  *
1303831d35Sstevel  * When distributing Covered Code, include this CDDL HEADER in each
1403831d35Sstevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1503831d35Sstevel  * If applicable, add the following below this CDDL HEADER, with the
1603831d35Sstevel  * fields enclosed by brackets "[]" replaced with your own identifying
1703831d35Sstevel  * information: Portions Copyright [yyyy] [name of copyright owner]
1803831d35Sstevel  *
1903831d35Sstevel  * CDDL HEADER END
2003831d35Sstevel  */
2103831d35Sstevel /*
222983dda7SMichael Bergknoff  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
23*2bcbf80cSPeter Tribble  * Copyright (c) 2020 Peter Tribble.
2403831d35Sstevel  */
2503831d35Sstevel 
2603831d35Sstevel #include <stdio.h>
2703831d35Sstevel #include <stdlib.h>
2803831d35Sstevel #include <unistd.h>
2903831d35Sstevel #include <ctype.h>
3003831d35Sstevel #include <string.h>
3103831d35Sstevel #include <kvm.h>
3203831d35Sstevel #include <varargs.h>
3303831d35Sstevel #include <time.h>
3403831d35Sstevel #include <dirent.h>
3503831d35Sstevel #include <fcntl.h>
3603831d35Sstevel #include <sys/param.h>
3703831d35Sstevel #include <sys/stat.h>
3803831d35Sstevel #include <sys/types.h>
3903831d35Sstevel #include <sys/utsname.h>
4003831d35Sstevel #include <sys/openpromio.h>
4103831d35Sstevel #include <libintl.h>
4203831d35Sstevel #include <syslog.h>
4303831d35Sstevel #include <sys/dkio.h>
4403831d35Sstevel #include "pdevinfo.h"
4503831d35Sstevel #include "display.h"
4603831d35Sstevel #include "pdevinfo_sun4u.h"
4703831d35Sstevel #include "display_sun4u.h"
4803831d35Sstevel #include "libprtdiag.h"
4903831d35Sstevel 
5003831d35Sstevel 
5103831d35Sstevel #if !defined(TEXT_DOMAIN)
5203831d35Sstevel #define	TEXT_DOMAIN	"SYS_TEST"
5303831d35Sstevel #endif
5403831d35Sstevel 
5503831d35Sstevel extern	int sys_clk;
5603831d35Sstevel 
5703831d35Sstevel int
display(Sys_tree * tree,Prom_node * root,struct system_kstat_data * kstats,int syserrlog)5803831d35Sstevel display(Sys_tree *tree,
5903831d35Sstevel 	Prom_node *root,
6003831d35Sstevel 	struct system_kstat_data *kstats,
6103831d35Sstevel 	int syserrlog)
6203831d35Sstevel {
6303831d35Sstevel 	int exit_code = 0;	/* init to all OK */
6403831d35Sstevel 	void *value;		/* used for opaque PROM data */
6503831d35Sstevel 	struct mem_total memory_total;	/* Total memory in system */
6603831d35Sstevel 
6703831d35Sstevel 	sys_clk = -1;  /* System clock freq. (in MHz) */
6803831d35Sstevel 
6903831d35Sstevel 	/*
7003831d35Sstevel 	 * silently check for any types of machine errors
7103831d35Sstevel 	 */
7203831d35Sstevel 	exit_code = error_check(tree, kstats);
7303831d35Sstevel 
7403831d35Sstevel 	/*
7503831d35Sstevel 	 * Now display the machine's configuration. We do this if we
7603831d35Sstevel 	 * are not logging or exit_code is set (machine is broke).
7703831d35Sstevel 	 */
7803831d35Sstevel 	if (!logging || exit_code) {
7903831d35Sstevel 		struct utsname uts_buf;
8003831d35Sstevel 
8103831d35Sstevel 		/*
8203831d35Sstevel 		 * Display system banner
8303831d35Sstevel 		 */
8403831d35Sstevel 		(void) uname(&uts_buf);
8503831d35Sstevel 
862983dda7SMichael Bergknoff 		log_printf(dgettext(TEXT_DOMAIN, "System Configuration:  "
872983dda7SMichael Bergknoff 		    "Oracle Corporation  %s %s\n"), uts_buf.machine,
882983dda7SMichael Bergknoff 		    get_prop_val(find_prop(root, "banner-name")), 0);
8903831d35Sstevel 
9003831d35Sstevel 		/* display system clock frequency */
9103831d35Sstevel 		value = get_prop_val(find_prop(root, "clock-frequency"));
9203831d35Sstevel 		if (value != NULL) {
9303831d35Sstevel 			sys_clk = ((*((int *)value)) + 500000) / 1000000;
9403831d35Sstevel 			log_printf(dgettext(TEXT_DOMAIN, "System clock "
952983dda7SMichael Bergknoff 			    "frequency: %d MHz\n"), sys_clk, 0);
9603831d35Sstevel 		}
9703831d35Sstevel 
9803831d35Sstevel 		/* Display the Memory Size */
99*2bcbf80cSPeter Tribble 		display_memorysize(tree, kstats, &memory_total);
10003831d35Sstevel 
10103831d35Sstevel 		/* Display platform specific configuration info */
10203831d35Sstevel 		display_platform_specific_header();
10303831d35Sstevel 
10403831d35Sstevel 		/* Display the CPU devices */
10503831d35Sstevel 		display_cpu_devices(tree);
10603831d35Sstevel 
10703831d35Sstevel 		/* Display the Memory configuration */
108*2bcbf80cSPeter Tribble 		display_memoryconf(tree);
10903831d35Sstevel 
11003831d35Sstevel 		/* Display all the IO cards. */
11103831d35Sstevel 		(void) display_io_devices(tree);
11203831d35Sstevel 
11303831d35Sstevel 
11403831d35Sstevel 		/*
11503831d35Sstevel 		 * Display any Hot plugged, disabled and failed board(s)
11603831d35Sstevel 		 * where appropriate.
11703831d35Sstevel 		 */
11803831d35Sstevel 		display_hp_fail_fault(tree, kstats);
11903831d35Sstevel 
12003831d35Sstevel 		display_diaginfo((syserrlog || (logging && exit_code)),
1212983dda7SMichael Bergknoff 		    root, tree, kstats);
12203831d35Sstevel 	}
12303831d35Sstevel 
12403831d35Sstevel 	return (exit_code);
12503831d35Sstevel }
12603831d35Sstevel 
12703831d35Sstevel 
12803831d35Sstevel int
error_check(Sys_tree * tree,struct system_kstat_data * kstats)12903831d35Sstevel error_check(Sys_tree *tree, struct system_kstat_data *kstats)
13003831d35Sstevel {
13103831d35Sstevel #ifdef	lint
13203831d35Sstevel 	tree = tree;
13303831d35Sstevel 	kstats = kstats;
13403831d35Sstevel #endif
13503831d35Sstevel 	/*
13603831d35Sstevel 	 * This function is intentionally empty
13703831d35Sstevel 	 */
13803831d35Sstevel 	return (0);
13903831d35Sstevel }
14003831d35Sstevel 
14103831d35Sstevel int
disp_fail_parts(Sys_tree * tree)14203831d35Sstevel disp_fail_parts(Sys_tree *tree)
14303831d35Sstevel {
14403831d35Sstevel #ifdef	lint
14503831d35Sstevel 	tree = tree;
14603831d35Sstevel #endif
14703831d35Sstevel 	/*
14803831d35Sstevel 	 * This function is intentionally empty
14903831d35Sstevel 	 */
15003831d35Sstevel 	return (0);
15103831d35Sstevel }
15203831d35Sstevel 
15303831d35Sstevel 
15403831d35Sstevel void
display_hp_fail_fault(Sys_tree * tree,struct system_kstat_data * kstats)15503831d35Sstevel display_hp_fail_fault(Sys_tree *tree, struct system_kstat_data *kstats)
15603831d35Sstevel {
15703831d35Sstevel #ifdef	lint
15803831d35Sstevel 	tree = tree;
15903831d35Sstevel 	kstats = kstats;
16003831d35Sstevel #endif
16103831d35Sstevel 	/*
16203831d35Sstevel 	 * This function is intentionally empty
16303831d35Sstevel 	 */
16403831d35Sstevel }
16503831d35Sstevel 
16603831d35Sstevel void
display_diaginfo(int flag,Prom_node * root,Sys_tree * tree,struct system_kstat_data * kstats)16703831d35Sstevel display_diaginfo(int flag, Prom_node *root, Sys_tree *tree,
16803831d35Sstevel 			struct system_kstat_data *kstats)
16903831d35Sstevel {
17003831d35Sstevel #ifdef	lint
17103831d35Sstevel 	flag = flag;
17203831d35Sstevel 	root = root;
17303831d35Sstevel 	tree = tree;
17403831d35Sstevel 	kstats = kstats;
17503831d35Sstevel #endif
17603831d35Sstevel 	/*
17703831d35Sstevel 	 * This function is intentionally empty
17803831d35Sstevel 	 */
17903831d35Sstevel }
18003831d35Sstevel 
18103831d35Sstevel 
18203831d35Sstevel void
resolve_board_types(Sys_tree * tree)18303831d35Sstevel resolve_board_types(Sys_tree *tree)
18403831d35Sstevel {
18503831d35Sstevel #ifdef	lint
18603831d35Sstevel 	tree = tree;
18703831d35Sstevel #endif
18803831d35Sstevel 	/*
18903831d35Sstevel 	 * This function is intentionally empty
19003831d35Sstevel 	 */
19103831d35Sstevel }
19203831d35Sstevel 
19303831d35Sstevel void
display_boardnum(int num)19403831d35Sstevel display_boardnum(int num)
19503831d35Sstevel {
19603831d35Sstevel 	log_printf("%2d   ", num, 0);
19703831d35Sstevel }
19803831d35Sstevel 
19903831d35Sstevel 
20003831d35Sstevel /*
20103831d35Sstevel  * The various platforms can over-ride this function to
20203831d35Sstevel  * return any platform specific configuration information
20303831d35Sstevel  * they may wish to return in addition to the generic output.
20403831d35Sstevel  */
20503831d35Sstevel void
display_platform_specific_header(void)20603831d35Sstevel display_platform_specific_header(void)
20703831d35Sstevel {
20803831d35Sstevel 	/*
20903831d35Sstevel 	 * This function is intentionally empty
21003831d35Sstevel 	 */
21103831d35Sstevel }
212