xref: /titanic_52/usr/src/uts/sun4u/lw8/sys/sgfrutree.h (revision d14abf155341d55053c76eeec58b787a456b753b)
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 2000 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SGFRUTREE_H
28 #define	_SGFRUTREE_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/types.h>
37 #include <sys/sgfru.h>
38 
39 #define	ROOTPARENT		0		/* well-known node value */
40 #define	MAX_NODE_CHILDREN	16		/* hint */
41 #define	MAX_NODE_NAME		16		/* max name size */
42 
43 /*
44  * PICL classes used by serengeti sgfrutree
45  */
46 #define	TEMP_CLASS		0x0		/* currently unused */
47 #define	FRU_CLASS		0x1		/* fru class */
48 #define	LOCATION_CLASS		0x2		/* location class */
49 #define	PSEUDO_FRU_CLASS	0x3		/* fru class with no seeprom */
50 
51 typedef struct {
52 	fru_hdl_t	handle;			/* (container) handle */
53 	char		nodename[MAX_NODE_NAME]; /* picl nodename, thing name */
54 	int16_t		has_children;		/* hint if node has children */
55 	uint16_t	class;			/* one of the picl classes */
56 	union class_info {
57 	    struct location_info {
58 		int16_t	slot;			/* location: valid slot or -1 */
59 		char	label[MAX_NODE_NAME];	/* label property, place name */
60 	    } linfo;
61 	} cinfo;
62 } node_t;
63 
64 #define	location_slot	cinfo.linfo.slot
65 #define	location_label	cinfo.linfo.label
66 
67 typedef frup_info_t	child_info_t;
68 typedef frup_info_t	handles_t;
69 typedef frup_info_t	node_info_t;
70 
71 /*
72  *   PICL FRU Hierarchy
73  *
74  *	    + frutree
75  *	    |
76  *	    +-- safari-node
77  *		|
78  *		+-- picl fru node, name = <name> (picl class = fru)
79  *		|
80  *		+-- picl location node, name = <name> (picl class = location)
81  *		|     o optional property slot = <instance>
82  *		|
83  *		+-- picl location node, name = <name> (picl class = location)
84  *		|  |  o optional property slot = <instance>
85  *		|  |
86  *		|  +-- picl fru node, name = <name> (picl class = fru)
87  *		|
88  *		+-- picl tree sibling +-- picl tree child
89  *
90  *
91  * Request: child_info_t, with parent fru handle and max count
92  * Receive: child_info_t, with child_info_t array and actual count
93  */
94 #define	SGFRU_GETCHILDLIST			0x000f
95 /*
96  * Request: handles_t, with fru handle, max count, and preallocated buffer
97  * Receive: handles_t, with handle array and actual count
98  */
99 #define	SGFRU_GETCHILDHANDLES			0x0010
100 /*
101  * Request: node_info_t, with fru handle
102  * Receive: node_info_t, with node_t info for the node
103  */
104 #define	SGFRU_GETNODEINFO			0x0020
105 
106 #ifdef DEBUG
107 /*
108  * DESCRIPTION
109  *   fru_get_children() fills an array of structures representing the
110  *   children of a node.
111  *
112  * ARGUMENTS
113  *
114  * RETURN
115  *   int
116  *     On success, the number of node_t structures written is returned;
117  *     on error, -1 is returned and "errno" is set appropriately.
118  *
119  * ERRORS
120  *   ENOMEM
121  *     The parent FRU has more than "max_children" children.
122  */
123 int fru_get_children(fru_hdl_t parent, node_t *children, int max_children);
124 
125 /*
126  * DESCRIPTION
127  *   fru_get_handles() fills an array of structures representing the
128  *   children of a node that have FRUs. Use 0 for the top root node.
129  *
130  * ARGUMENTS
131  *
132  * RETURN
133  *   int
134  *     On success, the number of fru_hdl_t structures written is returned;
135  *     on error, -1 is returned and "errno" is set appropriately.
136  *
137  * ERRORS
138  *   ENOMEM
139  *     The parent FRU has more than "max_handles" children.
140  */
141 int fru_get_handles(fru_hdl_t parent, fru_hdl_t *children, int max_handles);
142 
143 /*
144  * DESCRIPTION
145  *   fru_get_node_info() gets the node_t info for a handle.
146  *
147  * ARGUMENTS
148  *
149  * RETURN
150  *   int
151  *     On success, 0 is returned as well as the node_info;
152  *     on error, -1 is returned and "errno" is set appropriately.
153  *
154  * ERRORS
155  */
156 int fru_get_node_info(fru_hdl_t node_hdl, node_t *node);
157 #endif /* DEBUG */
158 
159 #ifdef	__cplusplus
160 }
161 #endif
162 
163 #endif	/* _SGFRUTREE_H */
164