Add bios post checking support

Some sensors aren't available until after bios post
add support to check for post when needed.

Tested-by: SSB temp no longer asserted thresholds before
bios post.

Change-Id: I9251c2c501e082ef4bb0e9eb7909dc137771e120
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/Utils.cpp b/src/Utils.cpp
index cd7baa4..4e7e029 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -30,6 +30,7 @@
     "/xyz/openbmc_project/Chassis/Control/Power0";
 
 static bool powerStatusOn = false;
+static bool biosHasPost = false;
 static std::unique_ptr<sdbusplus::bus::match::match> powerMatch = nullptr;
 
 bool getSensorConfiguration(
@@ -118,16 +119,24 @@
     return powerStatusOn;
 }
 
+bool hasBiosPost(void)
+{
+    if (!powerMatch)
+    {
+        throw std::runtime_error("Power Match Not Created");
+    }
+    return biosHasPost;
+}
+
 void setupPowerMatch(const std::shared_ptr<sdbusplus::asio::connection>& conn)
 {
-
     // create a match for powergood changes, first time do a method call to
     // cache the correct value
     std::function<void(sdbusplus::message::message & message)> eventHandler =
         [](sdbusplus::message::message& message) {
             std::string objectName;
-            boost::container::flat_map<std::string,
-                                       sdbusplus::message::variant<int32_t>>
+            boost::container::flat_map<
+                std::string, sdbusplus::message::variant<int32_t, bool>>
                 values;
             message.read(objectName, values);
             auto findPgood = values.find("pgood");
@@ -136,6 +145,12 @@
                 powerStatusOn = sdbusplus::message::variant_ns::get<int32_t>(
                     findPgood->second);
             }
+            auto findPostComplete = values.find("post_complete");
+            if (findPostComplete != values.end())
+            {
+                biosHasPost = sdbusplus::message::variant_ns::get<bool>(
+                    findPostComplete->second);
+            }
         };
 
     powerMatch = std::make_unique<sdbusplus::bus::match::match>(
@@ -157,6 +172,20 @@
         },
         powerInterfaceName, powerObjectName, "org.freedesktop.DBus.Properties",
         "Get", powerInterfaceName, "pgood");
+
+    conn->async_method_call(
+        [](boost::system::error_code ec,
+           const sdbusplus::message::variant<int32_t>& postComplete) {
+            if (ec)
+            {
+                std::cerr << "Error getting initial post status\n";
+                return;
+            }
+            biosHasPost =
+                sdbusplus::message::variant_ns::get<int32_t>(postComplete);
+        },
+        powerInterfaceName, powerObjectName, "org.freedesktop.DBus.Properties",
+        "Get", powerInterfaceName, "post_complete");
 }
 
 // replaces limits if MinReading and MaxReading are found.
@@ -180,4 +209,4 @@
         limits.second = sdbusplus::message::variant_ns::visit(
             VariantToDoubleVisitor(), maxFind->second);
     }
-}
\ No newline at end of file
+}