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