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
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.
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]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
30 * This file consists of routines to manage objects in the
31 * "Platform Environment Services Framework". The classes
32 * and subclasses are defined by attributes and methods.
33 * The objects, and their initial, static, attribute values are
34 * specified in a configuration file, "psvcobj.conf".
35 * psvc_init() reads the configuration file and creates a repository
36 * of environmental objects in memory. A client application may manipulate
37 * these objects by invoking the psvc_get_attr(), and psvc_set_attr()
38 * routines with the object's string ID specified as an argument.
52 #include <sys/systeminfo.h>
54 #define LIBRARY_BUILD 1
55 #include <psvc_objects.h>
56 #include <psvc_objects_class.h>
57 #include <sys/i2c/clients/i2c_client.h>
59 /* Mutex used for Daktari Fan speed reading */
60 pthread_mutex_t fan_mutex
= PTHREAD_MUTEX_INITIALIZER
;
64 #define ENV_DEBUG(str, id) printf("%s id %s\n", (str), (id))
69 #define SUBCLASS_MAX 10
71 static int32_t i_psvc_constructor_0_0(EHdl_t
*, char *, EObj_t
**);
72 static int32_t i_psvc_constructor_0_1(EHdl_t
*, char *, EObj_t
**);
73 static int32_t i_psvc_constructor_1_0(EHdl_t
*, char *, EObj_t
**);
74 static int32_t i_psvc_constructor_2_0(EHdl_t
*, char *, EObj_t
**);
75 static int32_t i_psvc_constructor_2_1(EHdl_t
*, char *, EObj_t
**);
76 static int32_t i_psvc_constructor_2_2(EHdl_t
*, char *, EObj_t
**);
77 static int32_t i_psvc_constructor_3_0(EHdl_t
*, char *, EObj_t
**);
78 static int32_t i_psvc_constructor_4_0(EHdl_t
*, char *, EObj_t
**);
79 static int32_t i_psvc_constructor_5_0(EHdl_t
*, char *, EObj_t
**);
80 static int32_t i_psvc_constructor_6_0(EHdl_t
*, char *, EObj_t
**);
81 static int32_t i_psvc_constructor_7_0(EHdl_t
*, char *, EObj_t
**);
82 static int32_t i_psvc_constructor_8_0(EHdl_t
*, char *, EObj_t
**);
83 static int32_t i_psvc_constructor_9_0(EHdl_t
*, char *, EObj_t
**);
84 static int32_t i_psvc_constructor_10_0(EHdl_t
*, char *, EObj_t
**);
85 static int32_t i_psvc_constructor_10_1(EHdl_t
*, char *, EObj_t
**);
86 static int32_t i_psvc_constructor_11_0(EHdl_t
*, char *, EObj_t
**);
87 static int32_t i_psvc_constructor_11_1(EHdl_t
*, char *, EObj_t
**);
88 static int32_t i_psvc_constructor_11_2(EHdl_t
*, char *, EObj_t
**);
89 static int32_t i_psvc_constructor_11_3(EHdl_t
*, char *, EObj_t
**);
90 static int32_t i_psvc_constructor_11_4(EHdl_t
*, char *, EObj_t
**);
91 static int32_t i_psvc_constructor_11_5(EHdl_t
*, char *, EObj_t
**);
92 static int32_t i_psvc_constructor_11_6(EHdl_t
*, char *, EObj_t
**);
93 static int32_t i_psvc_constructor_11_7(EHdl_t
*, char *, EObj_t
**);
94 static int32_t i_psvc_constructor_11_8(EHdl_t
*, char *, EObj_t
**);
95 static int32_t i_psvc_constructor_11_9(EHdl_t
*, char *, EObj_t
**);
97 static int32_t i_psvc_get_obj(EHdl_t
*, char *, EObj_t
**);
98 static int32_t i_psvc_destructor(EHdl_t
*, char *, void *);
99 static int32_t i_psvc_get_devpath(EHdl_t
*, uint64_t, char *);
100 static int32_t i_psvc_get_attr_generic(EHdl_t
*, EObj_t
*, int32_t, void *);
101 static int32_t i_psvc_get_attr_6_0(EHdl_t
*, EObj_t
*, int32_t, void *);
102 static int32_t i_psvc_get_reg_11_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
,
104 static int32_t i_psvc_get_attr_10_1(EHdl_t
*, EObj_t
*, int32_t, void *);
105 static int32_t psvc_get_str_key(char *object
);
107 int32_t ioctl_retry(int fp
, int request
, void * arg_pointer
);
110 * Method lookup tables
111 * Update when adding classes or subclasses.
115 /* Lookup method by class, subclass, used when calling method */
116 static int32_t (*i_psvc_constructor
[CLASS_MAX
][SUBCLASS_MAX
])(EHdl_t
*,
117 char *, EObj_t
**) = {
118 {i_psvc_constructor_0_0
, i_psvc_constructor_0_1
, 0, 0, 0, 0, 0, 0, 0, 0},
119 {i_psvc_constructor_1_0
, 0, 0, 0, 0, 0, 0, 0, 0, 0},
120 {i_psvc_constructor_2_0
, i_psvc_constructor_2_1
, i_psvc_constructor_2_2
,
121 0, 0, 0, 0, 0, 0, 0},
122 {i_psvc_constructor_3_0
, 0, 0, 0, 0, 0, 0, 0, 0, 0},
123 {i_psvc_constructor_4_0
, 0, 0, 0, 0, 0, 0, 0, 0, 0},
124 {i_psvc_constructor_5_0
, 0, 0, 0, 0, 0, 0, 0, 0, 0},
125 {i_psvc_constructor_6_0
, 0, 0, 0, 0, 0, 0, 0, 0, 0},
126 {i_psvc_constructor_7_0
, 0, 0, 0, 0, 0, 0, 0, 0, 0},
127 {i_psvc_constructor_8_0
, 0, 0, 0, 0, 0, 0, 0, 0, 0},
128 {i_psvc_constructor_9_0
, 0, 0, 0, 0, 0, 0, 0, 0, 0},
129 {i_psvc_constructor_10_0
, i_psvc_constructor_10_1
, 0, 0, 0, 0, 0, 0, 0, 0},
130 {i_psvc_constructor_11_0
, i_psvc_constructor_11_1
, i_psvc_constructor_11_2
,
131 i_psvc_constructor_11_3
, i_psvc_constructor_11_4
,
132 i_psvc_constructor_11_5
, i_psvc_constructor_11_6
,
133 i_psvc_constructor_11_7
, i_psvc_constructor_11_8
,
134 i_psvc_constructor_11_9
},
137 static int32_t i_psvc_cell_size
[8] = {1, 1, 2, 2, 4, 4, 8, 8};
143 {PSVC_DEV_PERM
, "PERM="},
144 {PSVC_DEV_HOTPLUG
, "HOTPLUG="},
145 {PSVC_DEV_OPTION
, "OPTION="},
146 {PSVC_DEV_PRIMARY
, "PRIMARY="},
147 {PSVC_DEV_SECONDARY
, "SECONDARY="},
148 {PSVC_DEV_RDONLY
, "RDONLY="},
149 {PSVC_DEV_RDWR
, "RDWR="},
150 {PSVC_DEV_FRU
, "FRU="},
151 {PSVC_LOW_WARN
, "LO_WARN_MASK="},
152 {PSVC_LOW_SHUT
, "LO_SHUT_MASK="},
153 {PSVC_HIGH_WARN
, "HI_WARN_MASK="},
154 {PSVC_HIGH_SHUT
, "HI_SHUT_MASK="},
155 {PSVC_CONVERSION_TABLE
, "CONV_TABLE="},
156 {PSVC_OPT_TEMP
, "OPT_TEMP_MASK="},
157 {PSVC_HW_LOW_SHUT
, "HW_LO_MASK="},
158 {PSVC_HW_HIGH_SHUT
, "HW_HI_MASK="},
159 {PSVC_FAN_DRIVE_PR
, "FAN_DRIVE_PR="},
160 {PSVC_TEMP_DRIVEN
, "TEMP_DRIVEN="},
161 {PSVC_SPEED_CTRL_PR
, "SPEED_CTRL_PR="},
162 {PSVC_FAN_ON_OFF
, "FAN_ON_OFF="},
163 {PSVC_CLOSED_LOOP_CTRL
, "CLOSED_LOOP_CTRL="},
164 {PSVC_FAN_DRIVE_TABLE_PR
, "FAN_DRIVE_TABLE_PR="},
165 {PSVC_DIE_TEMP
, "DIE_TEMP="},
166 {PSVC_AMB_TEMP
, "AMB_TEMP="},
167 {PSVC_DIGI_SENSOR
, "DIGI_SENSOR="},
168 {PSVC_BI_STATE
, "BI_STATE="},
169 {PSVC_TRI_STATE
, "TRI_STATE="},
170 {PSVC_GREEN
, "GREEN="},
171 {PSVC_AMBER
, "AMBER="},
172 {PSVC_OUTPUT
, "OUTPUT="},
173 {PSVC_INPUT
, "INPUT="},
174 {PSVC_BIDIR
, "BIDIR="},
175 {PSVC_BIT_POS
, "BIT_POS="},
176 {PSVC_VAL_POS
, "VAL_POS="},
177 {PSVC_NORMAL_POS_AV
, "NORMAL_POS_AV="},
178 {PSVC_DIAG_POS_AV
, "DIAG_POS_AV="},
179 {PSVC_LOCK_POS_AV
, "LOCK_POS_AV="},
180 {PSVC_OFF_POS_AV
, "OFF_POS_AV="},
181 {PSVC_GPIO_PORT
, "GPIO_PORT="},
182 {PSVC_GPIO_REG
, "GPIO_REG="}
185 #define ASSOC_STR_TAB_SIZE 33
186 static char *assoc_str_tab
[] = {
187 "PSVC_PRESENCE_SENSOR", /* 0 */
188 "PSVC_FAN_ONOFF_SENSOR", /* 1 */
189 "PSVC_FAN_SPEED_TACHOMETER", /* 2 */
190 "PSVC_FAN_PRIM_SEC_SELECTOR", /* 3 */
191 "PSVC_DEV_TEMP_SENSOR", /* 4 */
192 "PSVC_FAN_DRIVE_CONTROL", /* 5 */
193 "PSVC_KS_NORMAL_POS_SENSOR", /* 6 */
194 "PSVC_KS_DIAG_POS_SENSOR", /* 7 */
195 "PSVC_KS_LOCK_POS_SENSOR", /* 8 */
196 "PSVC_KS_OFF_POS_SENSOR", /* 9 */
197 "PSVC_SLOT_FAULT_LED", /* 10 */
198 "PSVC_SLOT_REMOVE_LED", /* 11 */
199 "PSVC_TS_OVERTEMP_LED", /* 12 */
200 "PSVC_PS_I_SENSOR", /* 13 */
201 "PSVC_DEV_FAULT_SENSOR", /* 14 */
202 "PSVC_DEV_FAULT_LED", /* 15 */
203 "PSVC_TABLE", /* 16 */
204 "PSVC_PARENT", /* 17 */
206 "PSVC_ALTERNATE", /* 19 */
207 "PSVC_HOTPLUG_ENABLE_SWITCH", /* 20 */
211 "PSVC_DISK", /* 24 */
213 "PSVC_FSP_LED", /* 26 */
214 "PSVC_KEYSWITCH", /* 27 */
215 "PSVC_PCI_CARD", /* 28 */
216 "PSVC_PHYSICAL_DEVICE", /* 29 */
217 "PSVC_DEV_TYPE_SENSOR", /* 30 */
218 "PSVC_FAN_TRAY_FANS", /* 31 */
222 #define FEATURE_BITS (sizeof (feature_bits) / sizeof (struct bits))
224 static struct bitfield
{
230 {PSVC_VERSION_SHIFT
, "VERSION=", "%d"},
231 {PSVC_ACTIVE_LOW_SHIFT
, "ACTIVE_LOW=", "%d"},
232 {PSVC_BIT_NUM_SHIFT
, "BIT_NUM=", "%d"},
233 {PSVC_INVERT_SHIFT
, "INVERT=", "%d"},
234 {PSVC_PORT_SHIFT
, "PORT=", "%d"},
235 {PSVC_BITSHIFT_SHIFT
, "BITSHIFT=", "%d"},
236 {PSVC_BYTEMASK_SHIFT
, "BYTEMASK=", "%x"},
237 {PSVC_REG_SHIFT
, "REG=", "%d"},
238 {PSVC_TYPE_SHIFT
, "TYPE=", "%d"},
239 {PSVC_BUSADDR_SHIFT
, "BUSADDR=", "%x"},
240 {PSVC_BUSNUM_SHIFT
, "BUSNUM=", "%d"},
241 {PSVC_CNTLR_SHIFT
, "CNTLR=", "%d"},
243 #define ADDR_BITFIELDS (sizeof (addr_fields) / sizeof (struct bitfield))
247 * pathname label1=val1,label2=val2,label3=val3
248 * Must be a space after the pathname and a comma between variables.
252 find_label(char *str
, char *label
)
256 start
= strchr(str
, ' ');
262 if (strncmp(start
, label
, strlen(label
)) == 0)
265 start
= strchr(start
, ',');
266 } while (start
!= NULL
);
272 i_psvc_value(char *buf
, int32_t attr_id
, void *attrp
)
286 case PSVC_CLASS_ATTR
:
287 case PSVC_SUBCLASS_ATTR
:
288 case PSVC_INSTANCE_ATTR
:
289 case PSVC_LO_WARN_ATTR
:
290 case PSVC_LO_SHUT_ATTR
:
291 case PSVC_HI_WARN_ATTR
:
292 case PSVC_HI_SHUT_ATTR
:
293 case PSVC_HW_HI_SHUT_ATTR
:
294 case PSVC_HW_LO_SHUT_ATTR
:
295 case PSVC_OPTIMAL_TEMP_ATTR
:
296 snprintf(label
, sizeof (label
), "%s=", attr_str_tab
[attr_id
]);
297 val
= find_label(buf
, label
);
300 return (PSVC_FAILURE
);
302 found
= sscanf(val
+ strlen(label
),
303 "%d", (int32_t *)attrp
);
305 *(int32_t *)attrp
= 0;
307 case PSVC_SETPOINT_ATTR
:
308 case PSVC_HYSTERESIS_ATTR
:
309 case PSVC_LOOPGAIN_ATTR
:
310 case PSVC_LOOPBIAS_ATTR
:
311 snprintf(label
, sizeof (label
), "%s=", attr_str_tab
[attr_id
]);
312 val
= find_label(buf
, label
);
315 return (PSVC_FAILURE
);
318 found
= sscanf(val
+ strlen(label
), "%hd", (int16_t *)attrp
);
320 *(int16_t *)attrp
= 0;
322 case PSVC_LED_COLOR_ATTR
:
323 case PSVC_LED_IS_LOCATOR_ATTR
:
324 case PSVC_LED_LOCATOR_NAME_ATTR
:
325 snprintf(label
, sizeof (label
), "%s=", attr_str_tab
[attr_id
]);
326 val
= find_label(buf
, label
);
329 return (PSVC_FAILURE
);
331 val_size
= strlen(val
);
332 label_size
= strlen(label
);
334 for (i
= 0; i
< val_size
&& val
[i
] != ','; i
++);
335 if (i
< strlen(val
) - 1) {
336 strncpy((char *)attrp
, val
+label_size
,
339 found
= sscanf(val
+ label_size
, "%s", (char *)attrp
);
341 strcpy((char *)attrp
, "");
343 case PSVC_FEATURES_ATTR
:
345 for (i
= 0; i
< FEATURE_BITS
; ++i
) {
346 val
= find_label(buf
, feature_bits
[i
].label
);
349 found
= sscanf(val
+ strlen(feature_bits
[i
].label
),
353 result
|= feature_bits
[i
].bit
;
356 *(uint64_t *)attrp
= result
;
358 case PSVC_ADDR_SPEC_ATTR
:
360 for (i
= 0; i
< ADDR_BITFIELDS
; ++i
) {
361 val
= find_label(buf
, addr_fields
[i
].label
);
364 found
= sscanf(val
+ strlen(addr_fields
[i
].label
),
365 addr_fields
[i
].format
, &temp32
);
368 temp64
<<= addr_fields
[i
].shift
;
372 *(uint64_t *)attrp
= result
;
376 return (PSVC_FAILURE
);
378 return (PSVC_SUCCESS
);
381 /* determine number of records in file section */
383 i_psvc_count_records(FILE *fp
, char *end
, uint32_t *countp
)
390 first_record
= ftell(fp
);
392 while ((ret
= fgets(buf
, BUFSZ
, fp
)) != NULL
) {
393 if (strncmp(end
, buf
, strlen(end
)) == 0)
400 return (PSVC_FAILURE
);
403 fseek(fp
, first_record
, SEEK_SET
);
405 return (PSVC_SUCCESS
);
408 /* determine number of records in file section */
410 i_psvc_count_tables_associations(FILE *fp
, uint32_t *countp
, char *end
)
417 first_record
= ftell(fp
);
419 while ((ret
= fgets(buf
, BUFSZ
, fp
)) != NULL
) {
420 if (strncmp(end
, buf
, strlen(end
)) == 0)
427 fseek(fp
, first_record
, SEEK_SET
);
429 return (PSVC_SUCCESS
);
432 /* determine number of records in a table */
434 i_psvc_count_table_records(FILE *fp
, char *end
, uint32_t *countp
)
441 first_record
= ftell(fp
);
443 while ((ret
= fscanf(fp
, "%s", string
)) == 1) {
444 if (strncmp(end
, string
, strlen(end
)) == 0)
451 return (PSVC_FAILURE
);
454 fseek(fp
, first_record
, SEEK_SET
);
456 return (PSVC_SUCCESS
);
460 * Find number of matches to an antecedent_id of a certain
464 i_psvc_get_assoc_matches(EHdl_t
*hdlp
, char *antecedent
, int32_t assoc_id
,
469 EAssocList_t
*ap
= hdlp
->assoc_tbl
+ assoc_id
;
473 if (ap
->table
== 0) {
475 return (PSVC_FAILURE
);
478 key
= psvc_get_str_key(antecedent
);
480 for (i
= 0; i
< ap
->count
; ++i
) {
481 if (ap
->table
[i
].ant_key
== key
) {
482 if (strcmp(ap
->table
[i
].antecedent_id
, antecedent
)
487 return (PSVC_SUCCESS
);
491 * Find 1st m matches to an antecedent_id of a certain
493 * Returns zero for success, -1 for failure.
496 i_psvc_get_assoc_id(EHdl_t
*hdlp
, char *antecedent
, int32_t assoc_id
,
497 int32_t match
, char **id_list
)
502 EAssocList_t
*ap
= &hdlp
->assoc_tbl
[assoc_id
];
504 if (ap
->table
== 0) {
509 key
= psvc_get_str_key(antecedent
);
511 for (i
= 0; i
< ap
->count
; ++i
) {
512 if (ap
->table
[i
].ant_key
== key
) {
513 if (strcmp(ap
->table
[i
].antecedent_id
, antecedent
)
515 if (found
== match
) {
516 *id_list
= ap
->table
[i
].dependent_id
;
529 i_psvc_get_table_value(EHdl_t
*hdlp
, char *table_id
, uint32_t index
,
534 ETable_Array
*tbl_arr
;
537 key
= psvc_get_str_key(table_id
);
538 array
= key
% PSVC_MAX_TABLE_ARRAYS
;
539 tbl_arr
= &(hdlp
->tbl_arry
[array
]);
541 for (i
= 0; i
< tbl_arr
->obj_count
; ++i
) {
542 if (key
== tbl_arr
->obj_tbl
[i
].key
) {
543 if (strcmp(tbl_arr
->obj_tbl
[i
].name
,
549 if (tbl_arr
->obj_tbl
[i
].type
!= PSVC_TBL
)
550 return (PSVC_FAILURE
);
552 tblp
= (ETable_t
*)tbl_arr
->obj_tbl
[i
].objp
;
554 if (tblp
->table
== NULL
)
555 return (PSVC_FAILURE
);
557 if (index
>= tblp
->size
)
558 return (PSVC_FAILURE
);
560 switch (tblp
->cell_type
) {
562 *(int8_t *)value
= *((int8_t *)tblp
->table
+ index
);
565 *(uint8_t *)value
= *((uint8_t *)tblp
->table
+ index
);
568 *(int16_t *)value
= *((int16_t *)tblp
->table
+ index
);
571 *(uint16_t *)value
= *((uint16_t *)tblp
->table
+ index
);
574 *(int32_t *)value
= *((int32_t *)tblp
->table
+ index
);
577 *(uint32_t *)value
= *((uint32_t *)tblp
->table
+ index
);
580 *(int64_t *)value
= *((int64_t *)tblp
->table
+ index
);
583 *(uint64_t *)value
= *((uint64_t *)tblp
->table
+ index
);
586 return (PSVC_FAILURE
);
589 return (PSVC_SUCCESS
);
593 psvc_get_attr(EHdl_t
*hdlp
, char *name
, int32_t attr_id
, void *attr_valuep
, ...)
596 int32_t status
= PSVC_SUCCESS
;
600 pthread_mutex_lock(&hdlp
->mutex
);
602 if (attr_valuep
== NULL
) {
604 pthread_mutex_unlock(&hdlp
->mutex
);
605 return (PSVC_FAILURE
);
609 case PSVC_TABLE_VALUE_ATTR
:
610 va_start(ap
, attr_valuep
);
611 status
= i_psvc_get_table_value(hdlp
, name
,
612 va_arg(ap
, uint32_t), attr_valuep
);
615 case PSVC_ASSOC_MATCHES_ATTR
:
616 va_start(ap
, attr_valuep
);
617 status
= i_psvc_get_assoc_matches(hdlp
, name
,
618 va_arg(ap
, int32_t), attr_valuep
);
621 case PSVC_ASSOC_ID_ATTR
:
622 va_start(ap
, attr_valuep
);
623 arg1
= va_arg(ap
, int32_t);
624 arg2
= va_arg(ap
, int32_t);
625 status
= i_psvc_get_assoc_id(hdlp
, name
,
626 arg1
, arg2
, attr_valuep
);
630 status
= i_psvc_get_obj(hdlp
, name
, &objp
);
631 if (status
!= PSVC_SUCCESS
) {
632 pthread_mutex_unlock(&hdlp
->mutex
);
635 status
= (*objp
->get_attr
)(hdlp
, objp
, attr_id
,
639 if (status
!= PSVC_SUCCESS
) {
640 pthread_mutex_unlock(&hdlp
->mutex
);
644 pthread_mutex_unlock(&hdlp
->mutex
);
649 psvc_set_attr(EHdl_t
*hdlp
, char *name
, int32_t attr_id
, void *attr_valuep
)
652 int32_t status
= PSVC_SUCCESS
;
654 pthread_mutex_lock(&hdlp
->mutex
);
655 status
= i_psvc_get_obj(hdlp
, name
, &objp
);
656 if (status
!= PSVC_SUCCESS
) {
657 pthread_mutex_unlock(&hdlp
->mutex
);
661 if (attr_valuep
== NULL
) {
663 pthread_mutex_unlock(&hdlp
->mutex
);
664 return (PSVC_FAILURE
);
667 status
= (*objp
->set_attr
)(hdlp
, objp
, attr_id
, attr_valuep
);
668 if (status
!= PSVC_SUCCESS
) {
669 pthread_mutex_unlock(&hdlp
->mutex
);
673 pthread_mutex_unlock(&hdlp
->mutex
);
679 i_psvc_get_presence(EHdl_t
*hdlp
, EObj_t
*objp
, boolean_t
*pr
)
681 EObj_t
*pobjp
, *mobjp
;
685 int32_t status
= PSVC_SUCCESS
;
686 uint8_t value_8bit
, value_8bit_inv
;
687 boolean_t active_low
, value
;
689 if (strcmp(objp
->label
, PSVC_CHASSIS
) == 0) {
691 objp
->present
= PSVC_PRESENT
;
692 return (PSVC_SUCCESS
);
695 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PARENT
, 0,
697 if (status
!= PSVC_SUCCESS
)
700 if (strcmp(parent_id
, PSVC_CHASSIS
)) {
701 status
= i_psvc_get_obj(hdlp
, parent_id
, &pobjp
);
702 if (status
!= PSVC_SUCCESS
)
704 if (!pobjp
->present
) {
705 pobjp
->get_attr(hdlp
, pobjp
, PSVC_PRESENCE_ATTR
, pr
);
706 *pr
= pobjp
->present
;
707 objp
->present
= pobjp
->present
;
712 (void) i_psvc_get_assoc_matches(hdlp
, objp
->label
,
713 PSVC_PRESENCE_SENSOR
, &matches
);
716 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
,
717 PSVC_PRESENCE_SENSOR
, 0, &mid
);
718 if (status
!= PSVC_SUCCESS
)
720 status
= i_psvc_get_obj(hdlp
, mid
, &mobjp
);
721 if (status
!= PSVC_SUCCESS
)
724 active_low
= PSVC_IS_ACTIVE_LOW(mobjp
->addr_spec
);
726 if (mobjp
->class == PSVC_BOOLEAN_GPIO_CLASS
) {
727 status
= mobjp
->get_attr(hdlp
, mobjp
,
728 PSVC_GPIO_VALUE_ATTR
, &value
);
729 if (status
!= PSVC_SUCCESS
)
741 } else if (mobjp
->class == PSVC_8BIT_GPIO_CLASS
) {
742 uint8_t bitshift
, bytemask
;
744 status
= mobjp
->get_attr(hdlp
, mobjp
,
745 PSVC_GPIO_VALUE_ATTR
, &value_8bit
);
746 if (status
!= PSVC_SUCCESS
)
748 if (PSVC_HP_INVERT(mobjp
->addr_spec
))
749 value_8bit_inv
= ~value_8bit
;
751 value_8bit_inv
= value_8bit
;
752 bitshift
= PSVC_GET_ASPEC_BITSHIFT(mobjp
->addr_spec
);
753 bytemask
= PSVC_GET_ASPEC_BYTEMASK(mobjp
->addr_spec
);
755 value_8bit_inv
& (bytemask
>> bitshift
);
757 if (value_8bit_inv
== 0)
762 if (value_8bit_inv
== 0)
768 return (PSVC_FAILURE
);
780 i_psvc_get_device_value_0_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t *temp
)
782 int32_t status
= PSVC_SUCCESS
, m
;
788 if (objp
->present
!= PSVC_PRESENT
) {
790 return (PSVC_FAILURE
);
793 status
= i_psvc_get_assoc_id(
794 hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
, 0, &physid
);
795 if (status
!= PSVC_SUCCESS
) {
798 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
799 if (status
!= PSVC_SUCCESS
) {
803 status
= ((EPhysDev_t
*)physobjp
)->get_temperature(hdlp
,
804 objp
->addr_spec
, temp
);
805 if (status
!= PSVC_SUCCESS
) {
809 if (objp
->features
& PSVC_CONVERSION_TABLE
) {
810 status
= i_psvc_get_assoc_matches(hdlp
, objp
->label
,
812 if ((status
!= PSVC_SUCCESS
) || (m
!= 1)) {
816 (void) i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_TABLE
, 0,
819 status
= i_psvc_get_table_value(hdlp
, tid
, *temp
, &temp16
);
826 i_psvc_get_device_value_0_1(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t *temp
)
828 int32_t status
= PSVC_SUCCESS
, m
;
834 if (objp
->present
!= PSVC_PRESENT
) {
836 return (PSVC_FAILURE
);
839 status
= i_psvc_get_assoc_id(
840 hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
, 0, &physid
);
841 if (status
!= PSVC_SUCCESS
) {
844 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
845 if (status
!= PSVC_SUCCESS
) {
849 status
= ((EPhysDev_t
*)physobjp
)->get_temperature(hdlp
,
850 objp
->addr_spec
, temp
);
851 if (status
!= PSVC_SUCCESS
) {
855 if (objp
->features
& PSVC_CONVERSION_TABLE
) {
856 status
= i_psvc_get_assoc_matches(hdlp
, objp
->label
,
858 if ((status
!= PSVC_SUCCESS
) || (m
!= 1)) {
862 (void) i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_TABLE
, 0,
865 status
= i_psvc_get_table_value(hdlp
, tid
, *temp
, &temp16
);
872 i_psvc_get_device_value_4_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t *value
)
874 int32_t status
= PSVC_SUCCESS
;
878 if (objp
->present
!= PSVC_PRESENT
) {
880 return (PSVC_FAILURE
);
883 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
885 if (status
!= PSVC_SUCCESS
)
887 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
888 if (status
!= PSVC_SUCCESS
)
891 status
= ((EPhysDev_t
*)physobjp
)->get_input(hdlp
, objp
->addr_spec
,
893 if (status
!= PSVC_SUCCESS
)
896 if (objp
->features
& PSVC_CONVERSION_TABLE
) {
901 status
= i_psvc_get_assoc_matches(hdlp
, objp
->label
,
903 if ((status
!= PSVC_SUCCESS
) || (m
!= 1)) {
907 (void) i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_TABLE
, 0,
910 status
= i_psvc_get_table_value(hdlp
, tid
, *value
, &temp16
);
918 i_psvc_set_device_value_5_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t *value
)
920 int32_t status
= PSVC_SUCCESS
;
924 if (objp
->present
!= PSVC_PRESENT
) {
926 return (PSVC_FAILURE
);
929 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
931 if (status
!= PSVC_SUCCESS
)
933 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
934 if (status
!= PSVC_SUCCESS
)
936 status
= ((EPhysDev_t
*)physobjp
)->set_output(hdlp
, objp
->addr_spec
,
938 if (status
!= PSVC_SUCCESS
)
945 i_psvc_get_device_value_5_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t *value
)
947 int32_t status
= PSVC_SUCCESS
;
951 if (objp
->present
!= PSVC_PRESENT
) {
953 return (PSVC_FAILURE
);
956 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
958 if (status
!= PSVC_SUCCESS
)
960 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
961 if (status
!= PSVC_SUCCESS
)
964 status
= ((EPhysDev_t
*)physobjp
)->get_output(hdlp
, objp
->addr_spec
,
966 if (status
!= PSVC_SUCCESS
)
969 if (objp
->features
& PSVC_CONVERSION_TABLE
) {
974 status
= i_psvc_get_assoc_matches(hdlp
, objp
->label
,
976 if ((status
!= PSVC_SUCCESS
) || (m
!= 1)) {
980 (void) i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_TABLE
, 0,
983 status
= i_psvc_get_table_value(hdlp
, tid
, *value
, &temp16
);
990 i_psvc_get_device_value_6_0(EHdl_t
*hdlp
, EObj_t
*objp
, boolean_t
*value
)
992 int32_t status
= PSVC_SUCCESS
;
997 if (objp
->present
!= PSVC_PRESENT
) {
999 return (PSVC_FAILURE
);
1002 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1004 if (status
!= PSVC_SUCCESS
)
1006 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1007 if (status
!= PSVC_SUCCESS
)
1010 status
= ((EPhysDev_t
*)physobjp
)->get_bit(hdlp
, objp
->addr_spec
,
1012 if (status
!= PSVC_SUCCESS
)
1021 i_psvc_set_device_value_6_0(EHdl_t
*hdlp
, EObj_t
*objp
, boolean_t
*value
)
1023 int32_t status
= PSVC_SUCCESS
;
1028 if (objp
->present
!= PSVC_PRESENT
) {
1030 return (PSVC_FAILURE
);
1034 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1036 if (status
!= PSVC_SUCCESS
)
1038 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1039 if (status
!= PSVC_SUCCESS
)
1042 status
= ((EPhysDev_t
*)physobjp
)->set_bit(hdlp
, objp
->addr_spec
,
1044 if (status
!= PSVC_SUCCESS
)
1051 i_psvc_get_device_value_1_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t *fan_speed
)
1053 int32_t status
= PSVC_SUCCESS
;
1057 if (objp
->present
!= PSVC_PRESENT
) {
1059 return (PSVC_FAILURE
);
1062 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
,
1063 PSVC_FAN_SPEED_TACHOMETER
, 0, &fan_tach
);
1064 if (status
!= PSVC_SUCCESS
)
1067 status
= i_psvc_get_obj(hdlp
, fan_tach
, &ftobjp
);
1068 if (status
!= PSVC_SUCCESS
)
1071 status
= ftobjp
->get_attr(hdlp
, ftobjp
, PSVC_SENSOR_VALUE_ATTR
,
1073 if (status
!= PSVC_SUCCESS
)
1080 i_psvc_get_device_value_7_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t *fan_speed
)
1084 int32_t status
= PSVC_SUCCESS
;
1086 if (objp
->present
!= PSVC_PRESENT
) {
1088 return (PSVC_FAILURE
);
1091 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1093 if (status
!= PSVC_SUCCESS
)
1095 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1096 if (status
!= PSVC_SUCCESS
)
1099 status
= ((EPhysDev_t
*)physobjp
)->get_fanspeed(hdlp
, objp
->addr_spec
,
1101 if (status
!= PSVC_SUCCESS
)
1104 if (objp
->features
& PSVC_CONVERSION_TABLE
) {
1109 status
= i_psvc_get_assoc_matches(hdlp
, objp
->label
,
1111 if ((status
!= PSVC_SUCCESS
) || (m
!= 1)) {
1115 (void) i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_TABLE
, 0,
1118 status
= i_psvc_get_table_value(hdlp
, tid
, *fan_speed
, &temp16
);
1119 *fan_speed
= temp16
;
1125 i_psvc_get_device_state_2_0(EHdl_t
*hdlp
, EObj_t
*objp
, char *led_state
)
1127 int32_t status
= PSVC_SUCCESS
;
1129 boolean_t active_low
;
1133 if (objp
->present
!= PSVC_PRESENT
) {
1135 return (PSVC_FAILURE
);
1138 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1140 if (status
!= PSVC_SUCCESS
)
1142 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1143 if (status
!= PSVC_SUCCESS
)
1146 status
= ((EPhysDev_t
*)physobjp
)->get_bit(hdlp
, objp
->addr_spec
,
1148 if (status
!= PSVC_SUCCESS
)
1151 active_low
= PSVC_IS_ACTIVE_LOW(objp
->addr_spec
);
1154 strcpy(led_state
, PSVC_LED_ON
);
1156 strcpy(led_state
, PSVC_LED_OFF
);
1159 strcpy(led_state
, PSVC_LED_OFF
);
1161 strcpy(led_state
, PSVC_LED_ON
);
1167 i_psvc_set_device_state_2_0(EHdl_t
*hdlp
, EObj_t
*objp
, char *led_state
)
1169 int32_t status
= PSVC_SUCCESS
;
1170 boolean_t active_low
;
1175 if (objp
->present
!= PSVC_PRESENT
) {
1177 return (PSVC_FAILURE
);
1180 if (strcmp(((ELed_t
*)objp
)->is_locator
, PSVC_LOCATOR_TRUE
) != 0) {
1182 * For Locator LEDs we ignore lit_count. RSC may have
1183 * altered the LED state underneath us, So we should
1184 * always just do what the user asked instead of trying
1188 if (strcmp(led_state
, PSVC_LED_ON
) == 0)
1189 ((ELed_t
*)objp
)->lit_count
++;
1190 else if (strcmp(led_state
, PSVC_LED_OFF
) == 0) {
1191 if (--((ELed_t
*)objp
)->lit_count
> 0) {
1192 return (PSVC_SUCCESS
);
1193 } else if (((ELed_t
*)objp
)->lit_count
< 0)
1194 ((ELed_t
*)objp
)->lit_count
= 0;
1195 /* Fall through case is when lit_count is 0 */
1199 strcpy(objp
->previous_state
, objp
->state
);
1200 strcpy(objp
->state
, led_state
);
1202 bit_value
= (strcmp(led_state
, PSVC_LED_ON
) == 0);
1205 * Flip the bit if necessary (for active_low devices,
1206 * O ==> ON; 1 ==> OFF.
1208 active_low
= PSVC_IS_ACTIVE_LOW(objp
->addr_spec
);
1209 bit_value
^= active_low
;
1211 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1213 if (status
!= PSVC_SUCCESS
)
1215 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1216 if (status
!= PSVC_SUCCESS
)
1219 status
= ((EPhysDev_t
*)physobjp
)->set_bit(hdlp
, objp
->addr_spec
,
1225 i_psvc_get_device_state_2_1(EHdl_t
*hdlp
, EObj_t
*objp
, char *led_state
)
1227 int32_t status
= PSVC_SUCCESS
;
1232 if (objp
->present
!= PSVC_PRESENT
) {
1234 return (PSVC_FAILURE
);
1237 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1239 if (status
!= PSVC_SUCCESS
)
1241 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1242 if (status
!= PSVC_SUCCESS
)
1245 status
= ((EPhysDev_t
*)physobjp
)->get_reg(hdlp
, objp
->addr_spec
,
1247 if (status
!= PSVC_SUCCESS
)
1252 strcpy(led_state
, PSVC_LED_OFF
);
1255 strcpy(led_state
, PSVC_LED_SLOW_BLINK
);
1258 strcpy(led_state
, PSVC_LED_FAST_BLINK
);
1261 strcpy(led_state
, PSVC_LED_ON
);
1269 i_psvc_set_device_state_2_1(EHdl_t
*hdlp
, EObj_t
*objp
, char *led_state
)
1271 int32_t status
= PSVC_SUCCESS
;
1276 if (objp
->present
!= PSVC_PRESENT
) {
1278 return (PSVC_FAILURE
);
1281 if (strcmp(led_state
, PSVC_LED_ON
) == 0)
1282 ((ELed_t
*)objp
)->lit_count
++;
1283 else if (strcmp(led_state
, PSVC_LED_OFF
) == 0) {
1284 if (--((ELed_t
*)objp
)->lit_count
> 0) {
1285 return (PSVC_SUCCESS
);
1286 } else if (((ELed_t
*)objp
)->lit_count
< 0)
1287 ((ELed_t
*)objp
)->lit_count
= 0;
1289 /* Fall through case is when lit_count is 0 */
1292 strcpy(objp
->previous_state
, objp
->state
);
1293 strcpy(objp
->state
, led_state
);
1295 if (strcmp(led_state
, PSVC_LED_OFF
) == 0)
1297 else if (strcmp(led_state
, PSVC_LED_SLOW_BLINK
) == 0)
1299 else if (strcmp(led_state
, PSVC_LED_FAST_BLINK
) == 0)
1301 else if (strcmp(led_state
, PSVC_LED_ON
) == 0)
1304 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1306 if (status
!= PSVC_SUCCESS
)
1308 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1309 if (status
!= PSVC_SUCCESS
)
1312 status
= ((EPhysDev_t
*)physobjp
)->set_reg(hdlp
, objp
->addr_spec
,
1319 i_psvc_get_device_state_9_0(EHdl_t
*hdlp
, EObj_t
*objp
, char *pos
)
1321 int32_t status
= PSVC_SUCCESS
, matches
;
1326 if (objp
->present
!= PSVC_PRESENT
) {
1328 return (PSVC_FAILURE
);
1331 if (objp
->features
& PSVC_NORMAL_POS_AV
) {
1332 (void) i_psvc_get_assoc_matches(hdlp
, objp
->label
,
1333 PSVC_KS_NORMAL_POS_SENSOR
, &matches
);
1335 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
,
1336 PSVC_KS_NORMAL_POS_SENSOR
, 0, &sensorid
);
1337 if (status
!= PSVC_SUCCESS
)
1340 status
= i_psvc_get_obj(hdlp
, sensorid
, &sensorp
);
1341 if (status
!= PSVC_SUCCESS
)
1344 status
= sensorp
->get_attr(hdlp
, sensorp
,
1345 PSVC_SWITCH_STATE_ATTR
, state
);
1346 if (status
!= PSVC_SUCCESS
)
1349 if (strcmp(state
, PSVC_SWITCH_ON
) == 0) {
1350 strcpy(pos
, PSVC_NORMAL_POS
);
1351 return (PSVC_SUCCESS
);
1356 if (objp
->features
& PSVC_DIAG_POS_AV
) {
1357 (void) i_psvc_get_assoc_matches(hdlp
, objp
->label
,
1358 PSVC_KS_DIAG_POS_SENSOR
, &matches
);
1360 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
,
1361 PSVC_KS_DIAG_POS_SENSOR
, 0, &sensorid
);
1362 if (status
!= PSVC_SUCCESS
)
1365 status
= i_psvc_get_obj(hdlp
, sensorid
, &sensorp
);
1366 if (status
!= PSVC_SUCCESS
)
1369 status
= sensorp
->get_attr(hdlp
, sensorp
,
1370 PSVC_SWITCH_STATE_ATTR
, state
);
1371 if (status
!= PSVC_SUCCESS
)
1374 if (strcmp(state
, PSVC_SWITCH_ON
) == 0) {
1375 strcpy(pos
, PSVC_DIAG_POS
);
1376 return (PSVC_SUCCESS
);
1381 if (objp
->features
& PSVC_LOCK_POS_AV
) {
1382 (void) i_psvc_get_assoc_matches(hdlp
, objp
->label
,
1383 PSVC_KS_LOCK_POS_SENSOR
, &matches
);
1385 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
,
1386 PSVC_KS_LOCK_POS_SENSOR
, 0, &sensorid
);
1387 if (status
!= PSVC_SUCCESS
)
1390 status
= i_psvc_get_obj(hdlp
, sensorid
, &sensorp
);
1391 if (status
!= PSVC_SUCCESS
)
1394 status
= sensorp
->get_attr(hdlp
, sensorp
,
1395 PSVC_SWITCH_STATE_ATTR
, state
);
1396 if (status
!= PSVC_SUCCESS
)
1399 if (strcmp(state
, PSVC_SWITCH_ON
) == 0) {
1400 strcpy(pos
, PSVC_LOCKED_POS
);
1401 return (PSVC_SUCCESS
);
1406 if (objp
->features
& PSVC_OFF_POS_AV
) {
1407 (void) i_psvc_get_assoc_matches(hdlp
, objp
->label
,
1408 PSVC_KS_OFF_POS_SENSOR
, &matches
);
1410 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
,
1411 PSVC_KS_OFF_POS_SENSOR
, 0, &sensorid
);
1412 if (status
!= PSVC_SUCCESS
)
1415 status
= i_psvc_get_obj(hdlp
, sensorid
, &sensorp
);
1416 if (status
!= PSVC_SUCCESS
)
1419 status
= sensorp
->get_attr(hdlp
, sensorp
,
1420 PSVC_SWITCH_STATE_ATTR
, state
);
1421 if (status
!= PSVC_SUCCESS
)
1424 if (strcmp(state
, PSVC_SWITCH_ON
) == 0) {
1425 strcpy(pos
, PSVC_OFF_POS
);
1426 return (PSVC_SUCCESS
);
1430 /* If we have fallen through till here, something's wrong */
1432 return (PSVC_FAILURE
);
1437 i_psvc_get_device_value_10_0(EHdl_t
*hdlp
, EObj_t
*objp
, uint8_t *value
)
1439 int32_t status
= PSVC_SUCCESS
;
1443 if (objp
->present
!= PSVC_PRESENT
) {
1445 return (PSVC_FAILURE
);
1448 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1450 if (status
!= PSVC_SUCCESS
)
1452 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1453 if (status
!= PSVC_SUCCESS
)
1456 status
= ((EPhysDev_t
*)physobjp
)->get_reg(hdlp
, objp
->addr_spec
,
1458 if (status
!= PSVC_SUCCESS
)
1461 if (objp
->features
& PSVC_CONVERSION_TABLE
) {
1466 status
= i_psvc_get_assoc_matches(hdlp
, objp
->label
,
1468 if ((status
!= PSVC_SUCCESS
) || (m
!= 1)) {
1472 (void) i_psvc_get_assoc_id(hdlp
, objp
->label
,
1473 PSVC_TABLE
, 0, &tid
);
1475 status
= i_psvc_get_table_value(hdlp
, tid
, *value
, &temp8
);
1482 i_psvc_get_device_value_10_1(EHdl_t
*hdlp
, EObj_t
*objp
, uint8_t *value
)
1484 int32_t status
= PSVC_SUCCESS
;
1488 if (objp
->present
!= PSVC_PRESENT
) {
1490 return (PSVC_FAILURE
);
1493 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1495 if (status
!= PSVC_SUCCESS
)
1497 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1498 if (status
!= PSVC_SUCCESS
)
1501 status
= ((EPhysDev_t
*)physobjp
)->get_port(hdlp
, objp
->addr_spec
,
1503 if (status
!= PSVC_SUCCESS
)
1510 i_psvc_set_device_value_10_0(EHdl_t
*hdlp
, EObj_t
*objp
, uint8_t *value
)
1512 int32_t status
= PSVC_SUCCESS
;
1516 if (objp
->present
!= PSVC_PRESENT
) {
1518 return (PSVC_FAILURE
);
1521 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1523 if (status
!= PSVC_SUCCESS
)
1525 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1526 if (status
!= PSVC_SUCCESS
)
1529 status
= ((EPhysDev_t
*)physobjp
)->set_reg(hdlp
, objp
->addr_spec
,
1535 i_psvc_set_device_value_10_1(EHdl_t
*hdlp
, EObj_t
*objp
, uint8_t *value
)
1537 int32_t status
= PSVC_SUCCESS
;
1541 if (objp
->present
!= PSVC_PRESENT
) {
1543 return (PSVC_FAILURE
);
1546 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1548 if (status
!= PSVC_SUCCESS
)
1550 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1551 if (status
!= PSVC_SUCCESS
)
1554 status
= ((EPhysDev_t
*)physobjp
)->set_port(hdlp
, objp
->addr_spec
,
1560 i_psvc_get_device_state_8_0(EHdl_t
*hdlp
, EObj_t
*objp
, char *sw_state
)
1562 int32_t status
= PSVC_SUCCESS
;
1563 boolean_t active_low
;
1568 if (objp
->present
!= PSVC_PRESENT
) {
1570 return (PSVC_FAILURE
);
1573 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1575 if (status
!= PSVC_SUCCESS
)
1577 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1578 if (status
!= PSVC_SUCCESS
)
1581 status
= ((EPhysDev_t
*)physobjp
)->get_bit(hdlp
, objp
->addr_spec
,
1583 if (status
!= PSVC_SUCCESS
)
1586 active_low
= PSVC_IS_ACTIVE_LOW(objp
->addr_spec
);
1589 strcpy(sw_state
, PSVC_SWITCH_ON
);
1591 strcpy(sw_state
, PSVC_SWITCH_OFF
);
1594 strcpy(sw_state
, PSVC_SWITCH_OFF
);
1596 strcpy(sw_state
, PSVC_SWITCH_ON
);
1602 i_psvc_set_device_state_8_0(EHdl_t
*hdlp
, EObj_t
*objp
, char *sw_state
)
1604 int32_t status
= PSVC_SUCCESS
;
1605 boolean_t active_low
;
1610 if (objp
->present
!= PSVC_PRESENT
) {
1612 return (PSVC_FAILURE
);
1615 strcpy(objp
->previous_state
, objp
->state
);
1616 strcpy(objp
->state
, sw_state
);
1618 active_low
= PSVC_IS_ACTIVE_LOW(objp
->addr_spec
);
1621 if (strcmp(sw_state
, PSVC_SWITCH_ON
) == 0)
1626 if (strcmp(sw_state
, PSVC_SWITCH_ON
) == 0)
1631 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1633 if (status
!= PSVC_SUCCESS
)
1635 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1636 if (status
!= PSVC_SUCCESS
)
1639 status
= ((EPhysDev_t
*)physobjp
)->set_bit(hdlp
, objp
->addr_spec
,
1646 i_psvc_get_temperature_11_2(EHdl_t
*hdlp
, uint64_t aspec
, int32_t *temp
)
1648 int32_t status
= PSVC_SUCCESS
;
1653 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1654 if (status
!= PSVC_SUCCESS
)
1657 fp
= open(path
, O_RDWR
);
1659 return (PSVC_FAILURE
);
1661 status
= ioctl_retry(fp
, I2C_GET_TEMPERATURE
, (void *)&temp16
);
1665 return (PSVC_FAILURE
);
1676 i_psvc_get_temperature_11_4(EHdl_t
*hdlp
, uint64_t aspec
, int32_t *temp
)
1678 int32_t status
= PSVC_SUCCESS
;
1683 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1684 if (status
!= PSVC_SUCCESS
)
1687 fp
= open(path
, O_RDWR
);
1689 return (PSVC_FAILURE
);
1691 status
= ioctl_retry(fp
, I2C_GET_TEMPERATURE
, (void *)&temp16
);
1695 return (PSVC_FAILURE
);
1706 i_psvc_get_temperature_11_6(EHdl_t
*hdlp
, uint64_t aspec
, int32_t *temp
)
1708 int32_t status
= PSVC_SUCCESS
;
1712 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1713 if (status
!= PSVC_SUCCESS
)
1716 fp
= open(path
, O_RDWR
);
1718 return (PSVC_FAILURE
);
1720 status
= ioctl_retry(fp
, I2C_GET_INPUT
, (void *)temp
);
1734 i_psvc_get_fanspeed_11_7(EHdl_t
*hdlp
, uint64_t aspec
, int32_t *fan_speed
)
1736 int32_t ret
, status
= PSVC_SUCCESS
;
1740 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1741 if (status
!= PSVC_SUCCESS
)
1744 fp
= open(path
, O_RDWR
);
1746 return (PSVC_FAILURE
);
1748 ret
= ioctl_retry(fp
, I2C_GET_FAN_SPEED
, (void *)fan_speed
);
1762 i_psvc_get_input_11_6(EHdl_t
*hdlp
, uint64_t aspec
, int32_t *value
)
1764 int32_t ret
, status
= PSVC_SUCCESS
;
1768 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1769 if (status
!= PSVC_SUCCESS
)
1772 fp
= open(path
, O_RDWR
);
1774 return (PSVC_FAILURE
);
1776 ret
= ioctl_retry(fp
, I2C_GET_INPUT
, (void *)value
);
1790 i_psvc_get_output_11_3(EHdl_t
*hdlp
, uint64_t aspec
, int32_t *value
)
1792 int32_t ret
, status
= PSVC_SUCCESS
;
1796 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1797 if (status
!= PSVC_SUCCESS
)
1800 fp
= open(path
, O_RDWR
);
1802 return (PSVC_FAILURE
);
1804 ret
= ioctl_retry(fp
, I2C_GET_OUTPUT
, (void *)value
);
1808 return (PSVC_FAILURE
);
1818 i_psvc_get_output_11_6(EHdl_t
*hdlp
, uint64_t aspec
, int32_t *value
)
1820 int32_t ret
, status
= PSVC_SUCCESS
;
1824 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1825 if (status
!= PSVC_SUCCESS
)
1828 fp
= open(path
, O_RDWR
);
1830 return (PSVC_FAILURE
);
1832 ret
= ioctl_retry(fp
, I2C_GET_OUTPUT
, (void *)value
);
1836 return (PSVC_FAILURE
);
1846 i_psvc_get_output_11_8(EHdl_t
*hdlp
, uint64_t aspec
, int32_t *value
)
1848 int32_t ret
, status
= PSVC_SUCCESS
;
1853 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1854 if (status
!= PSVC_SUCCESS
)
1857 fp
= open(path
, O_RDWR
);
1859 return (PSVC_FAILURE
);
1861 ret
= read(fp
, &buf
, 1);
1865 return (PSVC_FAILURE
);
1876 i_psvc_set_output_11_3(EHdl_t
*hdlp
, uint64_t aspec
, int32_t value
)
1878 int32_t ret
, status
= PSVC_SUCCESS
;
1882 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1883 if (status
!= PSVC_SUCCESS
)
1886 fp
= open(path
, O_RDWR
);
1888 return (PSVC_FAILURE
);
1890 ret
= ioctl_retry(fp
, I2C_SET_OUTPUT
, (void *)&value
);
1894 return (PSVC_FAILURE
);
1904 i_psvc_set_output_11_6(EHdl_t
*hdlp
, uint64_t aspec
, int32_t value
)
1906 int32_t ret
, status
= PSVC_SUCCESS
;
1910 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1911 if (status
!= PSVC_SUCCESS
)
1914 fp
= open(path
, O_RDWR
);
1916 return (PSVC_FAILURE
);
1918 ret
= ioctl_retry(fp
, I2C_SET_OUTPUT
, (void *)&value
);
1922 return (PSVC_FAILURE
);
1932 i_psvc_set_output_11_8(EHdl_t
*hdlp
, uint64_t aspec
, int32_t value
)
1934 int32_t ret
, status
= PSVC_SUCCESS
;
1939 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1940 if (status
!= PSVC_SUCCESS
)
1943 fp
= open(path
, O_RDWR
);
1945 return (PSVC_FAILURE
);
1948 ret
= write(fp
, &buf
, 1);
1952 return (PSVC_FAILURE
);
1962 i_psvc_get_reg_11_1(EHdl_t
*hdlp
, uint64_t aspec
, uint8_t *value
)
1964 int32_t ret
, status
= PSVC_SUCCESS
;
1965 uint8_t bitshift
, bytemask
;
1967 i2c_reg_t i2cregarg
;
1970 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1971 if (status
!= PSVC_SUCCESS
)
1973 fp
= open(path
, O_RDWR
);
1975 return (PSVC_FAILURE
);
1977 i2cregarg
.reg_num
= PSVC_GET_ASPEC_REG(aspec
);
1978 ret
= ioctl_retry(fp
, I2C_GET_REG
, (void *)&i2cregarg
);
1985 bitshift
= PSVC_GET_ASPEC_BITSHIFT(aspec
);
1986 bytemask
= PSVC_GET_ASPEC_BYTEMASK(aspec
);
1988 *value
= (i2cregarg
.reg_value
& bytemask
) >> bitshift
;
1996 i_psvc_get_reg_11_7(EHdl_t
*hdlp
, uint64_t aspec
, uint8_t *value
)
1998 int32_t ret
, status
= PSVC_SUCCESS
;
1999 uint8_t bitshift
, bytemask
;
2001 i2c_reg_t i2cregarg
;
2004 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
2005 if (status
!= PSVC_SUCCESS
)
2008 fp
= open(path
, O_RDWR
);
2010 return (PSVC_FAILURE
);
2012 i2cregarg
.reg_num
= PSVC_GET_ASPEC_REG(aspec
);
2013 ret
= ioctl_retry(fp
, I2C_GET_REG
, (void *)&i2cregarg
);
2020 bitshift
= PSVC_GET_ASPEC_BITSHIFT(aspec
);
2021 bytemask
= PSVC_GET_ASPEC_BYTEMASK(aspec
);
2023 *value
= (i2cregarg
.reg_value
& bytemask
) >> bitshift
;
2032 i_psvc_set_reg_11_1(EHdl_t
*hdlp
, uint64_t aspec
, int32_t value
)
2034 int32_t ret
, status
= PSVC_SUCCESS
;
2036 i2c_reg_t i2cregarg
;
2038 uint8_t bitshift
, bytemask
;
2041 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
2042 if (status
!= PSVC_SUCCESS
)
2045 bitshift
= PSVC_GET_ASPEC_BITSHIFT(aspec
);
2046 bytemask
= PSVC_GET_ASPEC_BYTEMASK(aspec
);
2047 value
= value
<< bitshift
;
2049 fp
= open(path
, O_RDWR
);
2051 return (PSVC_FAILURE
);
2053 i2cregarg
.reg_num
= PSVC_GET_ASPEC_REG(aspec
);
2054 if (bytemask
!= 0xFF) {
2055 ret
= ioctl_retry(fp
, I2C_GET_REG
, (void *)&i2cregarg
);
2061 tval
= i2cregarg
.reg_value
;
2062 tval
= tval
& ~bytemask
;
2066 value
= tval
| value
;
2067 i2cregarg
.reg_value
= value
;
2068 ret
= ioctl_retry(fp
, I2C_SET_REG
, (void *)&i2cregarg
);
2082 i_psvc_set_reg_11_7(EHdl_t
*hdlp
, uint64_t aspec
, int32_t value
)
2084 int32_t ret
, status
= PSVC_SUCCESS
;
2086 i2c_reg_t i2cregarg
;
2088 uint8_t bitshift
, bytemask
;
2091 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
2092 if (status
!= PSVC_SUCCESS
)
2095 bitshift
= PSVC_GET_ASPEC_BITSHIFT(aspec
);
2096 bytemask
= PSVC_GET_ASPEC_BYTEMASK(aspec
);
2097 value
= value
<< bitshift
;
2099 fp
= open(path
, O_RDWR
);
2101 return (PSVC_FAILURE
);
2103 i2cregarg
.reg_num
= PSVC_GET_ASPEC_REG(aspec
);
2104 if (bytemask
!= 0xFF) {
2105 ret
= ioctl_retry(fp
, I2C_GET_REG
, (void *)&i2cregarg
);
2111 tval
= i2cregarg
.reg_value
;
2112 tval
= tval
& ~bytemask
;
2116 value
= tval
| value
;
2117 i2cregarg
.reg_value
= value
;
2118 ret
= ioctl_retry(fp
, I2C_SET_REG
, (void *)&i2cregarg
);
2132 i_psvc_get_bit_11_5(EHdl_t
*hdlp
, uint64_t aspec
, int32_t *value
)
2134 int32_t ret
, status
= PSVC_SUCCESS
;
2139 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
2140 if (status
!= PSVC_SUCCESS
)
2143 bitarg
.bit_num
= PSVC_GET_BIT_NUM(aspec
);
2144 bitarg
.direction
= DIR_NO_CHANGE
;
2146 fp
= open(path
, O_RDWR
);
2148 return (PSVC_FAILURE
);
2150 ret
= ioctl_retry(fp
, I2C_GET_BIT
, (void *)&bitarg
);
2157 *value
= bitarg
.bit_value
;
2166 i_psvc_get_port_11_5(EHdl_t
*hdlp
, uint64_t aspec
, uint8_t *value
)
2168 int32_t ret
, status
= PSVC_SUCCESS
;
2173 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
2174 if (status
!= PSVC_SUCCESS
)
2177 port
.direction
= DIR_NO_CHANGE
;
2179 fp
= open(path
, O_RDWR
);
2181 return (PSVC_FAILURE
);
2183 ret
= ioctl_retry(fp
, I2C_GET_PORT
, (void *)&port
);
2190 *value
= port
.value
;
2199 i_psvc_get_bit_11_7(EHdl_t
*hdlp
, uint64_t aspec
, int32_t *value
)
2201 int32_t ret
, status
= PSVC_SUCCESS
;
2206 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
2207 if (status
!= PSVC_SUCCESS
)
2210 bitarg
.bit_num
= PSVC_GET_BIT_NUM(aspec
);
2211 bitarg
.direction
= DIR_NO_CHANGE
;
2213 fp
= open(path
, O_RDWR
);
2215 return (PSVC_FAILURE
);
2217 ret
= ioctl_retry(fp
, I2C_GET_BIT
, (void *)&bitarg
);
2224 *value
= bitarg
.bit_value
;
2233 i_psvc_set_bit_11_5(EHdl_t
*hdlp
, uint64_t aspec
, int32_t value
)
2235 int32_t ret
, status
= PSVC_SUCCESS
;
2240 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
2241 if (status
!= PSVC_SUCCESS
)
2244 bitarg
.bit_value
= value
;
2245 bitarg
.bit_num
= PSVC_GET_BIT_NUM(aspec
);
2246 bitarg
.direction
= DIR_OUTPUT
;
2247 fp
= open(path
, O_RDWR
);
2249 return (PSVC_FAILURE
);
2251 ret
= ioctl_retry(fp
, I2C_SET_BIT
, (void *)&bitarg
);
2265 i_psvc_set_port_11_5(EHdl_t
*hdlp
, uint64_t aspec
, int32_t value
)
2267 int32_t ret
, status
= PSVC_SUCCESS
;
2272 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
2273 if (status
!= PSVC_SUCCESS
)
2276 port
.value
= (uint8_t)value
;
2277 port
.direction
= DIR_NO_CHANGE
;
2278 fp
= open(path
, O_RDWR
);
2280 return (PSVC_FAILURE
);
2282 ret
= ioctl_retry(fp
, I2C_SET_PORT
, (void *)&port
);
2296 i_psvc_set_bit_11_7(EHdl_t
*hdlp
, uint64_t aspec
, int32_t value
)
2298 int32_t ret
, status
= PSVC_SUCCESS
;
2303 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
2304 if (status
!= PSVC_SUCCESS
)
2307 bitarg
.bit_value
= value
;
2308 bitarg
.bit_num
= PSVC_GET_BIT_NUM(aspec
);
2309 bitarg
.direction
= DIR_OUTPUT
;
2311 fp
= open(path
, O_RDWR
);
2313 return (PSVC_FAILURE
);
2315 ret
= ioctl_retry(fp
, I2C_SET_BIT
, (void *)&bitarg
);
2329 i_psvc_probe_11_0(EHdl_t
*hdlp
, EObj_t
*objp
)
2331 int32_t ret
, status
= PSVC_SUCCESS
;
2336 if (objp
->present
!= PSVC_PRESENT
) {
2338 return (PSVC_FAILURE
);
2341 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
2342 if (status
!= PSVC_SUCCESS
) {
2346 fp
= open(path
, O_RDWR
);
2348 return (PSVC_FAILURE
);
2351 ret
= read(fp
, &value
, 1);
2365 i_psvc_probe_11_1(EHdl_t
*hdlp
, EObj_t
*objp
)
2367 int32_t ret
, status
= PSVC_SUCCESS
;
2372 if (objp
->present
!= PSVC_PRESENT
) {
2374 return (PSVC_FAILURE
);
2377 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
2378 if (status
!= PSVC_SUCCESS
)
2381 fp
= open(path
, O_RDWR
);
2383 return (PSVC_FAILURE
);
2386 ret
= ioctl_retry(fp
, I2C_GET_REG
, (void *)®
);
2400 i_psvc_probe_11_2(EHdl_t
*hdlp
, EObj_t
*objp
)
2402 int32_t ret
, status
= PSVC_SUCCESS
;
2407 if (objp
->present
!= PSVC_PRESENT
) {
2409 return (PSVC_FAILURE
);
2412 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
2413 if (status
!= PSVC_SUCCESS
) {
2417 fp
= open(path
, O_RDWR
);
2419 return (PSVC_FAILURE
);
2422 ret
= ioctl_retry(fp
, I2C_GET_TEMPERATURE
, (void *)&temp16
);
2436 i_psvc_probe_11_3(EHdl_t
*hdlp
, EObj_t
*objp
)
2438 int32_t ret
, status
= PSVC_SUCCESS
;
2443 if (objp
->present
!= PSVC_PRESENT
) {
2445 return (PSVC_FAILURE
);
2448 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
2449 if (status
!= PSVC_SUCCESS
) {
2453 fp
= open(path
, O_RDWR
);
2455 return (PSVC_FAILURE
);
2458 ret
= ioctl_retry(fp
, I2C_GET_OUTPUT
, (void *)&value
);
2465 ret
= ioctl_retry(fp
, I2C_SET_OUTPUT
, (void *)&value
);
2478 i_psvc_probe_11_4(EHdl_t
*hdlp
, EObj_t
*objp
)
2480 int32_t ret
, status
= PSVC_SUCCESS
;
2485 if (objp
->present
!= PSVC_PRESENT
) {
2487 return (PSVC_FAILURE
);
2490 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
2491 if (status
!= PSVC_SUCCESS
) {
2495 fp
= open(path
, O_RDWR
);
2497 return (PSVC_FAILURE
);
2500 ret
= ioctl_retry(fp
, I2C_GET_TEMPERATURE
, (void *)&temp16
);
2514 i_psvc_probe_11_5(EHdl_t
*hdlp
, EObj_t
*objp
)
2516 int32_t ret
, status
= PSVC_SUCCESS
;
2521 if (objp
->present
!= PSVC_PRESENT
) {
2523 return (PSVC_FAILURE
);
2526 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
2527 if (status
!= PSVC_SUCCESS
) {
2531 port
.direction
= DIR_NO_CHANGE
;
2533 fp
= open(path
, O_RDWR
);
2535 return (PSVC_FAILURE
);
2538 ret
= ioctl_retry(fp
, I2C_GET_PORT
, (void *)&port
);
2552 i_psvc_probe_11_6(EHdl_t
*hdlp
, EObj_t
*objp
)
2554 int32_t ret
, status
= PSVC_SUCCESS
;
2559 if (objp
->present
!= PSVC_PRESENT
) {
2561 return (PSVC_FAILURE
);
2564 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
2565 if (status
!= PSVC_SUCCESS
)
2568 fp
= open(path
, O_RDWR
);
2570 return (PSVC_FAILURE
);
2572 ret
= ioctl_retry(fp
, I2C_GET_INPUT
, (void *)&arg
);
2586 i_psvc_probe_11_7(EHdl_t
*hdlp
, EObj_t
*objp
)
2588 int32_t ret
, status
= PSVC_SUCCESS
;
2593 if (objp
->present
!= PSVC_PRESENT
) {
2595 return (PSVC_FAILURE
);
2598 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
2599 if (status
!= PSVC_SUCCESS
)
2602 port
.direction
= DIR_NO_CHANGE
;
2604 fp
= open(path
, O_RDWR
);
2606 return (PSVC_FAILURE
);
2608 ret
= ioctl_retry(fp
, I2C_GET_PORT
, (void *)&port
);
2622 i_psvc_probe_11_8(EHdl_t
*hdlp
, EObj_t
*objp
)
2624 int32_t ret
, status
= PSVC_SUCCESS
;
2629 if (objp
->present
!= PSVC_PRESENT
) {
2631 return (PSVC_FAILURE
);
2634 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
2635 if (status
!= PSVC_SUCCESS
)
2638 fp
= open(path
, O_RDWR
);
2640 return (PSVC_FAILURE
);
2642 ret
= read(fp
, &value
, 1);
2657 i_psvc_probe_11_9(EHdl_t
*hdlp
, EObj_t
*objp
)
2659 int32_t ret
, status
= PSVC_SUCCESS
;
2664 if (objp
->present
!= PSVC_PRESENT
) {
2666 return (PSVC_FAILURE
);
2669 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
2670 if (status
!= PSVC_SUCCESS
) {
2674 fp
= open(path
, O_RDWR
);
2676 return (PSVC_FAILURE
);
2680 * There are only a few register numbers that are valid numbers to
2681 * read from. 0x10 is one of these registers. Any non-valid registers
2682 * cause unknown behavior to the ssc100 device.
2685 ret
= ioctl_retry(fp
, I2C_GET_REG
, (void *)®
);
2699 * Find start of a section within the config file,
2700 * Returns number of records in the section.
2701 * FILE *fd is set to first data record within section.
2704 i_psvc_find_file_section(FILE *fd
, char *start
)
2711 fseek(fd
, 0, SEEK_SET
);
2712 while ((ret
= fgets(buf
, BUFSZ
, fd
)) != NULL
) {
2713 if (strncmp(start
, buf
, strlen(start
)) == 0)
2722 found
= sscanf(buf
, "%s", name
);
2732 /* compare routine for qsort of str_tbl */
2734 i_psvc_name_compare_qsort(EStringId_t
*s1
, EStringId_t
*s2
)
2736 return (strcmp(s1
->name
, s2
->name
));
2739 /* compare routine for bsearch of str_tbl */
2741 i_psvc_name_compare_bsearch(char *s1
, EStringId_t
*s2
)
2743 return (strcmp(s1
, s2
->name
));
2747 * Determine the initial state of a device.
2750 i_psvc_init_state(EHdl_t
*hp
, EObj_t
*objp
)
2752 int32_t status
= PSVC_SUCCESS
;
2754 if (objp
->class == PSVC_ON_OFF_SWITCH_CLASS
) {
2757 status
= objp
->get_attr(hp
, objp
, PSVC_SWITCH_STATE_ATTR
,
2759 if (status
!= PSVC_SUCCESS
)
2762 if (strcmp(state
, PSVC_SWITCH_ON
) == 0)
2763 strcpy(objp
->state
, PSVC_ON
);
2765 strcpy(objp
->state
, PSVC_OFF
);
2768 if (objp
->class == PSVC_KEYSWITCH_CLASS
) {
2771 status
= objp
->get_attr(hp
, objp
, PSVC_SWITCH_STATE_ATTR
,
2773 if (status
!= PSVC_SUCCESS
)
2775 strcpy(objp
->state
, state
);
2782 * Return the object pointer for the object name passed in.
2783 * Creates the object if this is the first access,
2784 * Returns 0 if successful, -1 if not.
2787 i_psvc_get_obj(EHdl_t
*hp
, char *dev_name
, EObj_t
**objp
)
2790 int32_t found
, key
, array
;
2791 int32_t class, subclass
;
2796 ETable_Array
*tbl_arr
;
2798 key
= psvc_get_str_key(dev_name
);
2799 array
= key
% PSVC_MAX_TABLE_ARRAYS
;
2800 tbl_arr
= &(hp
->tbl_arry
[array
]);
2802 for (i
= 0; i
< tbl_arr
->obj_count
; ++i
) {
2803 if (key
== tbl_arr
->obj_tbl
[i
].key
) {
2804 if (strcmp(dev_name
, tbl_arr
->obj_tbl
[i
].name
) == 0) {
2805 if (tbl_arr
->obj_tbl
[i
].type
!= PSVC_OBJ
)
2807 *objp
= tbl_arr
->obj_tbl
[i
].objp
;
2813 if (i_psvc_find_file_section(hp
->fp
, "OBJECT_INFO") == -1) {
2814 ENV_DEBUG("Couldn't find OBJECT_INFO section", dev_name
);
2818 fgets(buf
, BUFSZ
, hp
->fp
);
2819 while (strcmp(buf
, "OBJECT_INFO_END")) {
2820 start
= strrchr(buf
, '/');
2821 if (start
== NULL
) {
2823 return (PSVC_FAILURE
);
2825 found
= sscanf(start
+ 1, "%s", name
);
2828 return (PSVC_FAILURE
);
2831 if (strcmp(name
, dev_name
) == 0) {
2833 if (i_psvc_value(buf
, PSVC_CLASS_ATTR
, &class)
2835 return (PSVC_FAILURE
);
2836 if (i_psvc_value(buf
, PSVC_SUBCLASS_ATTR
, &subclass
)
2838 return (PSVC_FAILURE
);
2839 ret
= (*i_psvc_constructor
[class][subclass
])(hp
,
2841 if (ret
!= PSVC_SUCCESS
) {
2844 ret
= (*objp
)->get_attr(hp
, *objp
, PSVC_PRESENCE_ATTR
,
2846 (*objp
)->previous_presence
= presence
;
2847 if (ret
!= PSVC_SUCCESS
|| presence
!= PSVC_PRESENT
)
2850 return (i_psvc_init_state(hp
, *objp
));
2852 fgets(buf
, BUFSZ
, hp
->fp
);
2860 * Gets the device path associated with an object id.
2861 * Returns 0 if successful, -1 if not.
2864 i_psvc_get_devpath(EHdl_t
*hp
, uint64_t addr_spec
, char *path
)
2868 uint32_t controller
, bus
, addr
, port
;
2870 controller
= PSVC_GET_ASPEC_CNTLR(addr_spec
);
2871 bus
= PSVC_GET_ASPEC_BUSNUM(addr_spec
);
2872 addr
= PSVC_GET_ASPEC_BUSADDR(addr_spec
);
2873 port
= PSVC_GET_ASPEC_PORT(addr_spec
);
2875 for (i
= 0; i
< hp
->dev_count
; ++i
) {
2876 dp
= &hp
->dev_tbl
[i
];
2877 if (dp
->controller
== controller
&&
2881 strcpy(path
, dp
->path
);
2882 return (PSVC_SUCCESS
);
2887 return (PSVC_FAILURE
);
2891 /* Load the association table */
2893 i_psvc_load_associations(EHdl_t
*hp
, FILE *fp
)
2898 char name1
[32], name2
[32];
2906 * ignore count in the file, correct count is highest
2907 * association id + 1, now figured when loading ASSOC_STR
2910 if (i_psvc_find_file_section(fp
, "ASSOCIATIONS") != PSVC_SUCCESS
)
2912 if ((hp
->assoc_tbl
= malloc(sizeof (EAssocList_t
) * hp
->assoc_count
))
2916 memset(hp
->assoc_tbl
, 0, sizeof (EAssocList_t
) * hp
->assoc_count
);
2918 for (i
= 0; i
< hp
->assoc_count
; ++i
) {
2919 fgets(buf
, BUFSZ
, fp
);
2920 found
= sscanf(buf
, "%s %s", name1
, name2
);
2921 if (strcmp("ASSOCIATIONS_END", name1
) == 0)
2927 namep
= (EStringId_t
*)bsearch(name2
, hp
->othr_tbl
,
2928 hp
->othr_count
, sizeof (EStringId_t
),
2929 (int (*)(const void *, const void *))
2930 i_psvc_name_compare_bsearch
);
2931 if (namep
== NULL
) {
2937 status
= i_psvc_count_records(fp
, "ASSOCIATION_END", &count
);
2938 if (status
!= PSVC_SUCCESS
)
2940 hp
->assoc_tbl
[id
].count
= count
;
2941 hp
->assoc_tbl
[id
].table
=
2942 (EAssoc_t
*)malloc(sizeof (EAssoc_t
) * count
);
2943 if (hp
->assoc_tbl
[id
].table
== NULL
)
2946 for (j
= 0; j
< count
; ++j
) {
2947 ap
= &hp
->assoc_tbl
[id
].table
[j
];
2948 fgets(buf
, BUFSZ
, fp
);
2949 found
= sscanf(buf
, "%s %s", ap
->antecedent_id
,
2951 ap
->ant_key
= psvc_get_str_key(ap
->antecedent_id
);
2959 fgets(buf
, BUFSZ
, fp
);
2960 if (strncmp(buf
, "ASSOCIATION_END", 15) != 0) {
2969 /* Load the table of tables */
2971 i_psvc_load_tables(EHdl_t
*hp
, FILE *fp
)
2980 uint32_t table_count
;
2981 int32_t num
, key
, array
;
2983 ETable_Array
*tbl_arr
;
2985 if (i_psvc_find_file_section(fp
, "TABLES") != PSVC_SUCCESS
)
2986 return (PSVC_SUCCESS
); /* no tables */
2987 status
= i_psvc_count_tables_associations(fp
, &table_count
,
2989 if (status
!= PSVC_SUCCESS
|| table_count
== 0)
2992 for (i
= 0; i
< table_count
; ++i
) {
2996 fgets(buf
, BUFSZ
, fp
);
2997 if (strncmp(buf
, "TABLE", 5) != 0) {
3002 fgets(buf
, BUFSZ
, fp
);
3003 found
= sscanf(buf
, "%s %d", name
, &cell_type
);
3004 key
= psvc_get_str_key(name
);
3005 array
= key
% PSVC_MAX_TABLE_ARRAYS
;
3006 tbl_arr
= &(hp
->tbl_arry
[array
]);
3008 if (tbl_arr
->nextid
== hp
->total_obj_count
) {
3010 return (PSVC_FAILURE
);
3012 slot
= tbl_arr
->nextid
++;
3013 tbl_arr
->obj_count
++;
3016 strcpy(tbl_arr
->obj_tbl
[slot
].name
, name
);
3018 tblp
= (ETable_t
*)malloc(sizeof (ETable_t
));
3020 return (PSVC_FAILURE
);
3021 tbl_arr
->obj_tbl
[slot
].key
= key
;
3022 tbl_arr
->obj_tbl
[slot
].objp
= (EObj_t
*)(void *)tblp
;
3023 tbl_arr
->obj_tbl
[slot
].type
= PSVC_TBL
;
3025 status
= i_psvc_count_table_records(fp
, "TABLE_END",
3027 if (status
!= PSVC_SUCCESS
)
3029 tblp
->cell_type
= (uint8_t)cell_type
;
3035 /* allocate and load table */
3036 tblp
->table
= (int64_t *)malloc(tblp
->size
*
3037 i_psvc_cell_size
[tblp
->cell_type
]);
3038 if (tblp
->table
== NULL
) {
3042 table
= tblp
->table
;
3043 for (j
= 0; j
< tblp
->size
; ++j
) {
3044 switch (cell_type
) {
3046 ret
= fscanf(fp
, "%d", &num
);
3047 *((int8_t *)table
+ j
) = num
;
3050 ret
= fscanf(fp
, "%d", &num
);
3051 *((uint8_t *)table
+ j
) = (uint8_t)num
;
3054 ret
= fscanf(fp
, "%hd",
3055 ((int16_t *)table
+ j
));
3058 ret
= fscanf(fp
, "%hd",
3059 ((uint16_t *)table
+ j
));
3062 ret
= fscanf(fp
, "%d",
3063 ((int32_t *)table
+ j
));
3066 ret
= fscanf(fp
, "%d",
3067 ((uint32_t *)table
+ j
));
3070 ret
= fscanf(fp
, "%lld",
3071 ((int64_t *)table
+ j
));
3074 ret
= fscanf(fp
, "%lld",
3075 ((uint64_t *)table
+ j
));
3086 fgets(buf
, BUFSZ
, fp
); /* reads newline on data line */
3087 fgets(buf
, BUFSZ
, fp
);
3088 if (strncmp(buf
, "TABLE_END", 9) != 0) {
3099 i_psvc_destructor(EHdl_t
*hdlp
, char *name
, void *objp
)
3101 int32_t i
, key
, array
;
3103 key
= psvc_get_str_key(name
);
3104 array
= key
% PSVC_MAX_TABLE_ARRAYS
;
3106 for (i
= 0; i
< hdlp
->tbl_arry
[array
].obj_count
; ++i
) {
3107 if (key
== hdlp
->tbl_arry
[array
].obj_tbl
[i
].key
) {
3108 if (strcmp(hdlp
->tbl_arry
[array
].obj_tbl
[i
].name
,
3110 hdlp
->tbl_arry
[array
].obj_tbl
[i
].name
[0] = '\0';
3113 return (PSVC_SUCCESS
);
3118 return (PSVC_SUCCESS
);
3122 i_psvc_get_attr_generic(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
,
3125 int32_t status
= PSVC_SUCCESS
;
3129 case PSVC_ADDR_SPEC_ATTR
:
3130 *(uint64_t *)attrp
= objp
->addr_spec
;
3132 case PSVC_CLASS_ATTR
:
3133 *(int32_t *)attrp
= objp
->class;
3135 case PSVC_SUBCLASS_ATTR
:
3136 *(int32_t *)attrp
= objp
->subclass
;
3138 case PSVC_PRESENCE_ATTR
:
3139 status
= i_psvc_get_presence(hdlp
, objp
, (boolean_t
*)attrp
);
3141 case PSVC_PREV_PRESENCE_ATTR
:
3142 *(boolean_t
*)attrp
= objp
->previous_presence
;
3144 case PSVC_STATE_ATTR
:
3145 strcpy((char *)attrp
, objp
->state
);
3147 case PSVC_PREV_STATE_ATTR
:
3148 strcpy((char *)attrp
, objp
->previous_state
);
3150 case PSVC_ENABLE_ATTR
:
3151 *(boolean_t
*)attrp
= objp
->enabled
;
3153 case PSVC_FAULTID_ATTR
:
3154 strcpy((char *)attrp
, objp
->fault_id
);
3156 case PSVC_FEATURES_ATTR
:
3157 *(uint64_t *)attrp
= objp
->features
;
3159 case PSVC_LABEL_ATTR
:
3160 strcpy((char *)attrp
, objp
->label
);
3162 case PSVC_FRUID_ATTR
:
3163 while ((objp
->features
& PSVC_DEV_FRU
) == 0) {
3164 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
,
3165 PSVC_PARENT
, 0, &parent_id
);
3166 if (status
!= PSVC_SUCCESS
)
3169 status
= i_psvc_get_obj(hdlp
, parent_id
, &objp
);
3170 if (status
!= PSVC_SUCCESS
)
3174 strcpy((char *)attrp
, objp
->label
);
3176 case PSVC_INSTANCE_ATTR
:
3177 *(int32_t *)attrp
= objp
->instance
;
3181 return (PSVC_FAILURE
);
3188 i_psvc_set_attr_generic(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
,
3191 int32_t status
= PSVC_SUCCESS
;
3194 case PSVC_PREV_PRESENCE_ATTR
:
3195 objp
->previous_presence
= *(boolean_t
*)attrp
;
3197 case PSVC_STATE_ATTR
:
3198 strcpy(objp
->previous_state
, objp
->state
);
3199 strcpy(objp
->state
, (char *)attrp
);
3201 case PSVC_ENABLE_ATTR
:
3202 objp
->enabled
= *(boolean_t
*)attrp
;
3204 case PSVC_FAULTID_ATTR
:
3205 strcpy(objp
->fault_id
, (char *)attrp
);
3209 return (PSVC_FAILURE
);
3215 i_psvc_get_attr_0_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3217 int32_t status
= PSVC_SUCCESS
;
3220 case PSVC_SENSOR_VALUE_ATTR
:
3221 return (i_psvc_get_device_value_0_0(hdlp
, objp
, attrp
));
3222 case PSVC_LO_WARN_ATTR
:
3223 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->lo_warn
;
3225 case PSVC_LO_SHUT_ATTR
:
3226 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->lo_shut
;
3228 case PSVC_HI_WARN_ATTR
:
3229 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->hi_warn
;
3231 case PSVC_HI_SHUT_ATTR
:
3232 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->hi_shut
;
3236 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3242 i_psvc_get_attr_0_1(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3244 int32_t status
= PSVC_SUCCESS
;
3247 case PSVC_SENSOR_VALUE_ATTR
:
3248 return (i_psvc_get_device_value_0_1(hdlp
, objp
, attrp
));
3249 case PSVC_LO_WARN_ATTR
:
3250 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->lo_warn
;
3252 case PSVC_LO_SHUT_ATTR
:
3253 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->lo_shut
;
3255 case PSVC_HI_WARN_ATTR
:
3256 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->hi_warn
;
3258 case PSVC_HI_SHUT_ATTR
:
3259 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->hi_shut
;
3261 case PSVC_OPTIMAL_TEMP_ATTR
:
3262 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->opt_temp
;
3264 case PSVC_HW_HI_SHUT_ATTR
:
3265 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->hw_hi_shut
;
3267 case PSVC_HW_LO_SHUT_ATTR
:
3268 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->hw_lo_shut
;
3272 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3278 i_psvc_set_attr_0_1(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3280 int32_t status
= PSVC_SUCCESS
;
3283 case PSVC_LO_WARN_ATTR
:
3284 ((ETempSensor_t
*)objp
)->lo_warn
= *(int32_t *)attrp
;
3286 case PSVC_LO_SHUT_ATTR
:
3287 ((ETempSensor_t
*)objp
)->lo_shut
= *(int32_t *)attrp
;
3289 case PSVC_HI_WARN_ATTR
:
3290 ((ETempSensor_t
*)objp
)->hi_warn
= *(int32_t *)attrp
;
3292 case PSVC_HI_SHUT_ATTR
:
3293 ((ETempSensor_t
*)objp
)->hi_shut
= *(int32_t *)attrp
;
3295 case PSVC_OPTIMAL_TEMP_ATTR
:
3296 ((ETempSensor_t
*)objp
)->opt_temp
= *(int32_t *)attrp
;
3298 case PSVC_HW_HI_SHUT_ATTR
:
3299 ((ETempSensor_t
*)objp
)->hw_hi_shut
= *(int32_t *)attrp
;
3301 case PSVC_HW_LO_SHUT_ATTR
:
3302 ((ETempSensor_t
*)objp
)->hw_lo_shut
= *(int32_t *)attrp
;
3306 status
= i_psvc_set_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3312 i_psvc_get_attr_1_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3314 int32_t status
= PSVC_SUCCESS
;
3317 case PSVC_SENSOR_VALUE_ATTR
:
3318 return (i_psvc_get_device_value_1_0(hdlp
, objp
, attrp
));
3319 case PSVC_SETPOINT_ATTR
:
3320 *(int16_t *)attrp
= ((EFan_t
*)objp
)->setpoint
;
3322 case PSVC_HYSTERESIS_ATTR
:
3323 *(int16_t *)attrp
= ((EFan_t
*)objp
)->hysteresis
;
3325 case PSVC_LOOPGAIN_ATTR
:
3326 *(int16_t *)attrp
= ((EFan_t
*)objp
)->loopgain
;
3328 case PSVC_LOOPBIAS_ATTR
:
3329 *(int16_t *)attrp
= ((EFan_t
*)objp
)->loopbias
;
3331 case PSVC_TEMP_DIFFERENTIAL_ATTR
:
3332 memcpy(attrp
, ((EFan_t
*)objp
)->temp_differential
,
3333 sizeof (((EFan_t
*)objp
)->temp_differential
));
3335 case PSVC_TEMP_DIFFERENTIAL_INDEX_ATTR
:
3336 *(int16_t *)attrp
= ((EFan_t
*)objp
)->temp_differential_index
;
3340 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3346 i_psvc_set_attr_1_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3348 int32_t status
= PSVC_SUCCESS
;
3351 case PSVC_TEMP_DIFFERENTIAL_ATTR
:
3352 memcpy(((EFan_t
*)objp
)->temp_differential
, attrp
,
3353 sizeof (((EFan_t
*)objp
)->temp_differential
));
3355 case PSVC_TEMP_DIFFERENTIAL_INDEX_ATTR
:
3356 ((EFan_t
*)objp
)->temp_differential_index
= *(int16_t *)attrp
;
3358 case PSVC_SETPOINT_ATTR
:
3359 ((EFan_t
*)objp
)->setpoint
= *(int16_t *)attrp
;
3363 status
= i_psvc_set_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3365 return (PSVC_SUCCESS
);
3369 i_psvc_get_attr_2_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3371 int32_t status
= PSVC_SUCCESS
;
3374 case PSVC_LED_STATE_ATTR
:
3375 case PSVC_STATE_ATTR
:
3376 return (i_psvc_get_device_state_2_0(hdlp
, objp
, attrp
));
3377 case PSVC_LED_COLOR_ATTR
:
3378 strcpy((char *)attrp
, ((ELed_t
*)objp
)->color
);
3380 case PSVC_LIT_COUNT_ATTR
:
3381 *(int16_t *)attrp
= ((ELed_t
*)objp
)->lit_count
;
3385 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3391 i_psvc_set_attr_2_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3393 int32_t status
= PSVC_SUCCESS
;
3396 case PSVC_LED_STATE_ATTR
:
3397 case PSVC_STATE_ATTR
:
3398 return (i_psvc_set_device_state_2_0(hdlp
, objp
, attrp
));
3401 status
= i_psvc_set_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3407 i_psvc_get_attr_2_1(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3409 int32_t status
= PSVC_SUCCESS
;
3412 case PSVC_LED_STATE_ATTR
:
3413 case PSVC_STATE_ATTR
:
3414 return (i_psvc_get_device_state_2_1(hdlp
, objp
, attrp
));
3415 case PSVC_LED_COLOR_ATTR
:
3416 strcpy((char *)attrp
, ((ELed_t
*)objp
)->color
);
3418 case PSVC_LIT_COUNT_ATTR
:
3419 *(int16_t *)attrp
= ((ELed_t
*)objp
)->lit_count
;
3423 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3429 i_psvc_set_attr_2_1(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3431 int32_t status
= PSVC_SUCCESS
;
3434 case PSVC_LED_STATE_ATTR
:
3435 case PSVC_STATE_ATTR
:
3436 return (i_psvc_set_device_state_2_1(hdlp
, objp
, attrp
));
3439 status
= i_psvc_set_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3445 i_psvc_get_attr_2_2(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3447 int32_t status
= PSVC_SUCCESS
;
3450 case PSVC_LED_STATE_ATTR
:
3451 case PSVC_STATE_ATTR
:
3452 return (i_psvc_get_device_state_2_0(hdlp
, objp
, attrp
));
3453 case PSVC_LED_COLOR_ATTR
:
3454 strcpy((char *)attrp
, ((ELed_t
*)objp
)->color
);
3456 case PSVC_LIT_COUNT_ATTR
:
3457 *(int16_t *)attrp
= ((ELed_t
*)objp
)->lit_count
;
3459 case PSVC_LED_IS_LOCATOR_ATTR
:
3460 strcpy((char *)attrp
, ((ELed_t
*)objp
)->is_locator
);
3462 case PSVC_LED_LOCATOR_NAME_ATTR
:
3463 strcpy((char *)attrp
, ((ELed_t
*)objp
)->locator_name
);
3467 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3473 i_psvc_get_attr_4_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3475 int32_t status
= PSVC_SUCCESS
;
3478 case PSVC_SENSOR_VALUE_ATTR
:
3479 return (i_psvc_get_device_value_4_0(hdlp
, objp
, attrp
));
3480 case PSVC_LO_WARN_ATTR
:
3481 *(int32_t *)attrp
= ((EDigiSensor_t
*)objp
)->lo_warn
;
3483 case PSVC_LO_SHUT_ATTR
:
3484 *(int32_t *)attrp
= ((EDigiSensor_t
*)objp
)->lo_shut
;
3486 case PSVC_HI_WARN_ATTR
:
3487 *(int32_t *)attrp
= ((EDigiSensor_t
*)objp
)->hi_warn
;
3489 case PSVC_HI_SHUT_ATTR
:
3490 *(int32_t *)attrp
= ((EDigiSensor_t
*)objp
)->hi_shut
;
3494 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3496 return (PSVC_SUCCESS
);
3500 i_psvc_get_attr_5_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3502 int32_t status
= PSVC_SUCCESS
;
3504 if (attr_id
== PSVC_CONTROL_VALUE_ATTR
) {
3505 return (i_psvc_get_device_value_5_0(hdlp
, objp
, attrp
));
3508 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3514 i_psvc_set_attr_5_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3516 int32_t status
= PSVC_SUCCESS
;
3518 if (attr_id
== PSVC_CONTROL_VALUE_ATTR
) {
3519 return (i_psvc_set_device_value_5_0(hdlp
, objp
, attrp
));
3522 status
= i_psvc_set_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3528 i_psvc_get_attr_6_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3530 int32_t status
= PSVC_SUCCESS
;
3533 case PSVC_GPIO_VALUE_ATTR
:
3534 return (i_psvc_get_device_value_6_0(hdlp
, objp
, attrp
));
3535 case PSVC_GPIO_BITS
:
3536 *(int32_t *)attrp
= 1;
3540 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3546 i_psvc_set_attr_6_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3548 int32_t status
= PSVC_SUCCESS
;
3550 if (attr_id
== PSVC_GPIO_VALUE_ATTR
) {
3551 return (i_psvc_set_device_value_6_0(hdlp
, objp
, attrp
));
3554 status
= i_psvc_set_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3560 i_psvc_get_attr_7_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3562 int32_t status
= PSVC_SUCCESS
;
3565 case PSVC_SENSOR_VALUE_ATTR
:
3566 return (i_psvc_get_device_value_7_0(hdlp
, objp
, attrp
));
3567 case PSVC_LO_WARN_ATTR
:
3568 *(int32_t *)attrp
= ((EFanTach_t
*)objp
)->lo_warn
;
3570 case PSVC_LO_SHUT_ATTR
:
3571 *(int32_t *)attrp
= ((EFanTach_t
*)objp
)->lo_shut
;
3573 case PSVC_HI_WARN_ATTR
:
3574 *(int32_t *)attrp
= ((EFanTach_t
*)objp
)->hi_warn
;
3576 case PSVC_HI_SHUT_ATTR
:
3577 *(int32_t *)attrp
= ((EFanTach_t
*)objp
)->hi_shut
;
3581 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3583 return (PSVC_SUCCESS
);
3587 i_psvc_get_attr_8_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3589 int32_t status
= PSVC_SUCCESS
;
3592 case PSVC_SWITCH_STATE_ATTR
:
3593 case PSVC_STATE_ATTR
:
3594 return (i_psvc_get_device_state_8_0(hdlp
, objp
, attrp
));
3597 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3603 i_psvc_set_attr_8_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3605 int32_t status
= PSVC_SUCCESS
;
3608 case PSVC_SWITCH_STATE_ATTR
:
3609 case PSVC_STATE_ATTR
:
3610 return (i_psvc_set_device_state_8_0(hdlp
, objp
, attrp
));
3613 status
= i_psvc_set_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3619 i_psvc_get_attr_9_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3621 int32_t status
= PSVC_SUCCESS
;
3624 case PSVC_SWITCH_STATE_ATTR
:
3625 case PSVC_STATE_ATTR
:
3626 status
= i_psvc_get_device_state_9_0(hdlp
, objp
, attrp
);
3627 if ((status
== PSVC_FAILURE
) && (errno
== EINVAL
)) {
3628 strcpy((char *)attrp
, PSVC_ERROR
);
3629 return (PSVC_SUCCESS
);
3635 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3641 i_psvc_get_attr_10_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3643 int32_t status
= PSVC_SUCCESS
;
3646 case PSVC_GPIO_VALUE_ATTR
:
3647 return (i_psvc_get_device_value_10_0(hdlp
, objp
, attrp
));
3648 case PSVC_GPIO_BITS
:
3649 *(int32_t *)attrp
= 8;
3653 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3659 i_psvc_set_attr_10_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3661 int32_t status
= PSVC_SUCCESS
;
3663 if (attr_id
== PSVC_GPIO_VALUE_ATTR
) {
3664 return (i_psvc_set_device_value_10_0(hdlp
, objp
, attrp
));
3667 status
= i_psvc_set_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3673 i_psvc_get_attr_10_1(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3675 int32_t status
= PSVC_SUCCESS
;
3678 case PSVC_GPIO_VALUE_ATTR
:
3679 return (i_psvc_get_device_value_10_1(hdlp
, objp
, attrp
));
3680 case PSVC_GPIO_BITS
:
3681 *(int32_t *)attrp
= 8;
3685 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3691 i_psvc_set_attr_10_1(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3693 int32_t status
= PSVC_SUCCESS
;
3695 if (attr_id
== PSVC_GPIO_VALUE_ATTR
) {
3696 return (i_psvc_set_device_value_10_1(hdlp
, objp
, attrp
));
3699 status
= i_psvc_set_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3706 i_psvc_get_attr_11_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3708 int32_t status
= PSVC_SUCCESS
;
3709 int32_t probe_status
;
3712 case PSVC_PROBE_RESULT_ATTR
:
3713 probe_status
= i_psvc_probe_11_0(hdlp
, objp
);
3714 if (probe_status
== PSVC_SUCCESS
)
3715 strcpy((char *)attrp
, PSVC_OK
);
3717 strcpy((char *)attrp
, PSVC_ERROR
);
3719 case PSVC_FRU_INFO_ATTR
:
3720 status
= i_psvc_get_reg_11_0(hdlp
, objp
, attr_id
, attrp
);
3724 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3730 i_psvc_get_reg_11_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3732 int32_t status
= PSVC_SUCCESS
, ret
;
3733 char path
[1024], *data
;
3734 int32_t fp
, temp_errno
;
3735 fru_info_t
*fru_data
;
3737 fru_data
= (fru_info_t
*)attrp
;
3739 if (objp
->present
!= PSVC_PRESENT
) {
3741 return (PSVC_FAILURE
);
3744 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
3745 if (status
!= PSVC_SUCCESS
)
3748 fp
= open(path
, O_RDWR
);
3750 return (PSVC_FAILURE
);
3753 ret
= lseek(fp
, fru_data
->buf_start
, SEEK_SET
);
3754 if (ret
!= fru_data
->buf_start
) {
3758 return (PSVC_FAILURE
);
3761 data
= (char *)malloc(fru_data
->read_size
);
3762 ret
= read(fp
, data
, fru_data
->read_size
);
3770 memcpy(fru_data
->buf
, data
, fru_data
->read_size
);
3778 i_psvc_get_attr_11_1(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3780 int32_t status
= PSVC_SUCCESS
;
3781 int32_t probe_status
;
3783 if (attr_id
== PSVC_PROBE_RESULT_ATTR
) {
3784 probe_status
= i_psvc_probe_11_1(hdlp
, objp
);
3785 if (probe_status
== PSVC_SUCCESS
)
3786 strcpy((char *)attrp
, PSVC_OK
);
3788 strcpy((char *)attrp
, PSVC_ERROR
);
3792 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3798 i_psvc_get_attr_11_2(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3800 int32_t status
= PSVC_SUCCESS
;
3801 int32_t probe_status
;
3803 if (attr_id
== PSVC_PROBE_RESULT_ATTR
) {
3804 probe_status
= i_psvc_probe_11_2(hdlp
, objp
);
3805 if (probe_status
== PSVC_SUCCESS
)
3806 strcpy((char *)attrp
, PSVC_OK
);
3808 strcpy((char *)attrp
, PSVC_ERROR
);
3812 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3818 i_psvc_get_attr_11_3(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3820 int32_t status
= PSVC_SUCCESS
;
3821 int32_t probe_status
;
3823 if (attr_id
== PSVC_PROBE_RESULT_ATTR
) {
3824 probe_status
= i_psvc_probe_11_3(hdlp
, objp
);
3825 if (probe_status
== PSVC_SUCCESS
)
3826 strcpy((char *)attrp
, PSVC_OK
);
3828 strcpy((char *)attrp
, PSVC_ERROR
);
3832 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3838 i_psvc_get_attr_11_4(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3840 int32_t status
= PSVC_SUCCESS
;
3841 int32_t probe_status
;
3843 if (attr_id
== PSVC_PROBE_RESULT_ATTR
) {
3844 probe_status
= i_psvc_probe_11_4(hdlp
, objp
);
3845 if (probe_status
== PSVC_SUCCESS
)
3846 strcpy((char *)attrp
, PSVC_OK
);
3848 strcpy((char *)attrp
, PSVC_ERROR
);
3852 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3858 i_psvc_get_attr_11_5(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3860 int32_t status
= PSVC_SUCCESS
;
3861 int32_t probe_status
;
3863 if (attr_id
== PSVC_PROBE_RESULT_ATTR
) {
3864 probe_status
= i_psvc_probe_11_5(hdlp
, objp
);
3865 if (probe_status
== PSVC_SUCCESS
)
3866 strcpy((char *)attrp
, PSVC_OK
);
3868 strcpy((char *)attrp
, PSVC_ERROR
);
3872 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3878 i_psvc_get_attr_11_6(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3880 int32_t status
= PSVC_SUCCESS
;
3881 int32_t probe_status
;
3883 if (attr_id
== PSVC_PROBE_RESULT_ATTR
) {
3884 probe_status
= i_psvc_probe_11_6(hdlp
, objp
);
3885 if (probe_status
== PSVC_SUCCESS
)
3886 strcpy((char *)attrp
, PSVC_OK
);
3888 strcpy((char *)attrp
, PSVC_ERROR
);
3892 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3898 i_psvc_get_attr_11_7(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3900 int32_t status
= PSVC_SUCCESS
;
3901 int32_t probe_status
;
3903 if (attr_id
== PSVC_PROBE_RESULT_ATTR
) {
3904 probe_status
= i_psvc_probe_11_7(hdlp
, objp
);
3905 if (probe_status
== PSVC_SUCCESS
)
3906 strcpy((char *)attrp
, PSVC_OK
);
3908 strcpy((char *)attrp
, PSVC_ERROR
);
3912 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3918 i_psvc_get_attr_11_8(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3920 int32_t status
= PSVC_SUCCESS
;
3921 int32_t probe_status
;
3923 if (attr_id
== PSVC_PROBE_RESULT_ATTR
) {
3924 probe_status
= i_psvc_probe_11_8(hdlp
, objp
);
3925 if (probe_status
== PSVC_SUCCESS
)
3926 strcpy((char *)attrp
, PSVC_OK
);
3928 strcpy((char *)attrp
, PSVC_ERROR
);
3932 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3938 i_psvc_get_attr_11_9(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3940 int32_t status
= PSVC_SUCCESS
;
3941 int32_t probe_status
;
3943 if (attr_id
== PSVC_PROBE_RESULT_ATTR
) {
3944 probe_status
= i_psvc_probe_11_9(hdlp
, objp
);
3945 if (probe_status
== PSVC_SUCCESS
)
3946 strcpy((char *)attrp
, PSVC_OK
);
3948 strcpy((char *)attrp
, PSVC_ERROR
);
3952 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3958 i_psvc_load_generic(
3965 int32_t found
, key
, array
;
3968 char cur_device
[NAMELEN
];
3970 ETable_Array
*tbl_arr
;
3972 key
= psvc_get_str_key(name
);
3973 array
= key
% PSVC_MAX_TABLE_ARRAYS
;
3974 tbl_arr
= &(hdlp
->tbl_arry
[array
]);
3976 if (tbl_arr
->nextid
== hdlp
->total_obj_count
) {
3978 return (PSVC_FAILURE
);
3980 slot
= tbl_arr
->nextid
++;
3981 tbl_arr
->obj_count
++;
3984 if (i_psvc_find_file_section(hdlp
->fp
, "OBJECT_INFO") != PSVC_SUCCESS
)
3985 return (PSVC_FAILURE
);
3987 fgets(buf
, BUFSZ
, hdlp
->fp
);
3988 while (strcmp(buf
, "OBJECT_INFO_END")) {
3989 start
= strrchr(buf
, '/');
3990 if (start
== NULL
) {
3992 return (PSVC_FAILURE
);
3994 found
= sscanf(start
+ 1, "%s", cur_device
);
3997 return (PSVC_FAILURE
);
3999 if (strcmp(name
, cur_device
) == 0) /* found it */
4001 fgets(buf
, BUFSZ
, hdlp
->fp
);
4004 tbl_arr
->obj_tbl
[slot
].objp
= (EObj_t
*)malloc(obj_size
);
4005 if (tbl_arr
->obj_tbl
[slot
].objp
== 0)
4006 return (PSVC_FAILURE
);
4007 objp
= (EObj_t
*)tbl_arr
->obj_tbl
[slot
].objp
;
4008 tbl_arr
->obj_tbl
[slot
].type
= PSVC_OBJ
;
4010 memset(objp
, 0, obj_size
);
4011 strcpy(objp
->label
, name
);
4012 strcpy(tbl_arr
->obj_tbl
[slot
].name
, name
);
4014 tbl_arr
->obj_tbl
[slot
].key
= key
;
4016 if (i_psvc_value(buf
, PSVC_CLASS_ATTR
, &objp
->class) != PSVC_SUCCESS
) {
4017 i_psvc_destructor(hdlp
, name
, objp
);
4018 return (PSVC_FAILURE
);
4020 if (i_psvc_value(buf
, PSVC_SUBCLASS_ATTR
, &objp
->subclass
) !=
4022 i_psvc_destructor(hdlp
, name
, objp
);
4023 return (PSVC_FAILURE
);
4025 if (i_psvc_value(buf
, PSVC_INSTANCE_ATTR
, &objp
->instance
) !=
4027 i_psvc_destructor(hdlp
, name
, objp
);
4028 return (PSVC_FAILURE
);
4030 if (i_psvc_value(buf
, PSVC_FEATURES_ATTR
, &objp
->features
) !=
4032 i_psvc_destructor(hdlp
, name
, objp
);
4033 return (PSVC_FAILURE
);
4035 if (i_psvc_value(buf
, PSVC_ADDR_SPEC_ATTR
, &objp
->addr_spec
) !=
4037 i_psvc_destructor(hdlp
, name
, objp
);
4038 return (PSVC_FAILURE
);
4041 if (objp
->features
& PSVC_DEV_SECONDARY
)
4042 objp
->enabled
= PSVC_DISABLED
;
4044 objp
->enabled
= PSVC_ENABLED
;
4046 if (PSVC_GET_VERSION(objp
->addr_spec
) > PSVC_VERSION
) {
4048 i_psvc_destructor(hdlp
, name
, objp
);
4049 return (PSVC_FAILURE
);
4053 return (PSVC_SUCCESS
);
4059 i_psvc_not_supported()
4062 return (PSVC_FAILURE
);
4065 /* Temperature sensor */
4066 /* Class 0 Subclass 0 are temperature sensors that cannot be updated */
4068 i_psvc_constructor_0_0(
4077 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4078 sizeof (ETempSensor_t
));
4079 if (status
!= PSVC_SUCCESS
)
4082 /* Load class specific info */
4083 dp
= (ETempSensor_t
*)*objpp
;
4084 if (i_psvc_value(buf
, PSVC_LO_WARN_ATTR
, &dp
->lo_warn
)
4086 i_psvc_destructor(hdlp
, id
, dp
);
4087 return (PSVC_FAILURE
);
4089 if (i_psvc_value(buf
, PSVC_LO_SHUT_ATTR
, &dp
->lo_shut
)
4091 i_psvc_destructor(hdlp
, id
, dp
);
4092 return (PSVC_FAILURE
);
4094 if (i_psvc_value(buf
, PSVC_HI_WARN_ATTR
, &dp
->hi_warn
)
4096 i_psvc_destructor(hdlp
, id
, dp
);
4097 return (PSVC_FAILURE
);
4099 if (i_psvc_value(buf
, PSVC_HI_SHUT_ATTR
, &dp
->hi_shut
)
4101 i_psvc_destructor(hdlp
, id
, dp
);
4102 return (PSVC_FAILURE
);
4105 dp
->ld
.constructor
= i_psvc_constructor_0_0
;
4106 dp
->ld
.destructor
= i_psvc_destructor
;
4107 dp
->ld
.get_attr
= i_psvc_get_attr_0_0
;
4108 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4113 /* Class 0 Subclass 1 are temperature sensors that can be updated */
4115 i_psvc_constructor_0_1(
4124 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4125 sizeof (ETempSensor_t
));
4126 if (status
!= PSVC_SUCCESS
)
4129 /* Load class specific info */
4130 dp
= (ETempSensor_t
*)*objpp
;
4131 if (i_psvc_value(buf
, PSVC_LO_WARN_ATTR
, &dp
->lo_warn
)
4133 i_psvc_destructor(hdlp
, id
, dp
);
4134 return (PSVC_FAILURE
);
4136 if (i_psvc_value(buf
, PSVC_LO_SHUT_ATTR
, &dp
->lo_shut
)
4138 i_psvc_destructor(hdlp
, id
, dp
);
4139 return (PSVC_FAILURE
);
4141 if (i_psvc_value(buf
, PSVC_HI_WARN_ATTR
, &dp
->hi_warn
)
4143 i_psvc_destructor(hdlp
, id
, dp
);
4144 return (PSVC_FAILURE
);
4146 if (i_psvc_value(buf
, PSVC_HI_SHUT_ATTR
, &dp
->hi_shut
)
4148 i_psvc_destructor(hdlp
, id
, dp
);
4149 return (PSVC_FAILURE
);
4152 if ((*objpp
)->features
& PSVC_OPT_TEMP
) {
4153 if (i_psvc_value(buf
, PSVC_OPTIMAL_TEMP_ATTR
, &dp
->opt_temp
)
4155 i_psvc_destructor(hdlp
, id
, dp
);
4156 return (PSVC_FAILURE
);
4159 if ((*objpp
)->features
& PSVC_HW_LOW_SHUT
) {
4160 if (i_psvc_value(buf
, PSVC_HW_LO_SHUT_ATTR
, &dp
->hw_lo_shut
)
4162 i_psvc_destructor(hdlp
, id
, dp
);
4163 return (PSVC_FAILURE
);
4166 if ((*objpp
)->features
& PSVC_HW_HIGH_SHUT
) {
4167 if (i_psvc_value(buf
, PSVC_HW_HI_SHUT_ATTR
, &dp
->hw_hi_shut
)
4169 i_psvc_destructor(hdlp
, id
, dp
);
4170 return (PSVC_FAILURE
);
4174 dp
->ld
.constructor
= i_psvc_constructor_0_1
;
4175 dp
->ld
.destructor
= i_psvc_destructor
;
4176 dp
->ld
.get_attr
= i_psvc_get_attr_0_1
;
4177 dp
->ld
.set_attr
= i_psvc_set_attr_0_1
;
4184 i_psvc_constructor_1_0(
4193 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4195 if (status
!= PSVC_SUCCESS
)
4198 /* Load class specific info */
4199 dp
= (EFan_t
*)*objpp
;
4200 if (i_psvc_value(buf
, PSVC_SETPOINT_ATTR
, &dp
->setpoint
)
4202 i_psvc_destructor(hdlp
, id
, dp
);
4203 return (PSVC_FAILURE
);
4205 if (i_psvc_value(buf
, PSVC_HYSTERESIS_ATTR
, &dp
->hysteresis
)
4207 i_psvc_destructor(hdlp
, id
, dp
);
4208 return (PSVC_FAILURE
);
4210 if (i_psvc_value(buf
, PSVC_LOOPGAIN_ATTR
, &dp
->loopgain
)
4212 i_psvc_destructor(hdlp
, id
, dp
);
4213 return (PSVC_FAILURE
);
4215 if (i_psvc_value(buf
, PSVC_LOOPBIAS_ATTR
, &dp
->loopbias
)
4217 i_psvc_destructor(hdlp
, id
, dp
);
4218 return (PSVC_FAILURE
);
4221 dp
->ld
.constructor
= i_psvc_constructor_1_0
;
4222 dp
->ld
.destructor
= i_psvc_destructor
;
4223 dp
->ld
.get_attr
= i_psvc_get_attr_1_0
;
4224 dp
->ld
.set_attr
= i_psvc_set_attr_1_0
;
4226 return (PSVC_SUCCESS
);
4232 i_psvc_constructor_2_0(
4241 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4243 if (status
!= PSVC_SUCCESS
)
4246 /* Load class specific info */
4247 dp
= (ELed_t
*)*objpp
;
4249 if (i_psvc_value(buf
, PSVC_LED_COLOR_ATTR
, dp
->color
)
4251 i_psvc_destructor(hdlp
, id
, dp
);
4252 return (PSVC_FAILURE
);
4255 dp
->ld
.constructor
= i_psvc_constructor_2_0
;
4256 dp
->ld
.destructor
= i_psvc_destructor
;
4257 dp
->ld
.get_attr
= i_psvc_get_attr_2_0
;
4258 dp
->ld
.set_attr
= i_psvc_set_attr_2_0
;
4260 return (PSVC_SUCCESS
);
4264 i_psvc_constructor_2_1(
4273 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4275 if (status
!= PSVC_SUCCESS
)
4278 /* Load class specific info */
4279 dp
= (ELed_t
*)*objpp
;
4281 if (i_psvc_value(buf
, PSVC_LED_COLOR_ATTR
, dp
->color
)
4283 i_psvc_destructor(hdlp
, id
, dp
);
4284 return (PSVC_FAILURE
);
4287 dp
->ld
.constructor
= i_psvc_constructor_2_1
;
4288 dp
->ld
.destructor
= i_psvc_destructor
;
4289 dp
->ld
.get_attr
= i_psvc_get_attr_2_1
;
4290 dp
->ld
.set_attr
= i_psvc_set_attr_2_1
;
4292 return (PSVC_SUCCESS
);
4296 i_psvc_constructor_2_2(
4305 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4307 if (status
!= PSVC_SUCCESS
)
4310 /* Load class specific info */
4311 dp
= (ELed_t
*)*objpp
;
4313 if (i_psvc_value(buf
, PSVC_LED_COLOR_ATTR
, dp
->color
)
4315 i_psvc_destructor(hdlp
, id
, dp
);
4316 return (PSVC_FAILURE
);
4318 if (i_psvc_value(buf
, PSVC_LED_IS_LOCATOR_ATTR
, dp
->is_locator
)
4320 i_psvc_destructor(hdlp
, id
, dp
);
4321 return (PSVC_FAILURE
);
4323 if (strcmp(dp
->is_locator
, PSVC_LOCATOR_TRUE
) == 0) {
4324 if (i_psvc_value(buf
, PSVC_LED_LOCATOR_NAME_ATTR
,
4325 dp
->locator_name
) != PSVC_SUCCESS
) {
4326 i_psvc_destructor(hdlp
, id
, dp
);
4327 return (PSVC_FAILURE
);
4330 strcpy(dp
->locator_name
, "N/A");
4333 dp
->ld
.constructor
= i_psvc_constructor_2_2
;
4334 dp
->ld
.destructor
= i_psvc_destructor
;
4335 dp
->ld
.get_attr
= i_psvc_get_attr_2_2
;
4336 dp
->ld
.set_attr
= i_psvc_set_attr_2_0
;
4338 return (PSVC_SUCCESS
);
4343 i_psvc_constructor_3_0(
4352 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (ESystem_t
));
4353 if (status
!= PSVC_SUCCESS
)
4356 /* Load class specific info */
4357 dp
= (ESystem_t
*)*objpp
;
4359 dp
->ld
.constructor
= i_psvc_constructor_3_0
;
4360 dp
->ld
.destructor
= i_psvc_destructor
;
4361 dp
->ld
.get_attr
= i_psvc_get_attr_generic
;
4362 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4364 return (PSVC_SUCCESS
);
4367 /* Digital Sensor */
4369 i_psvc_constructor_4_0(
4378 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4379 sizeof (EDigiSensor_t
));
4380 if (status
!= PSVC_SUCCESS
) {
4384 /* Load class specific info */
4385 dp
= (EDigiSensor_t
*)*objpp
;
4386 if (i_psvc_value(buf
, PSVC_LO_WARN_ATTR
, &dp
->lo_warn
)
4388 i_psvc_destructor(hdlp
, id
, dp
);
4389 return (PSVC_FAILURE
);
4391 if (i_psvc_value(buf
, PSVC_LO_SHUT_ATTR
, &dp
->lo_shut
)
4393 i_psvc_destructor(hdlp
, id
, dp
);
4394 return (PSVC_FAILURE
);
4396 if (i_psvc_value(buf
, PSVC_HI_WARN_ATTR
, &dp
->hi_warn
)
4398 i_psvc_destructor(hdlp
, id
, dp
);
4399 return (PSVC_FAILURE
);
4401 if (i_psvc_value(buf
, PSVC_HI_SHUT_ATTR
, &dp
->hi_shut
)
4403 i_psvc_destructor(hdlp
, id
, dp
);
4404 return (PSVC_FAILURE
);
4407 dp
->ld
.constructor
= i_psvc_constructor_4_0
;
4408 dp
->ld
.destructor
= i_psvc_destructor
;
4409 dp
->ld
.get_attr
= i_psvc_get_attr_4_0
;
4410 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4412 return (PSVC_SUCCESS
);
4415 /* Digital Control */
4417 i_psvc_constructor_5_0(
4426 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4427 sizeof (EDigiControl_t
));
4428 if (status
!= PSVC_SUCCESS
)
4431 /* Load class specific info */
4432 dp
= (EDigiControl_t
*)*objpp
;
4434 dp
->ld
.constructor
= i_psvc_constructor_5_0
;
4435 dp
->ld
.destructor
= i_psvc_destructor
;
4436 dp
->ld
.get_attr
= i_psvc_get_attr_5_0
;
4437 dp
->ld
.set_attr
= i_psvc_set_attr_5_0
;
4438 return (PSVC_SUCCESS
);
4443 i_psvc_constructor_6_0(
4452 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4453 sizeof (EBoolSensor_t
));
4454 if (status
!= PSVC_SUCCESS
)
4457 /* Load class specific info */
4458 dp
= (EBoolSensor_t
*)*objpp
;
4460 dp
->ld
.constructor
= i_psvc_constructor_6_0
;
4461 dp
->ld
.destructor
= i_psvc_destructor
;
4462 dp
->ld
.get_attr
= i_psvc_get_attr_6_0
;
4463 dp
->ld
.set_attr
= i_psvc_set_attr_6_0
;
4465 return (PSVC_SUCCESS
);
4468 /* Fan Tachometer */
4470 i_psvc_constructor_7_0(
4479 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4480 sizeof (EFanTach_t
));
4481 if (status
!= PSVC_SUCCESS
)
4484 /* Load class specific info */
4485 dp
= (EFanTach_t
*)*objpp
;
4486 if (i_psvc_value(buf
, PSVC_LO_WARN_ATTR
, &dp
->lo_warn
)
4488 i_psvc_destructor(hdlp
, id
, dp
);
4489 return (PSVC_FAILURE
);
4491 if (i_psvc_value(buf
, PSVC_LO_SHUT_ATTR
, &dp
->lo_shut
)
4493 i_psvc_destructor(hdlp
, id
, dp
);
4494 return (PSVC_FAILURE
);
4496 if (i_psvc_value(buf
, PSVC_HI_WARN_ATTR
, &dp
->hi_warn
)
4498 i_psvc_destructor(hdlp
, id
, dp
);
4499 return (PSVC_FAILURE
);
4501 if (i_psvc_value(buf
, PSVC_HI_SHUT_ATTR
, &dp
->hi_shut
)
4503 i_psvc_destructor(hdlp
, id
, dp
);
4504 return (PSVC_FAILURE
);
4507 dp
->ld
.constructor
= i_psvc_constructor_7_0
;
4508 dp
->ld
.destructor
= i_psvc_destructor
;
4509 dp
->ld
.get_attr
= i_psvc_get_attr_7_0
;
4510 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4512 return (PSVC_SUCCESS
);
4517 i_psvc_constructor_8_0(
4526 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4527 sizeof (ESwitch_t
));
4528 if (status
!= PSVC_SUCCESS
)
4531 /* Load class specific info */
4532 dp
= (ESwitch_t
*)*objpp
;
4534 dp
->ld
.constructor
= i_psvc_constructor_8_0
;
4535 dp
->ld
.destructor
= i_psvc_destructor
;
4536 dp
->ld
.get_attr
= i_psvc_get_attr_8_0
;
4537 dp
->ld
.set_attr
= i_psvc_set_attr_8_0
;
4539 return (PSVC_SUCCESS
);
4544 i_psvc_constructor_9_0(
4553 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4554 sizeof (EKeySwitch_t
));
4555 if (status
!= PSVC_SUCCESS
)
4558 /* Load class specific info */
4559 dp
= (EKeySwitch_t
*)*objpp
;
4561 dp
->ld
.constructor
= i_psvc_constructor_9_0
;
4562 dp
->ld
.destructor
= i_psvc_destructor
;
4563 dp
->ld
.get_attr
= i_psvc_get_attr_9_0
;
4564 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4566 return (PSVC_SUCCESS
);
4569 /* 8 Bit GPIO , devices with registers, calls get_reg()/set_reg() */
4571 i_psvc_constructor_10_0(
4580 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EGPIO8_t
));
4581 if (status
!= PSVC_SUCCESS
)
4584 /* Load class specific info */
4585 dp
= (EGPIO8_t
*)*objpp
;
4587 dp
->ld
.constructor
= i_psvc_constructor_10_0
;
4588 dp
->ld
.destructor
= i_psvc_destructor
;
4589 dp
->ld
.get_attr
= i_psvc_get_attr_10_0
;
4590 dp
->ld
.set_attr
= i_psvc_set_attr_10_0
;
4592 return (PSVC_SUCCESS
);
4595 /* 8 Bit GPIO , devices with ports, calls get_port()/set_port() */
4597 i_psvc_constructor_10_1(
4606 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EGPIO8_t
));
4607 if (status
!= PSVC_SUCCESS
)
4610 /* Load class specific info */
4611 dp
= (EGPIO8_t
*)*objpp
;
4613 dp
->ld
.constructor
= i_psvc_constructor_10_1
;
4614 dp
->ld
.destructor
= i_psvc_destructor
;
4615 dp
->ld
.get_attr
= i_psvc_get_attr_10_1
;
4616 dp
->ld
.set_attr
= i_psvc_set_attr_10_1
;
4618 return (PSVC_SUCCESS
);
4623 i_psvc_constructor_11_0(
4632 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4633 sizeof (EPhysDev_t
));
4634 if (status
!= PSVC_SUCCESS
)
4637 /* Load class specific info */
4638 dp
= (EPhysDev_t
*)*objpp
;
4640 dp
->ld
.constructor
= i_psvc_constructor_11_0
;
4641 dp
->ld
.destructor
= i_psvc_destructor
;
4642 dp
->ld
.get_attr
= i_psvc_get_attr_11_0
;
4643 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4644 dp
->get_temperature
= i_psvc_not_supported
;
4645 dp
->get_fanspeed
= i_psvc_not_supported
;
4646 dp
->get_input
= i_psvc_not_supported
;
4647 dp
->get_bit
= i_psvc_not_supported
;
4648 dp
->set_bit
= i_psvc_not_supported
;
4649 dp
->get_port
= i_psvc_not_supported
;
4650 dp
->set_port
= i_psvc_not_supported
;
4651 dp
->get_output
= i_psvc_not_supported
;
4652 dp
->set_output
= i_psvc_not_supported
;
4653 dp
->get_reg
= i_psvc_get_reg_11_0
;
4654 dp
->set_reg
= i_psvc_not_supported
;
4656 return (PSVC_SUCCESS
);
4661 i_psvc_constructor_11_1(
4670 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EPhysDev_t
));
4671 if (status
!= PSVC_SUCCESS
)
4674 /* Load class specific info */
4675 dp
= (EPhysDev_t
*)*objpp
;
4677 dp
->ld
.constructor
= i_psvc_constructor_11_1
;
4678 dp
->ld
.destructor
= i_psvc_destructor
;
4679 dp
->ld
.get_attr
= i_psvc_get_attr_11_1
;
4680 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4681 dp
->get_temperature
= i_psvc_not_supported
;
4682 dp
->get_fanspeed
= i_psvc_not_supported
;
4683 dp
->get_input
= i_psvc_not_supported
;
4684 dp
->get_bit
= i_psvc_not_supported
;
4685 dp
->set_bit
= i_psvc_not_supported
;
4686 dp
->get_port
= i_psvc_not_supported
;
4687 dp
->set_port
= i_psvc_not_supported
;
4688 dp
->get_output
= i_psvc_not_supported
;
4689 dp
->set_output
= i_psvc_not_supported
;
4690 dp
->get_reg
= i_psvc_get_reg_11_1
;
4691 dp
->set_reg
= i_psvc_set_reg_11_1
;
4693 return (PSVC_SUCCESS
);
4698 i_psvc_constructor_11_2(
4707 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EPhysDev_t
));
4708 if (status
!= PSVC_SUCCESS
)
4711 /* Load class specific info */
4712 dp
= (EPhysDev_t
*)*objpp
;
4714 dp
->ld
.constructor
= i_psvc_constructor_11_2
;
4715 dp
->ld
.destructor
= i_psvc_destructor
;
4716 dp
->ld
.get_attr
= i_psvc_get_attr_11_2
;
4717 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4718 dp
->get_temperature
= i_psvc_get_temperature_11_2
;
4719 dp
->get_fanspeed
= i_psvc_not_supported
;
4720 dp
->get_input
= i_psvc_not_supported
;
4721 dp
->get_bit
= i_psvc_not_supported
;
4722 dp
->set_bit
= i_psvc_not_supported
;
4723 dp
->get_port
= i_psvc_not_supported
;
4724 dp
->set_port
= i_psvc_not_supported
;
4725 dp
->get_output
= i_psvc_not_supported
;
4726 dp
->set_output
= i_psvc_not_supported
;
4727 dp
->get_reg
= i_psvc_not_supported
;
4728 dp
->set_reg
= i_psvc_not_supported
;
4730 return (PSVC_SUCCESS
);
4735 i_psvc_constructor_11_3(
4745 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EPhysDev_t
));
4746 if (status
!= PSVC_SUCCESS
)
4750 * The following code upto and including the open() call is so the
4751 * device driver for the ltc1427 does not get unloaded by the OS at
4752 * any time. This is important as the device driver is a write only
4753 * physical device but DOES keep readable states in the device unitp
4754 * structure (I2C_GET_OUTPUT) as a result this device should not
4755 * be unload while PSVC is up and running
4757 status
= i_psvc_get_devpath(hdlp
, (*objpp
)->addr_spec
, path
);
4758 if (status
!= PSVC_SUCCESS
) {
4763 * We deliberately do not close our file handle, to prevent
4764 * any device instances from being detached. If an instance
4765 * is detached, the "readable states in the device unitp"
4766 * will be unloaded, causing loss of control of the device
4767 * and incorrect error(s) to be displayed.
4769 if (open(path
, O_RDWR
) == -1) {
4770 return (PSVC_FAILURE
);
4772 /* Load class specific info */
4773 dp
= (EPhysDev_t
*)*objpp
;
4775 dp
->ld
.constructor
= i_psvc_constructor_11_3
;
4776 dp
->ld
.destructor
= i_psvc_destructor
;
4777 dp
->ld
.get_attr
= i_psvc_get_attr_11_3
;
4778 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4779 dp
->get_temperature
= i_psvc_not_supported
;
4780 dp
->get_fanspeed
= i_psvc_not_supported
;
4781 dp
->get_input
= i_psvc_not_supported
;
4782 dp
->get_bit
= i_psvc_not_supported
;
4783 dp
->set_bit
= i_psvc_not_supported
;
4784 dp
->get_port
= i_psvc_not_supported
;
4785 dp
->set_port
= i_psvc_not_supported
;
4786 dp
->get_output
= i_psvc_get_output_11_3
;
4787 dp
->set_output
= i_psvc_set_output_11_3
;
4788 dp
->get_reg
= i_psvc_not_supported
;
4789 dp
->set_reg
= i_psvc_not_supported
;
4791 return (PSVC_SUCCESS
);
4796 i_psvc_constructor_11_4(
4805 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EPhysDev_t
));
4806 if (status
!= PSVC_SUCCESS
)
4809 /* Load class specific info */
4810 dp
= (EPhysDev_t
*)*objpp
;
4812 dp
->ld
.constructor
= i_psvc_constructor_11_4
;
4813 dp
->ld
.destructor
= i_psvc_destructor
;
4814 dp
->ld
.get_attr
= i_psvc_get_attr_11_4
;
4815 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4816 dp
->get_temperature
= i_psvc_get_temperature_11_4
;
4817 dp
->get_fanspeed
= i_psvc_not_supported
;
4818 dp
->get_input
= i_psvc_not_supported
;
4819 dp
->get_bit
= i_psvc_not_supported
;
4820 dp
->set_bit
= i_psvc_not_supported
;
4821 dp
->get_port
= i_psvc_not_supported
;
4822 dp
->set_port
= i_psvc_not_supported
;
4823 dp
->get_output
= i_psvc_not_supported
;
4824 dp
->set_output
= i_psvc_not_supported
;
4825 dp
->get_reg
= i_psvc_not_supported
;
4826 dp
->set_reg
= i_psvc_not_supported
;
4828 return (PSVC_SUCCESS
);
4833 i_psvc_constructor_11_5(
4842 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EPhysDev_t
));
4843 if (status
!= PSVC_SUCCESS
)
4846 /* Load class specific info */
4847 dp
= (EPhysDev_t
*)*objpp
;
4849 dp
->ld
.constructor
= i_psvc_constructor_11_5
;
4850 dp
->ld
.destructor
= i_psvc_destructor
;
4851 dp
->ld
.get_attr
= i_psvc_get_attr_11_5
;
4852 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4853 dp
->get_temperature
= i_psvc_not_supported
;
4854 dp
->get_fanspeed
= i_psvc_not_supported
;
4855 dp
->get_input
= i_psvc_not_supported
;
4856 dp
->get_bit
= i_psvc_get_bit_11_5
;
4857 dp
->set_bit
= i_psvc_set_bit_11_5
;
4858 dp
->get_port
= i_psvc_get_port_11_5
;
4859 dp
->set_port
= i_psvc_set_port_11_5
;
4860 dp
->get_output
= i_psvc_not_supported
;
4861 dp
->set_output
= i_psvc_not_supported
;
4862 dp
->get_reg
= i_psvc_not_supported
;
4863 dp
->set_reg
= i_psvc_not_supported
;
4865 return (PSVC_SUCCESS
);
4870 i_psvc_constructor_11_6(
4879 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EPhysDev_t
));
4880 if (status
!= PSVC_SUCCESS
)
4883 /* Load class specific info */
4884 dp
= (EPhysDev_t
*)*objpp
;
4886 dp
->ld
.constructor
= i_psvc_constructor_11_6
;
4887 dp
->ld
.destructor
= i_psvc_destructor
;
4888 dp
->ld
.get_attr
= i_psvc_get_attr_11_6
;
4889 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4890 dp
->get_temperature
= i_psvc_get_temperature_11_6
;
4891 dp
->get_fanspeed
= i_psvc_not_supported
;
4892 dp
->get_input
= i_psvc_get_input_11_6
;
4893 dp
->get_bit
= i_psvc_not_supported
;
4894 dp
->set_bit
= i_psvc_not_supported
;
4895 dp
->get_port
= i_psvc_not_supported
;
4896 dp
->set_port
= i_psvc_not_supported
;
4897 dp
->get_output
= i_psvc_get_output_11_6
;
4898 dp
->set_output
= i_psvc_set_output_11_6
;
4899 dp
->get_reg
= i_psvc_not_supported
;
4900 dp
->set_reg
= i_psvc_not_supported
;
4902 return (PSVC_SUCCESS
);
4907 i_psvc_constructor_11_7(
4916 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EPhysDev_t
));
4917 if (status
!= PSVC_SUCCESS
)
4920 /* Load class specific info */
4921 dp
= (EPhysDev_t
*)*objpp
;
4923 dp
->ld
.constructor
= i_psvc_constructor_11_7
;
4924 dp
->ld
.destructor
= i_psvc_destructor
;
4925 dp
->ld
.get_attr
= i_psvc_get_attr_11_7
;
4926 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4927 dp
->get_temperature
= i_psvc_not_supported
;
4928 dp
->get_fanspeed
= i_psvc_get_fanspeed_11_7
;
4929 dp
->get_input
= i_psvc_not_supported
;
4930 dp
->get_bit
= i_psvc_get_bit_11_7
;
4931 dp
->set_bit
= i_psvc_set_bit_11_7
;
4932 dp
->get_port
= i_psvc_get_port_11_5
; /* same as for class = 11, 5 */
4933 dp
->set_port
= i_psvc_set_port_11_5
;
4934 dp
->get_output
= i_psvc_not_supported
;
4935 dp
->set_output
= i_psvc_not_supported
;
4936 dp
->get_reg
= i_psvc_get_reg_11_7
;
4937 dp
->set_reg
= i_psvc_set_reg_11_7
;
4939 return (PSVC_SUCCESS
);
4944 i_psvc_constructor_11_8(
4953 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EPhysDev_t
));
4954 if (status
!= PSVC_SUCCESS
)
4957 /* Load class specific info */
4958 dp
= (EPhysDev_t
*)*objpp
;
4960 dp
->ld
.constructor
= i_psvc_constructor_11_8
;
4961 dp
->ld
.destructor
= i_psvc_destructor
;
4962 dp
->ld
.get_attr
= i_psvc_get_attr_11_8
;
4963 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4964 dp
->get_temperature
= i_psvc_not_supported
;
4965 dp
->get_fanspeed
= i_psvc_not_supported
;
4966 dp
->get_input
= i_psvc_not_supported
;
4967 dp
->get_bit
= i_psvc_not_supported
;
4968 dp
->set_bit
= i_psvc_not_supported
;
4969 dp
->get_port
= i_psvc_not_supported
;
4970 dp
->set_port
= i_psvc_not_supported
;
4971 dp
->get_output
= i_psvc_get_output_11_8
;
4972 dp
->set_output
= i_psvc_set_output_11_8
;
4973 dp
->get_reg
= i_psvc_not_supported
;
4974 dp
->set_reg
= i_psvc_not_supported
;
4976 return (PSVC_SUCCESS
);
4981 i_psvc_constructor_11_9(
4990 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EPhysDev_t
));
4991 if (status
!= PSVC_SUCCESS
)
4994 /* Load class specific info */
4995 dp
= (EPhysDev_t
*)*objpp
;
4997 dp
->ld
.constructor
= i_psvc_constructor_11_9
;
4998 dp
->ld
.destructor
= i_psvc_destructor
;
4999 dp
->ld
.get_attr
= i_psvc_get_attr_11_9
;
5000 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
5001 dp
->get_temperature
= i_psvc_not_supported
;
5002 dp
->get_fanspeed
= i_psvc_not_supported
;
5003 dp
->get_input
= i_psvc_not_supported
;
5004 dp
->get_bit
= i_psvc_not_supported
;
5005 dp
->set_bit
= i_psvc_not_supported
;
5006 dp
->get_port
= i_psvc_get_port_11_5
; /* Same as for class = 11, 5 */
5007 dp
->set_port
= i_psvc_set_port_11_5
;
5008 dp
->get_output
= i_psvc_not_supported
;
5009 dp
->set_output
= i_psvc_not_supported
;
5010 dp
->get_reg
= i_psvc_not_supported
;
5011 dp
->set_reg
= i_psvc_not_supported
;
5013 return (PSVC_SUCCESS
);
5017 psvc_init(EHdl_t
**hdlpp
)
5026 pthread_mutexattr_t mutex_attr
;
5027 uint32_t table_count
;
5028 int forward_slash
= 47;
5032 hdlp
= (EHdl_t
*)malloc(sizeof (EHdl_t
));
5035 memset(hdlp
, 0, sizeof (EHdl_t
));
5037 /* Initialize the lock */
5038 status
= pthread_mutexattr_init(&mutex_attr
);
5043 status
= pthread_mutex_init(&hdlp
->mutex
, &mutex_attr
);
5048 pthread_mutexattr_destroy(&mutex_attr
);
5050 if (sysinfo(SI_PLATFORM
, platform
, sizeof (platform
)) == -1) {
5054 snprintf(filename
, sizeof (filename
),
5055 "/usr/platform/%s/lib/psvcobj.conf", platform
);
5056 if ((hdlp
->fp
= fopen(filename
, "r")) == NULL
) {
5061 /* Build the association ID lookup table */
5063 hdlp
->othr_count
= hdlp
->assoc_count
= ASSOC_STR_TAB_SIZE
;
5064 if ((hdlp
->othr_tbl
= (EStringId_t
*)malloc(sizeof (EStringId_t
) *
5065 hdlp
->othr_count
)) == NULL
) {
5069 for (i
= 0; i
< hdlp
->othr_count
; ++i
) {
5070 hdlp
->othr_tbl
[i
].id
= i
;
5071 strcpy(hdlp
->othr_tbl
[i
].name
, assoc_str_tab
[i
]);
5073 qsort(hdlp
->othr_tbl
, hdlp
->othr_count
, sizeof (EStringId_t
),
5074 (int (*)(const void *, const void *))i_psvc_name_compare_qsort
);
5076 /* determine total number of objects + tables */
5077 if (i_psvc_find_file_section(hdlp
->fp
, "OBJECT_INFO") == -1) {
5080 if (i_psvc_count_records(hdlp
->fp
, "OBJECT_INFO_END",
5081 &hdlp
->total_obj_count
) == -1) {
5084 if (i_psvc_find_file_section(hdlp
->fp
, "TABLES") == PSVC_SUCCESS
) {
5085 status
= i_psvc_count_tables_associations(hdlp
->fp
,
5086 &table_count
, "TABLE_END");
5087 if (status
== PSVC_FAILURE
) {
5090 hdlp
->total_obj_count
+= table_count
;
5093 /* Allocate object name to object pointer translation table */
5094 for (i
= 0; i
< PSVC_MAX_TABLE_ARRAYS
; i
++) {
5095 if ((hdlp
->tbl_arry
[i
].obj_tbl
=
5096 (ENamePtr_t
*)malloc(
5097 sizeof (ENamePtr_t
) *hdlp
->total_obj_count
)) == NULL
) {
5100 memset(hdlp
->tbl_arry
[i
].obj_tbl
, 0,
5101 sizeof (ENamePtr_t
) * hdlp
->total_obj_count
);
5102 hdlp
->tbl_arry
[i
].obj_count
= 0;
5105 /* Build the association table */
5106 if (i_psvc_load_associations(hdlp
, hdlp
->fp
) == -1)
5109 /* Build the table of device paths */
5110 if (i_psvc_find_file_section(hdlp
->fp
, "DEVPATHS") == -1)
5112 if (i_psvc_count_records(hdlp
->fp
, "DEVPATHS_END",
5113 &hdlp
->dev_count
) == -1)
5115 if ((hdlp
->dev_tbl
= (EDevice_t
*)malloc(sizeof (EDevice_t
) *
5116 hdlp
->dev_count
)) == NULL
) {
5119 for (i
= 0; i
< hdlp
->dev_count
; ++i
) {
5120 fgets(buf
, BUFSZ
, hdlp
->fp
);
5121 found
= sscanf(buf
, "%d %d %x %d",
5122 &hdlp
->dev_tbl
[i
].controller
,
5123 &hdlp
->dev_tbl
[i
].bus
, &hdlp
->dev_tbl
[i
].addr
,
5124 &hdlp
->dev_tbl
[i
].port
);
5129 strcpy(hdlp
->dev_tbl
[i
].path
, strchr(buf
, forward_slash
));
5131 * Replace new line character with NUL character
5133 nl_char
= strchr(hdlp
->dev_tbl
[i
].path
, new_line
);
5137 /* Build the table of tables */
5138 if (i_psvc_load_tables(hdlp
, hdlp
->fp
) == -1)
5145 psvc_fini(EHdl_t
*hdlp
)
5148 ETable_Array
*array
;
5151 return (PSVC_SUCCESS
);
5153 for (j
= 0; j
< PSVC_MAX_TABLE_ARRAYS
; j
++) {
5154 if (hdlp
->tbl_arry
[j
].obj_tbl
!= 0) {
5155 array
= &(hdlp
->tbl_arry
[j
]);
5156 for (i
= 0; i
< array
->obj_count
; ++i
) {
5157 if (array
->obj_tbl
[i
].type
== PSVC_OBJ
) {
5158 if (!array
->obj_tbl
[i
].objp
) {
5159 /* Skip non-existent object */
5162 array
->obj_tbl
[i
].objp
->destructor(hdlp
,
5163 array
->obj_tbl
[i
].objp
->label
,
5164 array
->obj_tbl
[i
].objp
);
5167 if (array
->obj_tbl
[i
].type
== PSVC_TBL
) {
5169 (ETable_t
*)array
->obj_tbl
[i
].objp
;
5170 if (tblp
->table
!= 0)
5175 free(array
->obj_tbl
);
5179 if (hdlp
->othr_tbl
!= 0)
5180 free(hdlp
->othr_tbl
);
5182 if (hdlp
->assoc_tbl
!= 0) {
5183 for (i
= 0; i
< hdlp
->assoc_count
; ++i
) {
5184 if (hdlp
->assoc_tbl
[i
].table
!= 0)
5185 free(hdlp
->assoc_tbl
[i
].table
);
5187 free(hdlp
->assoc_tbl
);
5190 if (hdlp
->dev_tbl
!= 0)
5191 free(hdlp
->dev_tbl
);
5194 pthread_mutex_destroy(&hdlp
->mutex
);
5196 return (PSVC_SUCCESS
);
5200 ioctl_retry(int fp
, int request
, void * arg_pointer
)
5202 int32_t ret
= PSVC_SUCCESS
;
5206 * Becuase the i2c bus is a multimaster bus we need to protect
5207 * ourselves from bus masters that are not being good bus citizens.
5208 * A retry number of 10 should be sufficient to handle any bad bus
5209 * citizens. After that we will simply say that there is something
5210 * wrong with the ioctl transaction and let it bubble back up.
5213 ret
= ioctl(fp
, request
, arg_pointer
);
5215 } while ((ret
== -1) && (tries
< 10));
5221 psvc_get_str_key(char *object
)
5226 length
= strlen(object
);
5227 for (i
= 0; i
< length
; i
++) {
5228 if ((object
[i
] > 47) && (object
[i
] < 58)) {
5229 key
= key
+ ((object
[i
] - 50) + 2);
5231 key
= key
+ object
[i
];