Implemented HardwareCalloutResolution::resolve()

Change-Id: I19a0d1da6b172fd74fab8680c515391b883dac95
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
diff --git a/analyzer/resolution.cpp b/analyzer/resolution.cpp
index 9d994ce..14842ad 100644
--- a/analyzer/resolution.cpp
+++ b/analyzer/resolution.cpp
@@ -1,11 +1,50 @@
 #include <analyzer/resolution.hpp>
+#include <util/pdbg.hpp>
+#include <util/trace.hpp>
 
 namespace analyzer
 {
 
-void HardwareCalloutResolution::resolve(ServiceData&) const
+void HardwareCalloutResolution::resolve(ServiceData& io_sd) const
 {
-    // TODO: Add location code to callout list and entity path to gard list.
+    // Get the chip target from the root cause signature.
+    auto trgt = util::pdbg::getTrgt(io_sd.getRootCause().getChip());
+    auto path = std::string{util::pdbg::getPath(trgt)};
+
+    // Get the unit target, if needed.
+    if (!iv_path.empty())
+    {
+        path += "/" + iv_path;
+        trgt = util::pdbg::getTrgt(path);
+        if (nullptr == trgt)
+        {
+            trace::err("Unable to find target for %s", path.c_str());
+            return; // can't continue
+        }
+    }
+
+    // Add location code to callout list.
+    auto locCode = util::pdbg::getLocationCode(trgt);
+    if (locCode.empty())
+    {
+        trace::err("Unable to find location code for %s", path.c_str());
+    }
+    else
+    {
+        io_sd.addCallout(
+            std::make_shared<HardwareCallout>(locCode, iv_priority));
+    }
+
+    // Add entity path to gard list.
+    auto entityPath = util::pdbg::getPhysDevPath(trgt);
+    if (entityPath.empty())
+    {
+        trace::err("Unable to find entity path for %s", path.c_str());
+    }
+    else
+    {
+        io_sd.addGuard(std::make_shared<Guard>(entityPath, iv_guard));
+    }
 }
 
 } // namespace analyzer
diff --git a/util/pdbg.cpp b/util/pdbg.cpp
index 03c8037..0ce56d6 100644
--- a/util/pdbg.cpp
+++ b/util/pdbg.cpp
@@ -23,6 +23,13 @@
 
 //------------------------------------------------------------------------------
 
+pdbg_target* getTrgt(const std::string& i_path)
+{
+    return pdbg_target_from_path(nullptr, i_path.c_str());
+}
+
+//------------------------------------------------------------------------------
+
 const char* getPath(pdbg_target* i_trgt)
 {
     return pdbg_target_path(i_trgt);
diff --git a/util/pdbg.hpp b/util/pdbg.hpp
index 9ad6d07..8de19cf 100644
--- a/util/pdbg.hpp
+++ b/util/pdbg.hpp
@@ -28,6 +28,9 @@
 /** @return The target associated with the given chip. */
 pdbg_target* getTrgt(const libhei::Chip& i_chip);
 
+/** @return The target associated with the given devtree path. */
+pdbg_target* getTrgt(const std::string& i_path);
+
 /** @return A string representing the given target's devtree path. */
 const char* getPath(pdbg_target* i_trgt);