Add feature Cold Redundancy

Add an Intel specific feature PSU Cold Redundancy. This is the first patch
which will get PSU information and PSU Event from D-Bus interfaces.
Cold Redundancy design document is in
https://gerrit.openbmc-project.xyz/c/openbmc/docs/+/27637

Signed-off-by: Cheng C Yang <cheng.c.yang@linux.intel.com>
Change-Id: Ic039118e4cebc8b0ff6ba80493180a1d8af0096b
diff --git a/cold-redundancy/util.cpp b/cold-redundancy/util.cpp
new file mode 100644
index 0000000..fea972e
--- /dev/null
+++ b/cold-redundancy/util.cpp
@@ -0,0 +1,46 @@
+/*
+// Copyright (c) 2019 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+
+#include "util.hpp"
+
+#include "utility.hpp"
+
+#include <boost/algorithm/string/predicate.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+
+namespace CR
+{
+
+void getPSUEvent(const std::shared_ptr<sdbusplus::asio::connection>& conn,
+                 const std::string& psuName, PSUState& state)
+{
+    state = PSUState::normal;
+    bool result = true;
+    // /State/Decorator/PSUx_OperationalStatus
+    std::string pathStr = psuEventPath + psuName + "_OperationalStatus";
+
+    phosphor::power::util::getProperty<bool>(
+        "xyz.openbmc_project.State.Decorator.OperationalStatus", "functional",
+        pathStr, "xyz.openbmc_project.PSUSensor",
+        static_cast<sdbusplus::bus::bus&>(*conn), result);
+
+    if (!result)
+    {
+        state = PSUState::acLost;
+    }
+}
+
+} // namespace CR