blob: ba714fe4b8fdf4da486964969c8e51a942162572 [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),
54};
AppaRao Pulie4e95652019-07-19 16:52:01 +053055
AppaRao Pulie90f1282019-11-05 01:07:05 +053056// Recovery reason map.
57// {<CPLD association>,{<Redfish MessageID>, <Recovery Reason>}}
58static const boost::container::flat_map<uint8_t,
59 std::pair<std::string, std::string>>
60 recoveryReasonMap = {
61 {0x01,
62 {"BIOSFirmwareRecoveryReason",
Chalapathi3fb544b2020-02-14 15:43:49 +000063 "BIOS active image authentication failure"}},
AppaRao Pulie90f1282019-11-05 01:07:05 +053064 {0x02,
65 {"BIOSFirmwareRecoveryReason",
Chalapathi3fb544b2020-02-14 15:43:49 +000066 "BIOS recovery image authentication failure"}},
AppaRao Pulie90f1282019-11-05 01:07:05 +053067 {0x03, {"MEFirmwareRecoveryReason", "ME launch failure"}},
68 {0x04, {"BIOSFirmwareRecoveryReason", "ACM launch failure"}},
69 {0x05, {"BIOSFirmwareRecoveryReason", "IBB launch failure"}},
70 {0x06, {"BIOSFirmwareRecoveryReason", "OBB launch failure"}},
71 {0x07,
72 {"BMCFirmwareRecoveryReason",
73 "BMC active image authentication failure"}},
74 {0x08,
75 {"BMCFirmwareRecoveryReason",
76 "BMC recovery image authentication failure"}},
77 {0x09, {"BMCFirmwareRecoveryReason", "BMC launch failure"}},
78 {0x0A, {"CPLDFirmwareRecoveryReason", "CPLD watchdog expired"}}};
AppaRao Puli88aa33b2019-07-18 23:49:55 +053079
AppaRao Pulie90f1282019-11-05 01:07:05 +053080// Panic Reason map.
81// {<CPLD association>, {<Redfish MessageID>, <Panic reason> })
82static const boost::container::flat_map<uint8_t,
83 std::pair<std::string, std::string>>
84 panicReasonMap = {
Chalapathi3fb544b2020-02-14 15:43:49 +000085 {0x01, {"BIOSFirmwarePanicReason", "BIOS update intent"}},
86 {0x02, {"BMCFirmwarePanicReason", "BMC update intent"}},
87 {0x03, {"BMCFirmwarePanicReason", "BMC reset detected"}},
88 {0x04, {"BMCFirmwarePanicReason", "BMC watchdog expired"}},
89 {0x05, {"MEFirmwarePanicReason", "ME watchdog expired"}},
90 {0x06, {"BIOSFirmwarePanicReason", "ACM watchdog expired"}},
91 {0x07, {"BIOSFirmwarePanicReason", "IBB watchdog expired"}},
92 {0x08, {"BIOSFirmwarePanicReason", "OBB watchdog expired"}},
AppaRao Pulie90f1282019-11-05 01:07:05 +053093 {0x09,
94 {"BIOSFirmwarePanicReason",
Chalapathi3fb544b2020-02-14 15:43:49 +000095 "ACM or IBB or OBB authentication failure"}}};
AppaRao Puli88aa33b2019-07-18 23:49:55 +053096
AppaRao Puli24766942019-11-13 19:27:08 +053097// Firmware resiliency major map.
98// {<CPLD association>, {<Redfish MessageID>, <Error reason> })
99static const boost::container::flat_map<uint8_t,
100 std::pair<std::string, std::string>>
101 majorErrorCodeMap = {
102 {0x01,
103 {"BMCFirmwareResiliencyError", "BMC image authentication failed"}},
104 {0x02,
105 {"BIOSFirmwareResiliencyError", "BIOS image authentication failed"}},
Chalapathi3fb544b2020-02-14 15:43:49 +0000106 {0x03, {"BIOSFirmwareResiliencyError", "Update from BIOS failed"}},
107 {0x04, {"BMCFirmwareResiliencyError", "Update from BMC failed"}}};
AppaRao Puli24766942019-11-13 19:27:08 +0530108
AppaRao Pulie4e95652019-07-19 16:52:01 +0530109static void updateDbusPropertiesCache()
110{
111 for (const auto& pfrVerObj : pfrVersionObjects)
112 {
113 pfrVerObj->updateVersion();
114 }
115
116 // Update provisoningStatus properties
117 pfrConfigObject->updateProvisioningStatus();
118
119 phosphor::logging::log<phosphor::logging::level::INFO>(
120 "PFR Manager service cache data updated.");
121}
122
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530123static void logLastRecoveryEvent()
124{
125 uint8_t reason = 0;
AppaRao Pulidcf13122020-05-28 01:21:39 +0530126 if (0 != readCpldReg(ActionType::recoveryReason, reason))
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530127 {
128 return;
129 }
130
AppaRao Pulie90f1282019-11-05 01:07:05 +0530131 auto it = recoveryReasonMap.find(reason);
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530132 if (it == recoveryReasonMap.end())
133 {
134 // No matching found. So just return without logging event.
135 return;
136 }
AppaRao Pulie90f1282019-11-05 01:07:05 +0530137 std::string msgId = "OpenBMC.0.1." + it->second.first;
138 sd_journal_send("MESSAGE=%s", "Platform firmware recovery occurred.",
139 "PRIORITY=%i", LOG_WARNING, "REDFISH_MESSAGE_ID=%s",
140 msgId.c_str(), "REDFISH_MESSAGE_ARGS=%s",
141 it->second.second.c_str(), NULL);
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530142}
143
144static void logLastPanicEvent()
145{
146 uint8_t reason = 0;
AppaRao Pulidcf13122020-05-28 01:21:39 +0530147 if (0 != readCpldReg(ActionType::panicReason, reason))
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530148 {
149 return;
150 }
151
AppaRao Pulie90f1282019-11-05 01:07:05 +0530152 auto it = panicReasonMap.find(reason);
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530153 if (it == panicReasonMap.end())
154 {
155 // No matching found. So just return without logging event.
156 return;
157 }
158
AppaRao Pulie90f1282019-11-05 01:07:05 +0530159 std::string msgId = "OpenBMC.0.1." + it->second.first;
160 sd_journal_send("MESSAGE=%s", "Platform firmware panic occurred.",
161 "PRIORITY=%i", LOG_WARNING, "REDFISH_MESSAGE_ID=%s",
162 msgId.c_str(), "REDFISH_MESSAGE_ARGS=%s",
163 it->second.second.c_str(), NULL);
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530164}
165
AppaRao Puli24766942019-11-13 19:27:08 +0530166static void logResiliencyErrorEvent(const uint8_t majorErrorCode,
167 const uint8_t minorErrorCode)
168{
169 auto it = majorErrorCodeMap.find(majorErrorCode);
170 if (it == majorErrorCodeMap.end())
171 {
172 // No matching found. So just return without logging event.
173 return;
174 }
175
176 std::string errorStr =
177 it->second.second + "(MinorCode:0x" + toHexString(minorErrorCode) + ")";
178 std::string msgId = "OpenBMC.0.1." + it->second.first;
179 sd_journal_send(
180 "MESSAGE=%s", "Platform firmware resiliency error occurred.",
181 "PRIORITY=%i", LOG_ERR, "REDFISH_MESSAGE_ID=%s", msgId.c_str(),
182 "REDFISH_MESSAGE_ARGS=%s", errorStr.c_str(), NULL);
183}
184
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530185static void checkAndLogEvents()
186{
187 uint8_t currPanicCount = 0;
AppaRao Pulidcf13122020-05-28 01:21:39 +0530188 if (0 == readCpldReg(ActionType::panicCount, currPanicCount))
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530189 {
190 if (lastPanicCount != currPanicCount)
191 {
192 // Update cached data and log redfish event by reading reason.
193 lastPanicCount = currPanicCount;
194 logLastPanicEvent();
195 }
196 }
197
198 uint8_t currRecoveryCount = 0;
AppaRao Pulidcf13122020-05-28 01:21:39 +0530199 if (0 == readCpldReg(ActionType::recoveryCount, currRecoveryCount))
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530200 {
201 if (lastRecoveryCount != currRecoveryCount)
202 {
203 // Update cached data and log redfish event by reading reason.
204 lastRecoveryCount = currRecoveryCount;
205 logLastRecoveryEvent();
206 }
207 }
208
209 uint8_t majorErr = 0;
210 uint8_t minorErr = 0;
AppaRao Pulidcf13122020-05-28 01:21:39 +0530211 if ((0 == readCpldReg(ActionType::majorError, majorErr)) &&
212 (0 == readCpldReg(ActionType::minorError, minorErr)))
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530213 {
214 if ((lastMajorErr != majorErr) || (lastMinorErr != minorErr))
215 {
216 lastMajorErr = majorErr;
217 lastMinorErr = minorErr;
218
AppaRao Puli24766942019-11-13 19:27:08 +0530219 logResiliencyErrorEvent(majorErr, minorErr);
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530220 }
221 }
222}
223
224static void monitorPlatformStateChange(
225 sdbusplus::asio::object_server& server,
226 std::shared_ptr<sdbusplus::asio::connection>& conn)
227{
228 constexpr size_t pollTimeout = 10; // seconds
229 stateTimer->expires_after(std::chrono::seconds(pollTimeout));
230 stateTimer->async_wait(
231 [&server, &conn](const boost::system::error_code& ec) {
232 if (ec == boost::asio::error::operation_aborted)
233 {
234 // Timer reset.
235 return;
236 }
237 if (ec)
238 {
239 // Platform State Monitor - Timer cancelled.
240 return;
241 }
242 checkAndLogEvents();
243 monitorPlatformStateChange(server, conn);
244 });
245}
246
AppaRao Puli46cead92019-07-22 16:50:09 +0530247void checkAndSetCheckpoint(sdbusplus::asio::object_server& server,
248 std::shared_ptr<sdbusplus::asio::connection>& conn)
249{
250 // Check whether systemd completed all the loading.
251 conn->async_method_call(
252 [&server, &conn](boost::system::error_code ec,
253 const std::variant<uint64_t>& value) {
AppaRao Pulib7e172c2019-12-13 14:46:25 +0530254 if (!ec)
AppaRao Puli46cead92019-07-22 16:50:09 +0530255 {
AppaRao Pulib7e172c2019-12-13 14:46:25 +0530256 if (std::get<uint64_t>(value))
AppaRao Puli46cead92019-07-22 16:50:09 +0530257 {
AppaRao Pulib7e172c2019-12-13 14:46:25 +0530258 phosphor::logging::log<phosphor::logging::level::INFO>(
259 "PFR: BMC boot completed. Setting checkpoint 9.");
260 if (!finishedSettingChkPoint)
261 {
262 finishedSettingChkPoint = true;
AppaRao Pulidcf13122020-05-28 01:21:39 +0530263 setBMCBootCheckpoint(bmcBootFinishedChkPoint);
AppaRao Pulib7e172c2019-12-13 14:46:25 +0530264 }
265 return;
AppaRao Puli46cead92019-07-22 16:50:09 +0530266 }
267 }
268 else
269 {
AppaRao Pulib7e172c2019-12-13 14:46:25 +0530270 // Failed to get data from systemd. System might not
271 // be ready yet. Attempt again for data.
272 phosphor::logging::log<phosphor::logging::level::ERR>(
273 "PFR: aync call failed to get FinishTimestamp.",
274 phosphor::logging::entry("MSG=%s", ec.message().c_str()));
AppaRao Puli46cead92019-07-22 16:50:09 +0530275 }
AppaRao Pulib7e172c2019-12-13 14:46:25 +0530276 // FIX-ME: Latest up-stream sync caused issue in receiving
277 // StartupFinished signal. Unable to get StartupFinished signal
278 // from systemd1 hence using poll method too, to trigger it
279 // properly.
280 constexpr size_t pollTimeout = 10; // seconds
281 initTimer->expires_after(std::chrono::seconds(pollTimeout));
282 initTimer->async_wait([&server,
283 &conn](const boost::system::error_code& ec) {
284 if (ec == boost::asio::error::operation_aborted)
285 {
286 // Timer reset.
287 phosphor::logging::log<phosphor::logging::level::INFO>(
288 "PFR: Set boot Checkpoint - Timer aborted or stopped.");
289 return;
290 }
291 if (ec)
292 {
293 phosphor::logging::log<phosphor::logging::level::ERR>(
294 "PFR: Set boot Checkpoint - async wait error.");
295 return;
296 }
297 checkAndSetCheckpoint(server, conn);
298 });
AppaRao Puli46cead92019-07-22 16:50:09 +0530299 },
300 "org.freedesktop.systemd1", "/org/freedesktop/systemd1",
301 "org.freedesktop.DBus.Properties", "Get",
302 "org.freedesktop.systemd1.Manager", "FinishTimestamp");
303}
304
AppaRao Pulia9bf9712020-01-12 05:45:48 +0530305void monitorSignals(sdbusplus::asio::object_server& server,
306 std::shared_ptr<sdbusplus::asio::connection>& conn)
AppaRao Pulie63eeda2019-07-05 16:25:38 +0530307{
AppaRao Puli46cead92019-07-22 16:50:09 +0530308 // Monitor Boot finished signal and set the checkpoint 9 to
309 // notify CPLD about BMC boot finish.
310 auto bootFinishedSignal = std::make_unique<sdbusplus::bus::match::match>(
311 static_cast<sdbusplus::bus::bus&>(*conn),
312 "type='signal',"
313 "member='StartupFinished',path='/org/freedesktop/systemd1',"
314 "interface='org.freedesktop.systemd1.Manager'",
315 [&server, &conn](sdbusplus::message::message& msg) {
316 if (!finishedSettingChkPoint)
317 {
AppaRao Pulib7e172c2019-12-13 14:46:25 +0530318 phosphor::logging::log<phosphor::logging::level::INFO>(
319 "PFR: BMC boot completed(StartupFinished). Setting "
320 "checkpoint 9.");
AppaRao Puli46cead92019-07-22 16:50:09 +0530321 finishedSettingChkPoint = true;
AppaRao Pulidcf13122020-05-28 01:21:39 +0530322 setBMCBootCheckpoint(bmcBootFinishedChkPoint);
AppaRao Puli46cead92019-07-22 16:50:09 +0530323 }
324 });
325 checkAndSetCheckpoint(server, conn);
326
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530327 // Capture the Chassis state and Start the monitor timer
328 // if state changed to 'On'. Run timer until OS boot.
329 // Stop timer if state changed to 'Off'.
330 static auto matchChassisState = sdbusplus::bus::match::match(
331 static_cast<sdbusplus::bus::bus&>(*conn),
332 "type='signal',member='PropertiesChanged', "
333 "interface='org.freedesktop.DBus.Properties', "
334 "sender='xyz.openbmc_project.State.Chassis', "
335 "arg0namespace='xyz.openbmc_project.State.Chassis'",
336 [&server, &conn](sdbusplus::message::message& message) {
337 std::string intfName;
338 std::map<std::string, std::variant<std::string>> properties;
339 message.read(intfName, properties);
340
341 const auto it = properties.find("CurrentPowerState");
342 if (it != properties.end())
343 {
344 const std::string* state =
345 std::get_if<std::string>(&it->second);
346 if (state != nullptr)
347 {
348 if ((*state ==
349 "xyz.openbmc_project.State.Chassis.PowerState.On") &&
350 (!stateTimerRunning))
351 {
352 stateTimerRunning = true;
353 monitorPlatformStateChange(server, conn);
354 }
355 else if ((*state == "xyz.openbmc_project.State.Chassis."
356 "PowerState.Off") &&
357 (stateTimerRunning))
358 {
359 stateTimer->cancel();
360 checkAndLogEvents();
361 stateTimerRunning = false;
362 }
363 }
AppaRao Pulie4e95652019-07-19 16:52:01 +0530364
365 // Update the D-Bus properties when chassis state changes.
366 updateDbusPropertiesCache();
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530367 }
368 });
369
370 // Capture the Host state and Start the monitor timer
371 // if state changed to 'Running'. Run timer until OS boot.
372 // Stop timer if state changed to 'Off'.
373 static auto matchHostState = sdbusplus::bus::match::match(
374 static_cast<sdbusplus::bus::bus&>(*conn),
375 "type='signal',member='PropertiesChanged', "
376 "interface='org.freedesktop.DBus.Properties', "
377 "sender='xyz.openbmc_project.State.Chassis', "
378 "arg0namespace='xyz.openbmc_project.State.Host'",
379 [&server, &conn](sdbusplus::message::message& message) {
380 std::string intfName;
381 std::map<std::string, std::variant<std::string>> properties;
382 message.read(intfName, properties);
383
384 const auto it = properties.find("CurrentHostState");
385 if (it != properties.end())
386 {
387 const std::string* state =
388 std::get_if<std::string>(&it->second);
389 if (state != nullptr)
390 {
391 if ((*state ==
392 "xyz.openbmc_project.State.Host.HostState.Running") &&
393 (!stateTimerRunning))
394 {
395 stateTimerRunning = true;
396 monitorPlatformStateChange(server, conn);
397 }
398 else if (((*state == "xyz.openbmc_project.State.Host."
399 "HostState.Off") ||
400 (*state == "xyz.openbmc_project.State.Host."
401 "HostState.Quiesced")) &&
402 (stateTimerRunning))
403 {
404 stateTimer->cancel();
405 checkAndLogEvents();
406 stateTimerRunning = false;
407 }
408 }
AppaRao Pulie4e95652019-07-19 16:52:01 +0530409
410 // Update the D-Bus properties when host state changes.
411 updateDbusPropertiesCache();
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530412 }
413 });
414
415 // Capture the OS state change and stop monitor timer
416 // if OS boots completly or becomes Inactive.
417 // start timer in other cases to mnitor states.
418 static auto matchOsState = sdbusplus::bus::match::match(
419 static_cast<sdbusplus::bus::bus&>(*conn),
420 "type='signal',member='PropertiesChanged', "
421 "interface='org.freedesktop.DBus.Properties', "
422 "sender='xyz.openbmc_project.State.Chassis', "
423 "arg0namespace='xyz.openbmc_project.State.OperatingSystem.Status'",
424 [&server, &conn](sdbusplus::message::message& message) {
425 std::string intfName;
426 std::map<std::string, std::variant<std::string>> properties;
427 message.read(intfName, properties);
428
429 const auto it = properties.find("OperatingSystemState");
430 if (it != properties.end())
431 {
432 const std::string* state =
433 std::get_if<std::string>(&it->second);
434 if (state != nullptr)
435 {
436 if (((*state == "BootComplete") ||
437 (*state == "Inactive")) &&
438 (stateTimerRunning))
439 {
440 stateTimer->cancel();
441 checkAndLogEvents();
442 stateTimerRunning = false;
443 }
444 else if (!stateTimerRunning)
445 {
446 stateTimerRunning = true;
447 monitorPlatformStateChange(server, conn);
448 }
449 }
450 }
451 });
452
453 // First time, check and log events if any.
454 checkAndLogEvents();
AppaRao Pulia9bf9712020-01-12 05:45:48 +0530455}
AppaRao Puli88aa33b2019-07-18 23:49:55 +0530456
Chalapathi Venkataramashettye6fb18e2021-02-03 14:51:00 +0000457static void updateCPLDversion(std::shared_ptr<sdbusplus::asio::connection> conn)
458{
459 std::string cpldVersion = pfr::readCPLDVersion();
460 conn->async_method_call(
461 [](const boost::system::error_code ec) {
462 if (ec)
463 {
464 phosphor::logging::log<phosphor::logging::level::ERR>(
465 "Unable to update cpld_active version",
466 phosphor::logging::entry("MSG=%s", ec.message().c_str()));
467 return;
468 }
469 },
470 "xyz.openbmc_project.Settings",
471 "/xyz/openbmc_project/software/cpld_active",
472 "org.freedesktop.DBus.Properties", "Set",
473 "xyz.openbmc_project.Software.Version", "Version",
474 std::variant<std::string>(cpldVersion));
475 return;
476}
477
AppaRao Pulidcf13122020-05-28 01:21:39 +0530478} // namespace pfr
479
AppaRao Pulia9bf9712020-01-12 05:45:48 +0530480int main()
481{
482 // setup connection to dbus
483 boost::asio::io_service io;
484 auto conn = std::make_shared<sdbusplus::asio::connection>(io);
AppaRao Pulidcf13122020-05-28 01:21:39 +0530485 pfr::stateTimer = std::make_unique<boost::asio::steady_timer>(io);
486 pfr::initTimer = std::make_unique<boost::asio::steady_timer>(io);
AppaRao Pulia9bf9712020-01-12 05:45:48 +0530487 auto server = sdbusplus::asio::object_server(conn, true);
AppaRao Pulidcf13122020-05-28 01:21:39 +0530488 pfr::monitorSignals(server, conn);
AppaRao Pulia9bf9712020-01-12 05:45:48 +0530489
Chalapathi Venkataramashettye6fb18e2021-02-03 14:51:00 +0000490 // Update CPLD Version to cpld_active object in settings.
491 pfr::updateCPLDversion(conn);
492
AppaRao Pulia9bf9712020-01-12 05:45:48 +0530493 server.add_manager("/xyz/openbmc_project/pfr");
494
495 // Create PFR attributes object and interface
AppaRao Pulidcf13122020-05-28 01:21:39 +0530496 pfr::pfrConfigObject = std::make_unique<pfr::PfrConfig>(server, conn);
AppaRao Pulia9bf9712020-01-12 05:45:48 +0530497
498 // Create Software objects using Versions interface
AppaRao Pulidcf13122020-05-28 01:21:39 +0530499 for (const auto& entry : pfr::verComponentList)
AppaRao Pulia9bf9712020-01-12 05:45:48 +0530500 {
AppaRao Pulidcf13122020-05-28 01:21:39 +0530501 pfr::pfrVersionObjects.emplace_back(std::make_unique<pfr::PfrVersion>(
AppaRao Pulia9bf9712020-01-12 05:45:48 +0530502 server, conn, std::get<0>(entry), std::get<1>(entry),
503 std::get<2>(entry)));
504 }
505
506 conn->request_name("xyz.openbmc_project.PFR.Manager");
AppaRao Pulie63eeda2019-07-05 16:25:38 +0530507 phosphor::logging::log<phosphor::logging::level::INFO>(
508 "Intel PFR service started successfully");
AppaRao Pulie63eeda2019-07-05 16:25:38 +0530509 io.run();
510
511 return 0;
512}