Initial end-to-end simulation support

Change-Id: Ifcdfb8e0ee3e40b9071ade2ff5dcab5037ec7887
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
diff --git a/src/isolator/hei_isolation_node.cpp b/src/isolator/hei_isolation_node.cpp
index 8d67094..e2bf61a 100644
--- a/src/isolator/hei_isolation_node.cpp
+++ b/src/isolator/hei_isolation_node.cpp
@@ -21,7 +21,7 @@
     const BitString* bs = rule_itr->second->getBitString(i_chip);
 
     // Ensure this BitString is not longer than the maximum bit field.
-    HEI_ASSERT(bs->getBitLen() <= sizeof(RegisterBit_t) * 8);
+    HEI_ASSERT(bs->getBitLen() <= (1 << (sizeof(RegisterBit_t) * 8)));
 
     // Find all active bits for this rule.
     for (RegisterBit_t bit = 0; bit < bs->getBitLen(); bit++)
diff --git a/src/isolator/hei_isolator.cpp b/src/isolator/hei_isolator.cpp
index 759eb13..68dda7d 100644
--- a/src/isolator/hei_isolator.cpp
+++ b/src/isolator/hei_isolator.cpp
@@ -5,6 +5,7 @@
 #include <util/hei_flyweight.hpp>
 
 // BEGIN temporary code
+#include <isolator/hei_isolation_node.hpp>
 #include <register/hei_scom_register.hpp>
 // END temporary code
 
@@ -20,18 +21,28 @@
     HEI_INF("Isolator::initialize(%p,%lu,%d)", i_buffer, i_bufferSize,
             i_forceInit);
 
-    Flyweight<ScomRegister>& sfw   = Flyweight<ScomRegister>::getSingleton();
-    Flyweight<IdScomRegister>& ifw = Flyweight<IdScomRegister>::getSingleton();
+    auto& scom_fw    = Flyweight<ScomRegister>::getSingleton();
+    auto& idScom_fw  = Flyweight<IdScomRegister>::getSingleton();
+    auto& isoNode_fw = Flyweight<IsolationNode>::getSingleton();
 
-    sfw.get(ScomRegister{CHIP_TYPE_INVALID, REG_ID_INVALID, REG_INST_DEFAULT,
-                         REG_ACCESS_RW, 0x01234567});
-    sfw.get(ScomRegister{CHIP_TYPE_INVALID, REG_ID_INVALID, REG_INST_DEFAULT,
-                         REG_ACCESS_RW, 0x00112233});
+    auto& idScom0 = idScom_fw.get(IdScomRegister{
+        static_cast<ChipType_t>(0xdeadbeef), static_cast<RegisterId_t>(0x1111),
+        REG_INST_DEFAULT, REG_ACCESS_RW, 0x80000000FF000000});
 
-    ifw.get(IdScomRegister{CHIP_TYPE_INVALID, REG_ID_INVALID, REG_INST_DEFAULT,
-                           REG_ACCESS_RW, 0x0123456789abcdef});
-    ifw.get(IdScomRegister{CHIP_TYPE_INVALID, REG_ID_INVALID, REG_INST_DEFAULT,
-                           REG_ACCESS_RW, 0x0011223344556677});
+    auto& scom0 = scom_fw.get(ScomRegister{
+        static_cast<ChipType_t>(0xdeadbeef), static_cast<RegisterId_t>(0x2222),
+        REG_INST_DEFAULT, REG_ACCESS_RW, 0x00FF0000});
+
+    auto& node0 = isoNode_fw.get(IsolationNode{idScom0});
+    auto& node1 = isoNode_fw.get(IsolationNode{scom0});
+
+    node0.addRule(ATTN_TYPE_CHECKSTOP, &idScom0);
+    node0.addChild(48, &node1);
+
+    node1.addRule(ATTN_TYPE_CHECKSTOP, &scom0);
+
+    iv_isoStart[static_cast<ChipType_t>(0xdeadbeef)].push_back(
+        {&node0, ATTN_TYPE_CHECKSTOP});
     // END temporary code
 
     return rc;
@@ -68,6 +79,23 @@
     {
         // BEGIN temporary code
         HEI_INF("Isolator::isolate(%p,%u)", chip.getChip(), chip.getType());
+
+        // Isolation objects for this chip's type must exist.
+        const auto& chip_itr = iv_isoStart.find(chip.getType());
+        HEI_ASSERT(iv_isoStart.end() != chip_itr);
+
+        for (const auto& pair : chip_itr->second)
+        {
+            if (pair.first->analyze(chip, pair.second, o_isoData))
+            {
+                for (const auto& sig : o_isoData.getSignatureList())
+                {
+                    HEI_INF("Signature(%p,0x%x,0x%x,0x%x,0x%x)",
+                            sig.getChip().getChip(), sig.getId(),
+                            sig.getInstance(), sig.getBit(), sig.getAttnType());
+                }
+            }
+        }
         // END temporary code
     }
 
diff --git a/src/isolator/hei_isolator.hpp b/src/isolator/hei_isolator.hpp
index d779b7b..c60835d 100644
--- a/src/isolator/hei_isolator.hpp
+++ b/src/isolator/hei_isolator.hpp
@@ -2,6 +2,7 @@
 
 #include <hei_includes.hpp>
 #include <hei_isolation_data.hpp>
+#include <isolator/hei_isolation_node.hpp>
 
 namespace libhei
 {
@@ -68,6 +69,18 @@
     /** @brief See API wrapper description in hei_main.hpp. */
     ReturnCode isolate(const std::vector<Chip>& i_chipList,
                        IsolationData& o_isoData) const;
+
+  private:
+    // BEGIN temporary code
+    /**
+     * Provides a list of isolation tree nodes used to start analysis based on
+     * the chip type and attention type.
+     */
+    std::map<ChipType_t,
+             std::vector<std::pair<const IsolationNode*, AttentionType_t>>>
+        iv_isoStart;
+    // END temporary code
+
 }; // end class Isolator
 
 } // end namespace libhei
diff --git a/src/isolator/hei_signature.hpp b/src/isolator/hei_signature.hpp
index 844aad6..2bf91e1 100644
--- a/src/isolator/hei_signature.hpp
+++ b/src/isolator/hei_signature.hpp
@@ -78,6 +78,51 @@
     {
         return iv_attnType;
     }
+
+  public: // Operators
+    /** @brief Equals operator. */
+    bool operator==(const Signature& i_r) const
+    {
+        return (getChip() == i_r.getChip() && getId() == i_r.getId() &&
+                getInstance() == i_r.getInstance() &&
+                getBit() == i_r.getBit() && getAttnType() == i_r.getAttnType());
+    }
+
+    /** @brief Less than operator. */
+    bool operator<(const Signature& i_r) const
+    {
+        if (getChip() < i_r.getChip())
+        {
+            return true;
+        }
+        else if (getChip() == i_r.getChip())
+        {
+            if (getId() < i_r.getId())
+            {
+                return true;
+            }
+            else if (getId() == i_r.getId())
+            {
+                if (getInstance() < i_r.getInstance())
+                {
+                    return true;
+                }
+                else if (getInstance() == i_r.getInstance())
+                {
+                    if (getBit() < i_r.getBit())
+                    {
+                        return true;
+                    }
+                    else if (getBit() == i_r.getBit())
+                    {
+                        return (getAttnType() < i_r.getAttnType());
+                    }
+                }
+            }
+        }
+
+        return false;
+    }
 };
 
 } // end namespace libhei