summaryrefslogtreecommitdiff
path: root/intel-pfr-manager
diff options
context:
space:
mode:
authorAppaRao Puli <apparao.puli@linux.intel.com>2019-07-05 13:55:38 +0300
committerAppaRao Puli <apparao.puli@linux.intel.com>2019-07-22 06:38:19 +0300
commit1cfdbe614f53ee0dc01a2a5e17ce1f873f1933bd (patch)
treeb6bfa054872ad09ee48d520d67d2c9871c34bb0e /intel-pfr-manager
parentf95328843ca04aa746f5bd8585f1d86c2ef84df7 (diff)
downloadprovingground-1cfdbe614f53ee0dc01a2a5e17ce1f873f1933bd.tar.xz
Adding intel-pfr-manager service
This commit adds the intel-pfr-manager service which creates the dbus service, objects and interfaces by reading data from CPLD. This is used to report PFR properties for use of user interfaces. 1) PFR provisioning status 2) BMC active/recovery version 3) BIOS active/recovery version 4) CPLD version Tested: Loaded new service and verified functionality using busctl. End-to-end testing will be done with redfish interface. Change-Id: I352a70fa9cb26a0e9e448e64e0b029fd18f9368a Signed-off-by: AppaRao Puli <apparao.puli@linux.intel.com>
Diffstat (limited to 'intel-pfr-manager')
-rw-r--r--intel-pfr-manager/CMakeLists.txt6
-rw-r--r--intel-pfr-manager/service/CMakeLists.txt50
-rw-r--r--intel-pfr-manager/service/inc/pfr_mgr.hpp65
-rw-r--r--intel-pfr-manager/service/src/mainapp.cpp45
-rw-r--r--intel-pfr-manager/service/src/pfr_mgr.cpp104
-rw-r--r--intel-pfr-manager/xyz.openbmc_project.Intel.PFR.Manager.service14
6 files changed, 284 insertions, 0 deletions
diff --git a/intel-pfr-manager/CMakeLists.txt b/intel-pfr-manager/CMakeLists.txt
index 970d237..ecdc2dd 100644
--- a/intel-pfr-manager/CMakeLists.txt
+++ b/intel-pfr-manager/CMakeLists.txt
@@ -3,5 +3,11 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libpfr/inc)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/service/inc)
add_subdirectory(libpfr)
+add_subdirectory(service)
+
+set(SERVICE_FILES
+ ${PROJECT_SOURCE_DIR}/xyz.openbmc_project.Intel.PFR.Manager.service)
+install(FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/)
diff --git a/intel-pfr-manager/service/CMakeLists.txt b/intel-pfr-manager/service/CMakeLists.txt
new file mode 100644
index 0000000..10377f1
--- /dev/null
+++ b/intel-pfr-manager/service/CMakeLists.txt
@@ -0,0 +1,50 @@
+cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
+project(intel-pfr-manager CXX)
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
+
+set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+
+include(GNUInstallDirs)
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc)
+
+set(SRC_FILES src/mainapp.cpp src/pfr_mgr.cpp)
+
+find_package(Boost REQUIRED)
+include_directories(${Boost_INCLUDE_DIRS})
+add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
+add_definitions(-DBOOST_SYSTEM_NO_DEPRECATED)
+add_definitions(-DBOOST_ALL_NO_LIB)
+add_definitions(-DBOOST_NO_RTTI)
+add_definitions(-DBOOST_NO_TYPEID)
+add_definitions(-DBOOST_ASIO_DISABLE_THREADS)
+
+# import libsystemd
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(SYSTEMD libsystemd REQUIRED)
+include_directories(${SYSTEMD_INCLUDE_DIRS})
+link_directories(${SYSTEMD_LIBRARY_DIRS})
+
+# import sdbusplus
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(SDBUSPLUSPLUS sdbusplus REQUIRED)
+include_directories(${SDBUSPLUSPLUS_INCLUDE_DIRS})
+link_directories(${SDBUSPLUSPLUS_LIBRARY_DIRS})
+find_program(SDBUSPLUSPLUS sdbus++)
+
+# import phosphor-logging
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(LOGGING phosphor-logging REQUIRED)
+include_directories(${LOGGING_INCLUDE_DIRS})
+link_directories(${LOGGING_LIBRARY_DIRS})
+
+add_executable(${PROJECT_NAME} ${SRC_FILES})
+target_link_libraries(${PROJECT_NAME} systemd)
+target_link_libraries(${PROJECT_NAME} "${SDBUSPLUSPLUS_LIBRARIES} -lstdc++fs")
+target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
+target_link_libraries(${PROJECT_NAME} phosphor_logging)
+target_link_libraries(${PROJECT_NAME} pfr)
+target_link_libraries(${PROJECT_NAME} i2c)
+
+install(TARGETS ${PROJECT_NAME} DESTINATION bin)
diff --git a/intel-pfr-manager/service/inc/pfr_mgr.hpp b/intel-pfr-manager/service/inc/pfr_mgr.hpp
new file mode 100644
index 0000000..d1bd7e5
--- /dev/null
+++ b/intel-pfr-manager/service/inc/pfr_mgr.hpp
@@ -0,0 +1,65 @@
+/*
+// Copyright (c) 2019 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+
+#pragma once
+
+#include <string>
+#include <sdbusplus/asio/object_server.hpp>
+#include <phosphor-logging/log.hpp>
+#include <boost/asio.hpp>
+
+namespace intel
+{
+namespace pfr
+{
+
+class PfrVersion
+{
+ public:
+ PfrVersion(sdbusplus::asio::object_server &srv_,
+ std::shared_ptr<sdbusplus::asio::connection> &conn_,
+ const std::string &path_);
+ ~PfrVersion() = default;
+
+ std::shared_ptr<sdbusplus::asio::connection> conn;
+
+ private:
+ sdbusplus::asio::object_server &server;
+
+ std::string path;
+ std::string version;
+ std::string purpose;
+};
+
+class PfrConfig
+{
+ public:
+ PfrConfig(sdbusplus::asio::object_server &srv_,
+ std::shared_ptr<sdbusplus::asio::connection> &conn_);
+ ~PfrConfig() = default;
+
+ std::shared_ptr<sdbusplus::asio::connection> conn;
+
+ private:
+ sdbusplus::asio::object_server &server;
+
+ bool getPFRProvisionedState();
+ std::string getBIOSVersion(uint8_t type);
+ std::string getBMCVersion(uint8_t type);
+};
+
+} // namespace pfr
+} // namespace intel
diff --git a/intel-pfr-manager/service/src/mainapp.cpp b/intel-pfr-manager/service/src/mainapp.cpp
new file mode 100644
index 0000000..d1f2b20
--- /dev/null
+++ b/intel-pfr-manager/service/src/mainapp.cpp
@@ -0,0 +1,45 @@
+/*
+// Copyright (c) 2019 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+
+#include "pfr_mgr.hpp"
+
+static std::array<std::string, 5> listVersionPaths = {
+ "bmc_active", "bmc_recovery", "bios_active", "bios_recovery", "cpld"};
+
+int main()
+{
+ // setup connection to dbus
+ boost::asio::io_service io;
+ auto conn = std::make_shared<sdbusplus::asio::connection>(io);
+ conn->request_name("xyz.openbmc_project.Intel.PFR.Manager");
+ auto server = sdbusplus::asio::object_server(conn, true);
+
+ // Create Intel PFR attributes object and interface
+ intel::pfr::PfrConfig obj(server, conn);
+
+ // Create Software objects using Versions interface
+ for (const auto& path : listVersionPaths)
+ {
+ intel::pfr::PfrVersion obj(server, conn, path);
+ }
+
+ phosphor::logging::log<phosphor::logging::level::INFO>(
+ "Intel PFR service started successfully");
+
+ io.run();
+
+ return 0;
+}
diff --git a/intel-pfr-manager/service/src/pfr_mgr.cpp b/intel-pfr-manager/service/src/pfr_mgr.cpp
new file mode 100644
index 0000000..91a9504
--- /dev/null
+++ b/intel-pfr-manager/service/src/pfr_mgr.cpp
@@ -0,0 +1,104 @@
+/*
+// Copyright (c) 2019 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+*/
+
+#include "pfr_mgr.hpp"
+#include "pfr.hpp"
+
+namespace intel
+{
+namespace pfr
+{
+
+static constexpr uint8_t activeImage = 0;
+static constexpr uint8_t recoveryImage = 1;
+
+PfrVersion::PfrVersion(sdbusplus::asio::object_server &srv_,
+ std::shared_ptr<sdbusplus::asio::connection> &conn_,
+ const std::string &path_) :
+ server(srv_),
+ conn(conn_), path(path_)
+{
+ if (path == "bmc_active")
+ {
+ purpose = "xyz.openbmc_project.Software.Version.VersionPurpose.BMC";
+ ImageType imgType = ImageType::bmcActive;
+ version = getVersionInfoCPLD(imgType);
+ }
+ else if (path == "bmc_recovery")
+ {
+ purpose = "xyz.openbmc_project.Software.Version.VersionPurpose.BMC";
+ ImageType imgType = ImageType::bmcRecovery;
+ version = getVersionInfoCPLD(imgType);
+ }
+ else if (path == "bios_active")
+ {
+ purpose = "xyz.openbmc_project.Software.Version.VersionPurpose.Host";
+ ImageType imgType = ImageType::biosActive;
+ version = getVersionInfoCPLD(imgType);
+ }
+ else if (path == "bios_recovery")
+ {
+ purpose = "xyz.openbmc_project.Software.Version.VersionPurpose.Host";
+ ImageType imgType = ImageType::biosRecovery;
+ version = getVersionInfoCPLD(imgType);
+ }
+ else if (path == "cpld")
+ {
+ purpose = "xyz.openbmc_project.Software.Version.VersionPurpose.Other";
+ ImageType imgType = ImageType::cpld;
+ version = getVersionInfoCPLD(imgType);
+ }
+ else
+ {
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Invalid path specified for PfrVersion");
+ return;
+ }
+
+ std::string objPath = "/xyz/openbmc_project/software/" + path;
+ auto iface =
+ server.add_interface(objPath, "xyz.openbmc_project.Software.Version");
+ iface->register_property("Purpose", purpose);
+ iface->register_property("Version", version);
+
+ iface->initialize();
+}
+
+bool PfrConfig::getPFRProvisionedState()
+{
+ bool ufmProvisioned = false;
+ bool ufmLocked = false;
+ getProvisioningStatus(ufmLocked, ufmProvisioned);
+
+ return ufmProvisioned;
+}
+
+PfrConfig::PfrConfig(sdbusplus::asio::object_server &srv_,
+ std::shared_ptr<sdbusplus::asio::connection> &conn_) :
+ server(srv_),
+ conn(conn_)
+{
+ auto pfrIntf =
+ server.add_interface("/xyz/openbmc_project/intel_pfr",
+ "xyz.openbmc_project.Intel_PFR.Attributes");
+
+ pfrIntf->register_property("provisioned_state", getPFRProvisionedState());
+
+ pfrIntf->initialize();
+}
+
+} // namespace pfr
+} // namespace intel
diff --git a/intel-pfr-manager/xyz.openbmc_project.Intel.PFR.Manager.service b/intel-pfr-manager/xyz.openbmc_project.Intel.PFR.Manager.service
new file mode 100644
index 0000000..6c270f8
--- /dev/null
+++ b/intel-pfr-manager/xyz.openbmc_project.Intel.PFR.Manager.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Daemon manages PFR dbus properties and Event logs
+
+[Service]
+Restart=always
+ExecStart=/usr/bin/env intel-pfr-manager
+RestartSec=5
+StartLimitInterval=0
+SyslogIdentifier=intel-pfr-manager
+Type=dbus
+BusName=xyz.openbmc_project.Intel.PFR.Manager
+
+[Install]
+WantedBy=multi-user.target