host-bmc: Implement VRM interface

Adds support to host Voltage Regulator Module interface.  Based on the
PDRs received from remote PLDM terminus, PLDM hosts the dbus interface
based on the entity type.  The VRM interface is defined at [1].

Tested:
   Functional test passed

[1]: https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Inventory/Item/Vrm.interface.yaml

Change-Id: I5124de5f34d3a482d17f1859ecfe8704901c5fad
Signed-off-by: Archana Kakani <archana.kakani@ibm.com>
diff --git a/host-bmc/dbus/custom_dbus.cpp b/host-bmc/dbus/custom_dbus.cpp
index 14d1541..42acc59 100644
--- a/host-bmc/dbus/custom_dbus.cpp
+++ b/host-bmc/dbus/custom_dbus.cpp
@@ -233,5 +233,15 @@
     }
 }
 
+void CustomDBus::implementVRMInterface(const std::string& path)
+{
+    if (!vrm.contains(path))
+    {
+        vrm.emplace(path,
+                    std::make_unique<VRM>(pldm::utils::DBusHandler::getBus(),
+                                          path.c_str()));
+    }
+}
+
 } // namespace dbus
 } // namespace pldm
diff --git a/host-bmc/dbus/custom_dbus.hpp b/host-bmc/dbus/custom_dbus.hpp
index d543e1f..d8d9375 100644
--- a/host-bmc/dbus/custom_dbus.hpp
+++ b/host-bmc/dbus/custom_dbus.hpp
@@ -15,6 +15,7 @@
 #include "pcie_device.hpp"
 #include "pcie_slot.hpp"
 #include "power_supply.hpp"
+#include "vrm.hpp"
 
 #include <sdbusplus/server.hpp>
 #include <xyz/openbmc_project/Inventory/Decorator/LocationCode/server.hpp>
@@ -205,6 +206,13 @@
      */
     void implementPanelInterface(const std::string& path);
 
+    /** @brief Implement Voltage Regulator Module Interface
+     *
+     *  @param[in] path - The object path
+     *
+     */
+    void implementVRMInterface(const std::string& path);
+
   private:
     std::unordered_map<ObjectPath, std::unique_ptr<Asset>> asset;
     std::unordered_map<ObjectPath, std::unique_ptr<Availability>>
@@ -224,6 +232,7 @@
     std::unordered_map<ObjectPath, std::unique_ptr<Fan>> fan;
     std::unordered_map<ObjectPath, std::unique_ptr<Connector>> connector;
     std::unordered_map<ObjectPath, std::unique_ptr<Panel>> panel;
+    std::unordered_map<ObjectPath, std::unique_ptr<VRM>> vrm;
 };
 
 } // namespace dbus
diff --git a/host-bmc/dbus/vrm.hpp b/host-bmc/dbus/vrm.hpp
new file mode 100644
index 0000000..c38bbf8
--- /dev/null
+++ b/host-bmc/dbus/vrm.hpp
@@ -0,0 +1,36 @@
+#pragma once
+
+#include <sdbusplus/bus.hpp>
+#include <sdbusplus/server.hpp>
+#include <sdbusplus/server/object.hpp>
+#include <xyz/openbmc_project/Inventory/Item/Vrm/server.hpp>
+
+#include <string>
+
+namespace pldm
+{
+namespace dbus
+{
+using ItemVRM = sdbusplus::server::object_t<
+    sdbusplus::xyz::openbmc_project::Inventory::Item::server::Vrm>;
+
+class VRM : public ItemVRM
+{
+  public:
+    VRM() = delete;
+    ~VRM() = default;
+    VRM(const VRM&) = delete;
+    VRM& operator=(const VRM&) = delete;
+    VRM(VRM&&) = delete;
+    VRM& operator=(VRM&&) = delete;
+
+    VRM(sdbusplus::bus_t& bus, const std::string& objPath) :
+        ItemVRM(bus, objPath.c_str()), path(objPath)
+    {}
+
+  private:
+    std::string path;
+};
+
+} // namespace dbus
+} // namespace pldm