platform-mc: Added Terminus/TerminusManager class

Added requester::sendRecvPldmMsg awaiter type to be able to send and
receive PLDM message by coroutine.
Added TerminusManager to discover terminus from EID list updated by
MCTPDiscovery class. The TerminusManager will initialize TID.

Signed-off-by: Gilbert Chen <gilbert.chen@arm.com>
Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Change-Id: Ifa5bdfff50648f1d7fba8710e160de662e8f9e06
diff --git a/platform-mc/terminus.cpp b/platform-mc/terminus.cpp
new file mode 100644
index 0000000..947571b
--- /dev/null
+++ b/platform-mc/terminus.cpp
@@ -0,0 +1,53 @@
+#include "terminus.hpp"
+
+#include "libpldm/platform.h"
+
+#include "terminus_manager.hpp"
+
+namespace pldm
+{
+namespace platform_mc
+{
+
+Terminus::Terminus(pldm_tid_t tid, uint64_t supportedTypes) :
+    initialized(false), tid(tid), supportedTypes(supportedTypes)
+{}
+
+bool Terminus::doesSupportType(uint8_t type)
+{
+    return supportedTypes.test(type);
+}
+
+bool Terminus::doesSupportCommand(uint8_t type, uint8_t command)
+{
+    if (!doesSupportType(type))
+    {
+        return false;
+    }
+
+    try
+    {
+        const size_t idx = type * (PLDM_MAX_CMDS_PER_TYPE / 8) + (command / 8);
+        if (idx >= supportedCmds.size())
+        {
+            return false;
+        }
+
+        if (supportedCmds[idx] & (1 << (command % 8)))
+        {
+            lg2::info(
+                "PLDM type {TYPE} command {CMD} is supported by terminus {TID}",
+                "TYPE", type, "CMD", command, "TID", getTid());
+            return true;
+        }
+    }
+    catch (const std::exception& e)
+    {
+        return false;
+    }
+
+    return false;
+}
+
+} // namespace platform_mc
+} // namespace pldm