Sampa Misra | aea5dde | 2020-08-31 08:33:47 -0500 | [diff] [blame] | 1 | #include "oem_ibm_handler.hpp" |
| 2 | |
| 3 | #include "libpldm/entity.h" |
| 4 | |
| 5 | namespace pldm |
| 6 | { |
| 7 | |
| 8 | namespace responder |
| 9 | { |
| 10 | |
| 11 | namespace oem_ibm_platform |
| 12 | { |
| 13 | |
| 14 | int pldm::responder::oem_ibm_platform::Handler:: |
| 15 | getOemStateSensorReadingsHandler( |
| 16 | EntityType entityType, EntityInstance entityInstance, |
| 17 | StateSetId stateSetId, CompositeCount compSensorCnt, |
| 18 | std::vector<get_sensor_state_field>& stateField) |
| 19 | { |
| 20 | int rc = PLDM_SUCCESS; |
| 21 | stateField.clear(); |
| 22 | |
| 23 | for (size_t i = 0; i < compSensorCnt; i++) |
| 24 | { |
| 25 | uint8_t sensorOpState{}; |
| 26 | if (entityType == PLDM_ENTITY_VIRTUAL_MACHINE_MANAGER && |
| 27 | stateSetId == PLDM_OEM_IBM_BOOT_STATE) |
| 28 | { |
| 29 | sensorOpState = fetchBootSide(entityInstance, codeUpdate); |
| 30 | } |
| 31 | else |
| 32 | { |
| 33 | rc = PLDM_PLATFORM_INVALID_STATE_VALUE; |
| 34 | break; |
| 35 | } |
| 36 | stateField.push_back({PLDM_SENSOR_ENABLED, PLDM_SENSOR_UNKNOWN, |
| 37 | PLDM_SENSOR_UNKNOWN, sensorOpState}); |
| 38 | } |
| 39 | return rc; |
| 40 | } |
| 41 | |
| 42 | int pldm::responder::oem_ibm_platform::Handler:: |
| 43 | oemSetStateEffecterStatesHandler( |
| 44 | EntityType entityType, EntityInstance entityInstance, |
| 45 | StateSetId stateSetId, CompositeCount compEffecterCnt, |
| 46 | const std::vector<set_effecter_state_field>& stateField) |
| 47 | { |
| 48 | int rc = PLDM_SUCCESS; |
| 49 | |
| 50 | for (uint8_t currState = 0; currState < compEffecterCnt; ++currState) |
| 51 | { |
| 52 | if (stateField[currState].set_request == PLDM_REQUEST_SET) |
| 53 | { |
| 54 | if (entityType == PLDM_ENTITY_VIRTUAL_MACHINE_MANAGER && |
| 55 | stateSetId == PLDM_OEM_IBM_BOOT_STATE) |
| 56 | { |
| 57 | rc = setBootSide(entityInstance, currState, stateField, |
| 58 | codeUpdate); |
| 59 | } |
| 60 | else |
| 61 | { |
| 62 | rc = PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE; |
| 63 | } |
| 64 | } |
| 65 | if (rc != PLDM_SUCCESS) |
| 66 | { |
| 67 | break; |
| 68 | } |
| 69 | } |
| 70 | return rc; |
| 71 | } |
| 72 | |
| 73 | void pldm::responder::oem_ibm_platform::Handler::setPlatformHandler( |
| 74 | pldm::responder::platform::Handler* handler) |
| 75 | { |
| 76 | platformHandler = handler; |
| 77 | } |
| 78 | |
| 79 | } // namespace oem_ibm_platform |
| 80 | |
| 81 | } // namespace responder |
| 82 | |
| 83 | } // namespace pldm |