sst: Rediscover profiles after host reboot

In some cases, host processor reboot may change the static SST-PP
profile information. This commit adds ability to register callbacks to
run upon hostState changes, and reruns SST discovery whenever the host
exits the power-off state.

Tested:
- Ran tools/sst-compare-redfish-os.py tool on platform with SPR host
  CPU, and observed no mismatches before and after a host reboot.
- Confirmed Redfish OperatingConfig properties still populated when host
  is off.

Signed-off-by: Jonathan Doman <jonathan.doman@intel.com>
Change-Id: I9e7b0ebb8c5ec7a8464346f3476490b765579428
diff --git a/include/cpuinfo_utils.hpp b/include/cpuinfo_utils.hpp
index 926c2d1..d57203b 100644
--- a/include/cpuinfo_utils.hpp
+++ b/include/cpuinfo_utils.hpp
@@ -47,6 +47,13 @@
  */
 void hostStateSetup(const std::shared_ptr<sdbusplus::asio::connection>& conn);
 
+/**
+ * Callback which is run whenever the HostState changes. First parameter is the
+ * old state, and second parameter is the new current state.
+ */
+using HostStateHandler = std::function<void(HostState, HostState)>;
+void addHostStateCallback(HostStateHandler cb);
+
 constexpr uint64_t bit(uint8_t index)
 {
     return (1ull << index);
diff --git a/include/speed_select.hpp b/include/speed_select.hpp
index 4b4189f..b7a41fb 100644
--- a/include/speed_select.hpp
+++ b/include/speed_select.hpp
@@ -27,19 +27,13 @@
 {
 
 /**
- * Retrieve all SST configuration info for all discoverable CPUs, and publish
+ * Initialize SST subsystem.
+ *
+ * This will schedule work to be done when the host is ready, in order to
+ * retrieve all SST configuration info for all discoverable CPUs, and publish
  * the info on new D-Bus objects on the given bus connection.
- *
- * This function may block until all discovery is completed (many seconds), or
- * it may schedule the work to be done at a later time (on the given ASIO
- * context) if CPUs are not currently available, and may also schedule periodic
- * work to be done after initial discovery is completed.
- *
- * @param[in,out]   ioc     ASIO IO context/service
- * @param[in,out]   conn    D-Bus ASIO connection.
  */
-void init(boost::asio::io_context& ioc,
-          const std::shared_ptr<sdbusplus::asio::connection>& conn);
+void init();
 
 class PECIError : public std::runtime_error
 {
@@ -61,18 +55,7 @@
  *
  * @return  List of bit indexes.
  */
-static std::vector<uint32_t> convertMaskToList(std::bitset<64> mask)
-{
-    std::vector<uint32_t> bitList;
-    for (size_t i = 0; i < mask.size(); ++i)
-    {
-        if (mask.test(i))
-        {
-            bitList.push_back(i);
-        }
-    }
-    return bitList;
-}
+std::vector<uint32_t> convertMaskToList(std::bitset<64> mask);
 
 using TurboEntry = std::tuple<uint32_t, size_t>;