GCOV Execution Analysis for sahpi_event_utils.c
The left column is the number of times the code was executed
during the unit test suites.
Exec | Code | Line # | |
---|---|---|---|
Source:sahpi_event_utils.c | 1 | ||
Graph:.libs/sahpi_event_utils.gcno | 2 | ||
Data:.libs/sahpi_event_utils.gcda | 3 | ||
Runs:378 | 4 | ||
Programs:378 | 5 | ||
/* -*- linux-c -*- | 6 | ||
* | 7 | ||
* (C) Copyright IBM Corp. 2004 | 8 | ||
* | 9 | ||
* This program is distributed in the hope that it will be useful, | 10 | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This | 12 | ||
* file and program are licensed under a BSD style license. See | 13 | ||
* the Copying file included with the OpenHPI distribution for | 14 | ||
* full licensing terms. | 15 | ||
* | 16 | ||
* Author(s): | 17 | ||
* Steve Sherman < address removed > | 18 | ||
*/ | 19 | ||
20 | |||
#include <glib.h> | 21 | ||
#include <stdlib.h> | 22 | ||
#include <stdio.h> | 23 | ||
#include <string.h> | 24 | ||
25 | |||
#include <SaHpi.h> | 26 | ||
#include <oh_utils.h> | 27 | ||
28 | |||
/** | 29 | ||
* oh_decode_eventstate: | 30 | ||
* @event_state: Event state bit map to be converted to a string. | 31 | ||
* @event_cat: Event category of @event_state. | 32 | ||
* @buffer: Pointer to buffer to store generated string. | 33 | ||
* | 34 | ||
* Converts @event_state into a string based on @event_state's HPI definition. | 35 | ||
* For example, @event_state = SAHPI_ES_UPPER_MAJOR | SAHPI_ES_UPPER_MINOR | 36 | ||
* is returned as the string "UPPER_MINOR | UPPER_MAJOR". | 37 | ||
* String is stored in an SaHpiTextBufferT data structure. | 38 | ||
* | 39 | ||
* Function validates that the @event_state bit map is valid for @event_cat. And | 40 | ||
* that the states are complete and not mutually exclusive. | 41 | ||
* | 42 | ||
* SAHPI_ES_UNSPECIFIED definitions are stripped from @event_state, if there are | 43 | ||
* other valid non-global states defined. For example, @event_state = | 44 | ||
* SAHPI_ES_IDLE | SAHPI_ES_UNSPECIFIED, returns the string "IDLE". | 45 | ||
* | 46 | ||
* Returns: | 47 | ||
* SA_OK - normal operation. | 48 | ||
* SA_ERR_HPI_INVALID_PARAMS - @buffer is NULL; Invalid @event_state or @event_cat. | 49 | ||
* SA_ERR_HPI_OUT_OF_SPACE - @buffer too small. | 50 | ||
**/ | 51 | ||
SaErrorT oh_decode_eventstate(SaHpiEventStateT event_state, | 52 | ||
SaHpiEventCategoryT event_cat, | 53 | ||
SaHpiTextBufferT *buffer) | 54 | ||
0 | { | 55 | |
0 | int i, found; | 56 | |
0 | SaErrorT err; | 57 | |
0 | SaHpiTextBufferT working; | 58 | |
59 | |||
0 | if (!buffer || !oh_valid_eventstate(event_state, event_cat)) { | 60 | |
0 | return(SA_ERR_HPI_INVALID_PARAMS); | 61 | |
} | 62 | ||
63 | |||
0 | err = oh_init_textbuffer(&working); | 64 | |
0 | if (err != SA_OK) { return(err); } | 65 | |
66 | |||
0 | found = 0; | 67 | |
/* Look for category's event states */ | 68 | ||
0 | for (i=0; i<OH_MAX_STATE_STRINGS; i++) { | 69 | |
0 | if (state_strings[i].category == event_cat) { | 70 | |
0 | if ((state_strings[i].state & event_state) == state_strings[i].state) { | 71 | |
0 | found++; | 72 | |
0 | err = oh_append_textbuffer(&working, state_strings[i].str); | 73 | |
0 | if (err != SA_OK) { return(err); } | 74 | |
0 | err = oh_append_textbuffer(&working, OH_ENCODE_DELIMITER); | 75 | |
0 | if (err != SA_OK) { return(err); } | 76 | |
} | 77 | ||
} | 78 | ||
} | 79 | ||
80 | |||
/* Look for global event states */ | 81 | ||
0 | for (i=0; i<OH_MAX_STATE_GLOBAL_STRINGS; i++) { | 82 | |
0 | if ((state_global_strings[i].state & event_state) == state_global_strings[i].state) { | 83 | |
/* Strip any UNSPECIFIED definitions, if another definition found */ | 84 | ||
0 | if (!(found && state_global_strings[i].state == SAHPI_ES_UNSPECIFIED)) { | 85 | |
0 | found++; | 86 | |
0 | err = oh_append_textbuffer(&working, state_global_strings[i].str); | 87 | |
0 | if (err != SA_OK) { return(err); } | 88 | |
0 | err = oh_append_textbuffer(&working, OH_ENCODE_DELIMITER); | 89 | |
0 | if (err != SA_OK) { return(err); } | 90 | |
} | 91 | ||
} | 92 | ||
} | 93 | ||
94 | |||
/* Remove last delimiter */ | 95 | ||
0 | if (found) { | 96 | |
0 | for (i=0; i<OH_ENCODE_DELIMITER_LENGTH + 1; i++) { | 97 | |
0 | working.Data[working.DataLength - i] = 0x00; | 98 | |
} | 99 | ||
0 | working.DataLength = working.DataLength - (i+1); | 100 | |
} | 101 | ||
102 | |||
0 | err = oh_copy_textbuffer(buffer, &working); | 103 | |
104 | |||
0 | return(SA_OK); | 105 | |
} | 106 | ||
107 | |||
/** | 108 | ||
* oh_encode_eventstate: | 109 | ||
* @buffer: Pointer to buffer containing string representation of event | 110 | ||
* state bit map. Generally received from oh_decode_eventstate(). | 111 | ||
* @event_state: Pointer to store generated event state bit map. | 112 | ||
* @event_cat: Pointer to store generated event category. | 113 | ||
* | 114 | ||
* Converts string representation of an event state bit map (usually generated | 115 | ||
* by oh_decode_eventstate() back into an HPI event state and category | 116 | ||
* structure. For example, the string "UPPER_MINOR | UPPER_MAJOR" generates | 117 | ||
* event state = SAHPI_ES_UPPER_MAJOR | SAHPI_ES_UPPER_MINOR and | 118 | ||
* event category = SAHPI_ES_THRESHOLD. | 119 | ||
120 | |||
* Function validates that the @event_state bit map is valid for @event_cat. And | 121 | ||
* that the states are complete and not mutually exclusive. | 122 | ||
* | 123 | ||
* NOTE! | 124 | ||
* @event_cat cannot always be deterministically calculated. | 125 | ||
* | 126 | ||
* - if @event_state is SAHPI_ES_UNSPECIFIED, @event_cat will be SAHPI_EC_UNSPECIFIED | 127 | ||
* (though any category is valid). | 128 | ||
* - For event categories with the same events defined (e.g. SAHPI_EC_GENERIC and | 129 | ||
* SAHPI_EC_SENSOR_SPECIFIC), the category returned may be either one. | 130 | ||
* | 131 | ||
* Returns: | 132 | ||
* SA_OK - normal operation. | 133 | ||
* SA_ERR_HPI_INVALID_PARAMS - @buffer, @event_state, or @event_cat NULL. | 134 | ||
* No Data in @buffer, invalid format, or | 135 | ||
* @event_state bit map not valid for @event_cat. | 136 | ||
* SA_ERR_HPI_OUT_OF_SPACE - @buffer too small. | 137 | ||
**/ | 138 | ||
SaErrorT oh_encode_eventstate(SaHpiTextBufferT *buffer, | 139 | ||
SaHpiEventStateT *event_state, | 140 | ||
SaHpiEventCategoryT *event_cat) | 141 | ||
0 | { | 142 | |
0 | gchar *gstr = NULL; | 143 | |
0 | gchar **eventdefs = NULL; | 144 | |
0 | int i, j, found_event, found_global_event; | 145 | |
0 | SaErrorT rtncode = SA_OK; | 146 | |
0 | SaHpiEventStateT working_state=0; | 147 | |
0 | SaHpiEventCategoryT working_cat=0; | 148 | |
149 | |||
0 | if (!buffer || !event_state || !event_cat) { | 150 | |
0 | return(SA_ERR_HPI_INVALID_PARAMS); | 151 | |
} | 152 | ||
0 | if (buffer->Data == NULL || buffer->Data[0] == '\0') { | 153 | |
0 | return(SA_ERR_HPI_INVALID_PARAMS); | 154 | |
} | 155 | ||
156 | |||
/* Split out event definitions */ | 157 | ||
0 | gstr = g_strstrip(g_strdup(buffer->Data)); | 158 | |
0 | if (gstr == NULL || gstr[0] == '\0') { | 159 | |
0 | dbg("g_strstrip failed"); | 160 | |
0 | rtncode = SA_ERR_HPI_INTERNAL_ERROR; | 161 | |
0 | goto CLEANUP; | 162 | |
} | 163 | ||
164 | |||
0 | eventdefs = g_strsplit(gstr, OH_ENCODE_DELIMITER_CHAR, -1); | 165 | |
0 | if (eventdefs == NULL) { | 166 | |
0 | rtncode = SA_ERR_HPI_INVALID_PARAMS; | 167 | |
0 | goto CLEANUP; | 168 | |
} | 169 | ||
170 | |||
0 | for (i=0; eventdefs[i] != NULL && eventdefs[i][0] != '\0'; i++) { | 171 | |
0 | eventdefs[i] = g_strstrip(eventdefs[i]); | 172 | |
173 | |||
0 | found_event = found_global_event = 0; | 174 | |
/* Look for category event states */ | 175 | ||
0 | for (j=0; j<OH_MAX_STATE_STRINGS; j++) { | 176 | |
0 | if (strcasecmp(eventdefs[i], state_strings[j].str) == 0) { | 177 | |
0 | found_event++; | 178 | |
/* Don't add twice for categories with duplicate events */ | 179 | ||
0 | if (!(working_state & state_strings[j].state)) { | 180 | |
0 | working_state = working_state + state_strings[j].state; | 181 | |
} | 182 | ||
0 | working_cat = state_strings[j].category; | 183 | |
} | 184 | ||
} | 185 | ||
/* Look for global event states */ | 186 | ||
0 | for (j=0; j<OH_MAX_STATE_GLOBAL_STRINGS; j++) { | 187 | |
0 | if (strcasecmp(eventdefs[i], state_global_strings[j].str) == 0) { | 188 | |
0 | found_global_event++; | 189 | |
/* Don't add twice for categories with duplicate events */ | 190 | ||
0 | if (!(working_state & state_global_strings[j].state)) { | 191 | |
0 | working_state = working_state + state_global_strings[j].state; | 192 | |
} | 193 | ||
0 | working_cat = state_global_strings[j].category; | 194 | |
} | 195 | ||
} | 196 | ||
197 | |||
0 | if (!found_event && !found_global_event) { | 198 | |
0 | rtncode = SA_ERR_HPI_INVALID_PARAMS; | 199 | |
0 | goto CLEANUP; | 200 | |
} | 201 | ||
} | 202 | ||
203 | |||
0 | if (oh_valid_eventstate(working_state, working_cat)) { | 204 | |
0 | *event_state = working_state; | 205 | |
0 | *event_cat = working_cat; | 206 | |
} | 207 | ||
else { | 208 | ||
0 | rtncode = SA_ERR_HPI_INVALID_PARAMS; | 209 | |
} | 210 | ||
211 | |||
CLEANUP: | 212 | ||
0 | g_free(gstr); | 213 | |
0 | g_strfreev(eventdefs); | 214 | |
215 | |||
0 | return(rtncode); | 216 | |
} | 217 | ||
218 | |||
/** | 219 | ||
* oh_valid_eventstate: | 220 | ||
* @event_state: Event state bit field. | 221 | ||
* @event_cat: Event's category. | 222 | ||
* | 223 | ||
* Validates that all the events in the event_state bit field are valid | 224 | ||
* for the event category. Routine also checks for mutually exclusive | 225 | ||
* events and that thresholds events have all the appropriate | 226 | ||
* lower-level threshold event states set. | 227 | ||
* | 228 | ||
* Returns: | 229 | ||
* SAHPI_TRUE - Event(s) valid for category and met HPI spec criteria | 230 | ||
* for exclusiveness and completeness. | 231 | ||
* SAHPI_FALSE - Any event(s) in bit field not valid for category or | 232 | ||
* category is invalid. | 233 | ||
**/ | 234 | ||
SaHpiBoolT oh_valid_eventstate(SaHpiEventStateT event_state, | 235 | ||
SaHpiEventCategoryT event_cat) | 236 | ||
0 | { | 237 | |
0 | SaHpiEventStateT valid_states; | 238 | |
239 | |||
0 | switch(event_cat) { | 240 | |
case SAHPI_EC_UNSPECIFIED: | 241 | ||
/* Only SAHPI_ES_UNSPECIFIED valid for this category */ | 242 | ||
0 | if (event_state) { | 243 | |
0 | return(SAHPI_FALSE); | 244 | |
} | 245 | ||
0 | return(SAHPI_TRUE); | 246 | |
247 | |||
case SAHPI_EC_THRESHOLD: | 248 | ||
0 | valid_states = SAHPI_ES_LOWER_MINOR | | 249 | |
SAHPI_ES_LOWER_MAJOR | | 250 | ||
SAHPI_ES_LOWER_CRIT | | 251 | ||
SAHPI_ES_UPPER_MINOR | | 252 | ||
SAHPI_ES_UPPER_MAJOR | | 253 | ||
SAHPI_ES_UPPER_CRIT; | 254 | ||
255 | |||
0 | if (event_state & (~valid_states)) { | 256 | |
0 | return(SAHPI_FALSE); | 257 | |
} | 258 | ||
259 | |||
/* Check that all lower-level thresholds are set */ | 260 | ||
0 | if (event_state & SAHPI_ES_LOWER_CRIT) { | 261 | |
0 | if (!(event_state & SAHPI_ES_LOWER_MAJOR)) { | 262 | |
0 | return(SAHPI_FALSE); | 263 | |
} | 264 | ||
} | 265 | ||
0 | if (event_state & SAHPI_ES_LOWER_MAJOR) { | 266 | |
0 | if (!(event_state & SAHPI_ES_LOWER_MINOR)) { | 267 | |
0 | return(SAHPI_FALSE); | 268 | |
} | 269 | ||
} | 270 | ||
0 | if (event_state & SAHPI_ES_UPPER_CRIT) { | 271 | |
0 | if (!(event_state & SAHPI_ES_UPPER_MAJOR)) { | 272 | |
0 | return(SAHPI_FALSE); | 273 | |
} | 274 | ||
} | 275 | ||
0 | if (event_state & SAHPI_ES_UPPER_MAJOR) { | 276 | |
0 | if (!(event_state & SAHPI_ES_UPPER_MINOR)) { | 277 | |
0 | return(SAHPI_FALSE); | 278 | |
} | 279 | ||
} | 280 | ||
281 | |||
0 | return(SAHPI_TRUE); | 282 | |
283 | |||
case SAHPI_EC_USAGE: | 284 | ||
0 | valid_states = SAHPI_ES_IDLE | | 285 | |
SAHPI_ES_ACTIVE | | 286 | ||
SAHPI_ES_BUSY; | 287 | ||
288 | |||
/* FIXME:: Are these mutally exclusive states?? */ | 289 | ||
0 | if (event_state & (~valid_states)) { | 290 | |
0 | return(SAHPI_FALSE); | 291 | |
} | 292 | ||
293 | |||
0 | return(SAHPI_TRUE); | 294 | |
295 | |||
case SAHPI_EC_STATE: | 296 | ||
0 | valid_states = SAHPI_ES_STATE_DEASSERTED | | 297 | |
SAHPI_ES_STATE_ASSERTED; | 298 | ||
299 | |||
0 | if (event_state & (~valid_states)) { | 300 | |
0 | return(SAHPI_FALSE); | 301 | |
} | 302 | ||
303 | |||
/* Enforce mutual exclusion */ | 304 | ||
0 | if ((event_state & SAHPI_ES_STATE_DEASSERTED) && | 305 | |
(event_state & SAHPI_ES_STATE_ASSERTED)) { | 306 | ||
0 | return(SAHPI_FALSE); | 307 | |
} | 308 | ||
309 | |||
0 | return(SAHPI_TRUE); | 310 | |
311 | |||
case SAHPI_EC_PRED_FAIL: | 312 | ||
0 | valid_states = SAHPI_ES_PRED_FAILURE_DEASSERT | | 313 | |
SAHPI_ES_PRED_FAILURE_ASSERT; | 314 | ||
315 | |||
0 | if (event_state & (~valid_states)) { | 316 | |
0 | return(SAHPI_FALSE); | 317 | |
} | 318 | ||
319 | |||
/* Enforce mutual exclusion */ | 320 | ||
0 | if ((event_state & SAHPI_ES_PRED_FAILURE_DEASSERT) && | 321 | |
(event_state & SAHPI_ES_PRED_FAILURE_ASSERT)) { | 322 | ||
0 | return(SAHPI_FALSE); | 323 | |
} | 324 | ||
325 | |||
0 | return(SAHPI_TRUE); | 326 | |
327 | |||
case SAHPI_EC_LIMIT: | 328 | ||
0 | valid_states = SAHPI_ES_LIMIT_NOT_EXCEEDED | | 329 | |
SAHPI_ES_LIMIT_EXCEEDED; | 330 | ||
331 | |||
0 | if (event_state & (~valid_states)) { | 332 | |
0 | return(SAHPI_FALSE); | 333 | |
} | 334 | ||
335 | |||
/* Enforce mutual exclusion */ | 336 | ||
0 | if ((event_state & SAHPI_ES_LIMIT_NOT_EXCEEDED) && | 337 | |
(event_state & SAHPI_ES_LIMIT_EXCEEDED)) { | 338 | ||
0 | return(SAHPI_FALSE); | 339 | |
} | 340 | ||
341 | |||
0 | return(SAHPI_TRUE); | 342 | |
343 | |||
case SAHPI_EC_PERFORMANCE: | 344 | ||
0 | valid_states = SAHPI_ES_PERFORMANCE_MET | | 345 | |
SAHPI_ES_PERFORMANCE_LAGS; | 346 | ||
347 | |||
0 | if (event_state & (~valid_states)) { | 348 | |
0 | return(SAHPI_FALSE); | 349 | |
} | 350 | ||
351 | |||
/* Enforce mutual exclusion */ | 352 | ||
0 | if ((event_state & SAHPI_ES_PERFORMANCE_MET) && | 353 | |
(event_state & SAHPI_ES_PERFORMANCE_LAGS)) { | 354 | ||
0 | return(SAHPI_FALSE); | 355 | |
} | 356 | ||
357 | |||
0 | return(SAHPI_TRUE); | 358 | |
359 | |||
case SAHPI_EC_SEVERITY: | 360 | ||
/* FIXME :: Any of these exclusive??? */ | 361 | ||
0 | valid_states = SAHPI_ES_OK | | 362 | |
SAHPI_ES_MINOR_FROM_OK | | 363 | ||
SAHPI_ES_MAJOR_FROM_LESS | | 364 | ||
SAHPI_ES_CRITICAL_FROM_LESS | | 365 | ||
SAHPI_ES_MINOR_FROM_MORE | | 366 | ||
SAHPI_ES_MAJOR_FROM_CRITICAL | | 367 | ||
SAHPI_ES_CRITICAL | | 368 | ||
SAHPI_ES_MONITOR | | 369 | ||
SAHPI_ES_INFORMATIONAL; | 370 | ||
371 | |||
0 | if (event_state & (~valid_states)) { | 372 | |
0 | return(SAHPI_FALSE); | 373 | |
} | 374 | ||
375 | |||
0 | return(SAHPI_TRUE); | 376 | |
377 | |||
case SAHPI_EC_PRESENCE: | 378 | ||
0 | valid_states = SAHPI_ES_ABSENT | | 379 | |
SAHPI_ES_PRESENT; | 380 | ||
381 | |||
0 | if (event_state & (~valid_states)) { | 382 | |
0 | return(SAHPI_FALSE); | 383 | |
} | 384 | ||
385 | |||
/* Enforce mutual exclusion */ | 386 | ||
0 | if ((event_state & SAHPI_ES_ABSENT) && | 387 | |
(event_state & SAHPI_ES_PRESENT)) { | 388 | ||
0 | return(SAHPI_FALSE); | 389 | |
} | 390 | ||
391 | |||
0 | return(SAHPI_TRUE); | 392 | |
393 | |||
case SAHPI_EC_ENABLE: | 394 | ||
0 | valid_states = SAHPI_ES_DISABLED | | 395 | |
SAHPI_ES_ENABLED; | 396 | ||
397 | |||
0 | if (event_state & (~valid_states)) { | 398 | |
0 | return(SAHPI_FALSE); | 399 | |
} | 400 | ||
401 | |||
/* Enforce mutual exclusion */ | 402 | ||
0 | if ((event_state & SAHPI_ES_DISABLED) && | 403 | |
(event_state & SAHPI_ES_ENABLED)) { | 404 | ||
0 | return(SAHPI_FALSE); | 405 | |
} | 406 | ||
407 | |||
0 | return(SAHPI_TRUE); | 408 | |
409 | |||
case SAHPI_EC_AVAILABILITY: | 410 | ||
/* FIXME:: Any of these exclusive? */ | 411 | ||
0 | valid_states = SAHPI_ES_RUNNING | | 412 | |
SAHPI_ES_TEST | | 413 | ||
SAHPI_ES_POWER_OFF | | 414 | ||
SAHPI_ES_ON_LINE | | 415 | ||
SAHPI_ES_OFF_LINE | | 416 | ||
SAHPI_ES_OFF_DUTY | | 417 | ||
SAHPI_ES_DEGRADED | | 418 | ||
SAHPI_ES_POWER_SAVE | | 419 | ||
SAHPI_ES_INSTALL_ERROR; | 420 | ||
421 | |||
0 | if (event_state & (~valid_states)) { | 422 | |
0 | return(SAHPI_FALSE); | 423 | |
} | 424 | ||
425 | |||
0 | return(SAHPI_TRUE); | 426 | |
427 | |||
case SAHPI_EC_REDUNDANCY: | 428 | ||
0 | valid_states = SAHPI_ES_FULLY_REDUNDANT | | 429 | |
SAHPI_ES_REDUNDANCY_LOST | | 430 | ||
SAHPI_ES_REDUNDANCY_DEGRADED | | 431 | ||
SAHPI_ES_REDUNDANCY_LOST_SUFFICIENT_RESOURCES | | 432 | ||
SAHPI_ES_NON_REDUNDANT_SUFFICIENT_RESOURCES | | 433 | ||
SAHPI_ES_NON_REDUNDANT_INSUFFICIENT_RESOURCES | | 434 | ||
SAHPI_ES_REDUNDANCY_DEGRADED_FROM_FULL | | 435 | ||
SAHPI_ES_REDUNDANCY_DEGRADED_FROM_NON; | 436 | ||
437 | |||
0 | if (event_state & (~valid_states)) { | 438 | |
0 | return(SAHPI_FALSE); | 439 | |
} | 440 | ||
441 | |||
/* Check for mutual exclusiveness */ | 442 | ||
/* Assume SAHPI_ES_REDUNDANCY_LOST or SAHPI_ES_REDUNDANCY_DEGRADED | 443 | ||
must be set in addition to the bits that establish direction */ | 444 | ||
0 | if (event_state & SAHPI_ES_FULLY_REDUNDANT) { | 445 | |
0 | if (event_state != SAHPI_ES_FULLY_REDUNDANT) { | 446 | |
0 | return(SAHPI_FALSE); | 447 | |
} | 448 | ||
} | 449 | ||
0 | if (event_state & SAHPI_ES_REDUNDANCY_LOST) { | 450 | |
0 | valid_states = SAHPI_ES_REDUNDANCY_LOST | | 451 | |
SAHPI_ES_REDUNDANCY_LOST_SUFFICIENT_RESOURCES | | 452 | ||
SAHPI_ES_NON_REDUNDANT_SUFFICIENT_RESOURCES | | 453 | ||
SAHPI_ES_NON_REDUNDANT_INSUFFICIENT_RESOURCES; | 454 | ||
0 | if (event_state & (~valid_states)) { | 455 | |
0 | return(SAHPI_FALSE); | 456 | |
} | 457 | ||
} | 458 | ||
0 | if (event_state & SAHPI_ES_REDUNDANCY_DEGRADED) { | 459 | |
0 | valid_states = SAHPI_ES_REDUNDANCY_DEGRADED | | 460 | |
SAHPI_ES_REDUNDANCY_DEGRADED_FROM_FULL | | 461 | ||
SAHPI_ES_REDUNDANCY_DEGRADED_FROM_NON; | 462 | ||
0 | if (event_state & (~valid_states)) { | 463 | |
0 | return(SAHPI_FALSE); | 464 | |
} | 465 | ||
} | 466 | ||
0 | if (event_state & SAHPI_ES_REDUNDANCY_DEGRADED_FROM_FULL) { | 467 | |
0 | if (event_state & SAHPI_ES_REDUNDANCY_DEGRADED_FROM_NON) { | 468 | |
0 | return(SAHPI_FALSE); | 469 | |
} | 470 | ||
} | 471 | ||
0 | if (event_state & SAHPI_ES_REDUNDANCY_LOST_SUFFICIENT_RESOURCES) { | 472 | |
0 | if (event_state & SAHPI_ES_NON_REDUNDANT_SUFFICIENT_RESOURCES) { | 473 | |
0 | return(SAHPI_FALSE); | 474 | |
} | 475 | ||
} | 476 | ||
477 | |||
0 | return(SAHPI_TRUE); | 478 | |
479 | |||
case SAHPI_EC_SENSOR_SPECIFIC: | 480 | ||
case SAHPI_EC_GENERIC: | 481 | ||
0 | valid_states = SAHPI_ES_STATE_00 | | 482 | |
SAHPI_ES_STATE_01 | | 483 | ||
SAHPI_ES_STATE_02 | | 484 | ||
SAHPI_ES_STATE_03 | | 485 | ||
SAHPI_ES_STATE_04 | | 486 | ||
SAHPI_ES_STATE_05 | | 487 | ||
SAHPI_ES_STATE_06 | | 488 | ||
SAHPI_ES_STATE_07 | | 489 | ||
SAHPI_ES_STATE_08 | | 490 | ||
SAHPI_ES_STATE_09 | | 491 | ||
SAHPI_ES_STATE_10 | | 492 | ||
SAHPI_ES_STATE_11 | | 493 | ||
SAHPI_ES_STATE_12 | | 494 | ||
SAHPI_ES_STATE_13 | | 495 | ||
SAHPI_ES_STATE_14; | 496 | ||
497 | |||
0 | if (event_state & (~valid_states)) { | 498 | |
0 | return(SAHPI_FALSE); | 499 | |
} | 500 | ||
501 | |||
0 | return(SAHPI_TRUE); | 502 | |
503 | |||
default: | 504 | ||
0 | return(SAHPI_FALSE); | 505 | |
} | 506 | ||
} | 507 | ||
508 | |||
/** | 509 | ||
* oh_valid_addevent: | 510 | ||
* @event: Pointer to add event. | 511 | ||
* | 512 | ||
* Validates @event is a valid event for SaHpiEventAdd. This routines makes | 513 | ||
* all the checks specified in the HPI spec to see if @event is valid. | 514 | ||
* | 515 | ||
* Returns: | 516 | ||
* SA_OK - Normal operation. | 517 | ||
* SA_ERR_HPI_INVALID_PARAMS - See HPI spec. | 518 | ||
**/ | 519 | ||
SaErrorT oh_valid_addevent(SaHpiEventT *event) | 520 | ||
9 | { | 521 | |
9 | if (!event) return(SA_ERR_HPI_INVALID_PARAMS); | 522 | |
523 | |||
8 | if (event->Source != SAHPI_UNSPECIFIED_RESOURCE_ID || | 524 | |
event->EventType != SAHPI_ET_USER || | 525 | ||
NULL == oh_lookup_severity(event->Severity) || | 526 | ||
!oh_valid_textbuffer(&(event->EventDataUnion.UserEvent.UserEventData))) { | 527 | ||
6 | return(SA_ERR_HPI_INVALID_PARAMS); | 528 | |
} | 529 | ||
530 | |||
/* No check for implementation-specific restriction on to how much data may | 531 | ||
be provided in the SAHPI_ET_USER event */ | 532 | ||
533 | |||
2 | return(SA_OK); | 534 | |
} | 535 |