xref: /titanic_50/usr/src/lib/libprtdiag/inc/libprtdiag.h (revision 3c112a2b34403220c06c3e2fcac403358cfba168)
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 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_LIBPRTDIAG_H
27 #define	_SYS_LIBPRTDIAG_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #include <sys/openpromio.h>
36 #include <sys/cheetahregs.h>
37 #include "pdevinfo.h"
38 #include "display.h"
39 #include "pdevinfo_sun4u.h"
40 #include "display_sun4u.h"
41 
42 #ifdef DEBUG
43 #define	D_PRINTF printf
44 #else
45 #define	D_PRINTF
46 #endif
47 
48 #define	EXIT_MSG(msg, err) \
49 	{ printf("\n%s failed with %d\n", msg, err); exit(err); }
50 
51 /* global data */
52 #define	PCI_DEVICE(x)		((x  >> 11) & 0x1f)
53 #define	PCI_REG_TO_DEV(x)	((x & 0xf800) >> 11)
54 #define	PCI_REG_TO_FUNC(x)	((x & 0x700) >> 8)
55 #define	BUS_TYPE		"UPA"
56 #define	MAX_SLOTS_PER_IO_BD	8
57 
58 
59 int	sys_clk;  /* System clock freq. (in MHz) */
60 
61 /*
62  * Defines for identifying PCI devices
63  */
64 #define	PCI_BRIDGE_CLASS		0x6
65 #define	PCI_CLASS_SHIFT			0x10
66 #define	PCI_PCI_BRIDGE_SUBCLASS		0x4
67 #define	PCI_SUBCLASS_SHIFT		0x8
68 #define	PCI_SUBCLASS_MASK		0xFF00
69 #define	PCI_SUBCLASS_OTHER		0x80
70 
71 #define	CLASS_REG_TO_SUBCLASS(class)	(((class) & PCI_SUBCLASS_MASK) \
72 						>> PCI_SUBCLASS_SHIFT)
73 #define	CLASS_REG_TO_CLASS(class)	((class) >> PCI_CLASS_SHIFT)
74 
75 /*
76  * display functions
77  */
78 int	error_check(Sys_tree *tree, struct system_kstat_data *kstats);
79 int	disp_fail_parts(Sys_tree *tree);
80 void	display_hp_fail_fault(Sys_tree *tree, struct system_kstat_data *kstats);
81 void	display_diaginfo(int flag, Prom_node *root, Sys_tree *tree,
82 	    struct system_kstat_data *kstats);
83 void	resolve_board_types(Sys_tree *);
84 void	display_boardnum(int num);
85 void	display_platform_specific_header(void);
86 
87 /*
88  * cpu functions
89  */
90 void	display_cpu_devices(Sys_tree *);
91 void	display_cpus(Board_node *);
92 void	display_mid(int mid);
93 uint_t	get_cpu_freq(Prom_node *);
94 int	get_ecache_size(Prom_node *);
95 
96 /*
97  * io functions
98  */
99 Prom_node *find_pci_bus(Prom_node *, int, int);
100 int	get_pci_bus(Prom_node *);
101 int	get_pci_device(Prom_node *);
102 int	get_pci_to_pci_device(Prom_node *);
103 void	free_io_cards(struct io_card *);
104 struct	io_card *insert_io_card(struct io_card *, struct io_card *);
105 char	*fmt_manf_id(unsigned int, char *);
106 int	get_sbus_slot(Prom_node *);
107 void	display_io_devices(Sys_tree *tree);
108 void	display_pci(Board_node *bnode);
109 void	display_io_cards(struct io_card *);
110 void	display_ffb(Board_node *, int);
111 void	display_sbus(Board_node *);
112 int	populate_slot_name_arr(Prom_node *pci, int *slot_name_bits,
113 	char **slot_name_arr, int num_slots);
114 int	get_card_frequency(Prom_node *pci);
115 void	get_dev_func_num(Prom_node *card_node, int *dev_no, int *func_no);
116 void	get_pci_class_codes(Prom_node *card_node, int *class_code,
117 	int *subclass_code);
118 int	is_pci_bridge(Prom_node *card_node, char *name);
119 int	is_pci_bridge_other(Prom_node *card_node, char *name);
120 void	get_pci_card_model(Prom_node *card_node, char *model);
121 void	create_io_card_name(Prom_node *card_node, char *name,
122 	char *card_name);
123 void	display_psycho_pci(Board_node *bnode);
124 void	get_slot_number_str(struct io_card *card, char **slot_name_arr,
125 	int slot_name_bits);
126 void	distinguish_identical_io_cards(char *name, Prom_node *node,
127 		struct io_card *card);
128 void	decode_qlc_card_model_prop(Prom_node *card_node, struct io_card *card);
129 
130 /*
131  * kstat functions
132  */
133 void	read_platform_kstats(Sys_tree *tree,
134 	    struct system_kstat_data *sys_kstat,
135 	    struct bd_kstat_data *bdp, struct envctrl_kstat_data *ep);
136 void	read_sun4u_kstats(Sys_tree *, struct system_kstat_data *);
137 
138 /*
139  * memory functions
140  */
141 void	display_memorysize(Sys_tree *tree, struct system_kstat_data *kstats,
142 	    struct grp_info *grps, struct mem_total *memory_total);
143 void	display_memoryconf(Sys_tree *tree, struct grp_info *grps);
144 
145 /*
146  * prom functions
147  */
148 void	platform_disp_prom_version(Sys_tree *);
149 void	disp_prom_version(Prom_node *);
150 void	add_node(Sys_tree *, Prom_node *);
151 Prom_node *find_device(Board_node *, int, char *);
152 Prom_node *walk(Sys_tree *, Prom_node *, int);
153 int	get_pci_class_code_reg(Prom_node *);
154 
155 /*
156  * libdevinfo functions
157  */
158 int	do_devinfo(int, char *, int, int);
159 
160 /*
161  * mc-us3 memory functions and structs
162  */
163 typedef struct memory_bank {
164 	int			id;
165 	int			portid;
166 	ushort_t		valid;
167 	ushort_t		uk;
168 	uint_t			um;
169 	uchar_t			lk;
170 	uchar_t			lm;
171 	uint64_t		bank_size;
172 	char			*bank_status;
173 	struct memory_bank	*next;		/* mc in the devtree */
174 	struct memory_bank	*seg_next;	/* in the segment */
175 } memory_bank_t;
176 
177 typedef struct memory_seg {
178 	int			id;
179 	int			intlv;  /* interleave for this segment */
180 	uint64_t		base;   /* base address for this segment */
181 	uint64_t		size;   /* size of this segment */
182 	int			nbanks; /* number of banks in this segment */
183 	memory_bank_t		*banks; /* pointer to the banks of this seg */
184 	struct memory_seg	*next;
185 } memory_seg_t;
186 
187 #define	NUM_MBANKS_PER_MC		4
188 
189 int	get_us3_mem_regs(Board_node *bnode);
190 void	display_us3_banks(void);
191 int	display_us3_failed_banks(int system_failed);
192 void    print_us3_memory_line(int portid, int bank_id, uint64_t bank_size,
193 	    char *bank_status, uint64_t dimm_size, uint32_t intlv, int seg_id);
194 void	print_us3_failed_memory_line(int portid, int bank_id,
195 	    char *bank_status);
196 
197 #ifdef	__cplusplus
198 }
199 #endif
200 
201 #endif	/* _SYS_LIBPRTDIAG_H */
202