xref: /titanic_50/usr/src/cmd/picl/plugins/sun4u/psvc/psvcobj/psvc_objects_class.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1999-2001, 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_PSVC_OBJECTS_CLASS_H
28 #define	_PSVC_OBJECTS_CLASS_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * Platform Services Framework private definitions
38  */
39 #include	<pthread.h>
40 
41 #define	NAMELEN		32
42 #define	PATHLEN		256
43 
44 /* Logical device class */
45 typedef struct {
46 	int32_t		class;
47 	int32_t		subclass;
48 	int32_t		instance;
49 	uint64_t	features;
50 	uint64_t	addr_spec;
51 	char		state[32];
52 	char		previous_state[32];
53 	char		fault_id[32];
54 	boolean_t	present;
55 	boolean_t	previous_presence;
56 	boolean_t	enabled;
57 	char		label[32];
58 	int32_t 	(*constructor)();
59 	int32_t		(*destructor)();
60 	int32_t		(*get_attr)();
61 	int32_t		(*set_attr)();
62 } EObj_t;
63 
64 typedef struct {
65 	EObj_t		ld;		/* logical device */
66 	int32_t		hw_lo_shut;
67 	int32_t		lo_warn;	/* low warning threshold */
68 	int32_t		lo_shut;	/* low shutdown threshold */
69 	int32_t		opt_temp;
70 	int32_t		hi_warn;	/* high warning threshold */
71 	int32_t		hi_shut;	/* high shutdown threshold */
72 	int32_t		hw_hi_shut;
73 } ETempSensor_t;
74 
75 typedef struct {
76 	EObj_t		ld;		/* logical device */
77 	int16_t		setpoint;
78 	int16_t		hysteresis;
79 	int16_t		loopgain;
80 	int16_t		loopbias;
81 	float		temp_differential[PSVC_MAXERRORS];
82 	int16_t		temp_differential_index;
83 } EFan_t;
84 
85 typedef struct {
86 	EObj_t		ld;			/* logical device */
87 } ESystem_t;
88 
89 typedef struct {
90 	EObj_t		ld;		/* logical device */
91 	int32_t		lo_warn;	/* low warning threshold */
92 	int32_t		lo_shut;	/* low shutdown threshold */
93 	int32_t		hi_warn;	/* high warning threshold */
94 	int32_t		hi_shut;	/* high shutdown threshold */
95 } EDigiSensor_t;
96 
97 typedef struct {
98 	EObj_t		ld;			/* logical device */
99 } EDigiControl_t;
100 
101 typedef struct {
102 	EObj_t		ld;			/* logical device */
103 } EBoolSensor_t;
104 
105 typedef struct {
106 	EObj_t		ld;
107 } EGPIO8_t;
108 
109 typedef struct {
110 	EObj_t		ld;			/* logical device */
111 	int16_t		lit_count;
112 	char		color[32];
113 	char		is_locator[8];
114 	char		locator_name[32];
115 } ELed_t;
116 
117 typedef struct {
118 	EObj_t		ld;		/* logical device */
119 	int32_t		lo_warn;	/* low warning threshold */
120 	int32_t		lo_shut;	/* low shutdown threshold */
121 	int32_t		hi_warn;	/* high warning threshold */
122 	int32_t		hi_shut;	/* high shutdown threshold */
123 } EFanTach_t;
124 
125 typedef struct {
126 	EObj_t		ld;			/* logical device */
127 	char		switch_state[32];
128 } ESwitch_t;
129 
130 typedef struct {
131 	EObj_t		ld;			/* logical device */
132 } EKeySwitch_t;
133 
134 typedef struct {
135 	EObj_t		ld;			/* logical device */
136 	int32_t		(*get_temperature)();
137 	int32_t		(*get_fanspeed)();
138 	int32_t		(*get_bit)();
139 	int32_t		(*set_bit)();
140 	int32_t		(*get_port)();
141 	int32_t		(*set_port)();
142 	int32_t		(*get_reg)();
143 	int32_t		(*set_reg)();
144 	int32_t		(*get_output)();
145 	int32_t		(*set_output)();
146 	int32_t		(*get_input)();
147 } EPhysDev_t;
148 
149 typedef struct {
150 	uint8_t		cell_type;
151 	uint32_t	size;
152 	int64_t		*table;
153 } ETable_t;
154 
155 typedef struct {
156 	char		antecedent_id[NAMELEN];
157 	int32_t		ant_key;
158 	char		dependent_id[NAMELEN];
159 } EAssoc_t;
160 
161 typedef struct {
162 	char		name[NAMELEN];
163 	uint32_t	count;
164 	EAssoc_t	*table;
165 } EAssocList_t;
166 
167 /* structure for translating string to id */
168 typedef struct {
169 	int32_t		id;
170 	char		name[NAMELEN];
171 } EStringId_t;
172 
173 typedef struct {
174 	uint32_t	controller;
175 	uint32_t	bus;
176 	uint32_t	addr;
177 	uint32_t	port;
178 	char		path[PATHLEN];
179 } EDevice_t;
180 
181 /* translate name to object (or table) pointer */
182 typedef struct {
183 	char		name[NAMELEN];
184 	int32_t		key;
185 	EObj_t		*objp;
186 	int32_t		type;		/* object or table */
187 } ENamePtr_t;
188 
189 typedef struct {
190 	ENamePtr_t	*obj_tbl;	/* object name to pointer translation */
191 	uint32_t	obj_count;	/* number of objects */
192 	uint32_t	nextid;		/* next open object slot */
193 } ETable_Array;
194 
195 #define	PSVC_OBJ	0
196 #define	PSVC_TBL	1
197 #define	PSVC_MAX_TABLE_ARRAYS	10
198 
199 typedef struct {
200 	ETable_Array	tbl_arry[PSVC_MAX_TABLE_ARRAYS];
201 	uint32_t	total_obj_count; /* Total number of objects */
202 	EStringId_t	*othr_tbl;	/* assoc string to id translations */
203 	uint32_t	othr_count;	/* number of assoc strings */
204 	EAssocList_t	*assoc_tbl;	/* associations between objects */
205 	uint32_t	assoc_count;	/* number of associations */
206 	EDevice_t	*dev_tbl;	/* device paths */
207 	uint32_t	dev_count;	/* number of device paths */
208 	FILE		*fp;		/* config file */
209 	pthread_mutex_t	mutex;		/* multi threaded protection */
210 } EHdl_t;
211 
212 /* String lookup table for attributes */
213 static char *attr_str_tab[] = {
214 	"_class",				/* 0 */
215 	"Subclass",				/* 1 */
216 	"Presence",				/* 2 */
217 	"Previous-presence",			/* 3 */
218 	"State",				/* 4 */
219 	"Previous-state",			/* 5 */
220 	"Enabled",				/* 6 */
221 	"FaultInformation",			/* 7 */
222 	"Features",				/* 8 */
223 	"Label",				/* 9 */
224 	"Fruid",				/* 10 */
225 	"Instance",				/* 11 */
226 	"Led-color",				/* 12 */
227 	"Lo-warn",				/* 13 */
228 	"Lo-shut",				/* 14 */
229 	"Hi-warn",				/* 15 */
230 	"Hi-shut",				/* 16 */
231 	"Opt-temp",				/* 17 */
232 	"Hw-hi-shut",				/* 18 */
233 	"Hw-lo-shut",				/* 19 */
234 	"Setpoint",				/* 20 */
235 	"Hysteresis",				/* 21 */
236 	"Loopgain",				/* 22 */
237 	"Loopbias",				/* 23 */
238 	"Temp_differential",			/* 24 */
239 	"Temp_differential_index",		/* 25 */
240 	"Sensor-value",				/* 26 */
241 	"Gpio-value",				/* 27 */
242 	"#Bits",				/* 28 */
243 	"Control-value",			/* 29 */
244 	"Led-state",				/* 30 */
245 	"Switch-state",				/* 31 */
246 	"Probe-result",				/* 32 */
247 	"Table_value",				/* 33 */
248 	"Assoc_id",				/* 34 */
249 	"Assoc_matches",			/* 35 */
250 	"Addr-spec",				/* 36 */
251 	"Object-id",				/* 37 */
252 	"Led-lit-count",			/* 38 */
253 	"FRU-info",				/* 39 */
254 	"IsLocator",				/* 40 */
255 	"LocatorName"				/* 41 */
256 };
257 
258 int	ATTR_STR_TAB_SIZE = sizeof (attr_str_tab) / sizeof (char *);
259 
260 #ifdef	__cplusplus
261 }
262 #endif
263 
264 #endif /* _PSVC_OBJECTS_CLASS_H */
265