PLDM Message Structure Change

With this change, PLDM code is optimised. The PLDM payload message
structure previously consisted of a pointer to the payload message and
the payload length, this structure is removed with this commit and the
PLDM message structure now has the PLDM header structure and an array of
size 1 whose address is the starting byte of message payload. Therefore,
pldm msg struct can represent a request/response message in contiguous
memory, thereby enabling simple casts and avoiding memcpys to get from a
uint8_t* to pldm msg or vice versa.

This commit also introduces a change to have the response handlers allocate
memory for responses. This is aligned with the message struct change, and
enables varying length responses.

Change-Id: Ia46d852b8b16bfc7cf04f38435bd4079ad33c66b
Signed-off-by: vkaverap <vkaverap@in.ibm.com>
diff --git a/libpldmresponder/bios.cpp b/libpldmresponder/bios.cpp
index 5c4a270..11c8251 100644
--- a/libpldmresponder/bios.cpp
+++ b/libpldmresponder/bios.cpp
@@ -47,7 +47,7 @@
 
 } // namespace utils
 
-void getDateTime(const pldm_msg_payload* request, pldm_msg* response)
+Response getDateTime(const pldm_msg* request)
 {
     uint8_t seconds = 0;
     uint8_t minutes = 0;
@@ -58,6 +58,8 @@
 
     constexpr auto timeInterface = "xyz.openbmc_project.Time.EpochTime";
     constexpr auto bmcTimePath = "/xyz/openbmc_project/time/bmc";
+    Response response(sizeof(pldm_msg_hdr) + PLDM_GET_DATE_TIME_RESP_BYTES, 0);
+    auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
     std::variant<EpochTimeUS> value;
 
     auto bus = sdbusplus::bus::new_default();
@@ -79,8 +81,8 @@
                         entry("TIME INTERACE=%s", timeInterface));
 
         encode_get_date_time_resp(0, PLDM_ERROR, seconds, minutes, hours, day,
-                                  month, year, response);
-        return;
+                                  month, year, responsePtr);
+        return response;
     }
 
     uint64_t timeUsec = std::get<EpochTimeUS>(value);
@@ -92,7 +94,8 @@
     utils::epochToBCDTime(timeSec, seconds, minutes, hours, day, month, year);
 
     encode_get_date_time_resp(0, PLDM_SUCCESS, seconds, minutes, hours, day,
-                              month, year, response);
+                              month, year, responsePtr);
+    return response;
 }
 
 } // namespace responder