summaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
authorRichard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>2019-03-18 21:58:30 +0300
committerRichard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>2019-03-19 17:52:21 +0300
commitc927781ad3ca1408cd7fb0b7cc2538ea10ded76b (patch)
tree3e599ba9094abd5e9d9103a12d2cd635a1413ec5 /services
parent3cc86d6c536b4c5ee7afb5447837b83ce8b3d149 (diff)
downloadprovingground-c927781ad3ca1408cd7fb0b7cc2538ea10ded76b.tar.xz
Cleanup: Chassis code moved to intel-chassis-ctrl
Get rid of dead code as chassis service code in proving-ground is no longer used and moved to intel-chassis-ctrl (separate-repo) Change-Id: I4da958ce8f56625969d31339e56c3448585d0cc9 Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
Diffstat (limited to 'services')
-rw-r--r--services/chassis/Buttons/.clang-format85
-rw-r--r--services/chassis/Buttons/CMakeLists.txt151
-rw-r--r--services/chassis/Buttons/inc/Common.hpp9
-rw-r--r--services/chassis/Buttons/inc/IDButton.hpp96
-rw-r--r--services/chassis/Buttons/inc/PowerButton.hpp100
-rw-r--r--services/chassis/Buttons/inc/ResetButton.hpp96
-rw-r--r--services/chassis/Buttons/src/IDButton.cpp39
-rw-r--r--services/chassis/Buttons/src/PowerButton.cpp54
-rw-r--r--services/chassis/Buttons/src/ResetButton.cpp39
-rw-r--r--services/chassis/Buttons/src/main.cpp70
-rw-r--r--services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/ID.errors.yaml9
-rw-r--r--services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/ID.interface.yaml24
-rw-r--r--services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/Power.errors.yaml9
-rw-r--r--services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/Power.interface.yaml51
-rw-r--r--services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/Reset.errors.yaml9
-rw-r--r--services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/Reset.interface.yaml24
-rw-r--r--services/chassis/CMakeLists.txt12
-rw-r--r--services/chassis/ChassisControl/CMakeLists.txt87
-rw-r--r--services/chassis/ChassisControl/inc/ChassisControl.hpp82
-rw-r--r--services/chassis/ChassisControl/src/ChassisControl.cpp107
-rw-r--r--services/chassis/ChassisControl/src/main.cpp59
-rw-r--r--services/chassis/ChassisControl/xyz/openbmc_project/Chassis/Control/Chassis.errors.yaml9
-rw-r--r--services/chassis/ChassisControl/xyz/openbmc_project/Chassis/Control/Chassis.interface.yaml94
-rw-r--r--services/chassis/Gpio/.clang-format85
-rw-r--r--services/chassis/Gpio/CMakeLists.txt14
-rw-r--r--services/chassis/Gpio/inc/Gpio.hpp3
-rw-r--r--services/chassis/Gpio/src/Gpio.cpp178
-rw-r--r--services/chassis/I2c/.clang-format85
-rw-r--r--services/chassis/I2c/CMakeLists.txt14
-rw-r--r--services/chassis/I2c/inc/I2c.hpp4
-rw-r--r--services/chassis/I2c/src/I2c.cpp83
-rw-r--r--services/chassis/PowerControl/.clang-format98
-rw-r--r--services/chassis/PowerControl/CMakeLists.txt97
-rw-r--r--services/chassis/PowerControl/inc/PowerControl.hpp139
-rw-r--r--services/chassis/PowerControl/inc/timer.hpp147
-rw-r--r--services/chassis/PowerControl/src/PowerControl.cpp110
-rw-r--r--services/chassis/PowerControl/src/main.cpp61
-rw-r--r--services/chassis/PowerControl/src/timer.cpp129
-rw-r--r--services/chassis/PowerControl/tests/inc/timer_test.hpp40
-rw-r--r--services/chassis/PowerControl/tests/src/timer_test.cpp72
-rw-r--r--services/chassis/PowerControl/xyz/openbmc_project/Chassis/Control/Power.errors.yaml9
-rw-r--r--services/chassis/PowerControl/xyz/openbmc_project/Chassis/Control/Power.interface.yaml88
42 files changed, 0 insertions, 2771 deletions
diff --git a/services/chassis/Buttons/.clang-format b/services/chassis/Buttons/.clang-format
deleted file mode 100644
index bbc1bb1..0000000
--- a/services/chassis/Buttons/.clang-format
+++ /dev/null
@@ -1,85 +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 ]
-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: false
-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/services/chassis/Buttons/CMakeLists.txt b/services/chassis/Buttons/CMakeLists.txt
deleted file mode 100644
index 7421972..0000000
--- a/services/chassis/Buttons/CMakeLists.txt
+++ /dev/null
@@ -1,151 +0,0 @@
-cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)
-project(Buttons CXX)
-set(CMAKE_CXX_STANDARD 14)
-set(CMAKE_CXX_STANDARD_REQUIRED ON)
-
-set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
-set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
-
-include(GNUInstallDirs)
-
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc)
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-set(POWER_DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Buttons/Power")
-set(POWER_DBUS_INTF_NAME "xyz.openbmc_project.Chassis.Buttons.Power")
-
-set(RESET_DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Buttons/Reset")
-set(RESET_DBUS_INTF_NAME "xyz.openbmc_project.Chassis.Buttons.Reset")
-
-set(ID_DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Buttons/ID")
-set(ID_DBUS_INTF_NAME "xyz.openbmc_project.Chassis.Buttons.ID")
-
-add_definitions(-DPOWER_DBUS_OBJECT_NAME="/${POWER_DBUS_OBJECT_NAME}0")
-add_definitions(-DRESET_DBUS_OBJECT_NAME="/${RESET_DBUS_OBJECT_NAME}0")
-add_definitions(-DID_DBUS_OBJECT_NAME="/${ID_DBUS_OBJECT_NAME}0")
-
-set(SRC_FILES
- src/PowerButton.cpp
- src/ResetButton.cpp
- src/IDButton.cpp
- src/main.cpp
-)
-set(GENERATED_SRC_FILES
- ${POWER_DBUS_OBJECT_NAME}/error.cpp
- ${POWER_DBUS_OBJECT_NAME}/server.cpp
- ${RESET_DBUS_OBJECT_NAME}/error.cpp
- ${RESET_DBUS_OBJECT_NAME}/server.cpp
- ${ID_DBUS_OBJECT_NAME}/error.cpp
- ${ID_DBUS_OBJECT_NAME}/server.cpp
-)
-
-# 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})
-
-# 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})
-
-#include_directories(${CMAKE_CURRENT_BINARY_DIR}/${DBUS_OBJECT_NAME})
-
-add_custom_command(
- OUTPUT ${ID_DBUS_OBJECT_NAME}/error.hpp
- OUTPUT ${ID_DBUS_OBJECT_NAME}/error.cpp
- COMMAND mkdir -p ${ID_DBUS_OBJECT_NAME}
- COMMAND ${SDBUSPLUSPLUS} -r ${CMAKE_CURRENT_SOURCE_DIR} error exception-header ${ID_DBUS_INTF_NAME} > ${ID_DBUS_OBJECT_NAME}/error.hpp
- COMMAND ${SDBUSPLUSPLUS} -r ${CMAKE_CURRENT_SOURCE_DIR} error exception-cpp ${ID_DBUS_INTF_NAME} > ${ID_DBUS_OBJECT_NAME}/error.cpp
- DEPENDS ${ID_DBUS_OBJECT_NAME}.errors.yaml
-)
-set_source_files_properties(
- ${ID_DBUS_OBJECT_NAME}/error.hpp
- ${ID_DBUS_OBJECT_NAME}/error.cpp
- PROPERTIES GENERATED TRUE)
-
-add_custom_command(
- OUTPUT ${POWER_DBUS_OBJECT_NAME}/error.hpp
- OUTPUT ${POWER_DBUS_OBJECT_NAME}/error.cpp
- COMMAND mkdir -p ${POWER_DBUS_OBJECT_NAME}
- COMMAND ${SDBUSPLUSPLUS} -r ${CMAKE_CURRENT_SOURCE_DIR} error exception-header ${POWER_DBUS_INTF_NAME} > ${POWER_DBUS_OBJECT_NAME}/error.hpp
- COMMAND ${SDBUSPLUSPLUS} -r ${CMAKE_CURRENT_SOURCE_DIR} error exception-cpp ${POWER_DBUS_INTF_NAME} > ${POWER_DBUS_OBJECT_NAME}/error.cpp
- DEPENDS ${POWER_DBUS_OBJECT_NAME}.errors.yaml
-)
-set_source_files_properties(
- ${POWER_DBUS_OBJECT_NAME}/error.hpp
- ${POWER_DBUS_OBJECT_NAME}/error.cpp
- PROPERTIES GENERATED TRUE)
-
-add_custom_command(
- OUTPUT ${RESET_DBUS_OBJECT_NAME}/error.hpp
- OUTPUT ${RESET_DBUS_OBJECT_NAME}/error.cpp
- COMMAND mkdir -p ${RESET_DBUS_OBJECT_NAME}
- COMMAND ${SDBUSPLUSPLUS} -r ${CMAKE_CURRENT_SOURCE_DIR} error exception-header ${RESET_DBUS_INTF_NAME} > ${RESET_DBUS_OBJECT_NAME}/error.hpp
- COMMAND ${SDBUSPLUSPLUS} -r ${CMAKE_CURRENT_SOURCE_DIR} error exception-cpp ${RESET_DBUS_INTF_NAME} > ${RESET_DBUS_OBJECT_NAME}/error.cpp
- DEPENDS ${RESET_DBUS_OBJECT_NAME}.errors.yaml
-)
-set_source_files_properties(
- ${RESET_DBUS_OBJECT_NAME}/error.hpp
- ${RESET_DBUS_OBJECT_NAME}/error.cpp
- PROPERTIES GENERATED TRUE)
-
-add_custom_command(
- OUTPUT ${ID_DBUS_OBJECT_NAME}/server.hpp
- OUTPUT ${ID_DBUS_OBJECT_NAME}/server.cpp
- COMMAND mkdir -p ${ID_DBUS_OBJECT_NAME}
- COMMAND ${SDBUSPLUSPLUS} -r ${CMAKE_CURRENT_SOURCE_DIR} interface server-header ${ID_DBUS_INTF_NAME} > ${ID_DBUS_OBJECT_NAME}/server.hpp
- COMMAND ${SDBUSPLUSPLUS} -r ${CMAKE_CURRENT_SOURCE_DIR} interface server-cpp ${ID_DBUS_INTF_NAME} > ${ID_DBUS_OBJECT_NAME}/server.cpp
- DEPENDS ${ID_DBUS_OBJECT_NAME}.interface.yaml
-)
-set_source_files_properties(
- ${POWER_DBUS_OBJECT_NAME}/server.hpp
- ${POWER_DBUS_OBJECT_NAME}/server.cpp
- PROPERTIES GENERATED TRUE)
-
-add_custom_command(
- OUTPUT ${POWER_DBUS_OBJECT_NAME}/server.hpp
- OUTPUT ${POWER_DBUS_OBJECT_NAME}/server.cpp
- COMMAND mkdir -p ${POWER_DBUS_OBJECT_NAME}
- COMMAND ${SDBUSPLUSPLUS} -r ${CMAKE_CURRENT_SOURCE_DIR} interface server-header ${POWER_DBUS_INTF_NAME} > ${POWER_DBUS_OBJECT_NAME}/server.hpp
- COMMAND ${SDBUSPLUSPLUS} -r ${CMAKE_CURRENT_SOURCE_DIR} interface server-cpp ${POWER_DBUS_INTF_NAME} > ${POWER_DBUS_OBJECT_NAME}/server.cpp
- DEPENDS ${POWER_DBUS_OBJECT_NAME}.interface.yaml
-)
-set_source_files_properties(
- ${POWER_DBUS_OBJECT_NAME}/server.hpp
- ${POWER_DBUS_OBJECT_NAME}/server.cpp
- PROPERTIES GENERATED TRUE)
-
-add_custom_command(
- OUTPUT ${RESET_DBUS_OBJECT_NAME}/server.hpp
- OUTPUT ${RESET_DBUS_OBJECT_NAME}/server.cpp
- COMMAND mkdir -p ${RESET_DBUS_OBJECT_NAME}
- COMMAND ${SDBUSPLUSPLUS} -r ${CMAKE_CURRENT_SOURCE_DIR} interface server-header ${RESET_DBUS_INTF_NAME} > ${RESET_DBUS_OBJECT_NAME}/server.hpp
- COMMAND ${SDBUSPLUSPLUS} -r ${CMAKE_CURRENT_SOURCE_DIR} interface server-cpp ${RESET_DBUS_INTF_NAME} > ${RESET_DBUS_OBJECT_NAME}/server.cpp
- DEPENDS ${RESET_DBUS_OBJECT_NAME}.interface.yaml
-)
-set_source_files_properties(
- ${RESET_DBUS_OBJECT_NAME}/server.hpp
- ${RESET_DBUS_OBJECT_NAME}/server.cpp
- PROPERTIES GENERATED TRUE)
-
-add_executable(${PROJECT_NAME} ${SRC_FILES} ${GENERATED_SRC_FILES})
-target_link_libraries(${PROJECT_NAME} ${SYSTEMD_LIBRARIES} gpio)
-target_link_libraries(${PROJECT_NAME} "${SDBUSPLUSPLUS_LIBRARIES} -lstdc++fs")
-
-install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/services/chassis/Buttons/inc/Common.hpp b/services/chassis/Buttons/inc/Common.hpp
deleted file mode 100644
index b7651ec..0000000
--- a/services/chassis/Buttons/inc/Common.hpp
+++ /dev/null
@@ -1,9 +0,0 @@
-#pragma once
-struct EventDeleter
-{
- void operator()(sd_event *event) const
- {
- event = sd_event_unref(event);
- }
-};
-using EventPtr = std::unique_ptr<sd_event, EventDeleter>; \ No newline at end of file
diff --git a/services/chassis/Buttons/inc/IDButton.hpp b/services/chassis/Buttons/inc/IDButton.hpp
deleted file mode 100644
index d050dce..0000000
--- a/services/chassis/Buttons/inc/IDButton.hpp
+++ /dev/null
@@ -1,96 +0,0 @@
-#pragma once
-#include "xyz/openbmc_project/Chassis/Buttons/ID/error.hpp"
-#include "xyz/openbmc_project/Chassis/Buttons/ID/server.hpp"
-#include "Common.hpp"
-#include "Gpio.hpp"
-
-const static constexpr char *ID_BUTTON = "ID_BTN";
-
-struct IDButton
- : sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::ID>
-{
-
- IDButton(sdbusplus::bus::bus &bus, const char *path, EventPtr &event,
- sd_event_io_handler_t handler = IDButton::EventHandler) :
- sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::ID>(
- bus, path),
- fd(-1), bus(bus), event(event), callbackHandler(handler)
- {
-
- int ret;
-
- // config gpio
- ret = ::configGpio(ID_BUTTON, &fd, bus);
- if (ret < 0)
- {
- throw std::runtime_error("failed to config GPIO");
- }
-
- ret = sd_event_add_io(event.get(), nullptr, fd, EPOLLPRI,
- callbackHandler, this);
- if (ret < 0)
- {
- throw std::runtime_error("failed to add to event loop");
- }
- }
-
- ~IDButton()
- {
- ::closeGpio(fd);
- }
- bool simPress() override;
- static int EventHandler(sd_event_source *es, int fd, uint32_t revents,
- void *userdata)
- {
-
- int n;
- char buf;
-
- IDButton *idButton = static_cast<IDButton *>(userdata);
-
- if (!idButton)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "null pointer!");
- return -1;
- }
-
- n = ::lseek(fd, 0, SEEK_SET);
-
- if (n < 0)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "lseek error!");
- return n;
- }
-
- n = ::read(fd, &buf, 1);
- if (n < 0)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "read error!");
- return n;
- }
-
- if (buf == '0')
- {
- // emit pressed signal
- idButton->pressed();
- }
- else
- {
- // released
- idButton->released();
- }
-
- return 0;
- }
-
- private:
- int fd;
- sdbusplus::bus::bus &bus;
- EventPtr &event;
- sd_event_io_handler_t callbackHandler;
-};
diff --git a/services/chassis/Buttons/inc/PowerButton.hpp b/services/chassis/Buttons/inc/PowerButton.hpp
deleted file mode 100644
index 4feb5f4..0000000
--- a/services/chassis/Buttons/inc/PowerButton.hpp
+++ /dev/null
@@ -1,100 +0,0 @@
-#pragma once
-#include "xyz/openbmc_project/Chassis/Buttons/Power/error.hpp"
-#include "xyz/openbmc_project/Chassis/Buttons/Power/server.hpp"
-#include "Common.hpp"
-#include "Gpio.hpp"
-
-const static constexpr char *POWER_BUTTON = "POWER_BUTTON";
-
-struct PowerButton
- : sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Power>
-{
-
- PowerButton(sdbusplus::bus::bus &bus, const char *path, EventPtr &event,
- sd_event_io_handler_t handler = PowerButton::EventHandler) :
- sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Power>(
- bus, path),
- fd(-1), bus(bus), event(event), callbackHandler(handler)
- {
-
- int ret;
-
- // config gpio
- ret = ::configGpio(POWER_BUTTON, &fd, bus);
- if (ret < 0)
- {
- throw std::runtime_error("failed to config GPIO");
- }
-
- ret = sd_event_add_io(event.get(), nullptr, fd, EPOLLPRI,
- callbackHandler, this);
- if (ret < 0)
- {
- throw std::runtime_error("failed to add to event loop");
- }
- }
-
- ~PowerButton()
- {
- ::closeGpio(fd);
- }
- bool simPress() override;
- bool simLongPress() override;
- static int EventHandler(sd_event_source *es, int fd, uint32_t revents,
- void *userdata)
- {
-
- int n;
- char buf;
-
- PowerButton *powerButton = static_cast<PowerButton *>(userdata);
-
- if (!powerButton)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "null pointer!");
- return -1;
- }
-
- n = ::lseek(fd, 0, SEEK_SET);
-
- if (n < 0)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "lseek error!");
- return n;
- }
-
- n = ::read(fd, &buf, 1);
- if (n < 0)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "read error!");
- return n;
- }
-
- phosphor::logging::log<phosphor::logging::level::DEBUG>(
- "PowerButton event", phosphor::logging::entry("BUF=%c", buf));
-
- if (buf == '0')
- {
- // emit pressed signal
- powerButton->pressed();
- }
- else
- {
- // released
- powerButton->released();
- }
-
- return 0;
- }
-
- private:
- int fd;
- sdbusplus::bus::bus &bus;
- EventPtr &event;
- sd_event_io_handler_t callbackHandler;
-};
diff --git a/services/chassis/Buttons/inc/ResetButton.hpp b/services/chassis/Buttons/inc/ResetButton.hpp
deleted file mode 100644
index f5f1aa7..0000000
--- a/services/chassis/Buttons/inc/ResetButton.hpp
+++ /dev/null
@@ -1,96 +0,0 @@
-#pragma once
-#include "xyz/openbmc_project/Chassis/Buttons/Reset/error.hpp"
-#include "xyz/openbmc_project/Chassis/Buttons/Reset/server.hpp"
-#include "Common.hpp"
-#include "Gpio.hpp"
-
-const static constexpr char *RESET_BUTTON = "RESET_BUTTON";
-
-struct ResetButton
- : sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Reset>
-{
-
- ResetButton(sdbusplus::bus::bus &bus, const char *path, EventPtr &event,
- sd_event_io_handler_t handler = ResetButton::EventHandler) :
- sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Reset>(
- bus, path),
- fd(-1), bus(bus), event(event), callbackHandler(handler)
- {
-
- int ret;
-
- // config gpio
- ret = ::configGpio(RESET_BUTTON, &fd, bus);
- if (ret < 0)
- {
- throw std::runtime_error("failed to config GPIO");
- }
-
- ret = sd_event_add_io(event.get(), nullptr, fd, EPOLLPRI,
- callbackHandler, this);
- if (ret < 0)
- {
- throw std::runtime_error("failed to add to event loop");
- }
- }
-
- ~ResetButton()
- {
- ::closeGpio(fd);
- }
- bool simPress() override;
- static int EventHandler(sd_event_source *es, int fd, uint32_t revents,
- void *userdata)
- {
-
- int n;
- char buf;
-
- ResetButton *resetButton = static_cast<ResetButton *>(userdata);
-
- if (!resetButton)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "null pointer!");
- return -1;
- }
-
- n = ::lseek(fd, 0, SEEK_SET);
-
- if (n < 0)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "lseek error!");
- return n;
- }
-
- n = ::read(fd, &buf, 1);
- if (n < 0)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "read error!");
- return n;
- }
-
- if (buf == '0')
- {
- // emit pressed signal
- resetButton->pressed();
- }
- else
- {
- // released
- resetButton->released();
- }
-
- return 0;
- }
-
- private:
- int fd;
- sdbusplus::bus::bus &bus;
- EventPtr &event;
- sd_event_io_handler_t callbackHandler;
-};
diff --git a/services/chassis/Buttons/src/IDButton.cpp b/services/chassis/Buttons/src/IDButton.cpp
deleted file mode 100644
index 30f6157..0000000
--- a/services/chassis/Buttons/src/IDButton.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-// Copyright (c) 2018 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 <chrono>
-#include <experimental/filesystem>
-#include <fcntl.h>
-#include <fstream>
-#include <iostream>
-#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/log.hpp>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <systemd/sd-event.h>
-#include <unistd.h>
-#include <xyz/openbmc_project/Common/error.hpp>
-#include "IDButton.hpp"
-
-const static constexpr char *SYSMGR_SERVICE = "org.openbmc.managers.System";
-const static constexpr char *SYSMGR_OBJ_PATH = "/org/openbmc/managers/System";
-const static constexpr char *SYSMGR_INTERFACE = "org.openbmc.managers.System";
-
-bool IDButton::simPress()
-{
- pressed();
- return true;
-} \ No newline at end of file
diff --git a/services/chassis/Buttons/src/PowerButton.cpp b/services/chassis/Buttons/src/PowerButton.cpp
deleted file mode 100644
index 79f9f83..0000000
--- a/services/chassis/Buttons/src/PowerButton.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-// Copyright (c) 2018 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 <chrono>
-#include <experimental/filesystem>
-#include <fcntl.h>
-#include <fstream>
-#include <iostream>
-#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/log.hpp>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <systemd/sd-event.h>
-#include <unistd.h>
-#include <xyz/openbmc_project/Common/error.hpp>
-#include "PowerButton.hpp"
-
-const static constexpr char *SYSMGR_SERVICE = "org.openbmc.managers.System";
-const static constexpr char *SYSMGR_OBJ_PATH = "/org/openbmc/managers/System";
-const static constexpr char *SYSMGR_INTERFACE = "org.openbmc.managers.System";
-
-static constexpr size_t LONG_PRESS_MS = 6000;
-
-bool PowerButton::simPress()
-{
- uint64_t currentTimeMs =
- std::chrono::duration_cast<std::chrono::milliseconds>(
- std::chrono::steady_clock::now().time_since_epoch())
- .count();
- pressedTime(currentTimeMs);
- buttonState(false);
- pressed();
- return true;
-}
-
-bool PowerButton::simLongPress()
-{
- buttonState(true);
- pressedLong();
- return true;
-} \ No newline at end of file
diff --git a/services/chassis/Buttons/src/ResetButton.cpp b/services/chassis/Buttons/src/ResetButton.cpp
deleted file mode 100644
index d299fee..0000000
--- a/services/chassis/Buttons/src/ResetButton.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-// Copyright (c) 2018 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 <chrono>
-#include <experimental/filesystem>
-#include <fcntl.h>
-#include <fstream>
-#include <iostream>
-#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/log.hpp>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <systemd/sd-event.h>
-#include <unistd.h>
-#include <xyz/openbmc_project/Common/error.hpp>
-#include "ResetButton.hpp"
-
-const static constexpr char *SYSMGR_SERVICE = "org.openbmc.managers.System";
-const static constexpr char *SYSMGR_OBJ_PATH = "/org/openbmc/managers/System";
-const static constexpr char *SYSMGR_INTERFACE = "org.openbmc.managers.System";
-
-bool ResetButton::simPress()
-{
- pressed();
- return true;
-} \ No newline at end of file
diff --git a/services/chassis/Buttons/src/main.cpp b/services/chassis/Buttons/src/main.cpp
deleted file mode 100644
index 24e6189..0000000
--- a/services/chassis/Buttons/src/main.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-#include <chrono>
-#include <experimental/filesystem>
-#include <fcntl.h>
-#include <fstream>
-#include <iostream>
-#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/log.hpp>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <systemd/sd-event.h>
-#include <unistd.h>
-#include <xyz/openbmc_project/Common/error.hpp>
-#include "ResetButton.hpp"
-#include "PowerButton.hpp"
-#include "IDButton.hpp"
-
-int main(int argc, char *argv[])
-{
- int ret = 0;
-
- phosphor::logging::log<phosphor::logging::level::INFO>(
- "Start power button service...");
-
- sd_event *event = nullptr;
- ret = sd_event_default(&event);
- if (ret < 0)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "Error creating a default sd_event handler");
- return ret;
- }
- EventPtr eventP{event};
- event = nullptr;
-
- auto bus = sdbusplus::bus::new_default();
- sdbusplus::server::manager::manager objManager{
- bus, "/xyz/openbmc_project/Chassis/Buttons"};
-
- bus.request_name("xyz.openbmc_project.Chassis.Buttons");
-
- PowerButton powerButton{bus, POWER_DBUS_OBJECT_NAME, eventP};
-
- ResetButton resetButton{bus, RESET_DBUS_OBJECT_NAME, eventP};
-
- IDButton idButton{bus, ID_DBUS_OBJECT_NAME, eventP};
-
- try
- {
- bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL);
-
- while (true)
- {
- ret = sd_event_run(eventP.get(), (uint64_t)-1);
- if (ret < 0)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "Error waiting for events");
- break;
- }
- }
- }
-
- catch (std::exception &e)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
- ret = -1;
- }
- return ret;
-}
diff --git a/services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/ID.errors.yaml b/services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/ID.errors.yaml
deleted file mode 100644
index 9de4b9d..0000000
--- a/services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/ID.errors.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-- name: UnsupportedCommand
- description: >
- An unsupported command was attempted.
-- name: InvalidParameter
- description: >
- An invalid parameter was attempted.
-- name: IOError
- description: >
- An IO error occurred.
diff --git a/services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/ID.interface.yaml b/services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/ID.interface.yaml
deleted file mode 100644
index e25942f..0000000
--- a/services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/ID.interface.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
-description: >
- ID button control service
-methods:
- - name: simPress
- description: >
- emulate ID button press.
- returns:
- - name: state
- type: boolean
- description: >
- The result of command.
- errors:
- - self.Error.UnsupportedCommand
- - self.Error.InvalidParameter
- - self.Error.IOError
-
-
-signals:
- - name: Released
- description: >
- ID button release signal
- - name: Pressed
- description: >
- ID button pressed signal
diff --git a/services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/Power.errors.yaml b/services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/Power.errors.yaml
deleted file mode 100644
index 9de4b9d..0000000
--- a/services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/Power.errors.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-- name: UnsupportedCommand
- description: >
- An unsupported command was attempted.
-- name: InvalidParameter
- description: >
- An invalid parameter was attempted.
-- name: IOError
- description: >
- An IO error occurred.
diff --git a/services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/Power.interface.yaml b/services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/Power.interface.yaml
deleted file mode 100644
index e361ce7..0000000
--- a/services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/Power.interface.yaml
+++ /dev/null
@@ -1,51 +0,0 @@
-description: >
- power button control service
-methods:
- - name: simPress
- description: >
- emulate power button press.
- returns:
- - name: state
- type: boolean
- description: >
- The result of command.
- errors:
- - self.Error.UnsupportedCommand
- - self.Error.InvalidParameter
- - self.Error.IOError
-
- - name: simLongPress
- description: >
- emulate power button long press.
- returns:
- - name: state
- type: boolean
- description: >
- The result of command.
- errors:
- - self.Error.UnsupportedCommand
- - self.Error.InvalidParameter
- - self.Error.IOError
-
-properties:
- - name: ButtonState
- type: boolean
- default: 0
- description: >
- power button value
-
- - name: PressedTime
- type: uint64
- default: 0
- description: >
- when power button is pressed
-signals:
- - name: Released
- description: >
- power button release signal
- - name: Pressed
- description: >
- power button pressed signal
- - name: PressedLong
- description: >
- power button long pressed signal
diff --git a/services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/Reset.errors.yaml b/services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/Reset.errors.yaml
deleted file mode 100644
index 9de4b9d..0000000
--- a/services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/Reset.errors.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-- name: UnsupportedCommand
- description: >
- An unsupported command was attempted.
-- name: InvalidParameter
- description: >
- An invalid parameter was attempted.
-- name: IOError
- description: >
- An IO error occurred.
diff --git a/services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/Reset.interface.yaml b/services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/Reset.interface.yaml
deleted file mode 100644
index 700583f..0000000
--- a/services/chassis/Buttons/xyz/openbmc_project/Chassis/Buttons/Reset.interface.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
-description: >
- reset button control service
-methods:
- - name: simPress
- description: >
- emulate reset button press.
- returns:
- - name: state
- type: boolean
- description: >
- The result of command.
- errors:
- - self.Error.UnsupportedCommand
- - self.Error.InvalidParameter
- - self.Error.IOError
-
-
-signals:
- - name: Released
- description: >
- reset button release signal
- - name: Pressed
- description: >
- reset button pressed signal
diff --git a/services/chassis/CMakeLists.txt b/services/chassis/CMakeLists.txt
deleted file mode 100644
index f46dc63..0000000
--- a/services/chassis/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)
-set(CMAKE_CXX_STANDARD 14)
-set(CMAKE_CXX_STANDARD_REQUIRED ON)
-
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Gpio/inc)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/I2c/inc)
-
-add_subdirectory(Gpio)
-add_subdirectory(I2c)
-add_subdirectory(Buttons)
-add_subdirectory(ChassisControl)
-add_subdirectory(PowerControl)
diff --git a/services/chassis/ChassisControl/CMakeLists.txt b/services/chassis/ChassisControl/CMakeLists.txt
deleted file mode 100644
index 48224c6..0000000
--- a/services/chassis/ChassisControl/CMakeLists.txt
+++ /dev/null
@@ -1,87 +0,0 @@
-cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)
-project(ChassisControl CXX)
-set(CMAKE_CXX_STANDARD 14)
-set(CMAKE_CXX_STANDARD_REQUIRED ON)
-
-set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
-set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
-
-include(GNUInstallDirs)
-
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc)
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-set(DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Control/Chassis")
-set(DBUS_INTF_NAME "xyz.openbmc_project.Chassis.Control.Chassis")
-
-add_definitions(-DDBUS_OBJECT_NAME="/${DBUS_OBJECT_NAME}0")
-add_definitions(-DDBUS_INTF_NAME="${DBUS_INTF_NAME}")
-
-set(SRC_FILES
- src/ChassisControl.cpp
- src/main.cpp
-)
-set(GENERATED_SRC_FILES
- ${DBUS_OBJECT_NAME}/error.cpp
- ${DBUS_OBJECT_NAME}/server.cpp
-)
-
-# 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})
-
-# 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})
-
-#include_directories(${CMAKE_CURRENT_BINARY_DIR}/${DBUS_OBJECT_NAME})
-
-add_custom_command(
- OUTPUT ${DBUS_OBJECT_NAME}/error.hpp
- OUTPUT ${DBUS_OBJECT_NAME}/error.cpp
- COMMAND mkdir -p ${DBUS_OBJECT_NAME}
- COMMAND ${SDBUSPLUSPLUS} -r ${CMAKE_CURRENT_SOURCE_DIR} error exception-header ${DBUS_INTF_NAME} > ${DBUS_OBJECT_NAME}/error.hpp
- COMMAND ${SDBUSPLUSPLUS} -r ${CMAKE_CURRENT_SOURCE_DIR} error exception-cpp ${DBUS_INTF_NAME} > ${DBUS_OBJECT_NAME}/error.cpp
- DEPENDS ${DBUS_OBJECT_NAME}.errors.yaml
-)
-set_source_files_properties(
- ${DBUS_OBJECT_NAME}/error.hpp
- ${DBUS_OBJECT_NAME}/error.cpp
- PROPERTIES GENERATED TRUE)
-
-
-add_custom_command(
- OUTPUT ${DBUS_OBJECT_NAME}/server.hpp
- OUTPUT ${DBUS_OBJECT_NAME}/server.cpp
- COMMAND mkdir -p ${DBUS_OBJECT_NAME}
- COMMAND ${SDBUSPLUSPLUS} -r ${CMAKE_CURRENT_SOURCE_DIR} interface server-header ${DBUS_INTF_NAME} > ${DBUS_OBJECT_NAME}/server.hpp
- COMMAND ${SDBUSPLUSPLUS} -r ${CMAKE_CURRENT_SOURCE_DIR} interface server-cpp ${DBUS_INTF_NAME} > ${DBUS_OBJECT_NAME}/server.cpp
- DEPENDS ${DBUS_OBJECT_NAME}.interface.yaml
-)
-set_source_files_properties(
- ${DBUS_OBJECT_NAME}/server.hpp
- ${DBUS_OBJECT_NAME}/server.cpp
- PROPERTIES GENERATED TRUE)
-
-
-add_executable(${PROJECT_NAME} ${SRC_FILES} ${GENERATED_SRC_FILES})
-target_link_libraries(${PROJECT_NAME} "${SDBUSPLUSPLUS_LIBRARIES} -lstdc++fs")
-
-install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/services/chassis/ChassisControl/inc/ChassisControl.hpp b/services/chassis/ChassisControl/inc/ChassisControl.hpp
deleted file mode 100644
index f88708d..0000000
--- a/services/chassis/ChassisControl/inc/ChassisControl.hpp
+++ /dev/null
@@ -1,82 +0,0 @@
-#pragma once
-#include "xyz/openbmc_project/Chassis/Control/Chassis/error.hpp"
-#include "xyz/openbmc_project/Chassis/Control/Chassis/server.hpp"
-#include <phosphor-logging/log.hpp>
-#include <systemd/sd-event.h>
-
-constexpr auto POWER_BUTTON_PATH =
- "/xyz/openbmc_project/Chassis/Buttons/Power0";
-constexpr auto POWER_BUTTON_INTF = "xyz.openbmc_project.Chassis.Buttons.Power";
-constexpr auto RESET_BUTTON_PATH =
- "/xyz/openbmc_project/Chassis/Buttons/Reset0";
-constexpr auto RESET_BUTTON_INTF = "xyz.openbmc_project.Chassis.Buttons.Reset";
-
-const static int32_t POWER_OFF = 0;
-const static int32_t POWER_ON = 1;
-namespace sdbusRule = sdbusplus::bus::match::rules;
-
-struct EventDeleter {
- void operator()(sd_event *event) const { event = sd_event_unref(event); }
-};
-
-using EventPtr = std::unique_ptr<sd_event, EventDeleter>;
-
-struct ChassisControl
- : sdbusplus::server::object_t<
- sdbusplus::xyz::openbmc_project::Chassis::Control::server::Chassis> {
- ChassisControl(sdbusplus::bus::bus &bus, const char *path, EventPtr &event)
- : sdbusplus::server::object_t<
- sdbusplus::xyz::openbmc_project::Chassis::Control::server::Chassis>(
- bus, path),
- mBus(bus),
- powerButtonPressedSignal(
- bus,
- sdbusRule::type::signal() + sdbusRule::member("Pressed") +
- sdbusRule::path(POWER_BUTTON_PATH) +
- sdbusRule::interface(POWER_BUTTON_INTF),
- [this](sdbusplus::message::message &msg) {
- phosphor::logging::log<phosphor::logging::level::INFO>(
- "powerButtonPressed callback function is called...");
- int32_t state = -1;
- state = this->getPowerState();
- if (POWER_ON == state) {
- this->powerOff();
- } else if (POWER_OFF == state) {
- this->powerOn();
- } else {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "UNKNOWN power state");
- }
- return;
- }
- ),
- resetButtonPressedSignal(
- bus,
- sdbusRule::type::signal() + sdbusRule::member("Pressed") +
- sdbusRule::path(RESET_BUTTON_PATH) +
- sdbusRule::interface(RESET_BUTTON_INTF),
- [this](sdbusplus::message::message &msg) {
- phosphor::logging::log<phosphor::logging::level::INFO>(
- "resetButtonPressed callback function is called...");
- this->reboot();
- return;
- }
- ){
- phosphor::logging::log<phosphor::logging::level::DEBUG>(
- "ChassisControl is created.");
- }
-
- int32_t powerOn() override;
- int32_t powerOff() override;
- int32_t softPowerOff() override;
- int32_t reboot() override;
- int32_t softReboot() override;
- int32_t quiesce() override;
- int32_t getPowerState() override;
-
-private:
- sdbusplus::bus::bus &mBus;
-
- sdbusplus::bus::match_t powerButtonPressedSignal;
- sdbusplus::bus::match_t resetButtonPressedSignal;
-};
diff --git a/services/chassis/ChassisControl/src/ChassisControl.cpp b/services/chassis/ChassisControl/src/ChassisControl.cpp
deleted file mode 100644
index e902786..0000000
--- a/services/chassis/ChassisControl/src/ChassisControl.cpp
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
-// Copyright (c) 2018 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 "ChassisControl.hpp"
-#include <chrono>
-#include <xyz/openbmc_project/Common/error.hpp>
-
-constexpr auto SYSTEMD_SERVICE = "org.freedesktop.systemd1";
-constexpr auto SYSTEMD_OBJ_PATH = "/org/freedesktop/systemd1";
-constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager";
-constexpr auto HOST_START_TARGET = "obmc-host-start@0.target";
-constexpr auto CHASSIS_HARD_POWER_OFF_TARGET =
- "obmc-chassis-hard-poweroff@0.target";
-constexpr auto CHASSIS_POWER_OFF_TARGET = "obmc-chassis-poweroff@0.target";
-constexpr auto CHASSIS_POWER_ON_TARGET = "obmc-chassis-poweron@0.target";
-
-constexpr auto POWER_CONTROL_SERVICE =
- "xyz.openbmc_project.Chassis.Control.Power";
-constexpr auto POWER_CONTROL_OBJ_PATH =
- "/xyz/openbmc_project/Chassis/Control/Power0";
-constexpr auto POWER_CONTROL_INTERFACE =
- "xyz.openbmc_project.Chassis.Control.Power";
-constexpr auto HOST_STATE_REBOOT_TGT = "obmc-host-reboot@0.target";
-
-
-int32_t ChassisControl::powerOn() {
- auto method = mBus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH,
- SYSTEMD_INTERFACE, "StartUnit");
- method.append(HOST_START_TARGET, "replace");
- auto response = mBus.call(method);
- if (response.is_method_error()) {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "ERROR: Failed to run obmc-chassis-poweron@0.target");
- return -1;
- }
-
- return 0;
-}
-int32_t ChassisControl::powerOff() {
- auto method = mBus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH,
- SYSTEMD_INTERFACE, "StartUnit");
- method.append(CHASSIS_POWER_OFF_TARGET);
- method.append("replace");
- auto response = mBus.call(method);
- if (response.is_method_error()) {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "ERROR: Failed to run obmc-chassis-poweroff@0.target");
- return -1;
- }
-
- return 0;
-}
-
-int32_t ChassisControl::softPowerOff() {
- // TODO
- return 0;
-}
-int32_t ChassisControl::reboot() {
- auto method = mBus.new_method_call(SYSTEMD_SERVICE, SYSTEMD_OBJ_PATH,
- SYSTEMD_INTERFACE, "StartUnit");
- method.append(HOST_STATE_REBOOT_TGT, "replace");
- auto response = mBus.call(method);
- if (response.is_method_error()) {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "ERROR: Failed to run obmc-host-reboot@0.target");
- return -1;
- }
-
- return 0;
-}
-int32_t ChassisControl::softReboot() {
- // TODO
- return 0;
-}
-int32_t ChassisControl::quiesce() {
- // TODO
- return 0;
-}
-int32_t ChassisControl::getPowerState() {
- int32_t state = 0;
- auto method =
- mBus.new_method_call(POWER_CONTROL_SERVICE, POWER_CONTROL_OBJ_PATH,
- POWER_CONTROL_INTERFACE, "getPowerState");
- auto result = mBus.call(method);
- if (result.is_method_error()) {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "ERROR: Failed to call power control method getPowerState");
- return -1;
- }
- result.read(state);
-
- return state;
-}
-
diff --git a/services/chassis/ChassisControl/src/main.cpp b/services/chassis/ChassisControl/src/main.cpp
deleted file mode 100644
index fde9e61..0000000
--- a/services/chassis/ChassisControl/src/main.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
-// Copyright (c) 2018 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 "ChassisControl.hpp"
-#include <unistd.h>
-#include <xyz/openbmc_project/Common/error.hpp>
-
-int main(int argc, char *argv[]) {
- int ret = 0;
-
- phosphor::logging::log<phosphor::logging::level::INFO>(
- "Start Chassis Control service...");
- sd_event *event = nullptr;
- ret = sd_event_default(&event);
- if (ret < 0) {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "Error creating a default sd_event handler");
- return ret;
- }
- EventPtr eventP{event};
- event = nullptr;
-
- auto bus = sdbusplus::bus::new_default();
- sdbusplus::server::manager::manager objManager{bus, DBUS_OBJECT_NAME};
-
- bus.request_name(DBUS_INTF_NAME);
-
- ChassisControl chassisControl{bus, DBUS_OBJECT_NAME, eventP};
-
- try {
- bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL);
- ret = sd_event_loop(eventP.get());
- if (ret < 0) {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "Failed call to sd_event_loop");
- ret = -1;
- }
- }
-
- catch (std::exception &e) {
- phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
- ret = -1;
- }
-
- return ret;
-}
diff --git a/services/chassis/ChassisControl/xyz/openbmc_project/Chassis/Control/Chassis.errors.yaml b/services/chassis/ChassisControl/xyz/openbmc_project/Chassis/Control/Chassis.errors.yaml
deleted file mode 100644
index 9de4b9d..0000000
--- a/services/chassis/ChassisControl/xyz/openbmc_project/Chassis/Control/Chassis.errors.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-- name: UnsupportedCommand
- description: >
- An unsupported command was attempted.
-- name: InvalidParameter
- description: >
- An invalid parameter was attempted.
-- name: IOError
- description: >
- An IO error occurred.
diff --git a/services/chassis/ChassisControl/xyz/openbmc_project/Chassis/Control/Chassis.interface.yaml b/services/chassis/ChassisControl/xyz/openbmc_project/Chassis/Control/Chassis.interface.yaml
deleted file mode 100644
index eda4bc0..0000000
--- a/services/chassis/ChassisControl/xyz/openbmc_project/Chassis/Control/Chassis.interface.yaml
+++ /dev/null
@@ -1,94 +0,0 @@
-description: >
- chassis control service
-methods:
- - name: powerOn
- description: >
- Power on system.
- returns:
- - name: state
- type: int32
- description: >
- The result of command.
- errors:
- - self.Error.UnsupportedCommand
- - self.Error.InvalidParameter
- - self.Error.IOError
-
- - name: powerOff
- description: >
- Power Off system.
- returns:
- - name: state
- type: int32
- description: >
- The result of command.
- errors:
- - self.Error.UnsupportedCommand
- - self.Error.InvalidParameter
- - self.Error.IOError
-
- - name: softPowerOff
- description: >
- Soft Power off system.
- returns:
- - name: state
- type: int32
- description: >
- The result of command.
- errors:
- - self.Error.UnsupportedCommand
- - self.Error.InvalidParameter
- - self.Error.IOError
-
- - name: reboot
- description: >
- reboot system.
- returns:
- - name: state
- type: int32
- description: >
- The result of command.
- errors:
- - self.Error.UnsupportedCommand
- - self.Error.InvalidParameter
- - self.Error.IOError
-
- - name: softReboot
- description: >
- Soft Reboot system.
- returns:
- - name: state
- type: int32
- description: >
- The result of command.
- errors:
- - self.Error.UnsupportedCommand
- - self.Error.InvalidParameter
- - self.Error.IOError
-
- - name: quiesce
- description: >
- Quiesce system.
- returns:
- - name: state
- type: int32
- description: >
- The result of command.
- errors:
- - self.Error.UnsupportedCommand
- - self.Error.InvalidParameter
- - self.Error.IOError
-
- - name: getPowerState
- description: >
- Get system power state.
- returns:
- - name: state
- type: int32
- description: >
- The result of command.
- errors:
- - self.Error.UnsupportedCommand
- - self.Error.InvalidParameter
- - self.Error.IOError
-
diff --git a/services/chassis/Gpio/.clang-format b/services/chassis/Gpio/.clang-format
deleted file mode 100644
index bbc1bb1..0000000
--- a/services/chassis/Gpio/.clang-format
+++ /dev/null
@@ -1,85 +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 ]
-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: false
-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/services/chassis/Gpio/CMakeLists.txt b/services/chassis/Gpio/CMakeLists.txt
deleted file mode 100644
index 5f4b0e1..0000000
--- a/services/chassis/Gpio/CMakeLists.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)
-project(gpio CXX)
-set(CMAKE_CXX_STANDARD 14)
-set(CMAKE_CXX_STANDARD_REQUIRED ON)
-
-include(GNUInstallDirs)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc)
-
-add_library(${PROJECT_NAME} SHARED src/Gpio.cpp)
-
-set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "0.1.0")
-set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION "0")
-
-install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
diff --git a/services/chassis/Gpio/inc/Gpio.hpp b/services/chassis/Gpio/inc/Gpio.hpp
deleted file mode 100644
index c906976..0000000
--- a/services/chassis/Gpio/inc/Gpio.hpp
+++ /dev/null
@@ -1,3 +0,0 @@
-#pragma once
-int configGpio(const char *gpioName, int *fd, sdbusplus::bus::bus &bus);
-int closeGpio(int fd); \ No newline at end of file
diff --git a/services/chassis/Gpio/src/Gpio.cpp b/services/chassis/Gpio/src/Gpio.cpp
deleted file mode 100644
index 3d74d96..0000000
--- a/services/chassis/Gpio/src/Gpio.cpp
+++ /dev/null
@@ -1,178 +0,0 @@
-#include <experimental/filesystem>
-#include <fcntl.h>
-#include <fstream>
-#include <phosphor-logging/elog-errors.hpp>
-#include <unistd.h>
-#include <xyz/openbmc_project/Common/error.hpp>
-#include "Gpio.hpp"
-
-const static constexpr char *SYSMGR_SERVICE = "org.openbmc.managers.System";
-const static constexpr char *SYSMGR_OBJ_PATH = "/org/openbmc/managers/System";
-const static constexpr char *SYSMGR_INTERFACE = "org.openbmc.managers.System";
-
-int closeGpio(int fd)
-{
- if (fd > 0)
- {
- ::close(fd);
- }
- return 0;
-}
-
-int configGpio(const char *gpioName, int *fd, sdbusplus::bus::bus &bus)
-{
- auto method = bus.new_method_call(SYSMGR_SERVICE, SYSMGR_OBJ_PATH,
- SYSMGR_INTERFACE, "gpioInit");
-
- method.append(gpioName);
-
- auto result = bus.call(method);
-
- if (result.is_method_error())
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "bus call error!");
- return -1;
- }
-
- int32_t gpioNum;
- std::string gpioDev;
- std::string gpioDirection;
-
- result.read(gpioDev, gpioNum, gpioDirection);
-
- std::string devPath;
-
- std::fstream stream;
-
- stream.exceptions(std::ifstream::failbit | std::ifstream::badbit);
-
- devPath.clear();
- devPath = gpioDev + "/gpio" + std::to_string(gpioNum) + "/value";
-
- std::experimental::filesystem::path fullPath(devPath);
-
- if (std::experimental::filesystem::exists(fullPath))
- {
- phosphor::logging::log<phosphor::logging::level::INFO>(
- "GPIO exported",
- phosphor::logging::entry("PATH=%s", devPath.c_str()));
- }
- else
- {
- devPath.clear();
- devPath = gpioDev + "/export";
-
- stream.open(devPath, std::fstream::out);
- try
- {
- stream << gpioNum;
- stream.close();
- }
-
- catch (const std::exception &e)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "Error in writing!",
- phosphor::logging::entry("PATH=%s", devPath.c_str()),
- phosphor::logging::entry("NUM=%d", gpioNum));
- return -1;
- }
- }
-
- if (gpioDirection == "out")
- {
- devPath.clear();
- devPath = gpioDev + "/gpio" + std::to_string(gpioNum) + "/value";
-
- uint32_t currentValue;
-
- stream.open(devPath, std::fstream::in);
- try
- {
- stream >> currentValue;
- stream.close();
- }
-
- catch (const std::exception &e)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "Error in reading!",
- phosphor::logging::entry("PATH=%s", devPath.c_str()));
- return -1;
- }
-
- const char *direction = currentValue ? "high" : "low";
-
- devPath.clear();
- devPath = gpioDev + "/gpio" + std::to_string(gpioNum) + "/direction";
-
- stream.open(devPath, std::fstream::out);
- try
- {
- stream << direction;
- stream.close();
- }
-
- catch (const std::exception &e)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "Error in writing!");
- return -1;
- }
- }
- else if (gpioDirection == "in")
- {
- devPath.clear();
- devPath = gpioDev + "/gpio" + std::to_string(gpioNum) + "/direction";
-
- stream.open(devPath, std::fstream::out);
- try
- {
- stream << gpioDirection;
- stream.close();
- }
-
- catch (const std::exception &e)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "Error in writing!");
- return -1;
- }
- }
- else if ((gpioDirection == "both"))
- {
-
- // For gpio configured as ‘both’, it is an interrupt pin and trigged on
- // both rising and falling signals
- devPath.clear();
- devPath = gpioDev + "/gpio" + std::to_string(gpioNum) + "/edge";
-
- stream.open(devPath, std::fstream::out);
- try
- {
- stream << gpioDirection;
- stream.close();
- }
-
- catch (const std::exception &e)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "Error in writing!");
- return -1;
- }
- }
-
- devPath.clear();
- devPath = gpioDev + "/gpio" + std::to_string(gpioNum) + "/value";
-
- *fd = ::open(devPath.c_str(), O_RDWR | O_NONBLOCK);
-
- if (*fd < 0)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>("open error!");
- return -1;
- }
-
- return 0;
-}
diff --git a/services/chassis/I2c/.clang-format b/services/chassis/I2c/.clang-format
deleted file mode 100644
index bbc1bb1..0000000
--- a/services/chassis/I2c/.clang-format
+++ /dev/null
@@ -1,85 +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 ]
-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: false
-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/services/chassis/I2c/CMakeLists.txt b/services/chassis/I2c/CMakeLists.txt
deleted file mode 100644
index 4d950db..0000000
--- a/services/chassis/I2c/CMakeLists.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)
-project(chassisi2c CXX)
-set(CMAKE_CXX_STANDARD 14)
-set(CMAKE_CXX_STANDARD_REQUIRED ON)
-
-include(GNUInstallDirs)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc)
-
-add_library(${PROJECT_NAME} SHARED src/I2c.cpp)
-
-set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "0.1.0")
-set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION "0")
-
-install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
diff --git a/services/chassis/I2c/inc/I2c.hpp b/services/chassis/I2c/inc/I2c.hpp
deleted file mode 100644
index 6298786..0000000
--- a/services/chassis/I2c/inc/I2c.hpp
+++ /dev/null
@@ -1,4 +0,0 @@
-#pragma once
-#include <cstdint>
-#include <linux/i2c-dev-user.h>
-int i2cSet(uint8_t bus, uint8_t slaveAddr, uint8_t regAddr, uint8_t value); \ No newline at end of file
diff --git a/services/chassis/I2c/src/I2c.cpp b/services/chassis/I2c/src/I2c.cpp
deleted file mode 100644
index 0eaa503..0000000
--- a/services/chassis/I2c/src/I2c.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-#include <experimental/filesystem>
-#include <fcntl.h>
-#include <phosphor-logging/elog-errors.hpp>
-#include <unistd.h>
-#include <xyz/openbmc_project/Common/error.hpp>
-#include "I2c.hpp"
-
-int i2cSet(uint8_t bus, uint8_t slaveAddr, uint8_t regAddr, uint8_t value)
-{
- unsigned long funcs;
- std::string devPath = "/dev/i2c-" + std::to_string(bus);
- std::experimental::filesystem::path fullPath(devPath);
-
- if (!std::experimental::filesystem::exists(fullPath))
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "i2c bus des not exist!",
- phosphor::logging::entry("PATH=%s", devPath.c_str()),
- phosphor::logging::entry("SLAVEADDR=%d", slaveAddr));
- return -1;
- }
-
- int fd = ::open(devPath.c_str(), O_RDWR);
- if (fd < 0)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "Error in open!",
- phosphor::logging::entry("PATH=%s", devPath.c_str()),
- phosphor::logging::entry("SLAVEADDR=%d", slaveAddr));
- return -1;
- }
-
- if (::ioctl(fd, I2C_FUNCS, &funcs) < 0)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "Error in I2C_FUNCS!",
- phosphor::logging::entry("PATH=%s", devPath.c_str()),
- phosphor::logging::entry("SLAVEADDR=%d", slaveAddr));
-
- ::close(fd);
- return -1;
- }
-
- if (!(funcs & I2C_FUNC_SMBUS_WRITE_BYTE_DATA))
- {
-
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "i2c bus des not support write!",
- phosphor::logging::entry("PATH=%s", devPath.c_str()),
- phosphor::logging::entry("SLAVEADDR=%d", slaveAddr));
- ::close(fd);
- return -1;
- }
-
- if (::ioctl(fd, I2C_SLAVE_FORCE, slaveAddr) < 0)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "Error in I2C_SLAVE_FORCE!",
- phosphor::logging::entry("PATH=%s", devPath.c_str()),
- phosphor::logging::entry("SLAVEADDR=%d", slaveAddr));
- ::close(fd);
- return -1;
- }
-
- if (::i2c_smbus_write_byte_data(fd, regAddr, value) < 0)
- {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "Error in i2c write!",
- phosphor::logging::entry("PATH=%s", devPath.c_str()),
- phosphor::logging::entry("SLAVEADDR=%d", slaveAddr));
- ::close(fd);
- return -1;
- }
-
- phosphor::logging::log<phosphor::logging::level::DEBUG>(
- "i2cset successfully",
- phosphor::logging::entry("PATH=%s", devPath.c_str()),
- phosphor::logging::entry("SLAVEADDR=0x%x", slaveAddr),
- phosphor::logging::entry("REGADDR=0x%x", regAddr),
- phosphor::logging::entry("VALUE=0x%x", value));
- ::close(fd);
- return 0;
-} \ No newline at end of file
diff --git a/services/chassis/PowerControl/.clang-format b/services/chassis/PowerControl/.clang-format
deleted file mode 100644
index 92dc471..0000000
--- a/services/chassis/PowerControl/.clang-format
+++ /dev/null
@@ -1,98 +0,0 @@
----
-BasedOnStyle: Google
-AccessModifierOffset: -1
-AlignAfterOpenBracket: Align
-AlignConsecutiveAssignments: false
-AlignConsecutiveDeclarations: false
-AlignEscapedNewlinesLeft: true
-AlignOperands: true
-AlignTrailingComments: true
-AllowAllParametersOfDeclarationOnNextLine: true
-AllowShortBlocksOnASingleLine: false
-AllowShortCaseLabelsOnASingleLine: false
-AllowShortFunctionsOnASingleLine: All
-AllowShortIfStatementsOnASingleLine: true
-AllowShortLoopsOnASingleLine: true
-AlwaysBreakAfterDefinitionReturnType: None
-AlwaysBreakAfterReturnType: None
-AlwaysBreakBeforeMultilineStrings: true
-AlwaysBreakTemplateDeclarations: true
-BinPackArguments: true
-BinPackParameters: true
-BraceWrapping:
- AfterClass: false
- AfterControlStatement: false
- AfterEnum: false
- AfterFunction: false
- AfterNamespace: false
- AfterObjCDeclaration: false
- AfterStruct: false
- AfterUnion: false
- BeforeCatch: false
- BeforeElse: false
- IndentBraces: false
-BreakBeforeBinaryOperators: None
-BreakBeforeBraces: Attach
-BreakBeforeTernaryOperators: true
-BreakConstructorInitializersBeforeComma: false
-ColumnLimit: 80
-CommentPragmas: '^ IWYU pragma:'
-ConstructorInitializerAllOnOneLineOrOnePerLine: true
-ConstructorInitializerIndentWidth: 4
-ContinuationIndentWidth: 4
-Cpp11BracedListStyle: true
-DerivePointerAlignment: true
-DisableFormat: false
-ExperimentalAutoDetectBinPacking: false
-ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
-IncludeCategories:
-
- - Regex: '^[<"](crow)'
- Priority: 5
- - Regex: '^[<"](boost)'
- Priority: 6
- - Regex: '^[<"](gtest|gmock)'
- Priority: 7
- - Regex: '^<.*\.h>'
- Priority: 1
- - Regex: '^<.*\.hpp>'
- Priority: 2
- - Regex: '^<.*'
- Priority: 3
- - Regex: '.*'
- Priority: 4
-IndentCaseLabels: true
-IndentWidth: 2
-IndentWrappedFunctionNames: false
-KeepEmptyLinesAtTheStartOfBlocks: false
-MacroBlockBegin: ''
-MacroBlockEnd: ''
-MaxEmptyLinesToKeep: 1
-NamespaceIndentation: None
-ObjCBlockIndentWidth: 2
-ObjCSpaceAfterProperty: false
-ObjCSpaceBeforeProtocolList: false
-PenaltyBreakBeforeFirstCallParameter: 1
-PenaltyBreakComment: 300
-PenaltyBreakFirstLessLess: 120
-PenaltyBreakString: 1000
-PenaltyExcessCharacter: 1000000
-PenaltyReturnTypeOnItsOwnLine: 200
-PointerAlignment: Left
-ReflowComments: true
-SortIncludes: true
-SpaceAfterCStyleCast: false
-SpaceBeforeAssignmentOperators: true
-SpaceBeforeParens: ControlStatements
-SpaceInEmptyParentheses: false
-SpacesBeforeTrailingComments: 2
-SpacesInAngles: false
-SpacesInContainerLiterals: true
-SpacesInCStyleCastParentheses: false
-SpacesInParentheses: false
-SpacesInSquareBrackets: false
-Standard: Auto
-TabWidth: 8
-UseTab: Never
-...
-
diff --git a/services/chassis/PowerControl/CMakeLists.txt b/services/chassis/PowerControl/CMakeLists.txt
deleted file mode 100644
index 4f08070..0000000
--- a/services/chassis/PowerControl/CMakeLists.txt
+++ /dev/null
@@ -1,97 +0,0 @@
-cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)
-project(PowerControl CXX)
-set(CMAKE_CXX_STANDARD 14)
-set(CMAKE_CXX_STANDARD_REQUIRED ON)
-
-set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
-set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
-include(GNUInstallDirs)
-
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc)
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-set(DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Control/Power")
-set(DBUS_INTF_NAME "xyz.openbmc_project.Chassis.Control.Power")
-
-add_definitions(-DDBUS_OBJECT_NAME="/${DBUS_OBJECT_NAME}0")
-add_definitions(-DDBUS_INTF_NAME="${DBUS_INTF_NAME}")
-set(SRC_FILES
- src/PowerControl.cpp
- src/timer.cpp
- src/main.cpp
-)
-
-set(GENERATED_SRC_FILES
- ${DBUS_OBJECT_NAME}/error.cpp
- ${DBUS_OBJECT_NAME}/server.cpp
-)
-
-# 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})
-
-# 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})
-
-option(ENABLE_GTEST "Enable Google Test" OFF)
-if(ENABLE_GTEST)
- enable_testing()
- find_package(Threads REQUIRED)
- find_package(GTest REQUIRED)
- include_directories(${GTEST_INCLUDE_DIRS})
- include_directories(${CMAKE_CURRENT_SOURCE_DIR}/tests/inc)
- add_executable(timertest tests/src/timer_test.cpp src/timer.cpp)
- target_link_libraries(timertest ${GTEST_BOTH_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${SDBUSPLUSPLUS_LIBRARIES} ${DBUSINTERFACE_LIBRARIES})
- add_test(NAME timertest COMMAND timertest)
-endif()
-
-add_custom_command(
- OUTPUT ${DBUS_OBJECT_NAME}/error.hpp
- OUTPUT ${DBUS_OBJECT_NAME}/error.cpp
- COMMAND mkdir -p ${DBUS_OBJECT_NAME}
- COMMAND ${SDBUSPLUSPLUS} -r ${CMAKE_CURRENT_SOURCE_DIR} error exception-header ${DBUS_INTF_NAME} > ${DBUS_OBJECT_NAME}/error.hpp
- COMMAND ${SDBUSPLUSPLUS} -r ${CMAKE_CURRENT_SOURCE_DIR} error exception-cpp ${DBUS_INTF_NAME} > ${DBUS_OBJECT_NAME}/error.cpp
- DEPENDS ${DBUS_OBJECT_NAME}.errors.yaml
-)
-set_source_files_properties(
- ${DBUS_OBJECT_NAME}/error.hpp
- ${DBUS_OBJECT_NAME}/error.cpp
- PROPERTIES GENERATED TRUE)
-
-add_custom_command(
- OUTPUT ${DBUS_OBJECT_NAME}/server.hpp
- OUTPUT ${DBUS_OBJECT_NAME}/server.cpp
- COMMAND mkdir -p ${DBUS_OBJECT_NAME}
- COMMAND ${SDBUSPLUSPLUS} -r ${CMAKE_CURRENT_SOURCE_DIR} interface server-header ${DBUS_INTF_NAME} > ${DBUS_OBJECT_NAME}/server.hpp
- COMMAND ${SDBUSPLUSPLUS} -r ${CMAKE_CURRENT_SOURCE_DIR} interface server-cpp ${DBUS_INTF_NAME} > ${DBUS_OBJECT_NAME}/server.cpp
- DEPENDS ${DBUS_OBJECT_NAME}.interface.yaml
-)
-set_source_files_properties(
- ${DBUS_OBJECT_NAME}/server.hpp
- ${DBUS_OBJECT_NAME}/server.cpp
- PROPERTIES GENERATED TRUE)
-
-add_executable(${PROJECT_NAME} ${SRC_FILES} ${GENERATED_SRC_FILES})
-target_link_libraries(${PROJECT_NAME} ${SYSTEMD_LIBRARIES} gpio chassisi2c)
-target_link_libraries(${PROJECT_NAME} "${SDBUSPLUSPLUS_LIBRARIES} -lstdc++fs")
-target_link_libraries(${PROJECT_NAME} ${DBUSINTERFACE_LIBRARIES})
-
-install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/services/chassis/PowerControl/inc/PowerControl.hpp b/services/chassis/PowerControl/inc/PowerControl.hpp
deleted file mode 100644
index cfaa3e7..0000000
--- a/services/chassis/PowerControl/inc/PowerControl.hpp
+++ /dev/null
@@ -1,139 +0,0 @@
-#pragma once
-#include <unistd.h>
-#include <phosphor-logging/elog-errors.hpp>
-#include <xyz/openbmc_project/Chassis/Control/Power/error.hpp>
-#include <xyz/openbmc_project/Chassis/Control/Power/server.hpp>
-#include <xyz/openbmc_project/Common/error.hpp>
-#include "Gpio.hpp"
-#include "I2c.hpp"
-#include "timer.hpp"
-
-static constexpr size_t POLLING_INTERVAL_MS = 500;
-
-const static constexpr char* PGOOD_PIN = "PGOOD";
-const static constexpr char* POWER_UP_PIN = "POWER_UP_PIN";
-
-const static constexpr size_t PCH_DEVICE_BUS_ADDRESS = 3;
-const static constexpr size_t PCH_DEVICE_SLAVE_ADDRESS = 0x44;
-const static constexpr size_t PCH_CMD_REGISTER = 0;
-const static constexpr size_t PCH_POWER_DOWN_CMD = 0x02;
-
-const static constexpr size_t POWER_ON_PULSE_TIME_MS = 200;
-const static constexpr size_t POWER_OFF_PULSE_TIME_MS = 4000;
-
-using pwr_control =
- sdbusplus::xyz::openbmc_project::Chassis::Control::server::Power;
-
-struct PowerControl : sdbusplus::server::object_t<pwr_control> {
- PowerControl(sdbusplus::bus::bus& bus, const char* path,
- phosphor::watchdog::EventPtr event,
- sd_event_io_handler_t handler = PowerControl::EventHandler)
- : sdbusplus::server::object_t<pwr_control>(bus, path),
- bus(bus),
- callbackHandler(handler),
- timer(event, std::bind(&PowerControl::timeOutHandler, this)) {
- int ret;
- char buf;
-
- // config gpio
- ret = configGpio(PGOOD_PIN, &pgood_fd, bus);
- if (ret < 0) {
- throw std::runtime_error("failed to config GPIO");
- return;
- }
-
- ret = configGpio(POWER_UP_PIN, &power_up_fd, bus);
- if (ret < 0) {
- throw std::runtime_error("failed to config GPIO");
- closeGpio(pgood_fd);
- return;
- }
-
- ret = sd_event_add_io(event.get(), nullptr, pgood_fd, EPOLLPRI,
- callbackHandler, this);
- if (ret < 0) {
- closeGpio(pgood_fd);
- closeGpio(power_up_fd);
- throw std::runtime_error("failed to add to event loop");
- }
-
- timer.start(std::chrono::duration_cast<std::chrono::microseconds>(
- std::chrono::milliseconds(POLLING_INTERVAL_MS)));
- timer.setEnabled<std::true_type>();
- phosphor::logging::log<phosphor::logging::level::DEBUG>("Enable timer");
- }
-
- ~PowerControl() {
- closeGpio(pgood_fd);
- closeGpio(power_up_fd);
- }
-
- void timeOutHandler() {
- // TODO polling acpi status
-
- this->timer.start(std::chrono::duration_cast<std::chrono::microseconds>(
- std::chrono::milliseconds(POLLING_INTERVAL_MS)));
- this->timer.setEnabled<std::true_type>();
- }
-
- static int EventHandler(sd_event_source* es, int fd, uint32_t revents,
- void* userdata) {
- // For the first event, only set the initial status, do not emit signal
- // since is it not triggered by the real gpio change
-
- static bool first_event = true;
- int n;
- char buf;
-
- PowerControl* powercontrol = static_cast<PowerControl*>(userdata);
-
- if (!powercontrol) {
- phosphor::logging::log<phosphor::logging::level::ERR>("null pointer!");
- return -1;
- }
-
- n = ::lseek(fd, 0, SEEK_SET);
- if (n < 0) {
- phosphor::logging::log<phosphor::logging::level::ERR>("lseek error!");
- return n;
- }
-
- n = ::read(fd, &buf, 1);
- if (n < 0) {
- phosphor::logging::log<phosphor::logging::level::ERR>("read error!");
- return n;
- }
-
- if (buf == '0') {
- powercontrol->state(0);
- powercontrol->pgood(0);
-
- if (first_event) {
- first_event = false;
- } else {
- powercontrol->gotoSystemState(std::string("HOST_POWERED_OFF"));
- }
- } else {
- powercontrol->state(1);
- powercontrol->pgood(1);
- if (first_event) {
- first_event = false;
- } else {
- powercontrol->gotoSystemState(std::string("HOST_POWERED_ON"));
- }
- }
-
- return 0;
- }
-
- int32_t forcePowerOff() override;
- int32_t setPowerState(int32_t newState) override;
- int32_t getPowerState() override;
-
- private:
- int power_up_fd;
- int pgood_fd;
- phosphor::watchdog::Timer timer;
- sdbusplus::bus::bus& bus;
- sd_event_io_handler_t callbackHandler;
-};
diff --git a/services/chassis/PowerControl/inc/timer.hpp b/services/chassis/PowerControl/inc/timer.hpp
deleted file mode 100644
index 3aa0f87..0000000
--- a/services/chassis/PowerControl/inc/timer.hpp
+++ /dev/null
@@ -1,147 +0,0 @@
-#pragma once
-
-#include <functional>
-#include <memory>
-#include <chrono>
-#include <systemd/sd-event.h>
-namespace phosphor
-{
-namespace watchdog
-{
-
-/* Need a custom deleter for freeing up sd_event */
-struct EventDeleter
-{
- void operator()(sd_event* event) const
- {
- event = sd_event_unref(event);
- }
-};
-using EventPtr = std::shared_ptr<sd_event>;
-
-/* Need a custom deleter for freeing up sd_event_source */
-struct EventSourceDeleter
-{
- void operator()(sd_event_source* eventSource) const
- {
- eventSource = sd_event_source_unref(eventSource);
- }
-};
-using EventSourcePtr = std::unique_ptr<sd_event_source, EventSourceDeleter>;
-
-/** @class Timer
- * @brief Manages starting timers and handling timeouts
- */
-class Timer
-{
- public:
- Timer() = delete;
- ~Timer() = default;
- Timer(const Timer&) = delete;
- Timer& operator=(const Timer&) = delete;
- Timer(Timer&&) = delete;
- Timer& operator=(Timer&&) = delete;
-
- /** @brief Constructs timer object
- *
- * @param[in] event - sd_event unique pointer
- * @param[in] userCallBack - Optional function callback
- * for timer expiration
- */
- Timer(EventPtr event,
- std::function<void()> userCallBack = nullptr)
- : event(event),
- userCallBack(userCallBack)
- {
- // Initialize the timer
- initialize();
- }
-
- void clearExpired(void)
- {
- expire = false;
- }
-
- /** @brief Tells whether the timer is expired or not */
- inline auto expired() const
- {
- return expire;
- }
-
- /** @brief Returns the current Timer enablement type */
- int getEnabled() const;
-
- /** @brief Enables / disables the timer.
- * <T> is an integral constant boolean
- */
- template <typename T> void setEnabled()
- {
- constexpr auto type = T::value ? SD_EVENT_ONESHOT : SD_EVENT_OFF;
- setEnabled(type);
- }
-
- /** @brief Returns time remaining in usec before expiration
- * which is an offset to current steady clock
- */
- std::chrono::microseconds getRemaining() const;
-
- /** @brief Starts the timer with specified expiration value.
- * std::steady_clock is used for base time.
- *
- * @param[in] usec - Microseconds from the current time
- * before expiration.
- *
- * @return None.
- *
- * @error Throws exception
- */
- void start(std::chrono::microseconds usec);
-
- /** @brief Gets the current time from steady clock */
- static std::chrono::microseconds getCurrentTime();
-
- private:
- /** @brief Reference to sd_event unique pointer */
- EventPtr event;
-
- /** @brief event source */
- EventSourcePtr eventSource;
-
- /** @brief Set to true when the timeoutHandler is called into */
- bool expire = false;
-
- /** @brief Optional function to call on timer expiration
- * This is called from timeout handler.
- */
- std::function<void()> userCallBack;
-
- /** @brief Initializes the timer object with infinite
- * expiration time and sets up the callback handler
- *
- * @return None.
- *
- * @error Throws exception
- */
- void initialize();
-
- /** @brief Callback function when timer goes off
- *
- * @param[in] eventSource - Source of the event
- * @param[in] usec - time in microseconds
- * @param[in] userData - User data pointer
- *
- */
- static int timeoutHandler(sd_event_source* eventSource,
- uint64_t usec, void* userData);
-
- /** @brief Enables / disables the timer
- *
- * @param[in] type - Timer type.
- * This implementation uses only SD_EVENT_OFF
- * and SD_EVENT_ONESHOT
- */
- void setEnabled(int type);
-};
-
-} // namespace watchdog
-} // namespace phosphor
diff --git a/services/chassis/PowerControl/src/PowerControl.cpp b/services/chassis/PowerControl/src/PowerControl.cpp
deleted file mode 100644
index caa69e5..0000000
--- a/services/chassis/PowerControl/src/PowerControl.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
-// Copyright (c) 2018 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 "PowerControl.hpp"
-
-int32_t PowerControl::forcePowerOff() {
- int ret = 0;
- ret = i2cSet(PCH_DEVICE_BUS_ADDRESS, PCH_DEVICE_SLAVE_ADDRESS,
- PCH_CMD_REGISTER, PCH_POWER_DOWN_CMD);
-
- if (ret < 0) {
- throw sdbusplus::xyz::openbmc_project::Chassis::Control::Power::Error::
- IOError();
- }
- return 0;
-}
-
-int32_t PowerControl::setPowerState(int32_t newState) {
- int ret = 0;
- int count = 0;
- char buf;
-
- phosphor::logging::log<phosphor::logging::level::DEBUG>(
- "setPowerState", phosphor::logging::entry("NEWSTATE=%d", newState));
-
- if (state() == newState) {
- phosphor::logging::log<phosphor::logging::level::DEBUG>(
- "Same powerstate", phosphor::logging::entry("NEWSTATE=%d", newState));
- }
-
- if (newState == 1) {
- gotoSystemState(std::string("HOST_POWERING_ON"));
- } else {
- gotoSystemState(std::string("HOST_POWERING_OFF"));
- }
-
- state(newState);
-
- ret = ::lseek(power_up_fd, 0, SEEK_SET);
- if (ret < 0) {
- phosphor::logging::log<phosphor::logging::level::ERR>("lseek error!");
- throw sdbusplus::xyz::openbmc_project::Chassis::Control::Power::Error::
- IOError();
- return ret;
- }
-
- buf = '0';
- ret = ::write(power_up_fd, &buf, 1);
- if (ret < 0) {
- phosphor::logging::log<phosphor::logging::level::ERR>("write error!");
- throw sdbusplus::xyz::openbmc_project::Chassis::Control::Power::Error::
- IOError();
- return ret;
- }
-
- if (1 == newState) { // start power on
- std::this_thread::sleep_for(
- std::chrono::milliseconds(POWER_ON_PULSE_TIME_MS));
- } else { // start power off
- std::this_thread::sleep_for(
- std::chrono::milliseconds(POWER_OFF_PULSE_TIME_MS));
- }
-
- buf = '1';
- ret = ::write(power_up_fd, &buf, 1);
- if (ret < 0) {
- phosphor::logging::log<phosphor::logging::level::ERR>("write error!");
- throw sdbusplus::xyz::openbmc_project::Chassis::Control::Power::Error::
- IOError();
- return ret;
- }
-
- if (0 == newState) {
- // For power off, currently there is a known issue, the “long-press” power
- // button cannot power off the host, a workaround is perform force power off
- std::this_thread::sleep_for(std::chrono::milliseconds(2000));
- if (1 == pgood()) { // still on, force off!
- phosphor::logging::log<phosphor::logging::level::DEBUG>(
- "Perform force power off");
- count = 0;
- do {
- if (count++ > 5) {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "forcePowerOff error!");
- throw sdbusplus::xyz::openbmc_project::Chassis::Control::Power::
- Error::IOError();
- return ret;
- }
- ret = forcePowerOff();
- std::this_thread::sleep_for(std::chrono::milliseconds(200));
- } while (ret != 0);
- }
- }
-
- return 0;
-}
-
-int32_t PowerControl::getPowerState() { return state(); }
diff --git a/services/chassis/PowerControl/src/main.cpp b/services/chassis/PowerControl/src/main.cpp
deleted file mode 100644
index eb9c4cc..0000000
--- a/services/chassis/PowerControl/src/main.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
-// Copyright (c) 2018 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 "PowerControl.hpp"
-
-int main(int argc, char* argv[]) {
- int ret = 0;
-
- phosphor::logging::log<phosphor::logging::level::INFO>(
- "Start Chassis power control service...");
-
- sd_event* event = nullptr;
- ret = sd_event_default(&event);
- if (ret < 0) {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "Error creating a default sd_event handler");
- return ret;
- }
- phosphor::watchdog::EventPtr eventP{event,
- phosphor::watchdog::EventDeleter()};
- event = nullptr;
-
- auto bus = sdbusplus::bus::new_default();
- sdbusplus::server::manager_t m{bus, DBUS_OBJECT_NAME};
-
- bus.request_name(DBUS_INTF_NAME);
-
- PowerControl powerControl{bus, DBUS_OBJECT_NAME, eventP};
-
- auto now_ms = std::chrono::time_point_cast<std::chrono::milliseconds>(
- std::chrono::system_clock::now());
-
- try {
- bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL);
- while (true) {
- ret = sd_event_run(eventP.get(), (uint64_t)-1);
- if (ret < 0) {
- phosphor::logging::log<phosphor::logging::level::ERR>(
- "Error waiting for events");
- }
- }
- }
-
- catch (std::exception& e) {
- phosphor::logging::log<phosphor::logging::level::ERR>(e.what());
- return -1;
- }
- return 0;
-}
diff --git a/services/chassis/PowerControl/src/timer.cpp b/services/chassis/PowerControl/src/timer.cpp
deleted file mode 100644
index d20f646..0000000
--- a/services/chassis/PowerControl/src/timer.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
- * Copyright © 2017 IBM 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 "timer.hpp"
-#include <systemd/sd-event.h>
-#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/log.hpp>
-#include <xyz/openbmc_project/Common/error.hpp>
-#include <chrono>
-namespace phosphor {
-namespace watchdog {
-
-// For throwing exception
-using namespace phosphor::logging;
-using InternalFailure =
- sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
-
-// Initializes the timer object
-void Timer::initialize() {
- // This can not be called more than once.
- if (eventSource.get()) {
- log<level::ERR>("Timer already initialized");
- elog<InternalFailure>();
- }
-
- // Add infinite expiration time
- decltype(eventSource.get()) sourcePtr = nullptr;
- auto r = sd_event_add_time(event.get(), &sourcePtr,
- CLOCK_MONOTONIC, // Time base
- UINT64_MAX, // Expire time - way long time
- 0, // Use default event accuracy
- timeoutHandler, // Callback handler on timeout
- this); // User data
- eventSource.reset(sourcePtr);
-
- if (r < 0) {
- log<level::ERR>("Timer initialization failed");
- elog<InternalFailure>();
- }
-
- // Disable the timer for now
- setEnabled<std::false_type>();
-}
-
-// callback handler on timeout
-int Timer::timeoutHandler(sd_event_source* eventSource, uint64_t usec,
- void* userData) {
- using namespace phosphor::logging;
-
- auto timer = static_cast<Timer*>(userData);
- timer->expire = true;
-
- // Call an optional callback function
- if (timer->userCallBack) {
- timer->userCallBack();
- }
- return 0;
-}
-
-// Gets the time from steady_clock
-std::chrono::microseconds Timer::getCurrentTime() {
- using namespace std::chrono;
- auto usec = steady_clock::now().time_since_epoch();
- return duration_cast<microseconds>(usec);
-}
-
-// Sets the expiration time and arms the timer
-void Timer::start(std::chrono::microseconds usec) {
- using namespace std::chrono;
-
- // Get the current MONOTONIC time and add the delta
- auto expireTime = getCurrentTime() + usec;
-
- // Set the time
- auto r = sd_event_source_set_time(eventSource.get(), expireTime.count());
- if (r < 0) {
- log<level::ERR>(
- "Error setting the expiration time",
- entry("MSEC=%llu", duration_cast<milliseconds>(usec).count()));
- elog<InternalFailure>();
- }
-}
-
-// Returns current timer enablement type
-int Timer::getEnabled() const {
- int enabled{};
- auto r = sd_event_source_get_enabled(eventSource.get(), &enabled);
- if (r < 0) {
- log<level::ERR>("Error geting current timer type enablement state");
- elog<InternalFailure>();
- }
- return enabled;
-}
-
-// Enables / disables the timer
-void Timer::setEnabled(int type) {
- auto r = sd_event_source_set_enabled(eventSource.get(), type);
- if (r < 0) {
- log<level::ERR>("Error setting the timer type", entry("TYPE=%d", type));
- elog<InternalFailure>();
- }
-}
-
-// Returns time remaining before expiration
-std::chrono::microseconds Timer::getRemaining() const {
- uint64_t next = 0;
- auto r = sd_event_source_get_time(eventSource.get(), &next);
- if (r < 0) {
- log<level::ERR>("Error fetching remaining time to expire");
- elog<InternalFailure>();
- }
- return std::chrono::microseconds(next);
-}
-
-} // namespace watchdog
-} // namespace phosphor
diff --git a/services/chassis/PowerControl/tests/inc/timer_test.hpp b/services/chassis/PowerControl/tests/inc/timer_test.hpp
deleted file mode 100644
index 85c443f..0000000
--- a/services/chassis/PowerControl/tests/inc/timer_test.hpp
+++ /dev/null
@@ -1,40 +0,0 @@
-#include <iostream>
-#include <gtest/gtest.h>
-#include <timer.hpp>
-
-// Base class for testing Timer
-class TimerTest : public testing::Test
-{
- public:
- // systemd event handler
- sd_event* events;
-
- // Need this so that events can be initialized.
- int rc;
-
- // Tells if the watchdog timer expired.
- bool expired = false;
-
- // Gets called as part of each TEST_F construction
- TimerTest()
- : rc(sd_event_default(&events)),
- eventP(events, phosphor::watchdog::EventDeleter())
- {
- // Check for successful creation of
- // event handler and bus handler
- EXPECT_GE(rc, 0);
-
- // Its already wrapped in eventP
- events = nullptr;
- }
-
- // unique_ptr for sd_event
- phosphor::watchdog::EventPtr eventP;
-
- // Handler called by timer expiration
- inline void timeOutHandler()
- {
- std::cout << "Time out handler called" << std::endl;
- expired = true;
- }
-};
diff --git a/services/chassis/PowerControl/tests/src/timer_test.cpp b/services/chassis/PowerControl/tests/src/timer_test.cpp
deleted file mode 100644
index e9f323b..0000000
--- a/services/chassis/PowerControl/tests/src/timer_test.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-#include <chrono>
-#include <timer_test.hpp>
-
-using namespace std::chrono;
-using namespace std::chrono_literals;
-
-/** @brief Starts the timer and expects it to
- * expire in configured time and expects the
- * deault callback handler to kick-in
- */
-TEST_F(TimerTest, testTimerForExpirationDefaultTimeoutHandler)
-{
- // Expect timer to expire in 2 seconds
- auto expireTime = seconds(2s);
-
- phosphor::watchdog::Timer timer(eventP);
-
- // Set the expiration and enable the timer
- timer.start(duration_cast<milliseconds>(expireTime));
- timer.setEnabled<std::true_type>();
-
- // Waiting 2 seconds to expect expiration
- int count = 0;
- while(count < expireTime.count() && !timer.expired())
- {
- // Returns -0- on timeout and positive number on dispatch
- auto sleepTime = duration_cast<microseconds>(seconds(1));
- if(!sd_event_run(eventP.get(), sleepTime.count()))
- {
- count++;
- }
- }
- EXPECT_EQ(true, timer.expired());
- EXPECT_EQ(expireTime.count() - 1, count);
-
- // Make sure secondary callback was not called.
- EXPECT_EQ(false, expired);
-}
-
-/** @brief Starts the timer and expects it to expire
- * in configured time and expects the secondary
- * callback to be called into along with default.
- */
-TEST_F(TimerTest, testTimerForExpirationSecondCallBack)
-{
- // Expect timer to expire in 2 seconds
- auto expireTime = seconds(2s);
-
- phosphor::watchdog::Timer timer(eventP,
- std::bind(&TimerTest::timeOutHandler, this));
-
- // Set the expiration and enable the timer
- timer.start(duration_cast<milliseconds>(expireTime));
- timer.setEnabled<std::true_type>();
-
- // Waiting 2 seconds to expect expiration
- int count = 0;
- while(count < expireTime.count() && !timer.expired())
- {
- // Returns -0- on timeout and positive number on dispatch
- auto sleepTime = duration_cast<microseconds>(seconds(1));
- if(!sd_event_run(eventP.get(), sleepTime.count()))
- {
- count++;
- }
- }
- EXPECT_EQ(true, timer.expired());
- EXPECT_EQ(expireTime.count() - 1, count);
-
- // This gets set as part of secondary callback
- EXPECT_EQ(true, expired);
-}
diff --git a/services/chassis/PowerControl/xyz/openbmc_project/Chassis/Control/Power.errors.yaml b/services/chassis/PowerControl/xyz/openbmc_project/Chassis/Control/Power.errors.yaml
deleted file mode 100644
index 9de4b9d..0000000
--- a/services/chassis/PowerControl/xyz/openbmc_project/Chassis/Control/Power.errors.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-- name: UnsupportedCommand
- description: >
- An unsupported command was attempted.
-- name: InvalidParameter
- description: >
- An invalid parameter was attempted.
-- name: IOError
- description: >
- An IO error occurred.
diff --git a/services/chassis/PowerControl/xyz/openbmc_project/Chassis/Control/Power.interface.yaml b/services/chassis/PowerControl/xyz/openbmc_project/Chassis/Control/Power.interface.yaml
deleted file mode 100644
index 445fef5..0000000
--- a/services/chassis/PowerControl/xyz/openbmc_project/Chassis/Control/Power.interface.yaml
+++ /dev/null
@@ -1,88 +0,0 @@
-description: >
- Chassis control service
-methods:
- - name: setPowerState
- description: >
- set host power state.
- parameters:
- - name: state
- type: int32
- description: >
- 0 for force power off host
- 1 for power on host
- returns:
- - name: status
- type: int32
- description: >
- The result of command.
- errors:
- - self.Error.UnsupportedCommand
- - self.Error.InvalidParameter
- - self.Error.IOError
-
- - name: getPowerState
- description: >
- Get current host power status.
- returns:
- - name: status
- type: int32
- description: >
- Current host status,
- 0 for host power off
- 1 for host power on
- errors:
- - self.Error.UnsupportedCommand
- - self.Error.InvalidParameter
- - self.Error.IOError
-
- - name: forcePowerOff
- description: >
- Force power off the host.
- returns:
- - name: status
- type: int32
- description: >
- The result of power off command.
- errors:
- - self.Error.UnsupportedCommand
- - self.Error.InvalidParameter
- - self.Error.IOError
-
-properties:
- - name: vrd_good
- type: int32
- default: 0
- description: >
- ACPI status
- - name: s4s5_state
- type: int32
- default: 0
- description: >
- ACPI status
- - name: pgood
- type: int32
- default: 0
- description: >
- pgood property
- - name: state
- type: int32
- default: 0
- description: >
- state property
- - name: pgood_timeout
- type: int32
- default: 0
- description: >
- pgoodtimeout property
-signals:
- - name: PowerGood
- description: >
- Signal for powergood
- - name: PowerLost
- description: >
- Signal for powerlost
- - name: GotoSystemState
- description: >
- Signal for GotoSystemState
- properties:
- - type: string \ No newline at end of file