blob: dfbf5820f805b01aaf76d35319aaae592d90f7f5 [file] [log] [blame]
AppaRao Pulie63eeda2019-07-05 16:25:38 +05301/*
2// Copyright (c) 2019 Intel Corporation
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15*/
16
AppaRao Puli67d184c2020-05-29 00:48:33 +053017#include "pfr.hpp"
18#include "pfr_mgr.hpp"
19
AppaRao Puli88aa33b2019-07-18 23:49:55 +053020#include <systemd/sd-journal.h>
21
AppaRao Puli46cead92019-07-22 16:50:09 +053022#include <boost/asio.hpp>
AppaRao Pulie63eeda2019-07-05 16:25:38 +053023
AppaRao Pulidcf13122020-05-28 01:21:39 +053024namespace pfr
25{
AppaRao Puli88aa33b2019-07-18 23:49:55 +053026// Caches the last Recovery/Panic Count to
27// identify any new Recovery/panic actions.
28/* TODO: When BMC Reset's, these values will be lost
29 * Persist this info using settingsd */
30static uint8_t lastRecoveryCount = 0;
31static uint8_t lastPanicCount = 0;
32static uint8_t lastMajorErr = 0;
33static uint8_t lastMinorErr = 0;
34
35static bool stateTimerRunning = false;
AppaRao Puli46cead92019-07-22 16:50:09 +053036bool finishedSettingChkPoint = false;
37static constexpr uint8_t bmcBootFinishedChkPoint = 0x09;
38
AppaRao Puli88aa33b2019-07-18 23:49:55 +053039std::unique_ptr<boost::asio::steady_timer> stateTimer = nullptr;
AppaRao Puli46cead92019-07-22 16:50:09 +053040std::unique_ptr<boost::asio::steady_timer> initTimer = nullptr;
AppaRao Puli88aa33b2019-07-18 23:49:55 +053041
AppaRao Pulidcf13122020-05-28 01:21:39 +053042std::vector<std::unique_ptr<PfrVersion>> pfrVersionObjects;
43std::unique_ptr<PfrConfig> pfrConfigObject;
AppaRao Pulie4e95652019-07-19 16:52:01 +053044
AppaRao Pulie4e95652019-07-19 16:52:01 +053045// List holds <ObjPath> <ImageType> <VersionPurpose>
46static std::vector<std::tuple<std::string, ImageType, std::string>>
47 verComponentList = {
AppaRao Pulie4e95652019-07-19 16:52:01 +053048 std::make_tuple("bmc_recovery", ImageType::bmcRecovery,
49 versionPurposeBMC),
AppaRao Pulie4e95652019-07-19 16:52:01 +053050 std::make_tuple("bios_recovery", ImageType::biosRecovery,
51 versionPurposeHost),
Vikram Bodireddy3c6c8c32019-12-05 11:06:15 +053052 std::make_tuple("cpld_recovery", ImageType::cpldRecovery,
53 versionPurposeOther),
Vikram Bodireddy8292dc62021-05-26 13:31:47 +053054 std::make_tuple("afm_active", ImageType::afmActive,
55 versionPurposeOther),
56 std::make_tuple("afm_recovery", ImageType::afmRecovery,
57 versionPurposeOther),
Vikram Bodireddy3c6c8c32019-12-05 11:06:15 +053058};
AppaRao Pulie4e95652019-07-19 16:52:01 +053059
AppaRao Pulie90f1282019-11-05 01:07:05 +053060// Recovery reason map.
61// {<CPLD association>,{<Redfish MessageID>, <Recovery Reason>}}
62static const boost::container::flat_map<uint8_t,
63 std::pair<std::string, std::string>>
64 recoveryReasonMap = {
65 {0x01,
66 {"BIOSFirmwareRecoveryReason",
Chalapathi3fb544b2020-02-14 15:43:49 +000067 "BIOS active image authentication failure"}},
AppaRao Pulie90f1282019-11-05 01:07:05 +053068 {0x02,
69 {"BIOSFirmwareRecoveryReason",
Chalapathi3fb544b2020-02-14 15:43:49 +000070 "BIOS recovery image authentication failure"}},
AppaRao Pulie90f1282019-11-05 01:07:05 +053071 {0x03, {"MEFirmwareRecoveryReason", "ME launch failure"}},
72 {0x04, {"BIOSFirmwareRecoveryReason", "ACM launch failure"}},
73 {0x05, {"BIOSFirmwareRecoveryReason", "IBB launch failure"}},
74 {0x06, {"BIOSFirmwareRecoveryReason", "OBB launch failure"}},
75 {0x07,
76 {"BMCFirmwareRecoveryReason",
77 "BMC active image authentication failure"}},
78 {0x08,
79 {"BMCFirmwareRecoveryReason",
80 "BMC recovery image authentication failure"}},
81 {0x09, {"BMCFirmwareRecoveryReason", "BMC launch failure"}},
82 {0x0A, {"CPLDFirmwareRecoveryReason", "CPLD watchdog expired"}}};
AppaRao Puli88aa33b2019-07-18 23:49:55 +053083
AppaRao Pulie90f1282019-11-05 01:07:05 +053084// Panic Reason map.
85// {<CPLD association>, {<Redfish MessageID>, <Panic reason> })
86static const boost::container::flat_map<uint8_t,
87 std::pair<std::string, std::string>>
88 panicReasonMap = {
Chalapathi3fb544b2020-02-14 15:43:49 +000089 {0x01, {"BIOSFirmwarePanicReason", "BIOS update intent"}},
90 {0x02, {"BMCFirmwarePanicReason", "BMC update intent"}},
91 {0x03, {"BMCFirmwarePanicReason", "BMC reset detected"}},
92 {0x04, {"BMCFirmwarePanicReason", "BMC watchdog expired"}},
93 {0x05, {"MEFirmwarePanicReason", "ME watchdog expired"}},
94 {0x06, {"BIOSFirmwarePanicReason", "ACM watchdog expired"}},
95 {0x07, {"BIOSFirmwarePanicReason", "IBB watchdog expired"}},
96 {0x08, {"BIOSFirmwarePanicReason", "OBB watchdog expired"}},
AppaRao Pulie90f1282019-11-05 01:07:05 +053097 {0x09,
98 {"BIOSFirmwarePanicReason",
Chalapathi3fb544b2020-02-14 15:43:49 +000099 "ACM or IBB or OBB authentication failure"}}};
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530100
AppaRao Puli24766942019-11-13 19:27:08 +0530101// Firmware resiliency major map.
102// {<CPLD association>, {<Redfish MessageID>, <Error reason> })
103static const boost::container::flat_map<uint8_t,
104 std::pair<std::string, std::string>>
105 majorErrorCodeMap = {
106 {0x01,
107 {"BMCFirmwareResiliencyError", "BMC image authentication failed"}},
108 {0x02,
109 {"BIOSFirmwareResiliencyError", "BIOS image authentication failed"}},
Chalapathi3fb544b2020-02-14 15:43:49 +0000110 {0x03, {"BIOSFirmwareResiliencyError", "Update from BIOS failed"}},
111 {0x04, {"BMCFirmwareResiliencyError", "Update from BMC failed"}}};
AppaRao Puli24766942019-11-13 19:27:08 +0530112
AppaRao Pulie4e95652019-07-19 16:52:01 +0530113static void updateDbusPropertiesCache()
114{
115 for (const auto& pfrVerObj : pfrVersionObjects)
116 {
117 pfrVerObj->updateVersion();
118 }
119
120 // Update provisoningStatus properties
121 pfrConfigObject->updateProvisioningStatus();
122
123 phosphor::logging::log<phosphor::logging::level::INFO>(
124 "PFR Manager service cache data updated.");
125}
126
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530127static void logLastRecoveryEvent()
128{
129 uint8_t reason = 0;
AppaRao Pulidcf13122020-05-28 01:21:39 +0530130 if (0 != readCpldReg(ActionType::recoveryReason, reason))
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530131 {
132 return;
133 }
134
AppaRao Pulie90f1282019-11-05 01:07:05 +0530135 auto it = recoveryReasonMap.find(reason);
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530136 if (it == recoveryReasonMap.end())
137 {
138 // No matching found. So just return without logging event.
139 return;
140 }
AppaRao Pulie90f1282019-11-05 01:07:05 +0530141 std::string msgId = "OpenBMC.0.1." + it->second.first;
142 sd_journal_send("MESSAGE=%s", "Platform firmware recovery occurred.",
143 "PRIORITY=%i", LOG_WARNING, "REDFISH_MESSAGE_ID=%s",
144 msgId.c_str(), "REDFISH_MESSAGE_ARGS=%s",
145 it->second.second.c_str(), NULL);
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530146}
147
148static void logLastPanicEvent()
149{
150 uint8_t reason = 0;
AppaRao Pulidcf13122020-05-28 01:21:39 +0530151 if (0 != readCpldReg(ActionType::panicReason, reason))
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530152 {
153 return;
154 }
155
AppaRao Pulie90f1282019-11-05 01:07:05 +0530156 auto it = panicReasonMap.find(reason);
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530157 if (it == panicReasonMap.end())
158 {
159 // No matching found. So just return without logging event.
160 return;
161 }
162
AppaRao Pulie90f1282019-11-05 01:07:05 +0530163 std::string msgId = "OpenBMC.0.1." + it->second.first;
164 sd_journal_send("MESSAGE=%s", "Platform firmware panic occurred.",
165 "PRIORITY=%i", LOG_WARNING, "REDFISH_MESSAGE_ID=%s",
166 msgId.c_str(), "REDFISH_MESSAGE_ARGS=%s",
167 it->second.second.c_str(), NULL);
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530168}
169
AppaRao Puli24766942019-11-13 19:27:08 +0530170static void logResiliencyErrorEvent(const uint8_t majorErrorCode,
171 const uint8_t minorErrorCode)
172{
173 auto it = majorErrorCodeMap.find(majorErrorCode);
174 if (it == majorErrorCodeMap.end())
175 {
176 // No matching found. So just return without logging event.
177 return;
178 }
179
180 std::string errorStr =
181 it->second.second + "(MinorCode:0x" + toHexString(minorErrorCode) + ")";
182 std::string msgId = "OpenBMC.0.1." + it->second.first;
183 sd_journal_send(
184 "MESSAGE=%s", "Platform firmware resiliency error occurred.",
185 "PRIORITY=%i", LOG_ERR, "REDFISH_MESSAGE_ID=%s", msgId.c_str(),
186 "REDFISH_MESSAGE_ARGS=%s", errorStr.c_str(), NULL);
187}
188
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530189static void checkAndLogEvents()
190{
191 uint8_t currPanicCount = 0;
AppaRao Pulidcf13122020-05-28 01:21:39 +0530192 if (0 == readCpldReg(ActionType::panicCount, currPanicCount))
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530193 {
194 if (lastPanicCount != currPanicCount)
195 {
196 // Update cached data and log redfish event by reading reason.
197 lastPanicCount = currPanicCount;
198 logLastPanicEvent();
199 }
200 }
201
202 uint8_t currRecoveryCount = 0;
AppaRao Pulidcf13122020-05-28 01:21:39 +0530203 if (0 == readCpldReg(ActionType::recoveryCount, currRecoveryCount))
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530204 {
205 if (lastRecoveryCount != currRecoveryCount)
206 {
207 // Update cached data and log redfish event by reading reason.
208 lastRecoveryCount = currRecoveryCount;
209 logLastRecoveryEvent();
210 }
211 }
212
213 uint8_t majorErr = 0;
214 uint8_t minorErr = 0;
AppaRao Pulidcf13122020-05-28 01:21:39 +0530215 if ((0 == readCpldReg(ActionType::majorError, majorErr)) &&
216 (0 == readCpldReg(ActionType::minorError, minorErr)))
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530217 {
218 if ((lastMajorErr != majorErr) || (lastMinorErr != minorErr))
219 {
220 lastMajorErr = majorErr;
221 lastMinorErr = minorErr;
222
AppaRao Puli24766942019-11-13 19:27:08 +0530223 logResiliencyErrorEvent(majorErr, minorErr);
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530224 }
225 }
226}
227
228static void monitorPlatformStateChange(
229 sdbusplus::asio::object_server& server,
230 std::shared_ptr<sdbusplus::asio::connection>& conn)
231{
232 constexpr size_t pollTimeout = 10; // seconds
233 stateTimer->expires_after(std::chrono::seconds(pollTimeout));
234 stateTimer->async_wait(
235 [&server, &conn](const boost::system::error_code& ec) {
236 if (ec == boost::asio::error::operation_aborted)
237 {
238 // Timer reset.
239 return;
240 }
241 if (ec)
242 {
243 // Platform State Monitor - Timer cancelled.
244 return;
245 }
246 checkAndLogEvents();
247 monitorPlatformStateChange(server, conn);
248 });
249}
250
AppaRao Puli46cead92019-07-22 16:50:09 +0530251void checkAndSetCheckpoint(sdbusplus::asio::object_server& server,
252 std::shared_ptr<sdbusplus::asio::connection>& conn)
253{
254 // Check whether systemd completed all the loading.
255 conn->async_method_call(
256 [&server, &conn](boost::system::error_code ec,
257 const std::variant<uint64_t>& value) {
AppaRao Pulib7e172c2019-12-13 14:46:25 +0530258 if (!ec)
AppaRao Puli46cead92019-07-22 16:50:09 +0530259 {
AppaRao Pulib7e172c2019-12-13 14:46:25 +0530260 if (std::get<uint64_t>(value))
AppaRao Puli46cead92019-07-22 16:50:09 +0530261 {
AppaRao Pulib7e172c2019-12-13 14:46:25 +0530262 phosphor::logging::log<phosphor::logging::level::INFO>(
263 "PFR: BMC boot completed. Setting checkpoint 9.");
264 if (!finishedSettingChkPoint)
265 {
266 finishedSettingChkPoint = true;
AppaRao Pulidcf13122020-05-28 01:21:39 +0530267 setBMCBootCheckpoint(bmcBootFinishedChkPoint);
AppaRao Pulib7e172c2019-12-13 14:46:25 +0530268 }
269 return;
AppaRao Puli46cead92019-07-22 16:50:09 +0530270 }
271 }
272 else
273 {
AppaRao Pulib7e172c2019-12-13 14:46:25 +0530274 // Failed to get data from systemd. System might not
275 // be ready yet. Attempt again for data.
276 phosphor::logging::log<phosphor::logging::level::ERR>(
277 "PFR: aync call failed to get FinishTimestamp.",
278 phosphor::logging::entry("MSG=%s", ec.message().c_str()));
AppaRao Puli46cead92019-07-22 16:50:09 +0530279 }
AppaRao Pulib7e172c2019-12-13 14:46:25 +0530280 // FIX-ME: Latest up-stream sync caused issue in receiving
281 // StartupFinished signal. Unable to get StartupFinished signal
282 // from systemd1 hence using poll method too, to trigger it
283 // properly.
284 constexpr size_t pollTimeout = 10; // seconds
285 initTimer->expires_after(std::chrono::seconds(pollTimeout));
286 initTimer->async_wait([&server,
287 &conn](const boost::system::error_code& ec) {
288 if (ec == boost::asio::error::operation_aborted)
289 {
290 // Timer reset.
291 phosphor::logging::log<phosphor::logging::level::INFO>(
292 "PFR: Set boot Checkpoint - Timer aborted or stopped.");
293 return;
294 }
295 if (ec)
296 {
297 phosphor::logging::log<phosphor::logging::level::ERR>(
298 "PFR: Set boot Checkpoint - async wait error.");
299 return;
300 }
301 checkAndSetCheckpoint(server, conn);
302 });
AppaRao Puli46cead92019-07-22 16:50:09 +0530303 },
304 "org.freedesktop.systemd1", "/org/freedesktop/systemd1",
305 "org.freedesktop.DBus.Properties", "Get",
306 "org.freedesktop.systemd1.Manager", "FinishTimestamp");
307}
308
AppaRao Pulia9bf9712020-01-12 05:45:48 +0530309void monitorSignals(sdbusplus::asio::object_server& server,
310 std::shared_ptr<sdbusplus::asio::connection>& conn)
AppaRao Pulie63eeda2019-07-05 16:25:38 +0530311{
AppaRao Puli46cead92019-07-22 16:50:09 +0530312 // Monitor Boot finished signal and set the checkpoint 9 to
313 // notify CPLD about BMC boot finish.
314 auto bootFinishedSignal = std::make_unique<sdbusplus::bus::match::match>(
315 static_cast<sdbusplus::bus::bus&>(*conn),
316 "type='signal',"
317 "member='StartupFinished',path='/org/freedesktop/systemd1',"
318 "interface='org.freedesktop.systemd1.Manager'",
319 [&server, &conn](sdbusplus::message::message& msg) {
320 if (!finishedSettingChkPoint)
321 {
AppaRao Pulib7e172c2019-12-13 14:46:25 +0530322 phosphor::logging::log<phosphor::logging::level::INFO>(
323 "PFR: BMC boot completed(StartupFinished). Setting "
324 "checkpoint 9.");
AppaRao Puli46cead92019-07-22 16:50:09 +0530325 finishedSettingChkPoint = true;
AppaRao Pulidcf13122020-05-28 01:21:39 +0530326 setBMCBootCheckpoint(bmcBootFinishedChkPoint);
AppaRao Puli46cead92019-07-22 16:50:09 +0530327 }
328 });
329 checkAndSetCheckpoint(server, conn);
330
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530331 // Capture the Chassis state and Start the monitor timer
332 // if state changed to 'On'. Run timer until OS boot.
333 // Stop timer if state changed to 'Off'.
334 static auto matchChassisState = sdbusplus::bus::match::match(
335 static_cast<sdbusplus::bus::bus&>(*conn),
336 "type='signal',member='PropertiesChanged', "
337 "interface='org.freedesktop.DBus.Properties', "
338 "sender='xyz.openbmc_project.State.Chassis', "
339 "arg0namespace='xyz.openbmc_project.State.Chassis'",
340 [&server, &conn](sdbusplus::message::message& message) {
341 std::string intfName;
342 std::map<std::string, std::variant<std::string>> properties;
343 message.read(intfName, properties);
344
345 const auto it = properties.find("CurrentPowerState");
346 if (it != properties.end())
347 {
348 const std::string* state =
349 std::get_if<std::string>(&it->second);
350 if (state != nullptr)
351 {
352 if ((*state ==
353 "xyz.openbmc_project.State.Chassis.PowerState.On") &&
354 (!stateTimerRunning))
355 {
356 stateTimerRunning = true;
357 monitorPlatformStateChange(server, conn);
358 }
359 else if ((*state == "xyz.openbmc_project.State.Chassis."
360 "PowerState.Off") &&
361 (stateTimerRunning))
362 {
363 stateTimer->cancel();
364 checkAndLogEvents();
365 stateTimerRunning = false;
366 }
367 }
AppaRao Pulie4e95652019-07-19 16:52:01 +0530368
369 // Update the D-Bus properties when chassis state changes.
370 updateDbusPropertiesCache();
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530371 }
372 });
373
374 // Capture the Host state and Start the monitor timer
375 // if state changed to 'Running'. Run timer until OS boot.
376 // Stop timer if state changed to 'Off'.
377 static auto matchHostState = sdbusplus::bus::match::match(
378 static_cast<sdbusplus::bus::bus&>(*conn),
379 "type='signal',member='PropertiesChanged', "
380 "interface='org.freedesktop.DBus.Properties', "
381 "sender='xyz.openbmc_project.State.Chassis', "
382 "arg0namespace='xyz.openbmc_project.State.Host'",
383 [&server, &conn](sdbusplus::message::message& message) {
384 std::string intfName;
385 std::map<std::string, std::variant<std::string>> properties;
386 message.read(intfName, properties);
387
388 const auto it = properties.find("CurrentHostState");
389 if (it != properties.end())
390 {
391 const std::string* state =
392 std::get_if<std::string>(&it->second);
393 if (state != nullptr)
394 {
395 if ((*state ==
396 "xyz.openbmc_project.State.Host.HostState.Running") &&
397 (!stateTimerRunning))
398 {
399 stateTimerRunning = true;
400 monitorPlatformStateChange(server, conn);
401 }
402 else if (((*state == "xyz.openbmc_project.State.Host."
403 "HostState.Off") ||
404 (*state == "xyz.openbmc_project.State.Host."
405 "HostState.Quiesced")) &&
406 (stateTimerRunning))
407 {
408 stateTimer->cancel();
409 checkAndLogEvents();
410 stateTimerRunning = false;
411 }
412 }
AppaRao Pulie4e95652019-07-19 16:52:01 +0530413
414 // Update the D-Bus properties when host state changes.
415 updateDbusPropertiesCache();
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530416 }
417 });
418
419 // Capture the OS state change and stop monitor timer
420 // if OS boots completly or becomes Inactive.
421 // start timer in other cases to mnitor states.
422 static auto matchOsState = sdbusplus::bus::match::match(
423 static_cast<sdbusplus::bus::bus&>(*conn),
424 "type='signal',member='PropertiesChanged', "
425 "interface='org.freedesktop.DBus.Properties', "
426 "sender='xyz.openbmc_project.State.Chassis', "
427 "arg0namespace='xyz.openbmc_project.State.OperatingSystem.Status'",
428 [&server, &conn](sdbusplus::message::message& message) {
429 std::string intfName;
430 std::map<std::string, std::variant<std::string>> properties;
431 message.read(intfName, properties);
432
433 const auto it = properties.find("OperatingSystemState");
434 if (it != properties.end())
435 {
436 const std::string* state =
437 std::get_if<std::string>(&it->second);
438 if (state != nullptr)
439 {
440 if (((*state == "BootComplete") ||
441 (*state == "Inactive")) &&
442 (stateTimerRunning))
443 {
444 stateTimer->cancel();
445 checkAndLogEvents();
446 stateTimerRunning = false;
447 }
448 else if (!stateTimerRunning)
449 {
450 stateTimerRunning = true;
451 monitorPlatformStateChange(server, conn);
452 }
453 }
454 }
455 });
456
457 // First time, check and log events if any.
458 checkAndLogEvents();
AppaRao Pulia9bf9712020-01-12 05:45:48 +0530459}
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530460
Chalapathi Venkataramashettye6fb18e2021-02-03 14:51:00 +0000461static void updateCPLDversion(std::shared_ptr<sdbusplus::asio::connection> conn)
462{
463 std::string cpldVersion = pfr::readCPLDVersion();
464 conn->async_method_call(
465 [](const boost::system::error_code ec) {
466 if (ec)
467 {
468 phosphor::logging::log<phosphor::logging::level::ERR>(
469 "Unable to update cpld_active version",
470 phosphor::logging::entry("MSG=%s", ec.message().c_str()));
471 return;
472 }
473 },
474 "xyz.openbmc_project.Settings",
475 "/xyz/openbmc_project/software/cpld_active",
476 "org.freedesktop.DBus.Properties", "Set",
477 "xyz.openbmc_project.Software.Version", "Version",
478 std::variant<std::string>(cpldVersion));
479 return;
480}
481
AppaRao Pulidcf13122020-05-28 01:21:39 +0530482} // namespace pfr
483
AppaRao Pulia9bf9712020-01-12 05:45:48 +0530484int main()
485{
486 // setup connection to dbus
487 boost::asio::io_service io;
488 auto conn = std::make_shared<sdbusplus::asio::connection>(io);
AppaRao Pulidcf13122020-05-28 01:21:39 +0530489 pfr::stateTimer = std::make_unique<boost::asio::steady_timer>(io);
490 pfr::initTimer = std::make_unique<boost::asio::steady_timer>(io);
AppaRao Pulia9bf9712020-01-12 05:45:48 +0530491 auto server = sdbusplus::asio::object_server(conn, true);
AppaRao Pulidcf13122020-05-28 01:21:39 +0530492 pfr::monitorSignals(server, conn);
AppaRao Pulia9bf9712020-01-12 05:45:48 +0530493
Chalapathi Venkataramashettye6fb18e2021-02-03 14:51:00 +0000494 // Update CPLD Version to cpld_active object in settings.
495 pfr::updateCPLDversion(conn);
496
AppaRao Pulia9bf9712020-01-12 05:45:48 +0530497 server.add_manager("/xyz/openbmc_project/pfr");
498
499 // Create PFR attributes object and interface
AppaRao Pulidcf13122020-05-28 01:21:39 +0530500 pfr::pfrConfigObject = std::make_unique<pfr::PfrConfig>(server, conn);
AppaRao Pulia9bf9712020-01-12 05:45:48 +0530501
502 // Create Software objects using Versions interface
AppaRao Pulidcf13122020-05-28 01:21:39 +0530503 for (const auto& entry : pfr::verComponentList)
AppaRao Pulia9bf9712020-01-12 05:45:48 +0530504 {
AppaRao Pulidcf13122020-05-28 01:21:39 +0530505 pfr::pfrVersionObjects.emplace_back(std::make_unique<pfr::PfrVersion>(
AppaRao Pulia9bf9712020-01-12 05:45:48 +0530506 server, conn, std::get<0>(entry), std::get<1>(entry),
507 std::get<2>(entry)));
508 }
509
510 conn->request_name("xyz.openbmc_project.PFR.Manager");
AppaRao Pulie63eeda2019-07-05 16:25:38 +0530511 phosphor::logging::log<phosphor::logging::level::INFO>(
512 "Intel PFR service started successfully");
AppaRao Pulie63eeda2019-07-05 16:25:38 +0530513 io.run();
514
515 return 0;
516}