pdr: Implement terminus locator PDR for BMC

This commit creates the TL PDR for the BMC. The TID and MCTP EID for
BMC is static, 1 and 8 respectively. BMC PDRs are assigned the value
of 1 for PLDMTerminusHandle. Added the parser for terminus locator
PDR in pldmtool.

Tested:

/tmp/pldmtool platform GetPdr -d 0

nextRecordHandle: 2
responseCount: 19
recordHandle: 1
PDRHeaderVersion: 1
PDRType: 1
recordChangeNumber: 0
dataLength: 9

PLDMTerminusHandle: 1
validity: valid
TID: 1
containerID: 0
terminusLocatorType: MCTP_EID
terminusLocatorValueSize: 1
EID: 8

Change-Id: I596301d6c676b450ae1f2cef872966b4c40d8bae
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
Signed-off-by: Sampa Misra <sampmisr@in.ibm.com>
diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp
index 211ff65..3a9266e 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -3,6 +3,7 @@
 
 #include "common/utils.hpp"
 #include "event_parser.hpp"
+#include "pdr.hpp"
 #include "pdr_numeric_effecter.hpp"
 #include "pdr_state_effecter.hpp"
 #include "platform_numeric_effecter.hpp"
@@ -137,6 +138,7 @@
 {
     if (!pdrCreated)
     {
+        generateTerminusLocatorPDR(pdrRepo);
         generate(*dBusIntf, pdrJsonsDir, pdrRepo);
         pdrCreated = true;
     }
@@ -556,6 +558,33 @@
     return ccOnlyResponse(request, rc);
 }
 
+void Handler::generateTerminusLocatorPDR(Repo& repo)
+{
+    std::vector<uint8_t> pdrBuffer(sizeof(pldm_terminus_locator_pdr));
+
+    auto pdr = reinterpret_cast<pldm_terminus_locator_pdr*>(pdrBuffer.data());
+
+    pdr->hdr.record_handle = 0;
+    pdr->hdr.version = 1;
+    pdr->hdr.type = PLDM_TERMINUS_LOCATOR_PDR;
+    pdr->hdr.record_change_num = 0;
+    pdr->hdr.length = sizeof(pldm_terminus_locator_pdr) - sizeof(pldm_pdr_hdr);
+    pdr->terminus_handle = BmcPldmTerminusHandle;
+    pdr->validity = PLDM_TL_PDR_VALID;
+    pdr->tid = BmcTerminusId;
+    pdr->container_id = 0x0;
+    pdr->terminus_locator_type = PLDM_TERMINUS_LOCATOR_TYPE_MCTP_EID;
+    pdr->terminus_locator_value_size =
+        sizeof(pldm_terminus_locator_type_mctp_eid);
+    auto locatorValue = reinterpret_cast<pldm_terminus_locator_type_mctp_eid*>(
+        pdr->terminus_locator_value);
+    locatorValue->eid = BmcMctpEid;
+
+    PdrEntry pdrEntry{};
+    pdrEntry.data = pdrBuffer.data();
+    pdrEntry.size = pdrBuffer.size();
+    repo.addRecord(pdrEntry);
+}
 } // namespace platform
 } // namespace responder
 } // namespace pldm