Initial classes for callout resolutions
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: I5df0c1cc59facc5c36aac20ca52503d20ae0f76a
diff --git a/analyzer/meson.build b/analyzer/meson.build
index 1ef013c..461244c 100644
--- a/analyzer/meson.build
+++ b/analyzer/meson.build
@@ -4,6 +4,7 @@
'create_pel.cpp',
'hei_user_interface.cpp',
'initialize_isolator.cpp',
+ 'resolution.cpp',
)
# Library dependencies.
diff --git a/analyzer/resolution.cpp b/analyzer/resolution.cpp
new file mode 100644
index 0000000..9d994ce
--- /dev/null
+++ b/analyzer/resolution.cpp
@@ -0,0 +1,11 @@
+#include <analyzer/resolution.hpp>
+
+namespace analyzer
+{
+
+void HardwareCalloutResolution::resolve(ServiceData&) const
+{
+ // TODO: Add location code to callout list and entity path to gard list.
+}
+
+} // namespace analyzer
diff --git a/analyzer/resolution.hpp b/analyzer/resolution.hpp
new file mode 100644
index 0000000..485de2c
--- /dev/null
+++ b/analyzer/resolution.hpp
@@ -0,0 +1,124 @@
+#pragma once
+
+#include <analyzer/service_data.hpp>
+
+namespace analyzer
+{
+
+/** @brief An abstract class for service event resolutions. */
+class Resolution
+{
+ public:
+ /** @brief Pure virtual destructor. */
+ virtual ~Resolution() = 0;
+
+ public:
+ /**
+ * @brief Resolves the service actions required by this resolution.
+ * @param io_sd An object containing the service data collected during
+ * hardware error analysis.
+ */
+ virtual void resolve(ServiceData& io_sd) const = 0;
+};
+
+// Pure virtual destructor must be defined.
+inline Resolution::~Resolution() {}
+
+/** @brief Resolves a hardware callout service event. */
+class HardwareCalloutResolution : public Resolution
+{
+ public:
+ /**
+ * @brief Constructor from components.
+ * @param i_path The devtree path of a guardable unit relative to a
+ * chip. An empty string refers to the chip itself.
+ * @param i_priority The callout priority.
+ * @param i_guard The guard type for this callout.
+ */
+ HardwareCalloutResolution(const std::string& i_path,
+ Callout::Priority i_priority,
+ Guard::Type i_guard) :
+ iv_path(i_path),
+ iv_priority(i_priority), iv_guard(i_guard)
+ {}
+
+ private:
+ /** The devtree path of a guardable unit relative to a chip. An empty string
+ * refers to the chip itself. */
+ const std::string iv_path;
+
+ /** The callout priority. */
+ const Callout::Priority iv_priority;
+
+ /** The guard type for this callout. */
+ const Guard::Type iv_guard;
+
+ public:
+ void resolve(ServiceData& io_sd) const override;
+};
+
+/** @brief Resolves a procedure callout service event. */
+class ProcedureCalloutResolution : public Resolution
+{
+ public:
+ /**
+ * @brief Constructor from components.
+ * @param i_procedure The procedure callout type.
+ * @param i_priority The callout priority.
+ */
+ ProcedureCalloutResolution(ProcedureCallout::Type i_procedure,
+ Callout::Priority i_priority) :
+ iv_procedure(i_procedure),
+ iv_priority(i_priority)
+ {}
+
+ private:
+ /** The procedure callout type. */
+ const ProcedureCallout::Type iv_procedure;
+
+ /** The callout priority. */
+ const Callout::Priority iv_priority;
+
+ public:
+ void resolve(ServiceData& io_sd) const override
+ {
+ // Simply add the procedure to the callout list.
+ io_sd.addCallout(
+ std::make_shared<ProcedureCallout>(iv_procedure, iv_priority));
+ }
+};
+
+/**
+ * @brief Links two resolutions into a single resolution. The resolutions will
+ * will be resolved in the order they are inputted into the constructor.
+ */
+class LinkResolution : public Resolution
+{
+ public:
+ /**
+ * @brief Constructor from components.
+ * @param i_first The first resolution.
+ * @param i_second The second resolution.
+ */
+ LinkResolution(const std::shared_ptr<Resolution>& i_first,
+ const std::shared_ptr<Resolution>& i_second) :
+ iv_first(i_first),
+ iv_second(i_second)
+ {}
+
+ private:
+ /** The first resolution. */
+ const std::shared_ptr<Resolution> iv_first;
+
+ /** The second resolution. */
+ const std::shared_ptr<Resolution> iv_second;
+
+ public:
+ void resolve(ServiceData& io_sd) const override
+ {
+ iv_first->resolve(io_sd);
+ iv_second->resolve(io_sd);
+ }
+};
+
+} // namespace analyzer
diff --git a/analyzer/service_data.hpp b/analyzer/service_data.hpp
index ffd0804..9f93bb9 100644
--- a/analyzer/service_data.hpp
+++ b/analyzer/service_data.hpp
@@ -114,7 +114,7 @@
{
public:
/** Supported service procedures. */
- enum Procedure
+ enum Type
{
NEXTLVL, ///< Contact next level support.
};
@@ -125,19 +125,19 @@
* @param i_procedure The location code of the hardware callout.
* @param i_priority The callout priority.
*/
- ProcedureCallout(Procedure i_procedure, Priority i_priority) :
+ ProcedureCallout(Type i_procedure, Priority i_priority) :
Callout(i_priority), iv_procedure(i_procedure)
{}
private:
/** The callout priority. */
- const Procedure iv_procedure;
+ const Type iv_procedure;
public:
void getJson(nlohmann::json& j) const override
{
// clang-format off
- static const std::map<Procedure, std::string> m =
+ static const std::map<Type, std::string> m =
{
{NEXTLVL, "NEXTLVL"},
};