oem ibm: infrastructure for oem handlers

1. This commit adds the framework for an oem handler
which can be used by specific oem use-cases
for implementing various commands.

2. This commit adds implementation for getStateSensorReadings
and setStateEffecterStates commands for oem state sets.

3. Also adds implementation for inband code update.

Change-Id: Ib38a66ee381dd06b93f6a9313d51de1c23e6ee65
Signed-off-by: Sampa Misra <sampmisr@in.ibm.com>
diff --git a/oem/ibm/libpldmresponder/oem_ibm_handler.cpp b/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
new file mode 100644
index 0000000..2e6bd4c
--- /dev/null
+++ b/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
@@ -0,0 +1,83 @@
+#include "oem_ibm_handler.hpp"
+
+#include "libpldm/entity.h"
+
+namespace pldm
+{
+
+namespace responder
+{
+
+namespace oem_ibm_platform
+{
+
+int pldm::responder::oem_ibm_platform::Handler::
+    getOemStateSensorReadingsHandler(
+        EntityType entityType, EntityInstance entityInstance,
+        StateSetId stateSetId, CompositeCount compSensorCnt,
+        std::vector<get_sensor_state_field>& stateField)
+{
+    int rc = PLDM_SUCCESS;
+    stateField.clear();
+
+    for (size_t i = 0; i < compSensorCnt; i++)
+    {
+        uint8_t sensorOpState{};
+        if (entityType == PLDM_ENTITY_VIRTUAL_MACHINE_MANAGER &&
+            stateSetId == PLDM_OEM_IBM_BOOT_STATE)
+        {
+            sensorOpState = fetchBootSide(entityInstance, codeUpdate);
+        }
+        else
+        {
+            rc = PLDM_PLATFORM_INVALID_STATE_VALUE;
+            break;
+        }
+        stateField.push_back({PLDM_SENSOR_ENABLED, PLDM_SENSOR_UNKNOWN,
+                              PLDM_SENSOR_UNKNOWN, sensorOpState});
+    }
+    return rc;
+}
+
+int pldm::responder::oem_ibm_platform::Handler::
+    oemSetStateEffecterStatesHandler(
+        EntityType entityType, EntityInstance entityInstance,
+        StateSetId stateSetId, CompositeCount compEffecterCnt,
+        const std::vector<set_effecter_state_field>& stateField)
+{
+    int rc = PLDM_SUCCESS;
+
+    for (uint8_t currState = 0; currState < compEffecterCnt; ++currState)
+    {
+        if (stateField[currState].set_request == PLDM_REQUEST_SET)
+        {
+            if (entityType == PLDM_ENTITY_VIRTUAL_MACHINE_MANAGER &&
+                stateSetId == PLDM_OEM_IBM_BOOT_STATE)
+            {
+                rc = setBootSide(entityInstance, currState, stateField,
+                                 codeUpdate);
+            }
+            else
+            {
+                rc = PLDM_PLATFORM_SET_EFFECTER_UNSUPPORTED_SENSORSTATE;
+            }
+        }
+        if (rc != PLDM_SUCCESS)
+        {
+            break;
+        }
+    }
+    return rc;
+}
+
+void pldm::responder::oem_ibm_platform::Handler::setPlatformHandler(
+    pldm::responder::platform::Handler* handler)
+{
+    platformHandler = handler;
+}
+
+} // namespace oem_ibm_platform
+
+} // namespace responder
+
+} // namespace pldm