Adhoc fixes in pfr-manager
1) Rename intel-pfr-manager to pfr-manger for syncing
with recipe name.
2) Removed intel namespace for wider OEM's usage.
3) fix for anti-pattern in systemd service files.
Tested:
pfr-manager service works fine.
Change-Id: Ibeccf38116148dc2d270505d4197620330ab3330
Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
diff --git a/libpfr/inc/file.hpp b/libpfr/inc/file.hpp
index 6079eac..e817e7c 100644
--- a/libpfr/inc/file.hpp
+++ b/libpfr/inc/file.hpp
@@ -20,6 +20,7 @@
#include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h>
+#include <unistd.h>
#include <phosphor-logging/log.hpp>
@@ -31,8 +32,6 @@
#include <linux/i2c-dev.h>
}
-namespace intel
-{
namespace pfr
{
@@ -129,4 +128,3 @@
};
} // namespace pfr
-} // namespace intel
diff --git a/libpfr/inc/pfr.hpp b/libpfr/inc/pfr.hpp
index 704d590..730e6eb 100644
--- a/libpfr/inc/pfr.hpp
+++ b/libpfr/inc/pfr.hpp
@@ -17,8 +17,6 @@
#include <string>
-namespace intel
-{
namespace pfr
{
@@ -49,4 +47,3 @@
int setBMCBootCheckpoint(const uint8_t checkPoint);
} // namespace pfr
-} // namespace intel
diff --git a/libpfr/inc/spiDev.hpp b/libpfr/inc/spiDev.hpp
index 667318a..6a8fc35 100644
--- a/libpfr/inc/spiDev.hpp
+++ b/libpfr/inc/spiDev.hpp
@@ -21,8 +21,6 @@
#include <cstring>
#include <experimental/filesystem>
-namespace intel
-{
namespace pfr
{
@@ -93,4 +91,3 @@
};
} // namespace pfr
-} // namespace intel
diff --git a/libpfr/src/pfr.cpp b/libpfr/src/pfr.cpp
index 6ee48f9..0cfbfbf 100644
--- a/libpfr/src/pfr.cpp
+++ b/libpfr/src/pfr.cpp
@@ -19,14 +19,10 @@
#include "file.hpp"
#include "spiDev.hpp"
-#include <unistd.h>
-
#include <iomanip>
#include <iostream>
#include <sstream>
-namespace intel
-{
namespace pfr
{
// TODO: Dynamically pull these values from configuration
@@ -273,4 +269,3 @@
}
} // namespace pfr
-} // namespace intel
diff --git a/service/CMakeLists.txt b/service/CMakeLists.txt
index 10377f1..7b58e9e 100644
--- a/service/CMakeLists.txt
+++ b/service/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
-project(intel-pfr-manager CXX)
+project(pfr-manager CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
diff --git a/service/inc/pfr_mgr.hpp b/service/inc/pfr_mgr.hpp
index 8a0acf6..13091d7 100644
--- a/service/inc/pfr_mgr.hpp
+++ b/service/inc/pfr_mgr.hpp
@@ -24,8 +24,6 @@
#include <string>
-namespace intel
-{
namespace pfr
{
@@ -85,4 +83,3 @@
};
} // namespace pfr
-} // namespace intel
diff --git a/service/src/mainapp.cpp b/service/src/mainapp.cpp
index 52e0b85..790162a 100644
--- a/service/src/mainapp.cpp
+++ b/service/src/mainapp.cpp
@@ -21,6 +21,8 @@
#include <boost/asio.hpp>
+namespace pfr
+{
// Caches the last Recovery/Panic Count to
// identify any new Recovery/panic actions.
/* TODO: When BMC Reset's, these values will be lost
@@ -37,10 +39,9 @@
std::unique_ptr<boost::asio::steady_timer> stateTimer = nullptr;
std::unique_ptr<boost::asio::steady_timer> initTimer = nullptr;
-std::vector<std::unique_ptr<intel::pfr::PfrVersion>> pfrVersionObjects;
-std::unique_ptr<intel::pfr::PfrConfig> pfrConfigObject;
+std::vector<std::unique_ptr<PfrVersion>> pfrVersionObjects;
+std::unique_ptr<PfrConfig> pfrConfigObject;
-using namespace intel::pfr;
// List holds <ObjPath> <ImageType> <VersionPurpose>
static std::vector<std::tuple<std::string, ImageType, std::string>>
verComponentList = {
@@ -127,8 +128,7 @@
static void logLastRecoveryEvent()
{
uint8_t reason = 0;
- if (0 !=
- intel::pfr::readCpldReg(intel::pfr::ActionType::recoveryReason, reason))
+ if (0 != readCpldReg(ActionType::recoveryReason, reason))
{
return;
}
@@ -149,8 +149,7 @@
static void logLastPanicEvent()
{
uint8_t reason = 0;
- if (0 !=
- intel::pfr::readCpldReg(intel::pfr::ActionType::panicReason, reason))
+ if (0 != readCpldReg(ActionType::panicReason, reason))
{
return;
}
@@ -191,8 +190,7 @@
static void checkAndLogEvents()
{
uint8_t currPanicCount = 0;
- if (0 == intel::pfr::readCpldReg(intel::pfr::ActionType::panicCount,
- currPanicCount))
+ if (0 == readCpldReg(ActionType::panicCount, currPanicCount))
{
if (lastPanicCount != currPanicCount)
{
@@ -203,8 +201,7 @@
}
uint8_t currRecoveryCount = 0;
- if (0 == intel::pfr::readCpldReg(intel::pfr::ActionType::recoveryCount,
- currRecoveryCount))
+ if (0 == readCpldReg(ActionType::recoveryCount, currRecoveryCount))
{
if (lastRecoveryCount != currRecoveryCount)
{
@@ -216,10 +213,8 @@
uint8_t majorErr = 0;
uint8_t minorErr = 0;
- if ((0 == intel::pfr::readCpldReg(intel::pfr::ActionType::majorError,
- majorErr)) &&
- (0 ==
- intel::pfr::readCpldReg(intel::pfr::ActionType::minorError, minorErr)))
+ if ((0 == readCpldReg(ActionType::majorError, majorErr)) &&
+ (0 == readCpldReg(ActionType::minorError, minorErr)))
{
if ((lastMajorErr != majorErr) || (lastMinorErr != minorErr))
{
@@ -270,8 +265,7 @@
if (!finishedSettingChkPoint)
{
finishedSettingChkPoint = true;
- intel::pfr::setBMCBootCheckpoint(
- bmcBootFinishedChkPoint);
+ setBMCBootCheckpoint(bmcBootFinishedChkPoint);
}
return;
}
@@ -330,7 +324,7 @@
"PFR: BMC boot completed(StartupFinished). Setting "
"checkpoint 9.");
finishedSettingChkPoint = true;
- intel::pfr::setBMCBootCheckpoint(bmcBootFinishedChkPoint);
+ setBMCBootCheckpoint(bmcBootFinishedChkPoint);
}
});
checkAndSetCheckpoint(server, conn);
@@ -465,27 +459,29 @@
checkAndLogEvents();
}
+} // namespace pfr
+
int main()
{
// setup connection to dbus
boost::asio::io_service io;
auto conn = std::make_shared<sdbusplus::asio::connection>(io);
- stateTimer = std::make_unique<boost::asio::steady_timer>(io);
- initTimer = std::make_unique<boost::asio::steady_timer>(io);
+ pfr::stateTimer = std::make_unique<boost::asio::steady_timer>(io);
+ pfr::initTimer = std::make_unique<boost::asio::steady_timer>(io);
auto server = sdbusplus::asio::object_server(conn, true);
- monitorSignals(server, conn);
+ pfr::monitorSignals(server, conn);
auto rootInterface = server.add_interface("/xyz/openbmc_project/pfr", "");
rootInterface->initialize();
server.add_manager("/xyz/openbmc_project/pfr");
// Create PFR attributes object and interface
- pfrConfigObject = std::make_unique<intel::pfr::PfrConfig>(server, conn);
+ pfr::pfrConfigObject = std::make_unique<pfr::PfrConfig>(server, conn);
// Create Software objects using Versions interface
- for (const auto& entry : verComponentList)
+ for (const auto& entry : pfr::verComponentList)
{
- pfrVersionObjects.emplace_back(std::make_unique<intel::pfr::PfrVersion>(
+ pfr::pfrVersionObjects.emplace_back(std::make_unique<pfr::PfrVersion>(
server, conn, std::get<0>(entry), std::get<1>(entry),
std::get<2>(entry)));
}
diff --git a/service/src/pfr_mgr.cpp b/service/src/pfr_mgr.cpp
index bb31b5c..4d77c0e 100644
--- a/service/src/pfr_mgr.cpp
+++ b/service/src/pfr_mgr.cpp
@@ -16,8 +16,6 @@
#include "pfr_mgr.hpp"
-namespace intel
-{
namespace pfr
{
@@ -175,4 +173,3 @@
}
} // namespace pfr
-} // namespace intel
diff --git a/xyz.openbmc_project.PFR.Manager.service b/xyz.openbmc_project.PFR.Manager.service
index 0f33aad..100fc09 100644
--- a/xyz.openbmc_project.PFR.Manager.service
+++ b/xyz.openbmc_project.PFR.Manager.service
@@ -3,10 +3,10 @@
[Service]
Restart=always
-ExecStart=/usr/bin/env intel-pfr-manager
+ExecStart=/usr/bin/pfr-manager
RestartSec=5
StartLimitInterval=0
-SyslogIdentifier=intel-pfr-manager
+SyslogIdentifier=pfr-manager
Type=dbus
BusName=xyz.openbmc_project.PFR.Manager