xref: /illumos-gate/usr/src/lib/fm/topo/modules/common/pcibus/pcibus_labels.h (revision cb6207858a9fcc2feaee22e626912fba281ac969)
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 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _PCIBUS_LABELS_H
28 #define	_PCIBUS_LABELS_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <hostbridge.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * When all we're provided is a physical slot number, these structures
40  * allow us to attach an accompanying label.
41  */
42 typedef struct physnm {
43 	int ps_num;
44 	const char *ps_label;
45 } physnm_t;
46 
47 typedef struct pphysnm {
48 	const char *pnm_platform;	/* platform on which the names apply */
49 	int pnm_nnames;			/* number of names */
50 	struct physnm *pnm_names;	/* array of labels */
51 } pphysnm_t;
52 
53 typedef struct physlot_names {
54 	int psn_nplats;
55 	struct pphysnm *psn_names;
56 } physlot_names_t;
57 
58 /*
59  * Sometimes OBP gets it wrong, there's a slot-names property, but it
60  * is incorrect.  These structures allow us to replace a given label A
61  * with a different label B prior to attaching the label to a topology node.
62  */
63 typedef struct slot_rwd {
64 	const char *srw_obp;		/* slot name found */
65 	const char *srw_new;		/* replacement slot name */
66 } slot_rwd_t;
67 
68 typedef struct plat_rwd {
69 	const char *prw_platform;	/* platform on which the names apply */
70 	int prw_nrewrites;		/* number of rewrites */
71 	struct slot_rwd *prw_rewrites;	/* array of rewrites */
72 } plat_rwd_t;
73 
74 typedef struct slotnm_rewrite {
75 	int srw_nplats;
76 	struct plat_rwd *srw_platrewrites;
77 } slotnm_rewrite_t;
78 
79 /*
80  * We can locate a label without help from OBP slot-names or a
81  * physical slot-name, if need be.  Having to resort to this, though is
82  * really an indication that there's a bug in the platform OBP.
83  */
84 typedef struct devlab {
85 	int dl_board;
86 	int dl_bridge;
87 	int dl_rc;
88 	int dl_bus;
89 	int dl_dev;
90 	const char *dl_label;
91 } devlab_t;
92 
93 typedef struct pdevlabs {
94 	const char *pdl_platform;	/* Name of the platform */
95 	int pdl_nnames;			/* number of missing names */
96 	struct devlab *pdl_names;	/* the missing names */
97 } pdevlabs_t;
98 
99 typedef struct missing_names {
100 	int mn_nplats;			/* number of platforms with entries */
101 	struct pdevlabs *mn_names;	/* platform entries */
102 } missing_names_t;
103 
104 extern int pci_label_cmn(topo_mod_t *mod, tnode_t *, nvlist_t *, nvlist_t **);
105 
106 #ifdef __cplusplus
107 }
108 #endif
109 
110 #endif /* _PCIBUS_LABELS_H */
111