xref: /onnv-gate/usr/src/lib/fm/topo/modules/i86pc/x86pi/x86pi_impl.h (revision 12832:f4172e28e09f)
110942STom.Pothier@Sun.COM /*
210942STom.Pothier@Sun.COM  * CDDL HEADER START
310942STom.Pothier@Sun.COM  *
410942STom.Pothier@Sun.COM  * The contents of this file are subject to the terms of the
510942STom.Pothier@Sun.COM  * Common Development and Distribution License (the "License").
610942STom.Pothier@Sun.COM  * You may not use this file except in compliance with the License.
710942STom.Pothier@Sun.COM  *
810942STom.Pothier@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
910942STom.Pothier@Sun.COM  * or http://www.opensolaris.org/os/licensing.
1010942STom.Pothier@Sun.COM  * See the License for the specific language governing permissions
1110942STom.Pothier@Sun.COM  * and limitations under the License.
1210942STom.Pothier@Sun.COM  *
1310942STom.Pothier@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
1410942STom.Pothier@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1510942STom.Pothier@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
1610942STom.Pothier@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
1710942STom.Pothier@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
1810942STom.Pothier@Sun.COM  *
1910942STom.Pothier@Sun.COM  * CDDL HEADER END
2010942STom.Pothier@Sun.COM  */
2110942STom.Pothier@Sun.COM 
2210942STom.Pothier@Sun.COM /*
23*12832STrang.Do@Sun.COM  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
2410942STom.Pothier@Sun.COM  */
2510942STom.Pothier@Sun.COM 
2610942STom.Pothier@Sun.COM #ifndef _X86PI_IMPL_H
2710942STom.Pothier@Sun.COM #define	_X86PI_IMPL_H
2810942STom.Pothier@Sun.COM 
2910942STom.Pothier@Sun.COM /*
3010942STom.Pothier@Sun.COM  * i86pc Generic Enumerator private interfaces
3110942STom.Pothier@Sun.COM  */
3210942STom.Pothier@Sun.COM 
3310942STom.Pothier@Sun.COM #ifdef __cplusplus
3410942STom.Pothier@Sun.COM extern "C" {
3510942STom.Pothier@Sun.COM #endif
3610942STom.Pothier@Sun.COM 
3710942STom.Pothier@Sun.COM #include <smbios.h>
3810942STom.Pothier@Sun.COM #include <ctype.h>
3910942STom.Pothier@Sun.COM 
4010942STom.Pothier@Sun.COM 
4110942STom.Pothier@Sun.COM /*
4210942STom.Pothier@Sun.COM  * Table showing the relationship between hc-canonical names and the
4310942STom.Pothier@Sun.COM  * SMBIOS tables/values.
4410942STom.Pothier@Sun.COM  *
4510942STom.Pothier@Sun.COM  * **************************************************************************
4610942STom.Pothier@Sun.COM  * | hc-name             | SMB Table | Offset - Name            | Value     |
4710942STom.Pothier@Sun.COM  * --------------------------------------------------------------------------
4810942STom.Pothier@Sun.COM  * --------------------------------------------------------------------------
4910942STom.Pothier@Sun.COM  * | "motherboard"       | Type 2    | 0x0D - Board Type        | 0x0A      |
5010942STom.Pothier@Sun.COM  * --------------------------------------------------------------------------
5110942STom.Pothier@Sun.COM  * | "cpuboard"          | Type 2    | 0x0D - Board Type        | 0x06      |
5210942STom.Pothier@Sun.COM  * --------------------------------------------------------------------------
5310942STom.Pothier@Sun.COM  * | "memboard"          | Type 2    | 0x0D - Board Type        | 0x08      |
5410942STom.Pothier@Sun.COM  * --------------------------------------------------------------------------
5510942STom.Pothier@Sun.COM  * | "ioboard"           | Type 2    | 0x0D - Board Type        | 0x07      |
5610942STom.Pothier@Sun.COM  * --------------------------------------------------------------------------
5710942STom.Pothier@Sun.COM  * | "systemboard"       | Type 2    | 0x0D - Board Type        | 0x03,0x09,|
5810942STom.Pothier@Sun.COM  * |                     |           |                          | 0x0B,0x0C |
5910942STom.Pothier@Sun.COM  * --------------------------------------------------------------------------
6011859STom.Pothier@Sun.COM  * | "bay"               | Type 136  |                                      |
6111859STom.Pothier@Sun.COM  * --------------------------------------------------------------------------
6210942STom.Pothier@Sun.COM  * | "hostbridge"        | Type 138  |                                      |
6310942STom.Pothier@Sun.COM  * --------------------------------------------------------------------------
6410942STom.Pothier@Sun.COM  * | "pciexrc"           | Type 138  |                                      |
6510942STom.Pothier@Sun.COM  * **************************************************************************
6610942STom.Pothier@Sun.COM  */
6710942STom.Pothier@Sun.COM 
6810942STom.Pothier@Sun.COM 
6910942STom.Pothier@Sun.COM /* Definitions used when registering the enumerator with libtopo */
7010942STom.Pothier@Sun.COM #define	X86PI_DESC	"i86pc Generic Topology Enumerator"
7110942STom.Pothier@Sun.COM #define	X86PI_SCHEME	"hc"
7210942STom.Pothier@Sun.COM #define	X86PI_VERSION	TOPO_VERSION
7310942STom.Pothier@Sun.COM 
7410942STom.Pothier@Sun.COM /*
7510942STom.Pothier@Sun.COM  * Solaris FMA Compliance level for SMBIOS.
7610942STom.Pothier@Sun.COM  * The same X86PI_* definitions are used in chip.h
7710942STom.Pothier@Sun.COM  * please keep them in sync
7810942STom.Pothier@Sun.COM  */
7910942STom.Pothier@Sun.COM #define	X86PI_FULL	1
8010942STom.Pothier@Sun.COM #define	X86PI_NONE	2
8110942STom.Pothier@Sun.COM 
8210942STom.Pothier@Sun.COM /* used in traversing contained bboards */
8310942STom.Pothier@Sun.COM #define	X86PI_VISITED	1
8410942STom.Pothier@Sun.COM 
8510942STom.Pothier@Sun.COM #define	LABEL		1
8610942STom.Pothier@Sun.COM 
8710942STom.Pothier@Sun.COM /* Flags used by x86pi_enum_generic */
8810942STom.Pothier@Sun.COM #define	X86PI_ENUM_FRU	0x0001	/* Indicates a FRU */
8910942STom.Pothier@Sun.COM 
9010942STom.Pothier@Sun.COM /* max allowed contained count */
9110942STom.Pothier@Sun.COM #define	SMB_MAX_ID	0x40
9210942STom.Pothier@Sun.COM 
9310942STom.Pothier@Sun.COM /* indication of successful fac node creation */
9410942STom.Pothier@Sun.COM int fac_done;
9510942STom.Pothier@Sun.COM 
9610942STom.Pothier@Sun.COM /*
9710942STom.Pothier@Sun.COM  * Count and smbios struct id(s) for each smbios struct type.
9810942STom.Pothier@Sun.COM  */
9910942STom.Pothier@Sun.COM typedef struct smbs_con_ids {
10010942STom.Pothier@Sun.COM 	id_t id;			/* smbios struct id */
10110942STom.Pothier@Sun.COM 	id_t con_cnt;			/* containee count */
10210942STom.Pothier@Sun.COM 	id_t con_ids[SMB_MAX_ID];	/* containee ids */
10310942STom.Pothier@Sun.COM 	id_t con_by_id;			/* container id */
10410942STom.Pothier@Sun.COM 	int visited;			/* visit flag */
10510942STom.Pothier@Sun.COM 	tnode_t *node;
10610942STom.Pothier@Sun.COM } smbs_con_ids_t;
10710942STom.Pothier@Sun.COM 
10810942STom.Pothier@Sun.COM typedef struct smbs_cnt {
10910942STom.Pothier@Sun.COM 	int type;		/* SMBIOS stucture type */
11010942STom.Pothier@Sun.COM 	int count;		/* number of table entries */
11110942STom.Pothier@Sun.COM 	smbs_con_ids_t ids[SMB_MAX_ID]; /* SMBIOS table entry id(s) */
11210942STom.Pothier@Sun.COM } smbs_cnt_t;
11310942STom.Pothier@Sun.COM 
11410942STom.Pothier@Sun.COM smbs_cnt_t stypes[SMB_TYPE_OEM_HI]; /* one for each struct */
11510942STom.Pothier@Sun.COM 
11610942STom.Pothier@Sun.COM /*
11710942STom.Pothier@Sun.COM  * The enumerator needs to pass some state in to the function that walks
11810942STom.Pothier@Sun.COM  * the PRI graph.  This structure contains the necessary information.
11910942STom.Pothier@Sun.COM  */
12010942STom.Pothier@Sun.COM struct x86pi_enum_s {
12110942STom.Pothier@Sun.COM 	topo_mod_t	*mod;		/* Topo module handle */
12210942STom.Pothier@Sun.COM 	tnode_t		*t_parent;	/* "Chassis" parent */
12310942STom.Pothier@Sun.COM 	uint32_t	force;		/* force legacy */
12410942STom.Pothier@Sun.COM 	void		*priv;		/* Private data */
12510942STom.Pothier@Sun.COM };
12610942STom.Pothier@Sun.COM typedef struct x86pi_enum_s x86pi_enum_t;
12710942STom.Pothier@Sun.COM 
12810942STom.Pothier@Sun.COM /*
12910942STom.Pothier@Sun.COM  * x86gentopo hcfmri info structure.
13010942STom.Pothier@Sun.COM  *
13110942STom.Pothier@Sun.COM  * Available unformed SMBIOS strings:
13210942STom.Pothier@Sun.COM  *  smbi_manufacturer
13310942STom.Pothier@Sun.COM  *  smbi_product
13410942STom.Pothier@Sun.COM  *  smbi_version
13510942STom.Pothier@Sun.COM  *  smbi_serial
13610942STom.Pothier@Sun.COM  *  smbi_asset
13710942STom.Pothier@Sun.COM  *  smbi_location
13810942STom.Pothier@Sun.COM  *  smbi_part
13910942STom.Pothier@Sun.COM  *
14010942STom.Pothier@Sun.COM  */
14110942STom.Pothier@Sun.COM struct x86pi_hcfmri_info_s {
14210942STom.Pothier@Sun.COM 	int		instance;
14310942STom.Pothier@Sun.COM 	int		rev;
14410942STom.Pothier@Sun.COM 
14510942STom.Pothier@Sun.COM 	const char	*hc_name;
14610942STom.Pothier@Sun.COM 	const char	*manufacturer;
14710942STom.Pothier@Sun.COM 	const char	*product;
14810942STom.Pothier@Sun.COM 	const char	*version;
14910942STom.Pothier@Sun.COM 	const char	*serial_number;
15010942STom.Pothier@Sun.COM 	const char	*asset_tag;
15110942STom.Pothier@Sun.COM 	const char	*location;
15210942STom.Pothier@Sun.COM 	const char	*part_number;
15310942STom.Pothier@Sun.COM };
15410942STom.Pothier@Sun.COM typedef struct x86pi_hcfmri_info_s x86pi_hcfmri_t;
15510942STom.Pothier@Sun.COM 
15610942STom.Pothier@Sun.COM /*
15710942STom.Pothier@Sun.COM  * Prototypes
15810942STom.Pothier@Sun.COM  */
15910942STom.Pothier@Sun.COM 
16010942STom.Pothier@Sun.COM /* SMBIOS */
16110942STom.Pothier@Sun.COM smbios_hdl_t *x86pi_smb_open(topo_mod_t *);
162*12832STrang.Do@Sun.COM void x86pi_smb_strcnt(topo_mod_t *, smbs_cnt_t *);
163*12832STrang.Do@Sun.COM int x86pi_check_comp(topo_mod_t *);
16410942STom.Pothier@Sun.COM 
16510942STom.Pothier@Sun.COM /* Node generation */
166*12832STrang.Do@Sun.COM tnode_t *x86pi_gen_chassis(topo_mod_t *, tnode_t *, int, int);
167*12832STrang.Do@Sun.COM tnode_t *x86pi_gen_bboard(topo_mod_t *, tnode_t *, int, int,
16810942STom.Pothier@Sun.COM     int);
16910942STom.Pothier@Sun.COM int x86pi_gen_cmp(topo_mod_t *, tnode_t *, smbios_hdl_t *, int, int, int);
17010942STom.Pothier@Sun.COM int x86pi_gen_core(topo_mod_t *, tnode_t *, int, int, int);
17110942STom.Pothier@Sun.COM int x86pi_gen_strand(topo_mod_t *, tnode_t *, int, int, int);
17210942STom.Pothier@Sun.COM int x86pi_gen_memarray(topo_mod_t *, tnode_t *, smbios_hdl_t *, int, int);
17310942STom.Pothier@Sun.COM void x86pi_gen_memdev(topo_mod_t *, tnode_t *, smbios_hdl_t *, int, int, int);
174*12832STrang.Do@Sun.COM int x86pi_gen_hbr(topo_mod_t *, tnode_t *, int, topo_instance_t,
175*12832STrang.Do@Sun.COM     topo_instance_t *);
176*12832STrang.Do@Sun.COM int x86pi_gen_bay(topo_mod_t *, tnode_t *, smbios_port_ext_t *,
17711859STom.Pothier@Sun.COM     int);
17810942STom.Pothier@Sun.COM 
17910942STom.Pothier@Sun.COM /* support routines */
18010942STom.Pothier@Sun.COM int x86pi_enum_generic(topo_mod_t *, x86pi_hcfmri_t *, tnode_t *, tnode_t *,
18110942STom.Pothier@Sun.COM     tnode_t **, int);
18210942STom.Pothier@Sun.COM tnode_t *x86pi_node_bind(topo_mod_t *, tnode_t *, x86pi_hcfmri_t *, nvlist_t *,
18310942STom.Pothier@Sun.COM     int);
18410942STom.Pothier@Sun.COM void x86pi_hcfmri_info_fini(topo_mod_t *, x86pi_hcfmri_t *);
18511859STom.Pothier@Sun.COM uint16_t x86pi_bdf(topo_mod_t *, di_node_t);
18611859STom.Pothier@Sun.COM int x86pi_phy(topo_mod_t *, di_node_t);
18710942STom.Pothier@Sun.COM 
18810942STom.Pothier@Sun.COM /* get/set info */
18910942STom.Pothier@Sun.COM char *x86pi_get_serverid(topo_mod_t *);
19010942STom.Pothier@Sun.COM int x86pi_set_frufmri(topo_mod_t *, x86pi_hcfmri_t *, tnode_t *, tnode_t *,
19110942STom.Pothier@Sun.COM     int);
19210942STom.Pothier@Sun.COM int x86pi_set_label(topo_mod_t *, const char *, const char *, tnode_t *);
19310942STom.Pothier@Sun.COM int x86pi_set_auth(topo_mod_t *, x86pi_hcfmri_t *, tnode_t *, tnode_t *);
19410942STom.Pothier@Sun.COM int x86pi_set_system(topo_mod_t *, tnode_t *);
19510942STom.Pothier@Sun.COM 
19610942STom.Pothier@Sun.COM /* hostbridge */
19710942STom.Pothier@Sun.COM int x86pi_hbr_enum_init(topo_mod_t *);
19810942STom.Pothier@Sun.COM void x86pi_hbr_enum_fini(topo_mod_t *);
19910942STom.Pothier@Sun.COM 
20010942STom.Pothier@Sun.COM /* base board */
201*12832STrang.Do@Sun.COM id_t x86pi_bb_topparent(topo_mod_t *, int, tnode_t **, id_t *);
202*12832STrang.Do@Sun.COM int x86pi_bb_contains(topo_mod_t *);
203*12832STrang.Do@Sun.COM int x86pi_bb_getchips(topo_mod_t *, int, int);
20410942STom.Pothier@Sun.COM 
20510942STom.Pothier@Sun.COM const char *x86pi_cleanup_smbios_str(topo_mod_t *, const char *, int);
20610942STom.Pothier@Sun.COM 
20710942STom.Pothier@Sun.COM #ifdef __cplusplus
20810942STom.Pothier@Sun.COM }
20910942STom.Pothier@Sun.COM #endif
21010942STom.Pothier@Sun.COM 
21110942STom.Pothier@Sun.COM #endif /* _X86PI_IMPL_H */
212