diff options
author | jmbills <jason.m.bills@intel.com> | 2022-01-18 21:55:05 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-18 21:55:05 +0300 |
commit | 7cf0c1cd0ce835d1833509b7b911e8a97380278b (patch) | |
tree | 0b45c3beaa9874facc4ed1a2395a31e42be0135d /meta-openbmc-mods/meta-common/recipes-phosphor/watchdog | |
parent | 4dac5fcd49b5e2de1074f1363775ec0f19041072 (diff) | |
parent | 1fc0d70f658da30091bcd49f9bf29aecd6b99ba7 (diff) | |
download | openbmc-7cf0c1cd0ce835d1833509b7b911e8a97380278b.tar.xz |
Merge pull request #76 from Intel-BMC/update1-0.86
Update
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/watchdog')
5 files changed, 0 insertions, 457 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/watchdog/frb2-watchdog.bb b/meta-openbmc-mods/meta-common/recipes-phosphor/watchdog/frb2-watchdog.bb deleted file mode 100644 index f8ddf7892..000000000 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/watchdog/frb2-watchdog.bb +++ /dev/null @@ -1,31 +0,0 @@ - -SUMMARY = "FRB2 timer service" -DESCRIPTION = "The FRB2 timer service will monitor the mailbox register 0\ -and start a watchdog for FRB2 if the data is 1(BIOS will write this value)" - -SRC_URI = "\ - file://CMakeLists.txt;subdir=${BP} \ - file://frb2-watchdog.cpp;subdir=${BP} \ - " -PV = "0.1" - -LICENSE = "Apache-2.0" -LIC_FILES_CHKSUM = "file://${INTELBASE}/COPYING.apache-2.0;md5=34400b68072d710fecd0a2940a0d1658" - -inherit cmake -inherit pkgconfig - -DEPENDS += " \ - systemd \ - sdbusplus \ - phosphor-logging \ - phosphor-dbus-interfaces \ - boost \ - " - -RDEPENDS:${PN} += " \ - libsystemd \ - sdbusplus \ - phosphor-logging \ - phosphor-dbus-interfaces \ - " diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/watchdog/frb2-watchdog/.clang-format b/meta-openbmc-mods/meta-common/recipes-phosphor/watchdog/frb2-watchdog/.clang-format deleted file mode 100644 index dd2770837..000000000 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/watchdog/frb2-watchdog/.clang-format +++ /dev/null @@ -1,98 +0,0 @@ ---- -Language: Cpp -# BasedOnStyle: LLVM -AccessModifierOffset: -2 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlinesLeft: false -AlignOperands: true -AlignTrailingComments: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: false -BinPackArguments: true -BinPackParameters: true -BraceWrapping: - AfterClass: true - AfterControlStatement: true - AfterEnum: true - AfterFunction: true - AfterNamespace: true - AfterObjCDeclaration: true - AfterStruct: true - AfterUnion: true - BeforeCatch: true - BeforeElse: true - IndentBraces: false -BreakBeforeBinaryOperators: None -BreakBeforeBraces: Custom -BreakBeforeTernaryOperators: true -BreakConstructorInitializers: AfterColon -ColumnLimit: 80 -CommentPragmas: '^ IWYU pragma:' -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: true -DerivePointerAlignment: true -PointerAlignment: Left -DisableFormat: false -ExperimentalAutoDetectBinPacking: false -FixNamespaceComments: true -ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] -IncludeBlocks: Regroup -IncludeCategories: - - Regex: '^[<"](gtest|gmock)' - Priority: 5 - - Regex: '^"config.h"' - Priority: -1 - - Regex: '^".*\.hpp"' - Priority: 1 - - Regex: '^<.*\.h>' - Priority: 2 - - Regex: '^<.*' - Priority: 3 - - Regex: '.*' - Priority: 4 -IndentCaseLabels: true -IndentWidth: 4 -IndentWrappedFunctionNames: true -KeepEmptyLinesAtTheStartOfBlocks: true -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -ObjCBlockIndentWidth: 2 -ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: true -PenaltyBreakBeforeFirstCallParameter: 19 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakString: 1000 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 60 -PointerAlignment: Right -ReflowComments: true -SortIncludes: true -SpaceAfterCStyleCast: false -SpaceBeforeAssignmentOperators: true -SpaceBeforeParens: ControlStatements -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInContainerLiterals: true -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: Cpp11 -TabWidth: 4 -UseTab: Never -... diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/watchdog/frb2-watchdog/CMakeLists.txt b/meta-openbmc-mods/meta-common/recipes-phosphor/watchdog/frb2-watchdog/CMakeLists.txt deleted file mode 100644 index bd5567d31..000000000 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/watchdog/frb2-watchdog/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -cmake_minimum_required (VERSION 3.5 FATAL_ERROR) -project (frb2-watchdog CXX) -set (CMAKE_CXX_STANDARD 17) -set (CMAKE_CXX_STANDARD_REQUIRED ON) -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") -set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti") - -include_directories (${CMAKE_CURRENT_SOURCE_DIR}) - -# boost support -find_package (Boost REQUIRED) -# pkg_check_modules(Boost 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}) - -# import phosphor-logging -find_package (PkgConfig REQUIRED) -pkg_check_modules (LOGGING phosphor-logging REQUIRED) -include_directories (${LOGGING_INCLUDE_DIRS}) -link_directories (${LOGGING_LIBRARY_DIRS}) - -# import phosphor-dbus-interfaces -find_package (PkgConfig REQUIRED) -pkg_check_modules (DBUSINTERFACE phosphor-dbus-interfaces REQUIRED) -include_directories (${DBUSINTERFACE_INCLUDE_DIRS}) -link_directories (${DBUSINTERFACE_LIBRARY_DIRS}) - -add_executable (frb2-watchdog frb2-watchdog.cpp) - -target_link_libraries (${PROJECT_NAME} systemd) -target_link_libraries (${PROJECT_NAME} ${Boost_LIBRARIES}) -target_link_libraries (${PROJECT_NAME} ${SDBUSPLUSPLUS_LIBRARIES}) -target_link_libraries (${PROJECT_NAME} ${DBUSINTERFACE_LIBRARIES} - phosphor_logging) -install (TARGETS frb2-watchdog DESTINATION bin) diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/watchdog/frb2-watchdog/cmake-format.json b/meta-openbmc-mods/meta-common/recipes-phosphor/watchdog/frb2-watchdog/cmake-format.json deleted file mode 100644 index 583c255a3..000000000 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/watchdog/frb2-watchdog/cmake-format.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "enum_char": ".", - "line_ending": "unix", - "bullet_char": "*", - "max_subargs_per_line": 99, - "command_case": "lower", - "tab_size": 4, - "line_width": 80, - "separate_fn_name_with_space": true, - "dangle_parens": true, - "separate_ctrl_name_with_space": true -}
\ No newline at end of file diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/watchdog/frb2-watchdog/frb2-watchdog.cpp b/meta-openbmc-mods/meta-common/recipes-phosphor/watchdog/frb2-watchdog/frb2-watchdog.cpp deleted file mode 100644 index bae54f335..000000000 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/watchdog/frb2-watchdog/frb2-watchdog.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/* Copyright 2018 Intel - * - * 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 <fcntl.h> -#include <stdlib.h> -#include <sys/ioctl.h> -#include <sys/stat.h> -#include <sys/types.h> -#include <unistd.h> - -#include <boost/asio/buffers_iterator.hpp> -#include <boost/asio/deadline_timer.hpp> -#include <boost/asio/io_service.hpp> -#include <boost/asio/ip/tcp.hpp> -#include <boost/asio/posix/stream_descriptor.hpp> -#include <boost/asio/read_until.hpp> -#include <boost/asio/streambuf.hpp> -#include <boost/container/flat_set.hpp> -#include <cassert> -#include <cstdint> -#include <cstring> -#include <iostream> -#include <memory> -#include <optional> -#include <phosphor-logging/log.hpp> -#include <sdbusplus/asio/object_server.hpp> -#include <sdbusplus/bus.hpp> -#include <sdbusplus/bus/match.hpp> -#include <sdbusplus/message.hpp> -#include <sdbusplus/timer.hpp> -#include <vector> -#include <xyz/openbmc_project/State/Watchdog/server.hpp> - -void handleResponse(const boost::system::error_code &err, - std::size_t bytes_transferred); - -static int mailboxDevFd = -1; - -static boost::asio::io_service io; -static auto conn = std::make_shared<sdbusplus::asio::connection>(io); -boost::asio::ip::tcp::socket mailBoxDevSocket(io); -boost::asio::deadline_timer pollTimer(io); -boost::asio::posix::stream_descriptor inputDevice(io); - -// mailbox registre data[0:0] for FRB2 enable bit -boost::asio::streambuf readBuf(1); -std::string dataRead; - -// FRB2 watchdog timeout is 6 minutes -static constexpr unsigned int frb2TimerIntervalMs = 360 * 1000; - -// mailbox device polling time interval is 2 seconds -static constexpr unsigned int pollMs = 2000; - -static constexpr unsigned int frb2Started = 1; -static constexpr unsigned int frb2Stopped = 0; - -// FRB2 status -static uint8_t frb2Status = frb2Stopped; - -static constexpr const char *mailboxDevName = "/dev/aspeed-mbox"; - -static constexpr const char frb2Bus[] = "xyz.openbmc_project.FRB2"; -static constexpr const char frb2Obj[] = "/xyz/openbmc_project/FRB2"; -static constexpr const char frb2Intf[] = "xyz.openbmc_project.FRB2"; - -static constexpr char powerBus[] = "xyz.openbmc_project.Chassis.Control.Power"; -static constexpr char powerPath[] = - "/xyz/openbmc_project/Chassis/Control/Power0"; -static constexpr char powerIntf[] = "xyz.openbmc_project.Chassis.Control.Power"; - -static constexpr char wdBus[] = "xyz.openbmc_project.Watchdog"; -static constexpr char wdPath[] = "/xyz/openbmc_project/watchdog/host0"; -static constexpr char wdIntf[] = "xyz.openbmc_project.State.Watchdog"; -static constexpr char propIntf[] = "org.freedesktop.DBus.Properties"; - -typedef boost::asio::buffers_iterator<boost::asio::const_buffers_1> iterator; - -// check if FRB2 bit is 0x1 -std::pair<iterator, bool> matchFRB2(iterator begin, iterator end) -{ - unsigned char ch = 0; - iterator i = begin; - - while (i != end) - { - ch = static_cast<unsigned char>(*i); - if (ch & 0x1) - { - return std::make_pair(i, true); - } - i++; - } - - return std::make_pair(i, false); -} - -static void startRead() -{ - boost::asio::async_read_until(inputDevice, readBuf, matchFRB2, - [&](const boost::system::error_code &ec, - std::size_t bytes_transferred) { - handleResponse(ec, bytes_transferred); - }); -} - -template <typename T> void setProperty(const std::string &key, const T &val) -{ - phosphor::logging::log<phosphor::logging::level::DEBUG>( - "setProperty", phosphor::logging::entry("KEY=%s", key.c_str())); - - try - { - conn->async_method_call( - [](const boost::system::error_code &err) { - if (err) - { - phosphor::logging::log<phosphor::logging::level::ERR>( - "async_method_call error!", - phosphor::logging::entry( - "ERROR=%s", - boost::system::system_error(err).what())); - } - }, - wdBus, wdPath, propIntf, "Set", wdIntf, key, std::variant<T>(val)); - } - catch (sdbusplus::exception::SdBusError &e) - { - phosphor::logging::log<phosphor::logging::level::ERR>( - "Dbus error!", phosphor::logging::entry("ERROR=%s", e.what())); - } -} -void handleResponse(const boost::system::error_code &err, - std::size_t bytes_transferred) -{ - std::istream responseStream(&readBuf); - std::string response; - int n = 0; - uint64_t interval = frb2TimerIntervalMs; - - std::getline(responseStream, response); - responseStream.clear(); - - if (err == boost::system::errc::bad_file_descriptor) - { - - phosphor::logging::log<phosphor::logging::level::DEBUG>( - "bad file descriptor"); - return; // we're being destroyed - } - - if (!err) - { - // FRB2 is set by BIOS - if (frb2Stopped == frb2Status) - { - // start FRB2 watchdog - frb2Status = frb2Started; - phosphor::logging::log<phosphor::logging::level::DEBUG>( - "FRB2 enable, start FRB2 watchdog"); - setProperty( - "ExpireAction", - std::string( - "xyz.openbmc_project.State.Watchdog.Action.HardReset")); - setProperty("Interval", interval); - setProperty("TimeRemaining", interval); - setProperty("Initialized", true); - setProperty("Enabled", true); - } - } - else if (err == boost::asio::error::misc_errors::not_found) - { - // FRB2 is clear, stop FRB2 watchdog if it is started - if (frb2Started == frb2Status) - { - frb2Status = frb2Stopped; - phosphor::logging::log<phosphor::logging::level::DEBUG>( - "FRB2 is unset, stop FRB2 watchdog"); - setProperty("Enabled", false); - } - } - else - { - phosphor::logging::log<phosphor::logging::level::ERR>( - "handleResponse error!", - phosphor::logging::entry("ERROR=%s", - boost::system::system_error(err).what())); - } - - pollTimer.expires_from_now(boost::posix_time::milliseconds(pollMs)); - pollTimer.async_wait( - [](const boost::system::error_code &ec) { startRead(); }); -} - -int main(int argc, char **argv) -{ - phosphor::logging::log<phosphor::logging::level::DEBUG>( - "Monitor FRB2 signal"); - - sdbusplus::bus::match_t biosPostSignal( - static_cast<sdbusplus::bus::bus &>(*conn), - sdbusplus::bus::match::rules::type::signal() + - sdbusplus::bus::match::rules::member("PostCompleted") + - sdbusplus::bus::match::rules::path(powerPath) + - sdbusplus::bus::match::rules::interface(powerIntf), - [](sdbusplus::message::message &msg) { - uint8_t value = 0; - ssize_t rc = 0; - phosphor::logging::log<phosphor::logging::level::INFO>( - "BIOS post completed signal"); - // stop FRB2 and clean mailbox - value = 0; - rc = ::pwrite(mailboxDevFd, &value, 1, 0); - if (rc != 1) - { - phosphor::logging::log<phosphor::logging::level::ERR>( - "mailbox write error!"); - } - setProperty("Enabled", false); - frb2Status = frb2Stopped; - return; - }); - - conn->request_name(frb2Bus); - - auto server = sdbusplus::asio::object_server(conn); - - std::shared_ptr<sdbusplus::asio::dbus_interface> frb2Iface = - server.add_interface(frb2Obj, frb2Intf); - - frb2Iface->register_property("frb2Status", frb2Status); - - frb2Iface->initialize(); - - mailboxDevFd = ::open(mailboxDevName, O_RDWR | O_CLOEXEC); - if (mailboxDevFd < 0) - { - phosphor::logging::log<phosphor::logging::level::ERR>( - "mailbox device open fail!"); - return -1; - } - - inputDevice.assign(mailboxDevFd); - - startRead(); - - io.run(); - - ::close(mailboxDevFd); - - return 0; -} |