xref: /titanic_41/usr/src/lib/fm/topo/modules/i86pc/x86pi/x86pi_impl.h (revision 6a634c9dca3093f3922e4b7ab826d7bdf17bf78e)
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 /*
23  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 
26 #ifndef _X86PI_IMPL_H
27 #define	_X86PI_IMPL_H
28 
29 /*
30  * i86pc Generic Enumerator private interfaces
31  */
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #include <smbios.h>
38 #include <ctype.h>
39 
40 
41 /*
42  * Table showing the relationship between hc-canonical names and the
43  * SMBIOS tables/values.
44  *
45  * **************************************************************************
46  * | hc-name             | SMB Table | Offset - Name            | Value     |
47  * --------------------------------------------------------------------------
48  * --------------------------------------------------------------------------
49  * | "motherboard"       | Type 2    | 0x0D - Board Type        | 0x0A      |
50  * --------------------------------------------------------------------------
51  * | "cpuboard"          | Type 2    | 0x0D - Board Type        | 0x06      |
52  * --------------------------------------------------------------------------
53  * | "memboard"          | Type 2    | 0x0D - Board Type        | 0x08      |
54  * --------------------------------------------------------------------------
55  * | "ioboard"           | Type 2    | 0x0D - Board Type        | 0x07      |
56  * --------------------------------------------------------------------------
57  * | "systemboard"       | Type 2    | 0x0D - Board Type        | 0x03,0x09,|
58  * |                     |           |                          | 0x0B,0x0C |
59  * --------------------------------------------------------------------------
60  * | "bay"               | Type 136  |                                      |
61  * --------------------------------------------------------------------------
62  * | "hostbridge"        | Type 138  |                                      |
63  * --------------------------------------------------------------------------
64  * | "pciexrc"           | Type 138  |                                      |
65  * **************************************************************************
66  */
67 
68 
69 /* Definitions used when registering the enumerator with libtopo */
70 #define	X86PI_DESC	"i86pc Generic Topology Enumerator"
71 #define	X86PI_SCHEME	"hc"
72 #define	X86PI_VERSION	TOPO_VERSION
73 
74 /*
75  * Solaris FMA Compliance level for SMBIOS.
76  * The same X86PI_* definitions are used in chip.h
77  * please keep them in sync
78  */
79 #define	X86PI_FULL	1
80 #define	X86PI_NONE	2
81 
82 /* used in traversing contained bboards */
83 #define	X86PI_VISITED	1
84 
85 #define	LABEL		1
86 
87 /* Flags used by x86pi_enum_generic */
88 #define	X86PI_ENUM_FRU	0x0001	/* Indicates a FRU */
89 
90 /* max allowed contained count */
91 #define	SMB_MAX_ID	0x40
92 
93 /* indication of successful fac node creation */
94 int fac_done;
95 
96 /*
97  * Count and smbios struct id(s) for each smbios struct type.
98  */
99 typedef struct smbs_con_ids {
100 	id_t id;			/* smbios struct id */
101 	id_t con_cnt;			/* containee count */
102 	id_t con_ids[SMB_MAX_ID];	/* containee ids */
103 	id_t con_by_id;			/* container id */
104 	int visited;			/* visit flag */
105 	tnode_t *node;
106 } smbs_con_ids_t;
107 
108 typedef struct smbs_cnt {
109 	int type;		/* SMBIOS stucture type */
110 	int count;		/* number of table entries */
111 	smbs_con_ids_t ids[SMB_MAX_ID]; /* SMBIOS table entry id(s) */
112 } smbs_cnt_t;
113 
114 smbs_cnt_t stypes[SMB_TYPE_OEM_HI]; /* one for each struct */
115 
116 /*
117  * The enumerator needs to pass some state in to the function that walks
118  * the PRI graph.  This structure contains the necessary information.
119  */
120 struct x86pi_enum_s {
121 	topo_mod_t	*mod;		/* Topo module handle */
122 	tnode_t		*t_parent;	/* "Chassis" parent */
123 	uint32_t	force;		/* force legacy */
124 	void		*priv;		/* Private data */
125 };
126 typedef struct x86pi_enum_s x86pi_enum_t;
127 
128 /*
129  * x86gentopo hcfmri info structure.
130  *
131  * Available unformed SMBIOS strings:
132  *  smbi_manufacturer
133  *  smbi_product
134  *  smbi_version
135  *  smbi_serial
136  *  smbi_asset
137  *  smbi_location
138  *  smbi_part
139  *
140  */
141 struct x86pi_hcfmri_info_s {
142 	int		instance;
143 	int		rev;
144 
145 	const char	*hc_name;
146 	const char	*manufacturer;
147 	const char	*product;
148 	const char	*version;
149 	const char	*serial_number;
150 	const char	*asset_tag;
151 	const char	*location;
152 	const char	*part_number;
153 };
154 typedef struct x86pi_hcfmri_info_s x86pi_hcfmri_t;
155 
156 /*
157  * Prototypes
158  */
159 
160 /* SMBIOS */
161 smbios_hdl_t *x86pi_smb_open(topo_mod_t *);
162 void x86pi_smb_strcnt(topo_mod_t *, smbs_cnt_t *);
163 int x86pi_check_comp(topo_mod_t *);
164 
165 /* Node generation */
166 tnode_t *x86pi_gen_chassis(topo_mod_t *, tnode_t *, int, int);
167 tnode_t *x86pi_gen_bboard(topo_mod_t *, tnode_t *, int, int,
168     int);
169 int x86pi_gen_cmp(topo_mod_t *, tnode_t *, smbios_hdl_t *, int, int, int);
170 int x86pi_gen_core(topo_mod_t *, tnode_t *, int, int, int);
171 int x86pi_gen_strand(topo_mod_t *, tnode_t *, int, int, int);
172 int x86pi_gen_memarray(topo_mod_t *, tnode_t *, smbios_hdl_t *, int, int);
173 void x86pi_gen_memdev(topo_mod_t *, tnode_t *, smbios_hdl_t *, int, int, int);
174 int x86pi_gen_hbr(topo_mod_t *, tnode_t *, int, topo_instance_t,
175     topo_instance_t *);
176 int x86pi_gen_bay(topo_mod_t *, tnode_t *, smbios_port_ext_t *,
177     int);
178 
179 /* support routines */
180 int x86pi_enum_generic(topo_mod_t *, x86pi_hcfmri_t *, tnode_t *, tnode_t *,
181     tnode_t **, int);
182 tnode_t *x86pi_node_bind(topo_mod_t *, tnode_t *, x86pi_hcfmri_t *, nvlist_t *,
183     int);
184 void x86pi_hcfmri_info_fini(topo_mod_t *, x86pi_hcfmri_t *);
185 uint16_t x86pi_bdf(topo_mod_t *, di_node_t);
186 int x86pi_phy(topo_mod_t *, di_node_t);
187 
188 /* get/set info */
189 char *x86pi_get_serverid(topo_mod_t *);
190 int x86pi_set_frufmri(topo_mod_t *, x86pi_hcfmri_t *, tnode_t *, tnode_t *,
191     int);
192 int x86pi_set_label(topo_mod_t *, const char *, const char *, tnode_t *);
193 int x86pi_set_auth(topo_mod_t *, x86pi_hcfmri_t *, tnode_t *, tnode_t *);
194 int x86pi_set_system(topo_mod_t *, tnode_t *);
195 
196 /* hostbridge */
197 int x86pi_hbr_enum_init(topo_mod_t *);
198 void x86pi_hbr_enum_fini(topo_mod_t *);
199 
200 /* base board */
201 id_t x86pi_bb_topparent(topo_mod_t *, int, tnode_t **, id_t *);
202 int x86pi_bb_contains(topo_mod_t *);
203 int x86pi_bb_getchips(topo_mod_t *, int, int);
204 
205 const char *x86pi_cleanup_smbios_str(topo_mod_t *, const char *, int);
206 
207 #ifdef __cplusplus
208 }
209 #endif
210 
211 #endif /* _X86PI_IMPL_H */
212