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.
28 * This file consists of routines to manage objects in the
29 * "Platform Environment Services Framework". The classes
30 * and subclasses are defined by attributes and methods.
31 * The objects, and their initial, static, attribute values are
32 * specified in a configuration file, "psvcobj.conf".
33 * psvc_init() reads the configuration file and creates a repository
34 * of environmental objects in memory. A client application may manipulate
35 * these objects by invoking the psvc_get_attr(), and psvc_set_attr()
36 * routines with the object's string ID specified as an argument.
50 #include <sys/systeminfo.h>
52 #define LIBRARY_BUILD 1
53 #include <psvc_objects.h>
54 #include <psvc_objects_class.h>
55 #include <sys/i2c/clients/i2c_client.h>
57 /* Mutex used for Daktari Fan speed reading */
58 pthread_mutex_t fan_mutex
= PTHREAD_MUTEX_INITIALIZER
;
62 #define ENV_DEBUG(str, id) printf("%s id %s\n", (str), (id))
67 #define SUBCLASS_MAX 10
69 static int32_t i_psvc_constructor_0_0(EHdl_t
*, char *, EObj_t
**);
70 static int32_t i_psvc_constructor_0_1(EHdl_t
*, char *, EObj_t
**);
71 static int32_t i_psvc_constructor_1_0(EHdl_t
*, char *, EObj_t
**);
72 static int32_t i_psvc_constructor_2_0(EHdl_t
*, char *, EObj_t
**);
73 static int32_t i_psvc_constructor_2_1(EHdl_t
*, char *, EObj_t
**);
74 static int32_t i_psvc_constructor_2_2(EHdl_t
*, char *, EObj_t
**);
75 static int32_t i_psvc_constructor_3_0(EHdl_t
*, char *, EObj_t
**);
76 static int32_t i_psvc_constructor_4_0(EHdl_t
*, char *, EObj_t
**);
77 static int32_t i_psvc_constructor_5_0(EHdl_t
*, char *, EObj_t
**);
78 static int32_t i_psvc_constructor_6_0(EHdl_t
*, char *, EObj_t
**);
79 static int32_t i_psvc_constructor_7_0(EHdl_t
*, char *, EObj_t
**);
80 static int32_t i_psvc_constructor_8_0(EHdl_t
*, char *, EObj_t
**);
81 static int32_t i_psvc_constructor_9_0(EHdl_t
*, char *, EObj_t
**);
82 static int32_t i_psvc_constructor_10_0(EHdl_t
*, char *, EObj_t
**);
83 static int32_t i_psvc_constructor_10_1(EHdl_t
*, char *, EObj_t
**);
84 static int32_t i_psvc_constructor_11_0(EHdl_t
*, char *, EObj_t
**);
85 static int32_t i_psvc_constructor_11_1(EHdl_t
*, char *, EObj_t
**);
86 static int32_t i_psvc_constructor_11_2(EHdl_t
*, char *, EObj_t
**);
87 static int32_t i_psvc_constructor_11_3(EHdl_t
*, char *, EObj_t
**);
88 static int32_t i_psvc_constructor_11_4(EHdl_t
*, char *, EObj_t
**);
89 static int32_t i_psvc_constructor_11_5(EHdl_t
*, char *, EObj_t
**);
90 static int32_t i_psvc_constructor_11_6(EHdl_t
*, char *, EObj_t
**);
91 static int32_t i_psvc_constructor_11_7(EHdl_t
*, char *, EObj_t
**);
92 static int32_t i_psvc_constructor_11_8(EHdl_t
*, char *, EObj_t
**);
93 static int32_t i_psvc_constructor_11_9(EHdl_t
*, char *, EObj_t
**);
95 static int32_t i_psvc_get_obj(EHdl_t
*, char *, EObj_t
**);
96 static int32_t i_psvc_destructor(EHdl_t
*, char *, void *);
97 static int32_t i_psvc_get_devpath(EHdl_t
*, uint64_t, char *);
98 static int32_t i_psvc_get_attr_generic(EHdl_t
*, EObj_t
*, int32_t, void *);
99 static int32_t i_psvc_get_attr_6_0(EHdl_t
*, EObj_t
*, int32_t, void *);
100 static int32_t i_psvc_get_reg_11_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
,
102 static int32_t i_psvc_get_attr_10_1(EHdl_t
*, EObj_t
*, int32_t, void *);
103 static int32_t psvc_get_str_key(char *object
);
105 int32_t ioctl_retry(int fp
, int request
, void * arg_pointer
);
108 * Method lookup tables
109 * Update when adding classes or subclasses.
113 /* Lookup method by class, subclass, used when calling method */
114 static int32_t (*i_psvc_constructor
[CLASS_MAX
][SUBCLASS_MAX
])(EHdl_t
*,
115 char *, EObj_t
**) = {
116 {i_psvc_constructor_0_0
, i_psvc_constructor_0_1
, 0, 0, 0, 0, 0, 0, 0, 0},
117 {i_psvc_constructor_1_0
, 0, 0, 0, 0, 0, 0, 0, 0, 0},
118 {i_psvc_constructor_2_0
, i_psvc_constructor_2_1
, i_psvc_constructor_2_2
,
119 0, 0, 0, 0, 0, 0, 0},
120 {i_psvc_constructor_3_0
, 0, 0, 0, 0, 0, 0, 0, 0, 0},
121 {i_psvc_constructor_4_0
, 0, 0, 0, 0, 0, 0, 0, 0, 0},
122 {i_psvc_constructor_5_0
, 0, 0, 0, 0, 0, 0, 0, 0, 0},
123 {i_psvc_constructor_6_0
, 0, 0, 0, 0, 0, 0, 0, 0, 0},
124 {i_psvc_constructor_7_0
, 0, 0, 0, 0, 0, 0, 0, 0, 0},
125 {i_psvc_constructor_8_0
, 0, 0, 0, 0, 0, 0, 0, 0, 0},
126 {i_psvc_constructor_9_0
, 0, 0, 0, 0, 0, 0, 0, 0, 0},
127 {i_psvc_constructor_10_0
, i_psvc_constructor_10_1
, 0, 0, 0, 0, 0, 0, 0, 0},
128 {i_psvc_constructor_11_0
, i_psvc_constructor_11_1
, i_psvc_constructor_11_2
,
129 i_psvc_constructor_11_3
, i_psvc_constructor_11_4
,
130 i_psvc_constructor_11_5
, i_psvc_constructor_11_6
,
131 i_psvc_constructor_11_7
, i_psvc_constructor_11_8
,
132 i_psvc_constructor_11_9
},
135 static int32_t i_psvc_cell_size
[8] = {1, 1, 2, 2, 4, 4, 8, 8};
141 {PSVC_DEV_PERM
, "PERM="},
142 {PSVC_DEV_HOTPLUG
, "HOTPLUG="},
143 {PSVC_DEV_OPTION
, "OPTION="},
144 {PSVC_DEV_PRIMARY
, "PRIMARY="},
145 {PSVC_DEV_SECONDARY
, "SECONDARY="},
146 {PSVC_DEV_RDONLY
, "RDONLY="},
147 {PSVC_DEV_RDWR
, "RDWR="},
148 {PSVC_DEV_FRU
, "FRU="},
149 {PSVC_LOW_WARN
, "LO_WARN_MASK="},
150 {PSVC_LOW_SHUT
, "LO_SHUT_MASK="},
151 {PSVC_HIGH_WARN
, "HI_WARN_MASK="},
152 {PSVC_HIGH_SHUT
, "HI_SHUT_MASK="},
153 {PSVC_CONVERSION_TABLE
, "CONV_TABLE="},
154 {PSVC_OPT_TEMP
, "OPT_TEMP_MASK="},
155 {PSVC_HW_LOW_SHUT
, "HW_LO_MASK="},
156 {PSVC_HW_HIGH_SHUT
, "HW_HI_MASK="},
157 {PSVC_FAN_DRIVE_PR
, "FAN_DRIVE_PR="},
158 {PSVC_TEMP_DRIVEN
, "TEMP_DRIVEN="},
159 {PSVC_SPEED_CTRL_PR
, "SPEED_CTRL_PR="},
160 {PSVC_FAN_ON_OFF
, "FAN_ON_OFF="},
161 {PSVC_CLOSED_LOOP_CTRL
, "CLOSED_LOOP_CTRL="},
162 {PSVC_FAN_DRIVE_TABLE_PR
, "FAN_DRIVE_TABLE_PR="},
163 {PSVC_DIE_TEMP
, "DIE_TEMP="},
164 {PSVC_AMB_TEMP
, "AMB_TEMP="},
165 {PSVC_DIGI_SENSOR
, "DIGI_SENSOR="},
166 {PSVC_BI_STATE
, "BI_STATE="},
167 {PSVC_TRI_STATE
, "TRI_STATE="},
168 {PSVC_GREEN
, "GREEN="},
169 {PSVC_AMBER
, "AMBER="},
170 {PSVC_OUTPUT
, "OUTPUT="},
171 {PSVC_INPUT
, "INPUT="},
172 {PSVC_BIDIR
, "BIDIR="},
173 {PSVC_BIT_POS
, "BIT_POS="},
174 {PSVC_VAL_POS
, "VAL_POS="},
175 {PSVC_NORMAL_POS_AV
, "NORMAL_POS_AV="},
176 {PSVC_DIAG_POS_AV
, "DIAG_POS_AV="},
177 {PSVC_LOCK_POS_AV
, "LOCK_POS_AV="},
178 {PSVC_OFF_POS_AV
, "OFF_POS_AV="},
179 {PSVC_GPIO_PORT
, "GPIO_PORT="},
180 {PSVC_GPIO_REG
, "GPIO_REG="}
183 #define ASSOC_STR_TAB_SIZE 33
184 static char *assoc_str_tab
[] = {
185 "PSVC_PRESENCE_SENSOR", /* 0 */
186 "PSVC_FAN_ONOFF_SENSOR", /* 1 */
187 "PSVC_FAN_SPEED_TACHOMETER", /* 2 */
188 "PSVC_FAN_PRIM_SEC_SELECTOR", /* 3 */
189 "PSVC_DEV_TEMP_SENSOR", /* 4 */
190 "PSVC_FAN_DRIVE_CONTROL", /* 5 */
191 "PSVC_KS_NORMAL_POS_SENSOR", /* 6 */
192 "PSVC_KS_DIAG_POS_SENSOR", /* 7 */
193 "PSVC_KS_LOCK_POS_SENSOR", /* 8 */
194 "PSVC_KS_OFF_POS_SENSOR", /* 9 */
195 "PSVC_SLOT_FAULT_LED", /* 10 */
196 "PSVC_SLOT_REMOVE_LED", /* 11 */
197 "PSVC_TS_OVERTEMP_LED", /* 12 */
198 "PSVC_PS_I_SENSOR", /* 13 */
199 "PSVC_DEV_FAULT_SENSOR", /* 14 */
200 "PSVC_DEV_FAULT_LED", /* 15 */
201 "PSVC_TABLE", /* 16 */
202 "PSVC_PARENT", /* 17 */
204 "PSVC_ALTERNATE", /* 19 */
205 "PSVC_HOTPLUG_ENABLE_SWITCH", /* 20 */
209 "PSVC_DISK", /* 24 */
211 "PSVC_FSP_LED", /* 26 */
212 "PSVC_KEYSWITCH", /* 27 */
213 "PSVC_PCI_CARD", /* 28 */
214 "PSVC_PHYSICAL_DEVICE", /* 29 */
215 "PSVC_DEV_TYPE_SENSOR", /* 30 */
216 "PSVC_FAN_TRAY_FANS", /* 31 */
220 #define FEATURE_BITS (sizeof (feature_bits) / sizeof (struct bits))
222 static struct bitfield
{
228 {PSVC_VERSION_SHIFT
, "VERSION=", "%d"},
229 {PSVC_ACTIVE_LOW_SHIFT
, "ACTIVE_LOW=", "%d"},
230 {PSVC_BIT_NUM_SHIFT
, "BIT_NUM=", "%d"},
231 {PSVC_INVERT_SHIFT
, "INVERT=", "%d"},
232 {PSVC_PORT_SHIFT
, "PORT=", "%d"},
233 {PSVC_BITSHIFT_SHIFT
, "BITSHIFT=", "%d"},
234 {PSVC_BYTEMASK_SHIFT
, "BYTEMASK=", "%x"},
235 {PSVC_REG_SHIFT
, "REG=", "%d"},
236 {PSVC_TYPE_SHIFT
, "TYPE=", "%d"},
237 {PSVC_BUSADDR_SHIFT
, "BUSADDR=", "%x"},
238 {PSVC_BUSNUM_SHIFT
, "BUSNUM=", "%d"},
239 {PSVC_CNTLR_SHIFT
, "CNTLR=", "%d"},
241 #define ADDR_BITFIELDS (sizeof (addr_fields) / sizeof (struct bitfield))
245 * pathname label1=val1,label2=val2,label3=val3
246 * Must be a space after the pathname and a comma between variables.
250 find_label(char *str
, char *label
)
254 start
= strchr(str
, ' ');
260 if (strncmp(start
, label
, strlen(label
)) == 0)
263 start
= strchr(start
, ',');
264 } while (start
!= NULL
);
270 i_psvc_value(char *buf
, int32_t attr_id
, void *attrp
)
284 case PSVC_CLASS_ATTR
:
285 case PSVC_SUBCLASS_ATTR
:
286 case PSVC_INSTANCE_ATTR
:
287 case PSVC_LO_WARN_ATTR
:
288 case PSVC_LO_SHUT_ATTR
:
289 case PSVC_HI_WARN_ATTR
:
290 case PSVC_HI_SHUT_ATTR
:
291 case PSVC_HW_HI_SHUT_ATTR
:
292 case PSVC_HW_LO_SHUT_ATTR
:
293 case PSVC_OPTIMAL_TEMP_ATTR
:
294 snprintf(label
, sizeof (label
), "%s=", attr_str_tab
[attr_id
]);
295 val
= find_label(buf
, label
);
298 return (PSVC_FAILURE
);
300 found
= sscanf(val
+ strlen(label
),
301 "%d", (int32_t *)attrp
);
303 *(int32_t *)attrp
= 0;
305 case PSVC_SETPOINT_ATTR
:
306 case PSVC_HYSTERESIS_ATTR
:
307 case PSVC_LOOPGAIN_ATTR
:
308 case PSVC_LOOPBIAS_ATTR
:
309 snprintf(label
, sizeof (label
), "%s=", attr_str_tab
[attr_id
]);
310 val
= find_label(buf
, label
);
313 return (PSVC_FAILURE
);
316 found
= sscanf(val
+ strlen(label
), "%hd", (int16_t *)attrp
);
318 *(int16_t *)attrp
= 0;
320 case PSVC_LED_COLOR_ATTR
:
321 case PSVC_LED_IS_LOCATOR_ATTR
:
322 case PSVC_LED_LOCATOR_NAME_ATTR
:
323 snprintf(label
, sizeof (label
), "%s=", attr_str_tab
[attr_id
]);
324 val
= find_label(buf
, label
);
327 return (PSVC_FAILURE
);
329 val_size
= strlen(val
);
330 label_size
= strlen(label
);
332 for (i
= 0; i
< val_size
&& val
[i
] != ','; i
++);
333 if (i
< strlen(val
) - 1) {
334 strncpy((char *)attrp
, val
+label_size
,
337 found
= sscanf(val
+ label_size
, "%s", (char *)attrp
);
339 strcpy((char *)attrp
, "");
341 case PSVC_FEATURES_ATTR
:
343 for (i
= 0; i
< FEATURE_BITS
; ++i
) {
344 val
= find_label(buf
, feature_bits
[i
].label
);
347 found
= sscanf(val
+ strlen(feature_bits
[i
].label
),
351 result
|= feature_bits
[i
].bit
;
354 *(uint64_t *)attrp
= result
;
356 case PSVC_ADDR_SPEC_ATTR
:
358 for (i
= 0; i
< ADDR_BITFIELDS
; ++i
) {
359 val
= find_label(buf
, addr_fields
[i
].label
);
362 found
= sscanf(val
+ strlen(addr_fields
[i
].label
),
363 addr_fields
[i
].format
, &temp32
);
366 temp64
<<= addr_fields
[i
].shift
;
370 *(uint64_t *)attrp
= result
;
374 return (PSVC_FAILURE
);
376 return (PSVC_SUCCESS
);
379 /* determine number of records in file section */
381 i_psvc_count_records(FILE *fp
, char *end
, uint32_t *countp
)
388 first_record
= ftell(fp
);
390 while ((ret
= fgets(buf
, BUFSZ
, fp
)) != NULL
) {
391 if (strncmp(end
, buf
, strlen(end
)) == 0)
398 return (PSVC_FAILURE
);
401 fseek(fp
, first_record
, SEEK_SET
);
403 return (PSVC_SUCCESS
);
406 /* determine number of records in file section */
408 i_psvc_count_tables_associations(FILE *fp
, uint32_t *countp
, char *end
)
415 first_record
= ftell(fp
);
417 while ((ret
= fgets(buf
, BUFSZ
, fp
)) != NULL
) {
418 if (strncmp(end
, buf
, strlen(end
)) == 0)
422 fseek(fp
, first_record
, SEEK_SET
);
424 return (PSVC_SUCCESS
);
427 /* determine number of records in a table */
429 i_psvc_count_table_records(FILE *fp
, char *end
, uint32_t *countp
)
436 first_record
= ftell(fp
);
438 while ((ret
= fscanf(fp
, "%s", string
)) == 1) {
439 if (strncmp(end
, string
, strlen(end
)) == 0)
446 return (PSVC_FAILURE
);
449 fseek(fp
, first_record
, SEEK_SET
);
451 return (PSVC_SUCCESS
);
455 * Find number of matches to an antecedent_id of a certain
459 i_psvc_get_assoc_matches(EHdl_t
*hdlp
, char *antecedent
, int32_t assoc_id
,
464 EAssocList_t
*ap
= hdlp
->assoc_tbl
+ assoc_id
;
468 if (ap
->table
== 0) {
470 return (PSVC_FAILURE
);
473 key
= psvc_get_str_key(antecedent
);
475 for (i
= 0; i
< ap
->count
; ++i
) {
476 if (ap
->table
[i
].ant_key
== key
) {
477 if (strcmp(ap
->table
[i
].antecedent_id
, antecedent
)
482 return (PSVC_SUCCESS
);
486 * Find 1st m matches to an antecedent_id of a certain
488 * Returns zero for success, -1 for failure.
491 i_psvc_get_assoc_id(EHdl_t
*hdlp
, char *antecedent
, int32_t assoc_id
,
492 int32_t match
, char **id_list
)
497 EAssocList_t
*ap
= &hdlp
->assoc_tbl
[assoc_id
];
499 if (ap
->table
== 0) {
504 key
= psvc_get_str_key(antecedent
);
506 for (i
= 0; i
< ap
->count
; ++i
) {
507 if (ap
->table
[i
].ant_key
== key
) {
508 if (strcmp(ap
->table
[i
].antecedent_id
, antecedent
)
510 if (found
== match
) {
511 *id_list
= ap
->table
[i
].dependent_id
;
524 i_psvc_get_table_value(EHdl_t
*hdlp
, char *table_id
, uint32_t index
,
529 ETable_Array
*tbl_arr
;
532 key
= psvc_get_str_key(table_id
);
533 array
= key
% PSVC_MAX_TABLE_ARRAYS
;
534 tbl_arr
= &(hdlp
->tbl_arry
[array
]);
536 for (i
= 0; i
< tbl_arr
->obj_count
; ++i
) {
537 if (key
== tbl_arr
->obj_tbl
[i
].key
) {
538 if (strcmp(tbl_arr
->obj_tbl
[i
].name
,
544 if (tbl_arr
->obj_tbl
[i
].type
!= PSVC_TBL
)
545 return (PSVC_FAILURE
);
547 tblp
= (ETable_t
*)tbl_arr
->obj_tbl
[i
].objp
;
549 if (tblp
->table
== NULL
)
550 return (PSVC_FAILURE
);
552 if (index
>= tblp
->size
)
553 return (PSVC_FAILURE
);
555 switch (tblp
->cell_type
) {
557 *(int8_t *)value
= *((int8_t *)tblp
->table
+ index
);
560 *(uint8_t *)value
= *((uint8_t *)tblp
->table
+ index
);
563 *(int16_t *)value
= *((int16_t *)tblp
->table
+ index
);
566 *(uint16_t *)value
= *((uint16_t *)tblp
->table
+ index
);
569 *(int32_t *)value
= *((int32_t *)tblp
->table
+ index
);
572 *(uint32_t *)value
= *((uint32_t *)tblp
->table
+ index
);
575 *(int64_t *)value
= *((int64_t *)tblp
->table
+ index
);
578 *(uint64_t *)value
= *((uint64_t *)tblp
->table
+ index
);
581 return (PSVC_FAILURE
);
584 return (PSVC_SUCCESS
);
588 psvc_get_attr(EHdl_t
*hdlp
, char *name
, int32_t attr_id
, void *attr_valuep
, ...)
591 int32_t status
= PSVC_SUCCESS
;
595 pthread_mutex_lock(&hdlp
->mutex
);
597 if (attr_valuep
== NULL
) {
599 pthread_mutex_unlock(&hdlp
->mutex
);
600 return (PSVC_FAILURE
);
604 case PSVC_TABLE_VALUE_ATTR
:
605 va_start(ap
, attr_valuep
);
606 status
= i_psvc_get_table_value(hdlp
, name
,
607 va_arg(ap
, uint32_t), attr_valuep
);
610 case PSVC_ASSOC_MATCHES_ATTR
:
611 va_start(ap
, attr_valuep
);
612 status
= i_psvc_get_assoc_matches(hdlp
, name
,
613 va_arg(ap
, int32_t), attr_valuep
);
616 case PSVC_ASSOC_ID_ATTR
:
617 va_start(ap
, attr_valuep
);
618 arg1
= va_arg(ap
, int32_t);
619 arg2
= va_arg(ap
, int32_t);
620 status
= i_psvc_get_assoc_id(hdlp
, name
,
621 arg1
, arg2
, attr_valuep
);
625 status
= i_psvc_get_obj(hdlp
, name
, &objp
);
626 if (status
!= PSVC_SUCCESS
) {
627 pthread_mutex_unlock(&hdlp
->mutex
);
630 status
= (*objp
->get_attr
)(hdlp
, objp
, attr_id
,
634 if (status
!= PSVC_SUCCESS
) {
635 pthread_mutex_unlock(&hdlp
->mutex
);
639 pthread_mutex_unlock(&hdlp
->mutex
);
644 psvc_set_attr(EHdl_t
*hdlp
, char *name
, int32_t attr_id
, void *attr_valuep
)
647 int32_t status
= PSVC_SUCCESS
;
649 pthread_mutex_lock(&hdlp
->mutex
);
650 status
= i_psvc_get_obj(hdlp
, name
, &objp
);
651 if (status
!= PSVC_SUCCESS
) {
652 pthread_mutex_unlock(&hdlp
->mutex
);
656 if (attr_valuep
== NULL
) {
658 pthread_mutex_unlock(&hdlp
->mutex
);
659 return (PSVC_FAILURE
);
662 status
= (*objp
->set_attr
)(hdlp
, objp
, attr_id
, attr_valuep
);
663 if (status
!= PSVC_SUCCESS
) {
664 pthread_mutex_unlock(&hdlp
->mutex
);
668 pthread_mutex_unlock(&hdlp
->mutex
);
674 i_psvc_get_presence(EHdl_t
*hdlp
, EObj_t
*objp
, boolean_t
*pr
)
676 EObj_t
*pobjp
, *mobjp
;
680 int32_t status
= PSVC_SUCCESS
;
681 uint8_t value_8bit
, value_8bit_inv
;
682 boolean_t active_low
, value
;
684 if (strcmp(objp
->label
, PSVC_CHASSIS
) == 0) {
686 objp
->present
= PSVC_PRESENT
;
687 return (PSVC_SUCCESS
);
690 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PARENT
, 0,
692 if (status
!= PSVC_SUCCESS
)
695 if (strcmp(parent_id
, PSVC_CHASSIS
)) {
696 status
= i_psvc_get_obj(hdlp
, parent_id
, &pobjp
);
697 if (status
!= PSVC_SUCCESS
)
699 if (!pobjp
->present
) {
700 pobjp
->get_attr(hdlp
, pobjp
, PSVC_PRESENCE_ATTR
, pr
);
701 *pr
= pobjp
->present
;
702 objp
->present
= pobjp
->present
;
707 (void) i_psvc_get_assoc_matches(hdlp
, objp
->label
,
708 PSVC_PRESENCE_SENSOR
, &matches
);
711 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
,
712 PSVC_PRESENCE_SENSOR
, 0, &mid
);
713 if (status
!= PSVC_SUCCESS
)
715 status
= i_psvc_get_obj(hdlp
, mid
, &mobjp
);
716 if (status
!= PSVC_SUCCESS
)
719 active_low
= PSVC_IS_ACTIVE_LOW(mobjp
->addr_spec
);
721 if (mobjp
->class == PSVC_BOOLEAN_GPIO_CLASS
) {
722 status
= mobjp
->get_attr(hdlp
, mobjp
,
723 PSVC_GPIO_VALUE_ATTR
, &value
);
724 if (status
!= PSVC_SUCCESS
)
736 } else if (mobjp
->class == PSVC_8BIT_GPIO_CLASS
) {
737 uint8_t bitshift
, bytemask
;
739 status
= mobjp
->get_attr(hdlp
, mobjp
,
740 PSVC_GPIO_VALUE_ATTR
, &value_8bit
);
741 if (status
!= PSVC_SUCCESS
)
743 if (PSVC_HP_INVERT(mobjp
->addr_spec
))
744 value_8bit_inv
= ~value_8bit
;
746 value_8bit_inv
= value_8bit
;
747 bitshift
= PSVC_GET_ASPEC_BITSHIFT(mobjp
->addr_spec
);
748 bytemask
= PSVC_GET_ASPEC_BYTEMASK(mobjp
->addr_spec
);
750 value_8bit_inv
& (bytemask
>> bitshift
);
752 if (value_8bit_inv
== 0)
757 if (value_8bit_inv
== 0)
763 return (PSVC_FAILURE
);
775 i_psvc_get_device_value_0_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t *temp
)
777 int32_t status
= PSVC_SUCCESS
, m
;
783 if (objp
->present
!= PSVC_PRESENT
) {
785 return (PSVC_FAILURE
);
788 status
= i_psvc_get_assoc_id(
789 hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
, 0, &physid
);
790 if (status
!= PSVC_SUCCESS
) {
793 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
794 if (status
!= PSVC_SUCCESS
) {
798 status
= ((EPhysDev_t
*)physobjp
)->get_temperature(hdlp
,
799 objp
->addr_spec
, temp
);
800 if (status
!= PSVC_SUCCESS
) {
804 if (objp
->features
& PSVC_CONVERSION_TABLE
) {
805 status
= i_psvc_get_assoc_matches(hdlp
, objp
->label
,
807 if ((status
!= PSVC_SUCCESS
) || (m
!= 1)) {
811 (void) i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_TABLE
, 0,
814 status
= i_psvc_get_table_value(hdlp
, tid
, *temp
, &temp16
);
821 i_psvc_get_device_value_0_1(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t *temp
)
823 int32_t status
= PSVC_SUCCESS
, m
;
829 if (objp
->present
!= PSVC_PRESENT
) {
831 return (PSVC_FAILURE
);
834 status
= i_psvc_get_assoc_id(
835 hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
, 0, &physid
);
836 if (status
!= PSVC_SUCCESS
) {
839 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
840 if (status
!= PSVC_SUCCESS
) {
844 status
= ((EPhysDev_t
*)physobjp
)->get_temperature(hdlp
,
845 objp
->addr_spec
, temp
);
846 if (status
!= PSVC_SUCCESS
) {
850 if (objp
->features
& PSVC_CONVERSION_TABLE
) {
851 status
= i_psvc_get_assoc_matches(hdlp
, objp
->label
,
853 if ((status
!= PSVC_SUCCESS
) || (m
!= 1)) {
857 (void) i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_TABLE
, 0,
860 status
= i_psvc_get_table_value(hdlp
, tid
, *temp
, &temp16
);
867 i_psvc_get_device_value_4_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t *value
)
869 int32_t status
= PSVC_SUCCESS
;
873 if (objp
->present
!= PSVC_PRESENT
) {
875 return (PSVC_FAILURE
);
878 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
880 if (status
!= PSVC_SUCCESS
)
882 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
883 if (status
!= PSVC_SUCCESS
)
886 status
= ((EPhysDev_t
*)physobjp
)->get_input(hdlp
, objp
->addr_spec
,
888 if (status
!= PSVC_SUCCESS
)
891 if (objp
->features
& PSVC_CONVERSION_TABLE
) {
896 status
= i_psvc_get_assoc_matches(hdlp
, objp
->label
,
898 if ((status
!= PSVC_SUCCESS
) || (m
!= 1)) {
902 (void) i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_TABLE
, 0,
905 status
= i_psvc_get_table_value(hdlp
, tid
, *value
, &temp16
);
913 i_psvc_set_device_value_5_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t *value
)
915 int32_t status
= PSVC_SUCCESS
;
919 if (objp
->present
!= PSVC_PRESENT
) {
921 return (PSVC_FAILURE
);
924 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
926 if (status
!= PSVC_SUCCESS
)
928 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
929 if (status
!= PSVC_SUCCESS
)
931 status
= ((EPhysDev_t
*)physobjp
)->set_output(hdlp
, objp
->addr_spec
,
933 if (status
!= PSVC_SUCCESS
)
940 i_psvc_get_device_value_5_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t *value
)
942 int32_t status
= PSVC_SUCCESS
;
946 if (objp
->present
!= PSVC_PRESENT
) {
948 return (PSVC_FAILURE
);
951 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
953 if (status
!= PSVC_SUCCESS
)
955 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
956 if (status
!= PSVC_SUCCESS
)
959 status
= ((EPhysDev_t
*)physobjp
)->get_output(hdlp
, objp
->addr_spec
,
961 if (status
!= PSVC_SUCCESS
)
964 if (objp
->features
& PSVC_CONVERSION_TABLE
) {
969 status
= i_psvc_get_assoc_matches(hdlp
, objp
->label
,
971 if ((status
!= PSVC_SUCCESS
) || (m
!= 1)) {
975 (void) i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_TABLE
, 0,
978 status
= i_psvc_get_table_value(hdlp
, tid
, *value
, &temp16
);
985 i_psvc_get_device_value_6_0(EHdl_t
*hdlp
, EObj_t
*objp
, boolean_t
*value
)
987 int32_t status
= PSVC_SUCCESS
;
992 if (objp
->present
!= PSVC_PRESENT
) {
994 return (PSVC_FAILURE
);
997 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
999 if (status
!= PSVC_SUCCESS
)
1001 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1002 if (status
!= PSVC_SUCCESS
)
1005 status
= ((EPhysDev_t
*)physobjp
)->get_bit(hdlp
, objp
->addr_spec
,
1007 if (status
!= PSVC_SUCCESS
)
1016 i_psvc_set_device_value_6_0(EHdl_t
*hdlp
, EObj_t
*objp
, boolean_t
*value
)
1018 int32_t status
= PSVC_SUCCESS
;
1023 if (objp
->present
!= PSVC_PRESENT
) {
1025 return (PSVC_FAILURE
);
1029 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1031 if (status
!= PSVC_SUCCESS
)
1033 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1034 if (status
!= PSVC_SUCCESS
)
1037 status
= ((EPhysDev_t
*)physobjp
)->set_bit(hdlp
, objp
->addr_spec
,
1039 if (status
!= PSVC_SUCCESS
)
1046 i_psvc_get_device_value_1_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t *fan_speed
)
1048 int32_t status
= PSVC_SUCCESS
;
1052 if (objp
->present
!= PSVC_PRESENT
) {
1054 return (PSVC_FAILURE
);
1057 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
,
1058 PSVC_FAN_SPEED_TACHOMETER
, 0, &fan_tach
);
1059 if (status
!= PSVC_SUCCESS
)
1062 status
= i_psvc_get_obj(hdlp
, fan_tach
, &ftobjp
);
1063 if (status
!= PSVC_SUCCESS
)
1066 status
= ftobjp
->get_attr(hdlp
, ftobjp
, PSVC_SENSOR_VALUE_ATTR
,
1068 if (status
!= PSVC_SUCCESS
)
1075 i_psvc_get_device_value_7_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t *fan_speed
)
1079 int32_t status
= PSVC_SUCCESS
;
1081 if (objp
->present
!= PSVC_PRESENT
) {
1083 return (PSVC_FAILURE
);
1086 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1088 if (status
!= PSVC_SUCCESS
)
1090 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1091 if (status
!= PSVC_SUCCESS
)
1094 status
= ((EPhysDev_t
*)physobjp
)->get_fanspeed(hdlp
, objp
->addr_spec
,
1096 if (status
!= PSVC_SUCCESS
)
1099 if (objp
->features
& PSVC_CONVERSION_TABLE
) {
1104 status
= i_psvc_get_assoc_matches(hdlp
, objp
->label
,
1106 if ((status
!= PSVC_SUCCESS
) || (m
!= 1)) {
1110 (void) i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_TABLE
, 0,
1113 status
= i_psvc_get_table_value(hdlp
, tid
, *fan_speed
, &temp16
);
1114 *fan_speed
= temp16
;
1120 i_psvc_get_device_state_2_0(EHdl_t
*hdlp
, EObj_t
*objp
, char *led_state
)
1122 int32_t status
= PSVC_SUCCESS
;
1124 boolean_t active_low
;
1128 if (objp
->present
!= PSVC_PRESENT
) {
1130 return (PSVC_FAILURE
);
1133 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1135 if (status
!= PSVC_SUCCESS
)
1137 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1138 if (status
!= PSVC_SUCCESS
)
1141 status
= ((EPhysDev_t
*)physobjp
)->get_bit(hdlp
, objp
->addr_spec
,
1143 if (status
!= PSVC_SUCCESS
)
1146 active_low
= PSVC_IS_ACTIVE_LOW(objp
->addr_spec
);
1149 strcpy(led_state
, PSVC_LED_ON
);
1151 strcpy(led_state
, PSVC_LED_OFF
);
1154 strcpy(led_state
, PSVC_LED_OFF
);
1156 strcpy(led_state
, PSVC_LED_ON
);
1162 i_psvc_set_device_state_2_0(EHdl_t
*hdlp
, EObj_t
*objp
, char *led_state
)
1164 int32_t status
= PSVC_SUCCESS
;
1165 boolean_t active_low
;
1170 if (objp
->present
!= PSVC_PRESENT
) {
1172 return (PSVC_FAILURE
);
1175 if (strcmp(((ELed_t
*)objp
)->is_locator
, PSVC_LOCATOR_TRUE
) != 0) {
1177 * For Locator LEDs we ignore lit_count. RSC may have
1178 * altered the LED state underneath us, So we should
1179 * always just do what the user asked instead of trying
1183 if (strcmp(led_state
, PSVC_LED_ON
) == 0)
1184 ((ELed_t
*)objp
)->lit_count
++;
1185 else if (strcmp(led_state
, PSVC_LED_OFF
) == 0) {
1186 if (--((ELed_t
*)objp
)->lit_count
> 0) {
1187 return (PSVC_SUCCESS
);
1188 } else if (((ELed_t
*)objp
)->lit_count
< 0)
1189 ((ELed_t
*)objp
)->lit_count
= 0;
1190 /* Fall through case is when lit_count is 0 */
1194 strcpy(objp
->previous_state
, objp
->state
);
1195 strcpy(objp
->state
, led_state
);
1197 bit_value
= (strcmp(led_state
, PSVC_LED_ON
) == 0);
1200 * Flip the bit if necessary (for active_low devices,
1201 * O ==> ON; 1 ==> OFF.
1203 active_low
= PSVC_IS_ACTIVE_LOW(objp
->addr_spec
);
1204 bit_value
^= active_low
;
1206 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1208 if (status
!= PSVC_SUCCESS
)
1210 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1211 if (status
!= PSVC_SUCCESS
)
1214 status
= ((EPhysDev_t
*)physobjp
)->set_bit(hdlp
, objp
->addr_spec
,
1220 i_psvc_get_device_state_2_1(EHdl_t
*hdlp
, EObj_t
*objp
, char *led_state
)
1222 int32_t status
= PSVC_SUCCESS
;
1227 if (objp
->present
!= PSVC_PRESENT
) {
1229 return (PSVC_FAILURE
);
1232 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1234 if (status
!= PSVC_SUCCESS
)
1236 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1237 if (status
!= PSVC_SUCCESS
)
1240 status
= ((EPhysDev_t
*)physobjp
)->get_reg(hdlp
, objp
->addr_spec
,
1242 if (status
!= PSVC_SUCCESS
)
1247 strcpy(led_state
, PSVC_LED_OFF
);
1250 strcpy(led_state
, PSVC_LED_SLOW_BLINK
);
1253 strcpy(led_state
, PSVC_LED_FAST_BLINK
);
1256 strcpy(led_state
, PSVC_LED_ON
);
1264 i_psvc_set_device_state_2_1(EHdl_t
*hdlp
, EObj_t
*objp
, char *led_state
)
1266 int32_t status
= PSVC_SUCCESS
;
1271 if (objp
->present
!= PSVC_PRESENT
) {
1273 return (PSVC_FAILURE
);
1276 if (strcmp(led_state
, PSVC_LED_ON
) == 0)
1277 ((ELed_t
*)objp
)->lit_count
++;
1278 else if (strcmp(led_state
, PSVC_LED_OFF
) == 0) {
1279 if (--((ELed_t
*)objp
)->lit_count
> 0) {
1280 return (PSVC_SUCCESS
);
1281 } else if (((ELed_t
*)objp
)->lit_count
< 0)
1282 ((ELed_t
*)objp
)->lit_count
= 0;
1284 /* Fall through case is when lit_count is 0 */
1287 strcpy(objp
->previous_state
, objp
->state
);
1288 strcpy(objp
->state
, led_state
);
1290 if (strcmp(led_state
, PSVC_LED_OFF
) == 0)
1292 else if (strcmp(led_state
, PSVC_LED_SLOW_BLINK
) == 0)
1294 else if (strcmp(led_state
, PSVC_LED_FAST_BLINK
) == 0)
1296 else if (strcmp(led_state
, PSVC_LED_ON
) == 0)
1299 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1301 if (status
!= PSVC_SUCCESS
)
1303 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1304 if (status
!= PSVC_SUCCESS
)
1307 status
= ((EPhysDev_t
*)physobjp
)->set_reg(hdlp
, objp
->addr_spec
,
1314 i_psvc_get_device_state_9_0(EHdl_t
*hdlp
, EObj_t
*objp
, char *pos
)
1316 int32_t status
= PSVC_SUCCESS
, matches
;
1321 if (objp
->present
!= PSVC_PRESENT
) {
1323 return (PSVC_FAILURE
);
1326 if (objp
->features
& PSVC_NORMAL_POS_AV
) {
1327 (void) i_psvc_get_assoc_matches(hdlp
, objp
->label
,
1328 PSVC_KS_NORMAL_POS_SENSOR
, &matches
);
1330 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
,
1331 PSVC_KS_NORMAL_POS_SENSOR
, 0, &sensorid
);
1332 if (status
!= PSVC_SUCCESS
)
1335 status
= i_psvc_get_obj(hdlp
, sensorid
, &sensorp
);
1336 if (status
!= PSVC_SUCCESS
)
1339 status
= sensorp
->get_attr(hdlp
, sensorp
,
1340 PSVC_SWITCH_STATE_ATTR
, state
);
1341 if (status
!= PSVC_SUCCESS
)
1344 if (strcmp(state
, PSVC_SWITCH_ON
) == 0) {
1345 strcpy(pos
, PSVC_NORMAL_POS
);
1346 return (PSVC_SUCCESS
);
1351 if (objp
->features
& PSVC_DIAG_POS_AV
) {
1352 (void) i_psvc_get_assoc_matches(hdlp
, objp
->label
,
1353 PSVC_KS_DIAG_POS_SENSOR
, &matches
);
1355 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
,
1356 PSVC_KS_DIAG_POS_SENSOR
, 0, &sensorid
);
1357 if (status
!= PSVC_SUCCESS
)
1360 status
= i_psvc_get_obj(hdlp
, sensorid
, &sensorp
);
1361 if (status
!= PSVC_SUCCESS
)
1364 status
= sensorp
->get_attr(hdlp
, sensorp
,
1365 PSVC_SWITCH_STATE_ATTR
, state
);
1366 if (status
!= PSVC_SUCCESS
)
1369 if (strcmp(state
, PSVC_SWITCH_ON
) == 0) {
1370 strcpy(pos
, PSVC_DIAG_POS
);
1371 return (PSVC_SUCCESS
);
1376 if (objp
->features
& PSVC_LOCK_POS_AV
) {
1377 (void) i_psvc_get_assoc_matches(hdlp
, objp
->label
,
1378 PSVC_KS_LOCK_POS_SENSOR
, &matches
);
1380 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
,
1381 PSVC_KS_LOCK_POS_SENSOR
, 0, &sensorid
);
1382 if (status
!= PSVC_SUCCESS
)
1385 status
= i_psvc_get_obj(hdlp
, sensorid
, &sensorp
);
1386 if (status
!= PSVC_SUCCESS
)
1389 status
= sensorp
->get_attr(hdlp
, sensorp
,
1390 PSVC_SWITCH_STATE_ATTR
, state
);
1391 if (status
!= PSVC_SUCCESS
)
1394 if (strcmp(state
, PSVC_SWITCH_ON
) == 0) {
1395 strcpy(pos
, PSVC_LOCKED_POS
);
1396 return (PSVC_SUCCESS
);
1401 if (objp
->features
& PSVC_OFF_POS_AV
) {
1402 (void) i_psvc_get_assoc_matches(hdlp
, objp
->label
,
1403 PSVC_KS_OFF_POS_SENSOR
, &matches
);
1405 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
,
1406 PSVC_KS_OFF_POS_SENSOR
, 0, &sensorid
);
1407 if (status
!= PSVC_SUCCESS
)
1410 status
= i_psvc_get_obj(hdlp
, sensorid
, &sensorp
);
1411 if (status
!= PSVC_SUCCESS
)
1414 status
= sensorp
->get_attr(hdlp
, sensorp
,
1415 PSVC_SWITCH_STATE_ATTR
, state
);
1416 if (status
!= PSVC_SUCCESS
)
1419 if (strcmp(state
, PSVC_SWITCH_ON
) == 0) {
1420 strcpy(pos
, PSVC_OFF_POS
);
1421 return (PSVC_SUCCESS
);
1425 /* If we have fallen through till here, something's wrong */
1427 return (PSVC_FAILURE
);
1432 i_psvc_get_device_value_10_0(EHdl_t
*hdlp
, EObj_t
*objp
, uint8_t *value
)
1434 int32_t status
= PSVC_SUCCESS
;
1438 if (objp
->present
!= PSVC_PRESENT
) {
1440 return (PSVC_FAILURE
);
1443 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1445 if (status
!= PSVC_SUCCESS
)
1447 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1448 if (status
!= PSVC_SUCCESS
)
1451 status
= ((EPhysDev_t
*)physobjp
)->get_reg(hdlp
, objp
->addr_spec
,
1453 if (status
!= PSVC_SUCCESS
)
1456 if (objp
->features
& PSVC_CONVERSION_TABLE
) {
1461 status
= i_psvc_get_assoc_matches(hdlp
, objp
->label
,
1463 if ((status
!= PSVC_SUCCESS
) || (m
!= 1)) {
1467 (void) i_psvc_get_assoc_id(hdlp
, objp
->label
,
1468 PSVC_TABLE
, 0, &tid
);
1470 status
= i_psvc_get_table_value(hdlp
, tid
, *value
, &temp8
);
1477 i_psvc_get_device_value_10_1(EHdl_t
*hdlp
, EObj_t
*objp
, uint8_t *value
)
1479 int32_t status
= PSVC_SUCCESS
;
1483 if (objp
->present
!= PSVC_PRESENT
) {
1485 return (PSVC_FAILURE
);
1488 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1490 if (status
!= PSVC_SUCCESS
)
1492 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1493 if (status
!= PSVC_SUCCESS
)
1496 status
= ((EPhysDev_t
*)physobjp
)->get_port(hdlp
, objp
->addr_spec
,
1498 if (status
!= PSVC_SUCCESS
)
1505 i_psvc_set_device_value_10_0(EHdl_t
*hdlp
, EObj_t
*objp
, uint8_t *value
)
1507 int32_t status
= PSVC_SUCCESS
;
1511 if (objp
->present
!= PSVC_PRESENT
) {
1513 return (PSVC_FAILURE
);
1516 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1518 if (status
!= PSVC_SUCCESS
)
1520 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1521 if (status
!= PSVC_SUCCESS
)
1524 status
= ((EPhysDev_t
*)physobjp
)->set_reg(hdlp
, objp
->addr_spec
,
1530 i_psvc_set_device_value_10_1(EHdl_t
*hdlp
, EObj_t
*objp
, uint8_t *value
)
1532 int32_t status
= PSVC_SUCCESS
;
1536 if (objp
->present
!= PSVC_PRESENT
) {
1538 return (PSVC_FAILURE
);
1541 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1543 if (status
!= PSVC_SUCCESS
)
1545 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1546 if (status
!= PSVC_SUCCESS
)
1549 status
= ((EPhysDev_t
*)physobjp
)->set_port(hdlp
, objp
->addr_spec
,
1555 i_psvc_get_device_state_8_0(EHdl_t
*hdlp
, EObj_t
*objp
, char *sw_state
)
1557 int32_t status
= PSVC_SUCCESS
;
1558 boolean_t active_low
;
1563 if (objp
->present
!= PSVC_PRESENT
) {
1565 return (PSVC_FAILURE
);
1568 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1570 if (status
!= PSVC_SUCCESS
)
1572 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1573 if (status
!= PSVC_SUCCESS
)
1576 status
= ((EPhysDev_t
*)physobjp
)->get_bit(hdlp
, objp
->addr_spec
,
1578 if (status
!= PSVC_SUCCESS
)
1581 active_low
= PSVC_IS_ACTIVE_LOW(objp
->addr_spec
);
1584 strcpy(sw_state
, PSVC_SWITCH_ON
);
1586 strcpy(sw_state
, PSVC_SWITCH_OFF
);
1589 strcpy(sw_state
, PSVC_SWITCH_OFF
);
1591 strcpy(sw_state
, PSVC_SWITCH_ON
);
1597 i_psvc_set_device_state_8_0(EHdl_t
*hdlp
, EObj_t
*objp
, char *sw_state
)
1599 int32_t status
= PSVC_SUCCESS
;
1600 boolean_t active_low
;
1605 if (objp
->present
!= PSVC_PRESENT
) {
1607 return (PSVC_FAILURE
);
1610 strcpy(objp
->previous_state
, objp
->state
);
1611 strcpy(objp
->state
, sw_state
);
1613 active_low
= PSVC_IS_ACTIVE_LOW(objp
->addr_spec
);
1616 if (strcmp(sw_state
, PSVC_SWITCH_ON
) == 0)
1621 if (strcmp(sw_state
, PSVC_SWITCH_ON
) == 0)
1626 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
, PSVC_PHYSICAL_DEVICE
,
1628 if (status
!= PSVC_SUCCESS
)
1630 status
= i_psvc_get_obj(hdlp
, physid
, &physobjp
);
1631 if (status
!= PSVC_SUCCESS
)
1634 status
= ((EPhysDev_t
*)physobjp
)->set_bit(hdlp
, objp
->addr_spec
,
1641 i_psvc_get_temperature_11_2(EHdl_t
*hdlp
, uint64_t aspec
, int32_t *temp
)
1643 int32_t status
= PSVC_SUCCESS
;
1648 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1649 if (status
!= PSVC_SUCCESS
)
1652 fp
= open(path
, O_RDWR
);
1654 return (PSVC_FAILURE
);
1656 status
= ioctl_retry(fp
, I2C_GET_TEMPERATURE
, (void *)&temp16
);
1660 return (PSVC_FAILURE
);
1671 i_psvc_get_temperature_11_4(EHdl_t
*hdlp
, uint64_t aspec
, int32_t *temp
)
1673 int32_t status
= PSVC_SUCCESS
;
1678 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1679 if (status
!= PSVC_SUCCESS
)
1682 fp
= open(path
, O_RDWR
);
1684 return (PSVC_FAILURE
);
1686 status
= ioctl_retry(fp
, I2C_GET_TEMPERATURE
, (void *)&temp16
);
1690 return (PSVC_FAILURE
);
1701 i_psvc_get_temperature_11_6(EHdl_t
*hdlp
, uint64_t aspec
, int32_t *temp
)
1703 int32_t status
= PSVC_SUCCESS
;
1707 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1708 if (status
!= PSVC_SUCCESS
)
1711 fp
= open(path
, O_RDWR
);
1713 return (PSVC_FAILURE
);
1715 status
= ioctl_retry(fp
, I2C_GET_INPUT
, (void *)temp
);
1729 i_psvc_get_fanspeed_11_7(EHdl_t
*hdlp
, uint64_t aspec
, int32_t *fan_speed
)
1731 int32_t ret
, status
= PSVC_SUCCESS
;
1735 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1736 if (status
!= PSVC_SUCCESS
)
1739 fp
= open(path
, O_RDWR
);
1741 return (PSVC_FAILURE
);
1743 ret
= ioctl_retry(fp
, I2C_GET_FAN_SPEED
, (void *)fan_speed
);
1757 i_psvc_get_input_11_6(EHdl_t
*hdlp
, uint64_t aspec
, int32_t *value
)
1759 int32_t ret
, status
= PSVC_SUCCESS
;
1763 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1764 if (status
!= PSVC_SUCCESS
)
1767 fp
= open(path
, O_RDWR
);
1769 return (PSVC_FAILURE
);
1771 ret
= ioctl_retry(fp
, I2C_GET_INPUT
, (void *)value
);
1785 i_psvc_get_output_11_3(EHdl_t
*hdlp
, uint64_t aspec
, int32_t *value
)
1787 int32_t ret
, status
= PSVC_SUCCESS
;
1791 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1792 if (status
!= PSVC_SUCCESS
)
1795 fp
= open(path
, O_RDWR
);
1797 return (PSVC_FAILURE
);
1799 ret
= ioctl_retry(fp
, I2C_GET_OUTPUT
, (void *)value
);
1803 return (PSVC_FAILURE
);
1813 i_psvc_get_output_11_6(EHdl_t
*hdlp
, uint64_t aspec
, int32_t *value
)
1815 int32_t ret
, status
= PSVC_SUCCESS
;
1819 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1820 if (status
!= PSVC_SUCCESS
)
1823 fp
= open(path
, O_RDWR
);
1825 return (PSVC_FAILURE
);
1827 ret
= ioctl_retry(fp
, I2C_GET_OUTPUT
, (void *)value
);
1831 return (PSVC_FAILURE
);
1841 i_psvc_get_output_11_8(EHdl_t
*hdlp
, uint64_t aspec
, int32_t *value
)
1843 int32_t ret
, status
= PSVC_SUCCESS
;
1848 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1849 if (status
!= PSVC_SUCCESS
)
1852 fp
= open(path
, O_RDWR
);
1854 return (PSVC_FAILURE
);
1856 ret
= read(fp
, &buf
, 1);
1860 return (PSVC_FAILURE
);
1871 i_psvc_set_output_11_3(EHdl_t
*hdlp
, uint64_t aspec
, int32_t value
)
1873 int32_t ret
, status
= PSVC_SUCCESS
;
1877 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1878 if (status
!= PSVC_SUCCESS
)
1881 fp
= open(path
, O_RDWR
);
1883 return (PSVC_FAILURE
);
1885 ret
= ioctl_retry(fp
, I2C_SET_OUTPUT
, (void *)&value
);
1889 return (PSVC_FAILURE
);
1899 i_psvc_set_output_11_6(EHdl_t
*hdlp
, uint64_t aspec
, int32_t value
)
1901 int32_t ret
, status
= PSVC_SUCCESS
;
1905 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1906 if (status
!= PSVC_SUCCESS
)
1909 fp
= open(path
, O_RDWR
);
1911 return (PSVC_FAILURE
);
1913 ret
= ioctl_retry(fp
, I2C_SET_OUTPUT
, (void *)&value
);
1917 return (PSVC_FAILURE
);
1927 i_psvc_set_output_11_8(EHdl_t
*hdlp
, uint64_t aspec
, int32_t value
)
1929 int32_t ret
, status
= PSVC_SUCCESS
;
1934 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1935 if (status
!= PSVC_SUCCESS
)
1938 fp
= open(path
, O_RDWR
);
1940 return (PSVC_FAILURE
);
1943 ret
= write(fp
, &buf
, 1);
1947 return (PSVC_FAILURE
);
1957 i_psvc_get_reg_11_1(EHdl_t
*hdlp
, uint64_t aspec
, uint8_t *value
)
1959 int32_t ret
, status
= PSVC_SUCCESS
;
1960 uint8_t bitshift
, bytemask
;
1962 i2c_reg_t i2cregarg
;
1965 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
1966 if (status
!= PSVC_SUCCESS
)
1968 fp
= open(path
, O_RDWR
);
1970 return (PSVC_FAILURE
);
1972 i2cregarg
.reg_num
= PSVC_GET_ASPEC_REG(aspec
);
1973 ret
= ioctl_retry(fp
, I2C_GET_REG
, (void *)&i2cregarg
);
1980 bitshift
= PSVC_GET_ASPEC_BITSHIFT(aspec
);
1981 bytemask
= PSVC_GET_ASPEC_BYTEMASK(aspec
);
1983 *value
= (i2cregarg
.reg_value
& bytemask
) >> bitshift
;
1991 i_psvc_get_reg_11_7(EHdl_t
*hdlp
, uint64_t aspec
, uint8_t *value
)
1993 int32_t ret
, status
= PSVC_SUCCESS
;
1994 uint8_t bitshift
, bytemask
;
1996 i2c_reg_t i2cregarg
;
1999 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
2000 if (status
!= PSVC_SUCCESS
)
2003 fp
= open(path
, O_RDWR
);
2005 return (PSVC_FAILURE
);
2007 i2cregarg
.reg_num
= PSVC_GET_ASPEC_REG(aspec
);
2008 ret
= ioctl_retry(fp
, I2C_GET_REG
, (void *)&i2cregarg
);
2015 bitshift
= PSVC_GET_ASPEC_BITSHIFT(aspec
);
2016 bytemask
= PSVC_GET_ASPEC_BYTEMASK(aspec
);
2018 *value
= (i2cregarg
.reg_value
& bytemask
) >> bitshift
;
2027 i_psvc_set_reg_11_1(EHdl_t
*hdlp
, uint64_t aspec
, int32_t value
)
2029 int32_t ret
, status
= PSVC_SUCCESS
;
2031 i2c_reg_t i2cregarg
;
2033 uint8_t bitshift
, bytemask
;
2036 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
2037 if (status
!= PSVC_SUCCESS
)
2040 bitshift
= PSVC_GET_ASPEC_BITSHIFT(aspec
);
2041 bytemask
= PSVC_GET_ASPEC_BYTEMASK(aspec
);
2042 value
= value
<< bitshift
;
2044 fp
= open(path
, O_RDWR
);
2046 return (PSVC_FAILURE
);
2048 i2cregarg
.reg_num
= PSVC_GET_ASPEC_REG(aspec
);
2049 if (bytemask
!= 0xFF) {
2050 ret
= ioctl_retry(fp
, I2C_GET_REG
, (void *)&i2cregarg
);
2056 tval
= i2cregarg
.reg_value
;
2057 tval
= tval
& ~bytemask
;
2061 value
= tval
| value
;
2062 i2cregarg
.reg_value
= value
;
2063 ret
= ioctl_retry(fp
, I2C_SET_REG
, (void *)&i2cregarg
);
2077 i_psvc_set_reg_11_7(EHdl_t
*hdlp
, uint64_t aspec
, int32_t value
)
2079 int32_t ret
, status
= PSVC_SUCCESS
;
2081 i2c_reg_t i2cregarg
;
2083 uint8_t bitshift
, bytemask
;
2086 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
2087 if (status
!= PSVC_SUCCESS
)
2090 bitshift
= PSVC_GET_ASPEC_BITSHIFT(aspec
);
2091 bytemask
= PSVC_GET_ASPEC_BYTEMASK(aspec
);
2092 value
= value
<< bitshift
;
2094 fp
= open(path
, O_RDWR
);
2096 return (PSVC_FAILURE
);
2098 i2cregarg
.reg_num
= PSVC_GET_ASPEC_REG(aspec
);
2099 if (bytemask
!= 0xFF) {
2100 ret
= ioctl_retry(fp
, I2C_GET_REG
, (void *)&i2cregarg
);
2106 tval
= i2cregarg
.reg_value
;
2107 tval
= tval
& ~bytemask
;
2111 value
= tval
| value
;
2112 i2cregarg
.reg_value
= value
;
2113 ret
= ioctl_retry(fp
, I2C_SET_REG
, (void *)&i2cregarg
);
2127 i_psvc_get_bit_11_5(EHdl_t
*hdlp
, uint64_t aspec
, int32_t *value
)
2129 int32_t ret
, status
= PSVC_SUCCESS
;
2134 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
2135 if (status
!= PSVC_SUCCESS
)
2138 bitarg
.bit_num
= PSVC_GET_BIT_NUM(aspec
);
2139 bitarg
.direction
= DIR_NO_CHANGE
;
2141 fp
= open(path
, O_RDWR
);
2143 return (PSVC_FAILURE
);
2145 ret
= ioctl_retry(fp
, I2C_GET_BIT
, (void *)&bitarg
);
2152 *value
= bitarg
.bit_value
;
2161 i_psvc_get_port_11_5(EHdl_t
*hdlp
, uint64_t aspec
, uint8_t *value
)
2163 int32_t ret
, status
= PSVC_SUCCESS
;
2168 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
2169 if (status
!= PSVC_SUCCESS
)
2172 port
.direction
= DIR_NO_CHANGE
;
2174 fp
= open(path
, O_RDWR
);
2176 return (PSVC_FAILURE
);
2178 ret
= ioctl_retry(fp
, I2C_GET_PORT
, (void *)&port
);
2185 *value
= port
.value
;
2194 i_psvc_get_bit_11_7(EHdl_t
*hdlp
, uint64_t aspec
, int32_t *value
)
2196 int32_t ret
, status
= PSVC_SUCCESS
;
2201 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
2202 if (status
!= PSVC_SUCCESS
)
2205 bitarg
.bit_num
= PSVC_GET_BIT_NUM(aspec
);
2206 bitarg
.direction
= DIR_NO_CHANGE
;
2208 fp
= open(path
, O_RDWR
);
2210 return (PSVC_FAILURE
);
2212 ret
= ioctl_retry(fp
, I2C_GET_BIT
, (void *)&bitarg
);
2219 *value
= bitarg
.bit_value
;
2228 i_psvc_set_bit_11_5(EHdl_t
*hdlp
, uint64_t aspec
, int32_t value
)
2230 int32_t ret
, status
= PSVC_SUCCESS
;
2235 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
2236 if (status
!= PSVC_SUCCESS
)
2239 bitarg
.bit_value
= value
;
2240 bitarg
.bit_num
= PSVC_GET_BIT_NUM(aspec
);
2241 bitarg
.direction
= DIR_OUTPUT
;
2242 fp
= open(path
, O_RDWR
);
2244 return (PSVC_FAILURE
);
2246 ret
= ioctl_retry(fp
, I2C_SET_BIT
, (void *)&bitarg
);
2260 i_psvc_set_port_11_5(EHdl_t
*hdlp
, uint64_t aspec
, int32_t value
)
2262 int32_t ret
, status
= PSVC_SUCCESS
;
2267 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
2268 if (status
!= PSVC_SUCCESS
)
2271 port
.value
= (uint8_t)value
;
2272 port
.direction
= DIR_NO_CHANGE
;
2273 fp
= open(path
, O_RDWR
);
2275 return (PSVC_FAILURE
);
2277 ret
= ioctl_retry(fp
, I2C_SET_PORT
, (void *)&port
);
2291 i_psvc_set_bit_11_7(EHdl_t
*hdlp
, uint64_t aspec
, int32_t value
)
2293 int32_t ret
, status
= PSVC_SUCCESS
;
2298 status
= i_psvc_get_devpath(hdlp
, aspec
, path
);
2299 if (status
!= PSVC_SUCCESS
)
2302 bitarg
.bit_value
= value
;
2303 bitarg
.bit_num
= PSVC_GET_BIT_NUM(aspec
);
2304 bitarg
.direction
= DIR_OUTPUT
;
2306 fp
= open(path
, O_RDWR
);
2308 return (PSVC_FAILURE
);
2310 ret
= ioctl_retry(fp
, I2C_SET_BIT
, (void *)&bitarg
);
2324 i_psvc_probe_11_0(EHdl_t
*hdlp
, EObj_t
*objp
)
2326 int32_t ret
, status
= PSVC_SUCCESS
;
2331 if (objp
->present
!= PSVC_PRESENT
) {
2333 return (PSVC_FAILURE
);
2336 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
2337 if (status
!= PSVC_SUCCESS
) {
2341 fp
= open(path
, O_RDWR
);
2343 return (PSVC_FAILURE
);
2346 ret
= read(fp
, &value
, 1);
2360 i_psvc_probe_11_1(EHdl_t
*hdlp
, EObj_t
*objp
)
2362 int32_t ret
, status
= PSVC_SUCCESS
;
2367 if (objp
->present
!= PSVC_PRESENT
) {
2369 return (PSVC_FAILURE
);
2372 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
2373 if (status
!= PSVC_SUCCESS
)
2376 fp
= open(path
, O_RDWR
);
2378 return (PSVC_FAILURE
);
2381 ret
= ioctl_retry(fp
, I2C_GET_REG
, (void *)®
);
2395 i_psvc_probe_11_2(EHdl_t
*hdlp
, EObj_t
*objp
)
2397 int32_t ret
, status
= PSVC_SUCCESS
;
2402 if (objp
->present
!= PSVC_PRESENT
) {
2404 return (PSVC_FAILURE
);
2407 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
2408 if (status
!= PSVC_SUCCESS
) {
2412 fp
= open(path
, O_RDWR
);
2414 return (PSVC_FAILURE
);
2417 ret
= ioctl_retry(fp
, I2C_GET_TEMPERATURE
, (void *)&temp16
);
2431 i_psvc_probe_11_3(EHdl_t
*hdlp
, EObj_t
*objp
)
2433 int32_t ret
, status
= PSVC_SUCCESS
;
2438 if (objp
->present
!= PSVC_PRESENT
) {
2440 return (PSVC_FAILURE
);
2443 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
2444 if (status
!= PSVC_SUCCESS
) {
2448 fp
= open(path
, O_RDWR
);
2450 return (PSVC_FAILURE
);
2453 ret
= ioctl_retry(fp
, I2C_GET_OUTPUT
, (void *)&value
);
2460 ret
= ioctl_retry(fp
, I2C_SET_OUTPUT
, (void *)&value
);
2473 i_psvc_probe_11_4(EHdl_t
*hdlp
, EObj_t
*objp
)
2475 int32_t ret
, status
= PSVC_SUCCESS
;
2480 if (objp
->present
!= PSVC_PRESENT
) {
2482 return (PSVC_FAILURE
);
2485 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
2486 if (status
!= PSVC_SUCCESS
) {
2490 fp
= open(path
, O_RDWR
);
2492 return (PSVC_FAILURE
);
2495 ret
= ioctl_retry(fp
, I2C_GET_TEMPERATURE
, (void *)&temp16
);
2509 i_psvc_probe_11_5(EHdl_t
*hdlp
, EObj_t
*objp
)
2511 int32_t ret
, status
= PSVC_SUCCESS
;
2516 if (objp
->present
!= PSVC_PRESENT
) {
2518 return (PSVC_FAILURE
);
2521 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
2522 if (status
!= PSVC_SUCCESS
) {
2526 port
.direction
= DIR_NO_CHANGE
;
2528 fp
= open(path
, O_RDWR
);
2530 return (PSVC_FAILURE
);
2533 ret
= ioctl_retry(fp
, I2C_GET_PORT
, (void *)&port
);
2547 i_psvc_probe_11_6(EHdl_t
*hdlp
, EObj_t
*objp
)
2549 int32_t ret
, status
= PSVC_SUCCESS
;
2554 if (objp
->present
!= PSVC_PRESENT
) {
2556 return (PSVC_FAILURE
);
2559 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
2560 if (status
!= PSVC_SUCCESS
)
2563 fp
= open(path
, O_RDWR
);
2565 return (PSVC_FAILURE
);
2567 ret
= ioctl_retry(fp
, I2C_GET_INPUT
, (void *)&arg
);
2581 i_psvc_probe_11_7(EHdl_t
*hdlp
, EObj_t
*objp
)
2583 int32_t ret
, status
= PSVC_SUCCESS
;
2588 if (objp
->present
!= PSVC_PRESENT
) {
2590 return (PSVC_FAILURE
);
2593 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
2594 if (status
!= PSVC_SUCCESS
)
2597 port
.direction
= DIR_NO_CHANGE
;
2599 fp
= open(path
, O_RDWR
);
2601 return (PSVC_FAILURE
);
2603 ret
= ioctl_retry(fp
, I2C_GET_PORT
, (void *)&port
);
2617 i_psvc_probe_11_8(EHdl_t
*hdlp
, EObj_t
*objp
)
2619 int32_t ret
, status
= PSVC_SUCCESS
;
2624 if (objp
->present
!= PSVC_PRESENT
) {
2626 return (PSVC_FAILURE
);
2629 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
2630 if (status
!= PSVC_SUCCESS
)
2633 fp
= open(path
, O_RDWR
);
2635 return (PSVC_FAILURE
);
2637 ret
= read(fp
, &value
, 1);
2652 i_psvc_probe_11_9(EHdl_t
*hdlp
, EObj_t
*objp
)
2654 int32_t ret
, status
= PSVC_SUCCESS
;
2659 if (objp
->present
!= PSVC_PRESENT
) {
2661 return (PSVC_FAILURE
);
2664 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
2665 if (status
!= PSVC_SUCCESS
) {
2669 fp
= open(path
, O_RDWR
);
2671 return (PSVC_FAILURE
);
2675 * There are only a few register numbers that are valid numbers to
2676 * read from. 0x10 is one of these registers. Any non-valid registers
2677 * cause unknown behavior to the ssc100 device.
2680 ret
= ioctl_retry(fp
, I2C_GET_REG
, (void *)®
);
2694 * Find start of a section within the config file,
2695 * Returns number of records in the section.
2696 * FILE *fd is set to first data record within section.
2699 i_psvc_find_file_section(FILE *fd
, char *start
)
2706 fseek(fd
, 0, SEEK_SET
);
2707 while ((ret
= fgets(buf
, BUFSZ
, fd
)) != NULL
) {
2708 if (strncmp(start
, buf
, strlen(start
)) == 0)
2717 found
= sscanf(buf
, "%s", name
);
2727 /* compare routine for qsort of str_tbl */
2729 i_psvc_name_compare_qsort(EStringId_t
*s1
, EStringId_t
*s2
)
2731 return (strcmp(s1
->name
, s2
->name
));
2734 /* compare routine for bsearch of str_tbl */
2736 i_psvc_name_compare_bsearch(char *s1
, EStringId_t
*s2
)
2738 return (strcmp(s1
, s2
->name
));
2742 * Determine the initial state of a device.
2745 i_psvc_init_state(EHdl_t
*hp
, EObj_t
*objp
)
2747 int32_t status
= PSVC_SUCCESS
;
2749 if (objp
->class == PSVC_ON_OFF_SWITCH_CLASS
) {
2752 status
= objp
->get_attr(hp
, objp
, PSVC_SWITCH_STATE_ATTR
,
2754 if (status
!= PSVC_SUCCESS
)
2757 if (strcmp(state
, PSVC_SWITCH_ON
) == 0)
2758 strcpy(objp
->state
, PSVC_ON
);
2760 strcpy(objp
->state
, PSVC_OFF
);
2763 if (objp
->class == PSVC_KEYSWITCH_CLASS
) {
2766 status
= objp
->get_attr(hp
, objp
, PSVC_SWITCH_STATE_ATTR
,
2768 if (status
!= PSVC_SUCCESS
)
2770 strcpy(objp
->state
, state
);
2777 * Return the object pointer for the object name passed in.
2778 * Creates the object if this is the first access,
2779 * Returns 0 if successful, -1 if not.
2782 i_psvc_get_obj(EHdl_t
*hp
, char *dev_name
, EObj_t
**objp
)
2785 int32_t found
, key
, array
;
2786 int32_t class, subclass
;
2791 ETable_Array
*tbl_arr
;
2793 key
= psvc_get_str_key(dev_name
);
2794 array
= key
% PSVC_MAX_TABLE_ARRAYS
;
2795 tbl_arr
= &(hp
->tbl_arry
[array
]);
2797 for (i
= 0; i
< tbl_arr
->obj_count
; ++i
) {
2798 if (key
== tbl_arr
->obj_tbl
[i
].key
) {
2799 if (strcmp(dev_name
, tbl_arr
->obj_tbl
[i
].name
) == 0) {
2800 if (tbl_arr
->obj_tbl
[i
].type
!= PSVC_OBJ
)
2802 *objp
= tbl_arr
->obj_tbl
[i
].objp
;
2808 if (i_psvc_find_file_section(hp
->fp
, "OBJECT_INFO") == -1) {
2809 ENV_DEBUG("Couldn't find OBJECT_INFO section", dev_name
);
2813 fgets(buf
, BUFSZ
, hp
->fp
);
2814 while (strcmp(buf
, "OBJECT_INFO_END")) {
2815 start
= strrchr(buf
, '/');
2816 if (start
== NULL
) {
2818 return (PSVC_FAILURE
);
2820 found
= sscanf(start
+ 1, "%s", name
);
2823 return (PSVC_FAILURE
);
2826 if (strcmp(name
, dev_name
) == 0) {
2828 if (i_psvc_value(buf
, PSVC_CLASS_ATTR
, &class)
2830 return (PSVC_FAILURE
);
2831 if (i_psvc_value(buf
, PSVC_SUBCLASS_ATTR
, &subclass
)
2833 return (PSVC_FAILURE
);
2834 ret
= (*i_psvc_constructor
[class][subclass
])(hp
,
2836 if (ret
!= PSVC_SUCCESS
) {
2839 ret
= (*objp
)->get_attr(hp
, *objp
, PSVC_PRESENCE_ATTR
,
2841 (*objp
)->previous_presence
= presence
;
2842 if (ret
!= PSVC_SUCCESS
|| presence
!= PSVC_PRESENT
)
2845 return (i_psvc_init_state(hp
, *objp
));
2847 fgets(buf
, BUFSZ
, hp
->fp
);
2855 * Gets the device path associated with an object id.
2856 * Returns 0 if successful, -1 if not.
2859 i_psvc_get_devpath(EHdl_t
*hp
, uint64_t addr_spec
, char *path
)
2863 uint32_t controller
, bus
, addr
, port
;
2865 controller
= PSVC_GET_ASPEC_CNTLR(addr_spec
);
2866 bus
= PSVC_GET_ASPEC_BUSNUM(addr_spec
);
2867 addr
= PSVC_GET_ASPEC_BUSADDR(addr_spec
);
2868 port
= PSVC_GET_ASPEC_PORT(addr_spec
);
2870 for (i
= 0; i
< hp
->dev_count
; ++i
) {
2871 dp
= &hp
->dev_tbl
[i
];
2872 if (dp
->controller
== controller
&&
2876 strcpy(path
, dp
->path
);
2877 return (PSVC_SUCCESS
);
2882 return (PSVC_FAILURE
);
2886 /* Load the association table */
2888 i_psvc_load_associations(EHdl_t
*hp
, FILE *fp
)
2893 char name1
[32], name2
[32];
2901 * ignore count in the file, correct count is highest
2902 * association id + 1, now figured when loading ASSOC_STR
2905 if (i_psvc_find_file_section(fp
, "ASSOCIATIONS") != PSVC_SUCCESS
)
2907 if ((hp
->assoc_tbl
= malloc(sizeof (EAssocList_t
) * hp
->assoc_count
))
2911 memset(hp
->assoc_tbl
, 0, sizeof (EAssocList_t
) * hp
->assoc_count
);
2913 for (i
= 0; i
< hp
->assoc_count
; ++i
) {
2914 fgets(buf
, BUFSZ
, fp
);
2915 found
= sscanf(buf
, "%s %s", name1
, name2
);
2916 if (strcmp("ASSOCIATIONS_END", name1
) == 0)
2922 namep
= (EStringId_t
*)bsearch(name2
, hp
->othr_tbl
,
2923 hp
->othr_count
, sizeof (EStringId_t
),
2924 (int (*)(const void *, const void *))
2925 i_psvc_name_compare_bsearch
);
2926 if (namep
== NULL
) {
2932 status
= i_psvc_count_records(fp
, "ASSOCIATION_END", &count
);
2933 if (status
!= PSVC_SUCCESS
)
2935 hp
->assoc_tbl
[id
].count
= count
;
2936 hp
->assoc_tbl
[id
].table
=
2937 (EAssoc_t
*)malloc(sizeof (EAssoc_t
) * count
);
2938 if (hp
->assoc_tbl
[id
].table
== NULL
)
2941 for (j
= 0; j
< count
; ++j
) {
2942 ap
= &hp
->assoc_tbl
[id
].table
[j
];
2943 fgets(buf
, BUFSZ
, fp
);
2944 found
= sscanf(buf
, "%s %s", ap
->antecedent_id
,
2946 ap
->ant_key
= psvc_get_str_key(ap
->antecedent_id
);
2954 fgets(buf
, BUFSZ
, fp
);
2955 if (strncmp(buf
, "ASSOCIATION_END", 15) != 0) {
2964 /* Load the table of tables */
2966 i_psvc_load_tables(EHdl_t
*hp
, FILE *fp
)
2975 uint32_t table_count
;
2976 int32_t num
, key
, array
;
2978 ETable_Array
*tbl_arr
;
2980 if (i_psvc_find_file_section(fp
, "TABLES") != PSVC_SUCCESS
)
2981 return (PSVC_SUCCESS
); /* no tables */
2982 status
= i_psvc_count_tables_associations(fp
, &table_count
,
2984 if (status
!= PSVC_SUCCESS
|| table_count
== 0)
2987 for (i
= 0; i
< table_count
; ++i
) {
2991 fgets(buf
, BUFSZ
, fp
);
2992 if (strncmp(buf
, "TABLE", 5) != 0) {
2997 fgets(buf
, BUFSZ
, fp
);
2998 found
= sscanf(buf
, "%s %d", name
, &cell_type
);
2999 key
= psvc_get_str_key(name
);
3000 array
= key
% PSVC_MAX_TABLE_ARRAYS
;
3001 tbl_arr
= &(hp
->tbl_arry
[array
]);
3003 if (tbl_arr
->nextid
== hp
->total_obj_count
) {
3005 return (PSVC_FAILURE
);
3007 slot
= tbl_arr
->nextid
++;
3008 tbl_arr
->obj_count
++;
3011 strcpy(tbl_arr
->obj_tbl
[slot
].name
, name
);
3013 tblp
= (ETable_t
*)malloc(sizeof (ETable_t
));
3015 return (PSVC_FAILURE
);
3016 tbl_arr
->obj_tbl
[slot
].key
= key
;
3017 tbl_arr
->obj_tbl
[slot
].objp
= (EObj_t
*)(void *)tblp
;
3018 tbl_arr
->obj_tbl
[slot
].type
= PSVC_TBL
;
3020 status
= i_psvc_count_table_records(fp
, "TABLE_END",
3022 if (status
!= PSVC_SUCCESS
)
3024 tblp
->cell_type
= (uint8_t)cell_type
;
3030 /* allocate and load table */
3031 tblp
->table
= (int64_t *)malloc(tblp
->size
*
3032 i_psvc_cell_size
[tblp
->cell_type
]);
3033 if (tblp
->table
== NULL
) {
3037 table
= tblp
->table
;
3038 for (j
= 0; j
< tblp
->size
; ++j
) {
3039 switch (cell_type
) {
3041 ret
= fscanf(fp
, "%d", &num
);
3042 *((int8_t *)table
+ j
) = num
;
3045 ret
= fscanf(fp
, "%d", &num
);
3046 *((uint8_t *)table
+ j
) = (uint8_t)num
;
3049 ret
= fscanf(fp
, "%hd",
3050 ((int16_t *)table
+ j
));
3053 ret
= fscanf(fp
, "%hd",
3054 ((uint16_t *)table
+ j
));
3057 ret
= fscanf(fp
, "%d",
3058 ((int32_t *)table
+ j
));
3061 ret
= fscanf(fp
, "%d",
3062 ((uint32_t *)table
+ j
));
3065 ret
= fscanf(fp
, "%lld",
3066 ((int64_t *)table
+ j
));
3069 ret
= fscanf(fp
, "%lld",
3070 ((uint64_t *)table
+ j
));
3081 fgets(buf
, BUFSZ
, fp
); /* reads newline on data line */
3082 fgets(buf
, BUFSZ
, fp
);
3083 if (strncmp(buf
, "TABLE_END", 9) != 0) {
3094 i_psvc_destructor(EHdl_t
*hdlp
, char *name
, void *objp
)
3096 int32_t i
, key
, array
;
3098 key
= psvc_get_str_key(name
);
3099 array
= key
% PSVC_MAX_TABLE_ARRAYS
;
3101 for (i
= 0; i
< hdlp
->tbl_arry
[array
].obj_count
; ++i
) {
3102 if (key
== hdlp
->tbl_arry
[array
].obj_tbl
[i
].key
) {
3103 if (strcmp(hdlp
->tbl_arry
[array
].obj_tbl
[i
].name
,
3105 hdlp
->tbl_arry
[array
].obj_tbl
[i
].name
[0] = '\0';
3107 return (PSVC_SUCCESS
);
3112 return (PSVC_SUCCESS
);
3116 i_psvc_get_attr_generic(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
,
3119 int32_t status
= PSVC_SUCCESS
;
3123 case PSVC_ADDR_SPEC_ATTR
:
3124 *(uint64_t *)attrp
= objp
->addr_spec
;
3126 case PSVC_CLASS_ATTR
:
3127 *(int32_t *)attrp
= objp
->class;
3129 case PSVC_SUBCLASS_ATTR
:
3130 *(int32_t *)attrp
= objp
->subclass
;
3132 case PSVC_PRESENCE_ATTR
:
3133 status
= i_psvc_get_presence(hdlp
, objp
, (boolean_t
*)attrp
);
3135 case PSVC_PREV_PRESENCE_ATTR
:
3136 *(boolean_t
*)attrp
= objp
->previous_presence
;
3138 case PSVC_STATE_ATTR
:
3139 strcpy((char *)attrp
, objp
->state
);
3141 case PSVC_PREV_STATE_ATTR
:
3142 strcpy((char *)attrp
, objp
->previous_state
);
3144 case PSVC_ENABLE_ATTR
:
3145 *(boolean_t
*)attrp
= objp
->enabled
;
3147 case PSVC_FAULTID_ATTR
:
3148 strcpy((char *)attrp
, objp
->fault_id
);
3150 case PSVC_FEATURES_ATTR
:
3151 *(uint64_t *)attrp
= objp
->features
;
3153 case PSVC_LABEL_ATTR
:
3154 strcpy((char *)attrp
, objp
->label
);
3156 case PSVC_FRUID_ATTR
:
3157 while ((objp
->features
& PSVC_DEV_FRU
) == 0) {
3158 status
= i_psvc_get_assoc_id(hdlp
, objp
->label
,
3159 PSVC_PARENT
, 0, &parent_id
);
3160 if (status
!= PSVC_SUCCESS
)
3163 status
= i_psvc_get_obj(hdlp
, parent_id
, &objp
);
3164 if (status
!= PSVC_SUCCESS
)
3168 strcpy((char *)attrp
, objp
->label
);
3170 case PSVC_INSTANCE_ATTR
:
3171 *(int32_t *)attrp
= objp
->instance
;
3175 return (PSVC_FAILURE
);
3182 i_psvc_set_attr_generic(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
,
3185 int32_t status
= PSVC_SUCCESS
;
3188 case PSVC_PREV_PRESENCE_ATTR
:
3189 objp
->previous_presence
= *(boolean_t
*)attrp
;
3191 case PSVC_STATE_ATTR
:
3192 strcpy(objp
->previous_state
, objp
->state
);
3193 strcpy(objp
->state
, (char *)attrp
);
3195 case PSVC_ENABLE_ATTR
:
3196 objp
->enabled
= *(boolean_t
*)attrp
;
3198 case PSVC_FAULTID_ATTR
:
3199 strcpy(objp
->fault_id
, (char *)attrp
);
3203 return (PSVC_FAILURE
);
3209 i_psvc_get_attr_0_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3211 int32_t status
= PSVC_SUCCESS
;
3214 case PSVC_SENSOR_VALUE_ATTR
:
3215 return (i_psvc_get_device_value_0_0(hdlp
, objp
, attrp
));
3216 case PSVC_LO_WARN_ATTR
:
3217 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->lo_warn
;
3219 case PSVC_LO_SHUT_ATTR
:
3220 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->lo_shut
;
3222 case PSVC_HI_WARN_ATTR
:
3223 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->hi_warn
;
3225 case PSVC_HI_SHUT_ATTR
:
3226 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->hi_shut
;
3230 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3236 i_psvc_get_attr_0_1(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3238 int32_t status
= PSVC_SUCCESS
;
3241 case PSVC_SENSOR_VALUE_ATTR
:
3242 return (i_psvc_get_device_value_0_1(hdlp
, objp
, attrp
));
3243 case PSVC_LO_WARN_ATTR
:
3244 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->lo_warn
;
3246 case PSVC_LO_SHUT_ATTR
:
3247 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->lo_shut
;
3249 case PSVC_HI_WARN_ATTR
:
3250 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->hi_warn
;
3252 case PSVC_HI_SHUT_ATTR
:
3253 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->hi_shut
;
3255 case PSVC_OPTIMAL_TEMP_ATTR
:
3256 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->opt_temp
;
3258 case PSVC_HW_HI_SHUT_ATTR
:
3259 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->hw_hi_shut
;
3261 case PSVC_HW_LO_SHUT_ATTR
:
3262 *(int32_t *)attrp
= ((ETempSensor_t
*)objp
)->hw_lo_shut
;
3266 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3272 i_psvc_set_attr_0_1(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3274 int32_t status
= PSVC_SUCCESS
;
3277 case PSVC_LO_WARN_ATTR
:
3278 ((ETempSensor_t
*)objp
)->lo_warn
= *(int32_t *)attrp
;
3280 case PSVC_LO_SHUT_ATTR
:
3281 ((ETempSensor_t
*)objp
)->lo_shut
= *(int32_t *)attrp
;
3283 case PSVC_HI_WARN_ATTR
:
3284 ((ETempSensor_t
*)objp
)->hi_warn
= *(int32_t *)attrp
;
3286 case PSVC_HI_SHUT_ATTR
:
3287 ((ETempSensor_t
*)objp
)->hi_shut
= *(int32_t *)attrp
;
3289 case PSVC_OPTIMAL_TEMP_ATTR
:
3290 ((ETempSensor_t
*)objp
)->opt_temp
= *(int32_t *)attrp
;
3292 case PSVC_HW_HI_SHUT_ATTR
:
3293 ((ETempSensor_t
*)objp
)->hw_hi_shut
= *(int32_t *)attrp
;
3295 case PSVC_HW_LO_SHUT_ATTR
:
3296 ((ETempSensor_t
*)objp
)->hw_lo_shut
= *(int32_t *)attrp
;
3300 status
= i_psvc_set_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3306 i_psvc_get_attr_1_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3308 int32_t status
= PSVC_SUCCESS
;
3311 case PSVC_SENSOR_VALUE_ATTR
:
3312 return (i_psvc_get_device_value_1_0(hdlp
, objp
, attrp
));
3313 case PSVC_SETPOINT_ATTR
:
3314 *(int16_t *)attrp
= ((EFan_t
*)objp
)->setpoint
;
3316 case PSVC_HYSTERESIS_ATTR
:
3317 *(int16_t *)attrp
= ((EFan_t
*)objp
)->hysteresis
;
3319 case PSVC_LOOPGAIN_ATTR
:
3320 *(int16_t *)attrp
= ((EFan_t
*)objp
)->loopgain
;
3322 case PSVC_LOOPBIAS_ATTR
:
3323 *(int16_t *)attrp
= ((EFan_t
*)objp
)->loopbias
;
3325 case PSVC_TEMP_DIFFERENTIAL_ATTR
:
3326 memcpy(attrp
, ((EFan_t
*)objp
)->temp_differential
,
3327 sizeof (((EFan_t
*)objp
)->temp_differential
));
3329 case PSVC_TEMP_DIFFERENTIAL_INDEX_ATTR
:
3330 *(int16_t *)attrp
= ((EFan_t
*)objp
)->temp_differential_index
;
3334 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3340 i_psvc_set_attr_1_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3342 int32_t status
= PSVC_SUCCESS
;
3345 case PSVC_TEMP_DIFFERENTIAL_ATTR
:
3346 memcpy(((EFan_t
*)objp
)->temp_differential
, attrp
,
3347 sizeof (((EFan_t
*)objp
)->temp_differential
));
3349 case PSVC_TEMP_DIFFERENTIAL_INDEX_ATTR
:
3350 ((EFan_t
*)objp
)->temp_differential_index
= *(int16_t *)attrp
;
3352 case PSVC_SETPOINT_ATTR
:
3353 ((EFan_t
*)objp
)->setpoint
= *(int16_t *)attrp
;
3357 status
= i_psvc_set_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3359 return (PSVC_SUCCESS
);
3363 i_psvc_get_attr_2_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3365 int32_t status
= PSVC_SUCCESS
;
3368 case PSVC_LED_STATE_ATTR
:
3369 case PSVC_STATE_ATTR
:
3370 return (i_psvc_get_device_state_2_0(hdlp
, objp
, attrp
));
3371 case PSVC_LED_COLOR_ATTR
:
3372 strcpy((char *)attrp
, ((ELed_t
*)objp
)->color
);
3374 case PSVC_LIT_COUNT_ATTR
:
3375 *(int16_t *)attrp
= ((ELed_t
*)objp
)->lit_count
;
3379 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3385 i_psvc_set_attr_2_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3387 int32_t status
= PSVC_SUCCESS
;
3390 case PSVC_LED_STATE_ATTR
:
3391 case PSVC_STATE_ATTR
:
3392 return (i_psvc_set_device_state_2_0(hdlp
, objp
, attrp
));
3395 status
= i_psvc_set_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3401 i_psvc_get_attr_2_1(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3403 int32_t status
= PSVC_SUCCESS
;
3406 case PSVC_LED_STATE_ATTR
:
3407 case PSVC_STATE_ATTR
:
3408 return (i_psvc_get_device_state_2_1(hdlp
, objp
, attrp
));
3409 case PSVC_LED_COLOR_ATTR
:
3410 strcpy((char *)attrp
, ((ELed_t
*)objp
)->color
);
3412 case PSVC_LIT_COUNT_ATTR
:
3413 *(int16_t *)attrp
= ((ELed_t
*)objp
)->lit_count
;
3417 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3423 i_psvc_set_attr_2_1(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3425 int32_t status
= PSVC_SUCCESS
;
3428 case PSVC_LED_STATE_ATTR
:
3429 case PSVC_STATE_ATTR
:
3430 return (i_psvc_set_device_state_2_1(hdlp
, objp
, attrp
));
3433 status
= i_psvc_set_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3439 i_psvc_get_attr_2_2(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3441 int32_t status
= PSVC_SUCCESS
;
3444 case PSVC_LED_STATE_ATTR
:
3445 case PSVC_STATE_ATTR
:
3446 return (i_psvc_get_device_state_2_0(hdlp
, objp
, attrp
));
3447 case PSVC_LED_COLOR_ATTR
:
3448 strcpy((char *)attrp
, ((ELed_t
*)objp
)->color
);
3450 case PSVC_LIT_COUNT_ATTR
:
3451 *(int16_t *)attrp
= ((ELed_t
*)objp
)->lit_count
;
3453 case PSVC_LED_IS_LOCATOR_ATTR
:
3454 strcpy((char *)attrp
, ((ELed_t
*)objp
)->is_locator
);
3456 case PSVC_LED_LOCATOR_NAME_ATTR
:
3457 strcpy((char *)attrp
, ((ELed_t
*)objp
)->locator_name
);
3461 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3467 i_psvc_get_attr_4_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3469 int32_t status
= PSVC_SUCCESS
;
3472 case PSVC_SENSOR_VALUE_ATTR
:
3473 return (i_psvc_get_device_value_4_0(hdlp
, objp
, attrp
));
3474 case PSVC_LO_WARN_ATTR
:
3475 *(int32_t *)attrp
= ((EDigiSensor_t
*)objp
)->lo_warn
;
3477 case PSVC_LO_SHUT_ATTR
:
3478 *(int32_t *)attrp
= ((EDigiSensor_t
*)objp
)->lo_shut
;
3480 case PSVC_HI_WARN_ATTR
:
3481 *(int32_t *)attrp
= ((EDigiSensor_t
*)objp
)->hi_warn
;
3483 case PSVC_HI_SHUT_ATTR
:
3484 *(int32_t *)attrp
= ((EDigiSensor_t
*)objp
)->hi_shut
;
3488 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3490 return (PSVC_SUCCESS
);
3494 i_psvc_get_attr_5_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3496 int32_t status
= PSVC_SUCCESS
;
3498 if (attr_id
== PSVC_CONTROL_VALUE_ATTR
) {
3499 return (i_psvc_get_device_value_5_0(hdlp
, objp
, attrp
));
3502 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3508 i_psvc_set_attr_5_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3510 int32_t status
= PSVC_SUCCESS
;
3512 if (attr_id
== PSVC_CONTROL_VALUE_ATTR
) {
3513 return (i_psvc_set_device_value_5_0(hdlp
, objp
, attrp
));
3516 status
= i_psvc_set_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3522 i_psvc_get_attr_6_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3524 int32_t status
= PSVC_SUCCESS
;
3527 case PSVC_GPIO_VALUE_ATTR
:
3528 return (i_psvc_get_device_value_6_0(hdlp
, objp
, attrp
));
3529 case PSVC_GPIO_BITS
:
3530 *(int32_t *)attrp
= 1;
3534 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3540 i_psvc_set_attr_6_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3542 int32_t status
= PSVC_SUCCESS
;
3544 if (attr_id
== PSVC_GPIO_VALUE_ATTR
) {
3545 return (i_psvc_set_device_value_6_0(hdlp
, objp
, attrp
));
3548 status
= i_psvc_set_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3554 i_psvc_get_attr_7_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3556 int32_t status
= PSVC_SUCCESS
;
3559 case PSVC_SENSOR_VALUE_ATTR
:
3560 return (i_psvc_get_device_value_7_0(hdlp
, objp
, attrp
));
3561 case PSVC_LO_WARN_ATTR
:
3562 *(int32_t *)attrp
= ((EFanTach_t
*)objp
)->lo_warn
;
3564 case PSVC_LO_SHUT_ATTR
:
3565 *(int32_t *)attrp
= ((EFanTach_t
*)objp
)->lo_shut
;
3567 case PSVC_HI_WARN_ATTR
:
3568 *(int32_t *)attrp
= ((EFanTach_t
*)objp
)->hi_warn
;
3570 case PSVC_HI_SHUT_ATTR
:
3571 *(int32_t *)attrp
= ((EFanTach_t
*)objp
)->hi_shut
;
3575 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3577 return (PSVC_SUCCESS
);
3581 i_psvc_get_attr_8_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3583 int32_t status
= PSVC_SUCCESS
;
3586 case PSVC_SWITCH_STATE_ATTR
:
3587 case PSVC_STATE_ATTR
:
3588 return (i_psvc_get_device_state_8_0(hdlp
, objp
, attrp
));
3591 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3597 i_psvc_set_attr_8_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3599 int32_t status
= PSVC_SUCCESS
;
3602 case PSVC_SWITCH_STATE_ATTR
:
3603 case PSVC_STATE_ATTR
:
3604 return (i_psvc_set_device_state_8_0(hdlp
, objp
, attrp
));
3607 status
= i_psvc_set_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3613 i_psvc_get_attr_9_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3615 int32_t status
= PSVC_SUCCESS
;
3618 case PSVC_SWITCH_STATE_ATTR
:
3619 case PSVC_STATE_ATTR
:
3620 status
= i_psvc_get_device_state_9_0(hdlp
, objp
, attrp
);
3621 if ((status
== PSVC_FAILURE
) && (errno
== EINVAL
)) {
3622 strcpy((char *)attrp
, PSVC_ERROR
);
3623 return (PSVC_SUCCESS
);
3629 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3635 i_psvc_get_attr_10_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3637 int32_t status
= PSVC_SUCCESS
;
3640 case PSVC_GPIO_VALUE_ATTR
:
3641 return (i_psvc_get_device_value_10_0(hdlp
, objp
, attrp
));
3642 case PSVC_GPIO_BITS
:
3643 *(int32_t *)attrp
= 8;
3647 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3653 i_psvc_set_attr_10_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3655 int32_t status
= PSVC_SUCCESS
;
3657 if (attr_id
== PSVC_GPIO_VALUE_ATTR
) {
3658 return (i_psvc_set_device_value_10_0(hdlp
, objp
, attrp
));
3661 status
= i_psvc_set_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3667 i_psvc_get_attr_10_1(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3669 int32_t status
= PSVC_SUCCESS
;
3672 case PSVC_GPIO_VALUE_ATTR
:
3673 return (i_psvc_get_device_value_10_1(hdlp
, objp
, attrp
));
3674 case PSVC_GPIO_BITS
:
3675 *(int32_t *)attrp
= 8;
3679 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3685 i_psvc_set_attr_10_1(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3687 int32_t status
= PSVC_SUCCESS
;
3689 if (attr_id
== PSVC_GPIO_VALUE_ATTR
) {
3690 return (i_psvc_set_device_value_10_1(hdlp
, objp
, attrp
));
3693 status
= i_psvc_set_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3700 i_psvc_get_attr_11_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3702 int32_t status
= PSVC_SUCCESS
;
3703 int32_t probe_status
;
3706 case PSVC_PROBE_RESULT_ATTR
:
3707 probe_status
= i_psvc_probe_11_0(hdlp
, objp
);
3708 if (probe_status
== PSVC_SUCCESS
)
3709 strcpy((char *)attrp
, PSVC_OK
);
3711 strcpy((char *)attrp
, PSVC_ERROR
);
3713 case PSVC_FRU_INFO_ATTR
:
3714 status
= i_psvc_get_reg_11_0(hdlp
, objp
, attr_id
, attrp
);
3718 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3724 i_psvc_get_reg_11_0(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3726 int32_t status
= PSVC_SUCCESS
, ret
;
3727 char path
[1024], *data
;
3728 int32_t fp
, temp_errno
;
3729 fru_info_t
*fru_data
;
3731 fru_data
= (fru_info_t
*)attrp
;
3733 if (objp
->present
!= PSVC_PRESENT
) {
3735 return (PSVC_FAILURE
);
3738 status
= i_psvc_get_devpath(hdlp
, objp
->addr_spec
, path
);
3739 if (status
!= PSVC_SUCCESS
)
3742 fp
= open(path
, O_RDWR
);
3744 return (PSVC_FAILURE
);
3747 ret
= lseek(fp
, fru_data
->buf_start
, SEEK_SET
);
3748 if (ret
!= fru_data
->buf_start
) {
3752 return (PSVC_FAILURE
);
3755 data
= (char *)malloc(fru_data
->read_size
);
3756 ret
= read(fp
, data
, fru_data
->read_size
);
3764 memcpy(fru_data
->buf
, data
, fru_data
->read_size
);
3772 i_psvc_get_attr_11_1(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3774 int32_t status
= PSVC_SUCCESS
;
3775 int32_t probe_status
;
3777 if (attr_id
== PSVC_PROBE_RESULT_ATTR
) {
3778 probe_status
= i_psvc_probe_11_1(hdlp
, objp
);
3779 if (probe_status
== PSVC_SUCCESS
)
3780 strcpy((char *)attrp
, PSVC_OK
);
3782 strcpy((char *)attrp
, PSVC_ERROR
);
3786 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3792 i_psvc_get_attr_11_2(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3794 int32_t status
= PSVC_SUCCESS
;
3795 int32_t probe_status
;
3797 if (attr_id
== PSVC_PROBE_RESULT_ATTR
) {
3798 probe_status
= i_psvc_probe_11_2(hdlp
, objp
);
3799 if (probe_status
== PSVC_SUCCESS
)
3800 strcpy((char *)attrp
, PSVC_OK
);
3802 strcpy((char *)attrp
, PSVC_ERROR
);
3806 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3812 i_psvc_get_attr_11_3(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3814 int32_t status
= PSVC_SUCCESS
;
3815 int32_t probe_status
;
3817 if (attr_id
== PSVC_PROBE_RESULT_ATTR
) {
3818 probe_status
= i_psvc_probe_11_3(hdlp
, objp
);
3819 if (probe_status
== PSVC_SUCCESS
)
3820 strcpy((char *)attrp
, PSVC_OK
);
3822 strcpy((char *)attrp
, PSVC_ERROR
);
3826 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3832 i_psvc_get_attr_11_4(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3834 int32_t status
= PSVC_SUCCESS
;
3835 int32_t probe_status
;
3837 if (attr_id
== PSVC_PROBE_RESULT_ATTR
) {
3838 probe_status
= i_psvc_probe_11_4(hdlp
, objp
);
3839 if (probe_status
== PSVC_SUCCESS
)
3840 strcpy((char *)attrp
, PSVC_OK
);
3842 strcpy((char *)attrp
, PSVC_ERROR
);
3846 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3852 i_psvc_get_attr_11_5(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3854 int32_t status
= PSVC_SUCCESS
;
3855 int32_t probe_status
;
3857 if (attr_id
== PSVC_PROBE_RESULT_ATTR
) {
3858 probe_status
= i_psvc_probe_11_5(hdlp
, objp
);
3859 if (probe_status
== PSVC_SUCCESS
)
3860 strcpy((char *)attrp
, PSVC_OK
);
3862 strcpy((char *)attrp
, PSVC_ERROR
);
3866 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3872 i_psvc_get_attr_11_6(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3874 int32_t status
= PSVC_SUCCESS
;
3875 int32_t probe_status
;
3877 if (attr_id
== PSVC_PROBE_RESULT_ATTR
) {
3878 probe_status
= i_psvc_probe_11_6(hdlp
, objp
);
3879 if (probe_status
== PSVC_SUCCESS
)
3880 strcpy((char *)attrp
, PSVC_OK
);
3882 strcpy((char *)attrp
, PSVC_ERROR
);
3886 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3892 i_psvc_get_attr_11_7(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3894 int32_t status
= PSVC_SUCCESS
;
3895 int32_t probe_status
;
3897 if (attr_id
== PSVC_PROBE_RESULT_ATTR
) {
3898 probe_status
= i_psvc_probe_11_7(hdlp
, objp
);
3899 if (probe_status
== PSVC_SUCCESS
)
3900 strcpy((char *)attrp
, PSVC_OK
);
3902 strcpy((char *)attrp
, PSVC_ERROR
);
3906 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3912 i_psvc_get_attr_11_8(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3914 int32_t status
= PSVC_SUCCESS
;
3915 int32_t probe_status
;
3917 if (attr_id
== PSVC_PROBE_RESULT_ATTR
) {
3918 probe_status
= i_psvc_probe_11_8(hdlp
, objp
);
3919 if (probe_status
== PSVC_SUCCESS
)
3920 strcpy((char *)attrp
, PSVC_OK
);
3922 strcpy((char *)attrp
, PSVC_ERROR
);
3926 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3932 i_psvc_get_attr_11_9(EHdl_t
*hdlp
, EObj_t
*objp
, int32_t attr_id
, void *attrp
)
3934 int32_t status
= PSVC_SUCCESS
;
3935 int32_t probe_status
;
3937 if (attr_id
== PSVC_PROBE_RESULT_ATTR
) {
3938 probe_status
= i_psvc_probe_11_9(hdlp
, objp
);
3939 if (probe_status
== PSVC_SUCCESS
)
3940 strcpy((char *)attrp
, PSVC_OK
);
3942 strcpy((char *)attrp
, PSVC_ERROR
);
3946 status
= i_psvc_get_attr_generic(hdlp
, objp
, attr_id
, attrp
);
3952 i_psvc_load_generic(
3959 int32_t found
, key
, array
;
3962 char cur_device
[NAMELEN
];
3964 ETable_Array
*tbl_arr
;
3966 key
= psvc_get_str_key(name
);
3967 array
= key
% PSVC_MAX_TABLE_ARRAYS
;
3968 tbl_arr
= &(hdlp
->tbl_arry
[array
]);
3970 if (tbl_arr
->nextid
== hdlp
->total_obj_count
) {
3972 return (PSVC_FAILURE
);
3974 slot
= tbl_arr
->nextid
++;
3975 tbl_arr
->obj_count
++;
3978 if (i_psvc_find_file_section(hdlp
->fp
, "OBJECT_INFO") != PSVC_SUCCESS
)
3979 return (PSVC_FAILURE
);
3981 fgets(buf
, BUFSZ
, hdlp
->fp
);
3982 while (strcmp(buf
, "OBJECT_INFO_END")) {
3983 start
= strrchr(buf
, '/');
3984 if (start
== NULL
) {
3986 return (PSVC_FAILURE
);
3988 found
= sscanf(start
+ 1, "%s", cur_device
);
3991 return (PSVC_FAILURE
);
3993 if (strcmp(name
, cur_device
) == 0) /* found it */
3995 fgets(buf
, BUFSZ
, hdlp
->fp
);
3998 tbl_arr
->obj_tbl
[slot
].objp
= (EObj_t
*)malloc(obj_size
);
3999 if (tbl_arr
->obj_tbl
[slot
].objp
== 0)
4000 return (PSVC_FAILURE
);
4001 objp
= (EObj_t
*)tbl_arr
->obj_tbl
[slot
].objp
;
4002 tbl_arr
->obj_tbl
[slot
].type
= PSVC_OBJ
;
4004 memset(objp
, 0, obj_size
);
4005 strcpy(objp
->label
, name
);
4006 strcpy(tbl_arr
->obj_tbl
[slot
].name
, name
);
4008 tbl_arr
->obj_tbl
[slot
].key
= key
;
4010 if (i_psvc_value(buf
, PSVC_CLASS_ATTR
, &objp
->class) != PSVC_SUCCESS
) {
4011 i_psvc_destructor(hdlp
, name
, objp
);
4012 return (PSVC_FAILURE
);
4014 if (i_psvc_value(buf
, PSVC_SUBCLASS_ATTR
, &objp
->subclass
) !=
4016 i_psvc_destructor(hdlp
, name
, objp
);
4017 return (PSVC_FAILURE
);
4019 if (i_psvc_value(buf
, PSVC_INSTANCE_ATTR
, &objp
->instance
) !=
4021 i_psvc_destructor(hdlp
, name
, objp
);
4022 return (PSVC_FAILURE
);
4024 if (i_psvc_value(buf
, PSVC_FEATURES_ATTR
, &objp
->features
) !=
4026 i_psvc_destructor(hdlp
, name
, objp
);
4027 return (PSVC_FAILURE
);
4029 if (i_psvc_value(buf
, PSVC_ADDR_SPEC_ATTR
, &objp
->addr_spec
) !=
4031 i_psvc_destructor(hdlp
, name
, objp
);
4032 return (PSVC_FAILURE
);
4035 if (objp
->features
& PSVC_DEV_SECONDARY
)
4036 objp
->enabled
= PSVC_DISABLED
;
4038 objp
->enabled
= PSVC_ENABLED
;
4040 if (PSVC_GET_VERSION(objp
->addr_spec
) > PSVC_VERSION
) {
4042 i_psvc_destructor(hdlp
, name
, objp
);
4043 return (PSVC_FAILURE
);
4047 return (PSVC_SUCCESS
);
4053 i_psvc_not_supported()
4056 return (PSVC_FAILURE
);
4059 /* Temperature sensor */
4060 /* Class 0 Subclass 0 are temperature sensors that cannot be updated */
4062 i_psvc_constructor_0_0(
4071 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4072 sizeof (ETempSensor_t
));
4073 if (status
!= PSVC_SUCCESS
)
4076 /* Load class specific info */
4077 dp
= (ETempSensor_t
*)*objpp
;
4078 if (i_psvc_value(buf
, PSVC_LO_WARN_ATTR
, &dp
->lo_warn
)
4080 i_psvc_destructor(hdlp
, id
, dp
);
4081 return (PSVC_FAILURE
);
4083 if (i_psvc_value(buf
, PSVC_LO_SHUT_ATTR
, &dp
->lo_shut
)
4085 i_psvc_destructor(hdlp
, id
, dp
);
4086 return (PSVC_FAILURE
);
4088 if (i_psvc_value(buf
, PSVC_HI_WARN_ATTR
, &dp
->hi_warn
)
4090 i_psvc_destructor(hdlp
, id
, dp
);
4091 return (PSVC_FAILURE
);
4093 if (i_psvc_value(buf
, PSVC_HI_SHUT_ATTR
, &dp
->hi_shut
)
4095 i_psvc_destructor(hdlp
, id
, dp
);
4096 return (PSVC_FAILURE
);
4099 dp
->ld
.constructor
= i_psvc_constructor_0_0
;
4100 dp
->ld
.destructor
= i_psvc_destructor
;
4101 dp
->ld
.get_attr
= i_psvc_get_attr_0_0
;
4102 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4107 /* Class 0 Subclass 1 are temperature sensors that can be updated */
4109 i_psvc_constructor_0_1(
4118 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4119 sizeof (ETempSensor_t
));
4120 if (status
!= PSVC_SUCCESS
)
4123 /* Load class specific info */
4124 dp
= (ETempSensor_t
*)*objpp
;
4125 if (i_psvc_value(buf
, PSVC_LO_WARN_ATTR
, &dp
->lo_warn
)
4127 i_psvc_destructor(hdlp
, id
, dp
);
4128 return (PSVC_FAILURE
);
4130 if (i_psvc_value(buf
, PSVC_LO_SHUT_ATTR
, &dp
->lo_shut
)
4132 i_psvc_destructor(hdlp
, id
, dp
);
4133 return (PSVC_FAILURE
);
4135 if (i_psvc_value(buf
, PSVC_HI_WARN_ATTR
, &dp
->hi_warn
)
4137 i_psvc_destructor(hdlp
, id
, dp
);
4138 return (PSVC_FAILURE
);
4140 if (i_psvc_value(buf
, PSVC_HI_SHUT_ATTR
, &dp
->hi_shut
)
4142 i_psvc_destructor(hdlp
, id
, dp
);
4143 return (PSVC_FAILURE
);
4146 if ((*objpp
)->features
& PSVC_OPT_TEMP
) {
4147 if (i_psvc_value(buf
, PSVC_OPTIMAL_TEMP_ATTR
, &dp
->opt_temp
)
4149 i_psvc_destructor(hdlp
, id
, dp
);
4150 return (PSVC_FAILURE
);
4153 if ((*objpp
)->features
& PSVC_HW_LOW_SHUT
) {
4154 if (i_psvc_value(buf
, PSVC_HW_LO_SHUT_ATTR
, &dp
->hw_lo_shut
)
4156 i_psvc_destructor(hdlp
, id
, dp
);
4157 return (PSVC_FAILURE
);
4160 if ((*objpp
)->features
& PSVC_HW_HIGH_SHUT
) {
4161 if (i_psvc_value(buf
, PSVC_HW_HI_SHUT_ATTR
, &dp
->hw_hi_shut
)
4163 i_psvc_destructor(hdlp
, id
, dp
);
4164 return (PSVC_FAILURE
);
4168 dp
->ld
.constructor
= i_psvc_constructor_0_1
;
4169 dp
->ld
.destructor
= i_psvc_destructor
;
4170 dp
->ld
.get_attr
= i_psvc_get_attr_0_1
;
4171 dp
->ld
.set_attr
= i_psvc_set_attr_0_1
;
4178 i_psvc_constructor_1_0(
4187 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4189 if (status
!= PSVC_SUCCESS
)
4192 /* Load class specific info */
4193 dp
= (EFan_t
*)*objpp
;
4194 if (i_psvc_value(buf
, PSVC_SETPOINT_ATTR
, &dp
->setpoint
)
4196 i_psvc_destructor(hdlp
, id
, dp
);
4197 return (PSVC_FAILURE
);
4199 if (i_psvc_value(buf
, PSVC_HYSTERESIS_ATTR
, &dp
->hysteresis
)
4201 i_psvc_destructor(hdlp
, id
, dp
);
4202 return (PSVC_FAILURE
);
4204 if (i_psvc_value(buf
, PSVC_LOOPGAIN_ATTR
, &dp
->loopgain
)
4206 i_psvc_destructor(hdlp
, id
, dp
);
4207 return (PSVC_FAILURE
);
4209 if (i_psvc_value(buf
, PSVC_LOOPBIAS_ATTR
, &dp
->loopbias
)
4211 i_psvc_destructor(hdlp
, id
, dp
);
4212 return (PSVC_FAILURE
);
4215 dp
->ld
.constructor
= i_psvc_constructor_1_0
;
4216 dp
->ld
.destructor
= i_psvc_destructor
;
4217 dp
->ld
.get_attr
= i_psvc_get_attr_1_0
;
4218 dp
->ld
.set_attr
= i_psvc_set_attr_1_0
;
4220 return (PSVC_SUCCESS
);
4226 i_psvc_constructor_2_0(
4235 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4237 if (status
!= PSVC_SUCCESS
)
4240 /* Load class specific info */
4241 dp
= (ELed_t
*)*objpp
;
4243 if (i_psvc_value(buf
, PSVC_LED_COLOR_ATTR
, dp
->color
)
4245 i_psvc_destructor(hdlp
, id
, dp
);
4246 return (PSVC_FAILURE
);
4249 dp
->ld
.constructor
= i_psvc_constructor_2_0
;
4250 dp
->ld
.destructor
= i_psvc_destructor
;
4251 dp
->ld
.get_attr
= i_psvc_get_attr_2_0
;
4252 dp
->ld
.set_attr
= i_psvc_set_attr_2_0
;
4254 return (PSVC_SUCCESS
);
4258 i_psvc_constructor_2_1(
4267 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4269 if (status
!= PSVC_SUCCESS
)
4272 /* Load class specific info */
4273 dp
= (ELed_t
*)*objpp
;
4275 if (i_psvc_value(buf
, PSVC_LED_COLOR_ATTR
, dp
->color
)
4277 i_psvc_destructor(hdlp
, id
, dp
);
4278 return (PSVC_FAILURE
);
4281 dp
->ld
.constructor
= i_psvc_constructor_2_1
;
4282 dp
->ld
.destructor
= i_psvc_destructor
;
4283 dp
->ld
.get_attr
= i_psvc_get_attr_2_1
;
4284 dp
->ld
.set_attr
= i_psvc_set_attr_2_1
;
4286 return (PSVC_SUCCESS
);
4290 i_psvc_constructor_2_2(
4299 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4301 if (status
!= PSVC_SUCCESS
)
4304 /* Load class specific info */
4305 dp
= (ELed_t
*)*objpp
;
4307 if (i_psvc_value(buf
, PSVC_LED_COLOR_ATTR
, dp
->color
)
4309 i_psvc_destructor(hdlp
, id
, dp
);
4310 return (PSVC_FAILURE
);
4312 if (i_psvc_value(buf
, PSVC_LED_IS_LOCATOR_ATTR
, dp
->is_locator
)
4314 i_psvc_destructor(hdlp
, id
, dp
);
4315 return (PSVC_FAILURE
);
4317 if (strcmp(dp
->is_locator
, PSVC_LOCATOR_TRUE
) == 0) {
4318 if (i_psvc_value(buf
, PSVC_LED_LOCATOR_NAME_ATTR
,
4319 dp
->locator_name
) != PSVC_SUCCESS
) {
4320 i_psvc_destructor(hdlp
, id
, dp
);
4321 return (PSVC_FAILURE
);
4324 strcpy(dp
->locator_name
, "N/A");
4327 dp
->ld
.constructor
= i_psvc_constructor_2_2
;
4328 dp
->ld
.destructor
= i_psvc_destructor
;
4329 dp
->ld
.get_attr
= i_psvc_get_attr_2_2
;
4330 dp
->ld
.set_attr
= i_psvc_set_attr_2_0
;
4332 return (PSVC_SUCCESS
);
4337 i_psvc_constructor_3_0(
4346 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (ESystem_t
));
4347 if (status
!= PSVC_SUCCESS
)
4350 /* Load class specific info */
4351 dp
= (ESystem_t
*)*objpp
;
4353 dp
->ld
.constructor
= i_psvc_constructor_3_0
;
4354 dp
->ld
.destructor
= i_psvc_destructor
;
4355 dp
->ld
.get_attr
= i_psvc_get_attr_generic
;
4356 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4358 return (PSVC_SUCCESS
);
4361 /* Digital Sensor */
4363 i_psvc_constructor_4_0(
4372 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4373 sizeof (EDigiSensor_t
));
4374 if (status
!= PSVC_SUCCESS
) {
4378 /* Load class specific info */
4379 dp
= (EDigiSensor_t
*)*objpp
;
4380 if (i_psvc_value(buf
, PSVC_LO_WARN_ATTR
, &dp
->lo_warn
)
4382 i_psvc_destructor(hdlp
, id
, dp
);
4383 return (PSVC_FAILURE
);
4385 if (i_psvc_value(buf
, PSVC_LO_SHUT_ATTR
, &dp
->lo_shut
)
4387 i_psvc_destructor(hdlp
, id
, dp
);
4388 return (PSVC_FAILURE
);
4390 if (i_psvc_value(buf
, PSVC_HI_WARN_ATTR
, &dp
->hi_warn
)
4392 i_psvc_destructor(hdlp
, id
, dp
);
4393 return (PSVC_FAILURE
);
4395 if (i_psvc_value(buf
, PSVC_HI_SHUT_ATTR
, &dp
->hi_shut
)
4397 i_psvc_destructor(hdlp
, id
, dp
);
4398 return (PSVC_FAILURE
);
4401 dp
->ld
.constructor
= i_psvc_constructor_4_0
;
4402 dp
->ld
.destructor
= i_psvc_destructor
;
4403 dp
->ld
.get_attr
= i_psvc_get_attr_4_0
;
4404 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4406 return (PSVC_SUCCESS
);
4409 /* Digital Control */
4411 i_psvc_constructor_5_0(
4420 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4421 sizeof (EDigiControl_t
));
4422 if (status
!= PSVC_SUCCESS
)
4425 /* Load class specific info */
4426 dp
= (EDigiControl_t
*)*objpp
;
4428 dp
->ld
.constructor
= i_psvc_constructor_5_0
;
4429 dp
->ld
.destructor
= i_psvc_destructor
;
4430 dp
->ld
.get_attr
= i_psvc_get_attr_5_0
;
4431 dp
->ld
.set_attr
= i_psvc_set_attr_5_0
;
4432 return (PSVC_SUCCESS
);
4437 i_psvc_constructor_6_0(
4446 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4447 sizeof (EBoolSensor_t
));
4448 if (status
!= PSVC_SUCCESS
)
4451 /* Load class specific info */
4452 dp
= (EBoolSensor_t
*)*objpp
;
4454 dp
->ld
.constructor
= i_psvc_constructor_6_0
;
4455 dp
->ld
.destructor
= i_psvc_destructor
;
4456 dp
->ld
.get_attr
= i_psvc_get_attr_6_0
;
4457 dp
->ld
.set_attr
= i_psvc_set_attr_6_0
;
4459 return (PSVC_SUCCESS
);
4462 /* Fan Tachometer */
4464 i_psvc_constructor_7_0(
4473 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4474 sizeof (EFanTach_t
));
4475 if (status
!= PSVC_SUCCESS
)
4478 /* Load class specific info */
4479 dp
= (EFanTach_t
*)*objpp
;
4480 if (i_psvc_value(buf
, PSVC_LO_WARN_ATTR
, &dp
->lo_warn
)
4482 i_psvc_destructor(hdlp
, id
, dp
);
4483 return (PSVC_FAILURE
);
4485 if (i_psvc_value(buf
, PSVC_LO_SHUT_ATTR
, &dp
->lo_shut
)
4487 i_psvc_destructor(hdlp
, id
, dp
);
4488 return (PSVC_FAILURE
);
4490 if (i_psvc_value(buf
, PSVC_HI_WARN_ATTR
, &dp
->hi_warn
)
4492 i_psvc_destructor(hdlp
, id
, dp
);
4493 return (PSVC_FAILURE
);
4495 if (i_psvc_value(buf
, PSVC_HI_SHUT_ATTR
, &dp
->hi_shut
)
4497 i_psvc_destructor(hdlp
, id
, dp
);
4498 return (PSVC_FAILURE
);
4501 dp
->ld
.constructor
= i_psvc_constructor_7_0
;
4502 dp
->ld
.destructor
= i_psvc_destructor
;
4503 dp
->ld
.get_attr
= i_psvc_get_attr_7_0
;
4504 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4506 return (PSVC_SUCCESS
);
4511 i_psvc_constructor_8_0(
4520 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4521 sizeof (ESwitch_t
));
4522 if (status
!= PSVC_SUCCESS
)
4525 /* Load class specific info */
4526 dp
= (ESwitch_t
*)*objpp
;
4528 dp
->ld
.constructor
= i_psvc_constructor_8_0
;
4529 dp
->ld
.destructor
= i_psvc_destructor
;
4530 dp
->ld
.get_attr
= i_psvc_get_attr_8_0
;
4531 dp
->ld
.set_attr
= i_psvc_set_attr_8_0
;
4533 return (PSVC_SUCCESS
);
4538 i_psvc_constructor_9_0(
4547 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4548 sizeof (EKeySwitch_t
));
4549 if (status
!= PSVC_SUCCESS
)
4552 /* Load class specific info */
4553 dp
= (EKeySwitch_t
*)*objpp
;
4555 dp
->ld
.constructor
= i_psvc_constructor_9_0
;
4556 dp
->ld
.destructor
= i_psvc_destructor
;
4557 dp
->ld
.get_attr
= i_psvc_get_attr_9_0
;
4558 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4560 return (PSVC_SUCCESS
);
4563 /* 8 Bit GPIO , devices with registers, calls get_reg()/set_reg() */
4565 i_psvc_constructor_10_0(
4574 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EGPIO8_t
));
4575 if (status
!= PSVC_SUCCESS
)
4578 /* Load class specific info */
4579 dp
= (EGPIO8_t
*)*objpp
;
4581 dp
->ld
.constructor
= i_psvc_constructor_10_0
;
4582 dp
->ld
.destructor
= i_psvc_destructor
;
4583 dp
->ld
.get_attr
= i_psvc_get_attr_10_0
;
4584 dp
->ld
.set_attr
= i_psvc_set_attr_10_0
;
4586 return (PSVC_SUCCESS
);
4589 /* 8 Bit GPIO , devices with ports, calls get_port()/set_port() */
4591 i_psvc_constructor_10_1(
4600 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EGPIO8_t
));
4601 if (status
!= PSVC_SUCCESS
)
4604 /* Load class specific info */
4605 dp
= (EGPIO8_t
*)*objpp
;
4607 dp
->ld
.constructor
= i_psvc_constructor_10_1
;
4608 dp
->ld
.destructor
= i_psvc_destructor
;
4609 dp
->ld
.get_attr
= i_psvc_get_attr_10_1
;
4610 dp
->ld
.set_attr
= i_psvc_set_attr_10_1
;
4612 return (PSVC_SUCCESS
);
4617 i_psvc_constructor_11_0(
4626 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
,
4627 sizeof (EPhysDev_t
));
4628 if (status
!= PSVC_SUCCESS
)
4631 /* Load class specific info */
4632 dp
= (EPhysDev_t
*)*objpp
;
4634 dp
->ld
.constructor
= i_psvc_constructor_11_0
;
4635 dp
->ld
.destructor
= i_psvc_destructor
;
4636 dp
->ld
.get_attr
= i_psvc_get_attr_11_0
;
4637 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4638 dp
->get_temperature
= i_psvc_not_supported
;
4639 dp
->get_fanspeed
= i_psvc_not_supported
;
4640 dp
->get_input
= i_psvc_not_supported
;
4641 dp
->get_bit
= i_psvc_not_supported
;
4642 dp
->set_bit
= i_psvc_not_supported
;
4643 dp
->get_port
= i_psvc_not_supported
;
4644 dp
->set_port
= i_psvc_not_supported
;
4645 dp
->get_output
= i_psvc_not_supported
;
4646 dp
->set_output
= i_psvc_not_supported
;
4647 dp
->get_reg
= i_psvc_get_reg_11_0
;
4648 dp
->set_reg
= i_psvc_not_supported
;
4650 return (PSVC_SUCCESS
);
4655 i_psvc_constructor_11_1(
4664 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EPhysDev_t
));
4665 if (status
!= PSVC_SUCCESS
)
4668 /* Load class specific info */
4669 dp
= (EPhysDev_t
*)*objpp
;
4671 dp
->ld
.constructor
= i_psvc_constructor_11_1
;
4672 dp
->ld
.destructor
= i_psvc_destructor
;
4673 dp
->ld
.get_attr
= i_psvc_get_attr_11_1
;
4674 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4675 dp
->get_temperature
= i_psvc_not_supported
;
4676 dp
->get_fanspeed
= i_psvc_not_supported
;
4677 dp
->get_input
= i_psvc_not_supported
;
4678 dp
->get_bit
= i_psvc_not_supported
;
4679 dp
->set_bit
= i_psvc_not_supported
;
4680 dp
->get_port
= i_psvc_not_supported
;
4681 dp
->set_port
= i_psvc_not_supported
;
4682 dp
->get_output
= i_psvc_not_supported
;
4683 dp
->set_output
= i_psvc_not_supported
;
4684 dp
->get_reg
= i_psvc_get_reg_11_1
;
4685 dp
->set_reg
= i_psvc_set_reg_11_1
;
4687 return (PSVC_SUCCESS
);
4692 i_psvc_constructor_11_2(
4701 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EPhysDev_t
));
4702 if (status
!= PSVC_SUCCESS
)
4705 /* Load class specific info */
4706 dp
= (EPhysDev_t
*)*objpp
;
4708 dp
->ld
.constructor
= i_psvc_constructor_11_2
;
4709 dp
->ld
.destructor
= i_psvc_destructor
;
4710 dp
->ld
.get_attr
= i_psvc_get_attr_11_2
;
4711 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4712 dp
->get_temperature
= i_psvc_get_temperature_11_2
;
4713 dp
->get_fanspeed
= i_psvc_not_supported
;
4714 dp
->get_input
= i_psvc_not_supported
;
4715 dp
->get_bit
= i_psvc_not_supported
;
4716 dp
->set_bit
= i_psvc_not_supported
;
4717 dp
->get_port
= i_psvc_not_supported
;
4718 dp
->set_port
= i_psvc_not_supported
;
4719 dp
->get_output
= i_psvc_not_supported
;
4720 dp
->set_output
= i_psvc_not_supported
;
4721 dp
->get_reg
= i_psvc_not_supported
;
4722 dp
->set_reg
= i_psvc_not_supported
;
4724 return (PSVC_SUCCESS
);
4729 i_psvc_constructor_11_3(
4739 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EPhysDev_t
));
4740 if (status
!= PSVC_SUCCESS
)
4744 * The following code upto and including the open() call is so the
4745 * device driver for the ltc1427 does not get unloaded by the OS at
4746 * any time. This is important as the device driver is a write only
4747 * physical device but DOES keep readable states in the device unitp
4748 * structure (I2C_GET_OUTPUT) as a result this device should not
4749 * be unload while PSVC is up and running
4751 status
= i_psvc_get_devpath(hdlp
, (*objpp
)->addr_spec
, path
);
4752 if (status
!= PSVC_SUCCESS
) {
4757 * We deliberately do not close our file handle, to prevent
4758 * any device instances from being detached. If an instance
4759 * is detached, the "readable states in the device unitp"
4760 * will be unloaded, causing loss of control of the device
4761 * and incorrect error(s) to be displayed.
4763 if (open(path
, O_RDWR
) == -1) {
4764 return (PSVC_FAILURE
);
4766 /* Load class specific info */
4767 dp
= (EPhysDev_t
*)*objpp
;
4769 dp
->ld
.constructor
= i_psvc_constructor_11_3
;
4770 dp
->ld
.destructor
= i_psvc_destructor
;
4771 dp
->ld
.get_attr
= i_psvc_get_attr_11_3
;
4772 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4773 dp
->get_temperature
= i_psvc_not_supported
;
4774 dp
->get_fanspeed
= i_psvc_not_supported
;
4775 dp
->get_input
= i_psvc_not_supported
;
4776 dp
->get_bit
= i_psvc_not_supported
;
4777 dp
->set_bit
= i_psvc_not_supported
;
4778 dp
->get_port
= i_psvc_not_supported
;
4779 dp
->set_port
= i_psvc_not_supported
;
4780 dp
->get_output
= i_psvc_get_output_11_3
;
4781 dp
->set_output
= i_psvc_set_output_11_3
;
4782 dp
->get_reg
= i_psvc_not_supported
;
4783 dp
->set_reg
= i_psvc_not_supported
;
4785 return (PSVC_SUCCESS
);
4790 i_psvc_constructor_11_4(
4799 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EPhysDev_t
));
4800 if (status
!= PSVC_SUCCESS
)
4803 /* Load class specific info */
4804 dp
= (EPhysDev_t
*)*objpp
;
4806 dp
->ld
.constructor
= i_psvc_constructor_11_4
;
4807 dp
->ld
.destructor
= i_psvc_destructor
;
4808 dp
->ld
.get_attr
= i_psvc_get_attr_11_4
;
4809 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4810 dp
->get_temperature
= i_psvc_get_temperature_11_4
;
4811 dp
->get_fanspeed
= i_psvc_not_supported
;
4812 dp
->get_input
= i_psvc_not_supported
;
4813 dp
->get_bit
= i_psvc_not_supported
;
4814 dp
->set_bit
= i_psvc_not_supported
;
4815 dp
->get_port
= i_psvc_not_supported
;
4816 dp
->set_port
= i_psvc_not_supported
;
4817 dp
->get_output
= i_psvc_not_supported
;
4818 dp
->set_output
= i_psvc_not_supported
;
4819 dp
->get_reg
= i_psvc_not_supported
;
4820 dp
->set_reg
= i_psvc_not_supported
;
4822 return (PSVC_SUCCESS
);
4827 i_psvc_constructor_11_5(
4836 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EPhysDev_t
));
4837 if (status
!= PSVC_SUCCESS
)
4840 /* Load class specific info */
4841 dp
= (EPhysDev_t
*)*objpp
;
4843 dp
->ld
.constructor
= i_psvc_constructor_11_5
;
4844 dp
->ld
.destructor
= i_psvc_destructor
;
4845 dp
->ld
.get_attr
= i_psvc_get_attr_11_5
;
4846 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4847 dp
->get_temperature
= i_psvc_not_supported
;
4848 dp
->get_fanspeed
= i_psvc_not_supported
;
4849 dp
->get_input
= i_psvc_not_supported
;
4850 dp
->get_bit
= i_psvc_get_bit_11_5
;
4851 dp
->set_bit
= i_psvc_set_bit_11_5
;
4852 dp
->get_port
= i_psvc_get_port_11_5
;
4853 dp
->set_port
= i_psvc_set_port_11_5
;
4854 dp
->get_output
= i_psvc_not_supported
;
4855 dp
->set_output
= i_psvc_not_supported
;
4856 dp
->get_reg
= i_psvc_not_supported
;
4857 dp
->set_reg
= i_psvc_not_supported
;
4859 return (PSVC_SUCCESS
);
4864 i_psvc_constructor_11_6(
4873 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EPhysDev_t
));
4874 if (status
!= PSVC_SUCCESS
)
4877 /* Load class specific info */
4878 dp
= (EPhysDev_t
*)*objpp
;
4880 dp
->ld
.constructor
= i_psvc_constructor_11_6
;
4881 dp
->ld
.destructor
= i_psvc_destructor
;
4882 dp
->ld
.get_attr
= i_psvc_get_attr_11_6
;
4883 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4884 dp
->get_temperature
= i_psvc_get_temperature_11_6
;
4885 dp
->get_fanspeed
= i_psvc_not_supported
;
4886 dp
->get_input
= i_psvc_get_input_11_6
;
4887 dp
->get_bit
= i_psvc_not_supported
;
4888 dp
->set_bit
= i_psvc_not_supported
;
4889 dp
->get_port
= i_psvc_not_supported
;
4890 dp
->set_port
= i_psvc_not_supported
;
4891 dp
->get_output
= i_psvc_get_output_11_6
;
4892 dp
->set_output
= i_psvc_set_output_11_6
;
4893 dp
->get_reg
= i_psvc_not_supported
;
4894 dp
->set_reg
= i_psvc_not_supported
;
4896 return (PSVC_SUCCESS
);
4901 i_psvc_constructor_11_7(
4910 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EPhysDev_t
));
4911 if (status
!= PSVC_SUCCESS
)
4914 /* Load class specific info */
4915 dp
= (EPhysDev_t
*)*objpp
;
4917 dp
->ld
.constructor
= i_psvc_constructor_11_7
;
4918 dp
->ld
.destructor
= i_psvc_destructor
;
4919 dp
->ld
.get_attr
= i_psvc_get_attr_11_7
;
4920 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4921 dp
->get_temperature
= i_psvc_not_supported
;
4922 dp
->get_fanspeed
= i_psvc_get_fanspeed_11_7
;
4923 dp
->get_input
= i_psvc_not_supported
;
4924 dp
->get_bit
= i_psvc_get_bit_11_7
;
4925 dp
->set_bit
= i_psvc_set_bit_11_7
;
4926 dp
->get_port
= i_psvc_get_port_11_5
; /* same as for class = 11, 5 */
4927 dp
->set_port
= i_psvc_set_port_11_5
;
4928 dp
->get_output
= i_psvc_not_supported
;
4929 dp
->set_output
= i_psvc_not_supported
;
4930 dp
->get_reg
= i_psvc_get_reg_11_7
;
4931 dp
->set_reg
= i_psvc_set_reg_11_7
;
4933 return (PSVC_SUCCESS
);
4938 i_psvc_constructor_11_8(
4947 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EPhysDev_t
));
4948 if (status
!= PSVC_SUCCESS
)
4951 /* Load class specific info */
4952 dp
= (EPhysDev_t
*)*objpp
;
4954 dp
->ld
.constructor
= i_psvc_constructor_11_8
;
4955 dp
->ld
.destructor
= i_psvc_destructor
;
4956 dp
->ld
.get_attr
= i_psvc_get_attr_11_8
;
4957 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4958 dp
->get_temperature
= i_psvc_not_supported
;
4959 dp
->get_fanspeed
= i_psvc_not_supported
;
4960 dp
->get_input
= i_psvc_not_supported
;
4961 dp
->get_bit
= i_psvc_not_supported
;
4962 dp
->set_bit
= i_psvc_not_supported
;
4963 dp
->get_port
= i_psvc_not_supported
;
4964 dp
->set_port
= i_psvc_not_supported
;
4965 dp
->get_output
= i_psvc_get_output_11_8
;
4966 dp
->set_output
= i_psvc_set_output_11_8
;
4967 dp
->get_reg
= i_psvc_not_supported
;
4968 dp
->set_reg
= i_psvc_not_supported
;
4970 return (PSVC_SUCCESS
);
4975 i_psvc_constructor_11_9(
4984 status
= i_psvc_load_generic(hdlp
, id
, objpp
, buf
, sizeof (EPhysDev_t
));
4985 if (status
!= PSVC_SUCCESS
)
4988 /* Load class specific info */
4989 dp
= (EPhysDev_t
*)*objpp
;
4991 dp
->ld
.constructor
= i_psvc_constructor_11_9
;
4992 dp
->ld
.destructor
= i_psvc_destructor
;
4993 dp
->ld
.get_attr
= i_psvc_get_attr_11_9
;
4994 dp
->ld
.set_attr
= i_psvc_set_attr_generic
;
4995 dp
->get_temperature
= i_psvc_not_supported
;
4996 dp
->get_fanspeed
= i_psvc_not_supported
;
4997 dp
->get_input
= i_psvc_not_supported
;
4998 dp
->get_bit
= i_psvc_not_supported
;
4999 dp
->set_bit
= i_psvc_not_supported
;
5000 dp
->get_port
= i_psvc_get_port_11_5
; /* Same as for class = 11, 5 */
5001 dp
->set_port
= i_psvc_set_port_11_5
;
5002 dp
->get_output
= i_psvc_not_supported
;
5003 dp
->set_output
= i_psvc_not_supported
;
5004 dp
->get_reg
= i_psvc_not_supported
;
5005 dp
->set_reg
= i_psvc_not_supported
;
5007 return (PSVC_SUCCESS
);
5011 psvc_init(EHdl_t
**hdlpp
)
5020 pthread_mutexattr_t mutex_attr
;
5021 uint32_t table_count
;
5022 int forward_slash
= 47;
5026 hdlp
= (EHdl_t
*)malloc(sizeof (EHdl_t
));
5029 memset(hdlp
, 0, sizeof (EHdl_t
));
5031 /* Initialize the lock */
5032 status
= pthread_mutexattr_init(&mutex_attr
);
5037 status
= pthread_mutex_init(&hdlp
->mutex
, &mutex_attr
);
5042 pthread_mutexattr_destroy(&mutex_attr
);
5044 if (sysinfo(SI_PLATFORM
, platform
, sizeof (platform
)) == -1) {
5048 snprintf(filename
, sizeof (filename
),
5049 "/usr/platform/%s/lib/psvcobj.conf", platform
);
5050 if ((hdlp
->fp
= fopen(filename
, "r")) == NULL
) {
5055 /* Build the association ID lookup table */
5057 hdlp
->othr_count
= hdlp
->assoc_count
= ASSOC_STR_TAB_SIZE
;
5058 if ((hdlp
->othr_tbl
= (EStringId_t
*)malloc(sizeof (EStringId_t
) *
5059 hdlp
->othr_count
)) == NULL
) {
5063 for (i
= 0; i
< hdlp
->othr_count
; ++i
) {
5064 hdlp
->othr_tbl
[i
].id
= i
;
5065 strcpy(hdlp
->othr_tbl
[i
].name
, assoc_str_tab
[i
]);
5067 qsort(hdlp
->othr_tbl
, hdlp
->othr_count
, sizeof (EStringId_t
),
5068 (int (*)(const void *, const void *))i_psvc_name_compare_qsort
);
5070 /* determine total number of objects + tables */
5071 if (i_psvc_find_file_section(hdlp
->fp
, "OBJECT_INFO") == -1) {
5074 if (i_psvc_count_records(hdlp
->fp
, "OBJECT_INFO_END",
5075 &hdlp
->total_obj_count
) == -1) {
5078 if (i_psvc_find_file_section(hdlp
->fp
, "TABLES") == PSVC_SUCCESS
) {
5079 status
= i_psvc_count_tables_associations(hdlp
->fp
,
5080 &table_count
, "TABLE_END");
5081 if (status
== PSVC_FAILURE
) {
5084 hdlp
->total_obj_count
+= table_count
;
5087 /* Allocate object name to object pointer translation table */
5088 for (i
= 0; i
< PSVC_MAX_TABLE_ARRAYS
; i
++) {
5089 if ((hdlp
->tbl_arry
[i
].obj_tbl
=
5090 (ENamePtr_t
*)malloc(
5091 sizeof (ENamePtr_t
) *hdlp
->total_obj_count
)) == NULL
) {
5094 memset(hdlp
->tbl_arry
[i
].obj_tbl
, 0,
5095 sizeof (ENamePtr_t
) * hdlp
->total_obj_count
);
5096 hdlp
->tbl_arry
[i
].obj_count
= 0;
5099 /* Build the association table */
5100 if (i_psvc_load_associations(hdlp
, hdlp
->fp
) == -1)
5103 /* Build the table of device paths */
5104 if (i_psvc_find_file_section(hdlp
->fp
, "DEVPATHS") == -1)
5106 if (i_psvc_count_records(hdlp
->fp
, "DEVPATHS_END",
5107 &hdlp
->dev_count
) == -1)
5109 if ((hdlp
->dev_tbl
= (EDevice_t
*)malloc(sizeof (EDevice_t
) *
5110 hdlp
->dev_count
)) == NULL
) {
5113 for (i
= 0; i
< hdlp
->dev_count
; ++i
) {
5114 fgets(buf
, BUFSZ
, hdlp
->fp
);
5115 found
= sscanf(buf
, "%d %d %x %d",
5116 &hdlp
->dev_tbl
[i
].controller
,
5117 &hdlp
->dev_tbl
[i
].bus
, &hdlp
->dev_tbl
[i
].addr
,
5118 &hdlp
->dev_tbl
[i
].port
);
5123 strcpy(hdlp
->dev_tbl
[i
].path
, strchr(buf
, forward_slash
));
5125 * Replace new line character with NUL character
5127 nl_char
= strchr(hdlp
->dev_tbl
[i
].path
, new_line
);
5131 /* Build the table of tables */
5132 if (i_psvc_load_tables(hdlp
, hdlp
->fp
) == -1)
5139 psvc_fini(EHdl_t
*hdlp
)
5142 ETable_Array
*array
;
5145 return (PSVC_SUCCESS
);
5147 for (j
= 0; j
< PSVC_MAX_TABLE_ARRAYS
; j
++) {
5148 if (hdlp
->tbl_arry
[j
].obj_tbl
!= 0) {
5149 array
= &(hdlp
->tbl_arry
[j
]);
5150 for (i
= 0; i
< array
->obj_count
; ++i
) {
5151 if (array
->obj_tbl
[i
].type
== PSVC_OBJ
) {
5152 if (!array
->obj_tbl
[i
].objp
) {
5153 /* Skip non-existent object */
5156 array
->obj_tbl
[i
].objp
->destructor(hdlp
,
5157 array
->obj_tbl
[i
].objp
->label
,
5158 array
->obj_tbl
[i
].objp
);
5161 if (array
->obj_tbl
[i
].type
== PSVC_TBL
) {
5163 (ETable_t
*)array
->obj_tbl
[i
].objp
;
5164 if (tblp
->table
!= 0)
5169 free(array
->obj_tbl
);
5173 if (hdlp
->othr_tbl
!= 0)
5174 free(hdlp
->othr_tbl
);
5176 if (hdlp
->assoc_tbl
!= 0) {
5177 for (i
= 0; i
< hdlp
->assoc_count
; ++i
) {
5178 if (hdlp
->assoc_tbl
[i
].table
!= 0)
5179 free(hdlp
->assoc_tbl
[i
].table
);
5181 free(hdlp
->assoc_tbl
);
5184 if (hdlp
->dev_tbl
!= 0)
5185 free(hdlp
->dev_tbl
);
5188 pthread_mutex_destroy(&hdlp
->mutex
);
5190 return (PSVC_SUCCESS
);
5194 ioctl_retry(int fp
, int request
, void * arg_pointer
)
5196 int32_t ret
= PSVC_SUCCESS
;
5200 * Becuase the i2c bus is a multimaster bus we need to protect
5201 * ourselves from bus masters that are not being good bus citizens.
5202 * A retry number of 10 should be sufficient to handle any bad bus
5203 * citizens. After that we will simply say that there is something
5204 * wrong with the ioctl transaction and let it bubble back up.
5207 ret
= ioctl(fp
, request
, arg_pointer
);
5209 } while ((ret
== -1) && (tries
< 10));
5215 psvc_get_str_key(char *object
)
5220 length
= strlen(object
);
5221 for (i
= 0; i
< length
; i
++) {
5222 if ((object
[i
] > 47) && (object
[i
] < 58)) {
5223 key
= key
+ ((object
[i
] - 50) + 2);
5225 key
= key
+ object
[i
];