Validate user power cap changes fall within limits

Add validation of the user power cap when changed via Redfish or during
boot.  Validation also needs to ensure the correct power types are being
compared (input/AC vs output/DC).

Verified on hardware with limits set via GUI and Redfish.

Change-Id: Ic0d8ce2df6fdb803bbede7e42f10f34c142c6b07
Signed-off-by: Chris Cain <cjcain@us.ibm.com>
diff --git a/powercap.hpp b/powercap.hpp
index edc68c6..b52ebda 100644
--- a/powercap.hpp
+++ b/powercap.hpp
@@ -53,9 +53,10 @@
             std::bind(std::mem_fn(&PowerCap::pcapChanged), this,
                       std::placeholders::_1)){};
 
-    /** @brief Return the appropriate value to write to the OCC
+    /** @brief Return the appropriate value to write to the OCC (output/DC
+     * power)
      *
-     * @param[in]  pcap        - Current user power cap setting
+     * @param[in]  pcap        - Current user power cap setting (input/AC power)
      * @param[in]  pcapEnabled - Current power cap enable setting
      *
      * @return The value to write to the occ user pcap
@@ -87,7 +88,7 @@
      */
     bool getPcapEnabled();
 
-    /** @brief Write the input power cap to the occ hwmon entry
+    /** @brief Write the output/DC power cap to the occ hwmon entry
      *
      * @param[in]  pcapValue - Power cap value to write to OCC
      */
@@ -128,7 +129,21 @@
      *
      * @return true if all parms were written successfully
      */
-    bool updateDbusPcap(uint32_t softMin, uint32_t hardMin, uint32_t pcapMax);
+    bool updateDbusPcapLimits(uint32_t softMin, uint32_t hardMin,
+                              uint32_t pcapMax);
+
+    /** @brief Read the power cap bounds from DBus
+     *
+     * @param[out]  softMin - soft minimum power cap in Watts
+     * @param[out]  hardMin - hard minimum power cap in Watts
+     * @param[out]  pcapMax - maximum power cap in Watts
+     *
+     * @return true if all parms were read successfully
+     *         If a parm is not successfully read, it will default to 0 for the
+     *           Min parameter and INT_MAX for the Max parameter
+     */
+    bool readDbusPcapLimits(uint32_t& softMin, uint32_t& hardMin,
+                            uint32_t& max);
 };
 
 } // namespace powercap