George Hung | 9d538eb | 2021-04-28 10:26:40 +0800 | [diff] [blame^] | 1 | From a1f9d797753e32b36e08e7d611ff88b10e9bbad2 Mon Sep 17 00:00:00 2001 |
| 2 | From: "Jason M. Bills" <jason.m.bills@linux.intel.com> |
| 3 | Date: Thu, 30 Jan 2020 16:18:33 -0800 |
| 4 | Subject: [PATCH 1/3] Add Chassis State Transition interface |
| 5 | |
| 6 | This adds the Chassis State Transition interface in preparation |
| 7 | to support the mapping defined in the design document below. |
| 8 | |
| 9 | ref: https://gerrit.openbmc-project.xyz/c/openbmc/docs/+/22358 |
| 10 | |
| 11 | Tested: |
| 12 | Ran each IPMI chassis control command to confirm the expected |
| 13 | behavior: |
| 14 | ipmitool power on: system is powered-on |
| 15 | ipmitool power off: system is forced off |
| 16 | ipmitool power cycle: system is forced off then powered-on |
| 17 | ipmitool power reset: system is hard reset |
| 18 | ipmitool power soft: soft power-off requested from system software |
| 19 | |
| 20 | Change-Id: I6acfb795a9a33ff5227a5d6e1830774ab732ac0c |
| 21 | Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com> |
| 22 | --- |
| 23 | chassishandler.cpp | 33 +++++++++++++++++++++++++++++++++ |
| 24 | 1 file changed, 33 insertions(+) |
| 25 | |
| 26 | diff --git a/chassishandler.cpp b/chassishandler.cpp |
| 27 | index 0d318647..fdbb9fa5 100644 |
| 28 | --- a/chassishandler.cpp |
| 29 | +++ b/chassishandler.cpp |
| 30 | @@ -31,6 +31,7 @@ |
| 31 | #include <xyz/openbmc_project/Control/Boot/Mode/server.hpp> |
| 32 | #include <xyz/openbmc_project/Control/Boot/Source/server.hpp> |
| 33 | #include <xyz/openbmc_project/Control/Power/RestorePolicy/server.hpp> |
| 34 | +#include <xyz/openbmc_project/State/Chassis/server.hpp> |
| 35 | #include <xyz/openbmc_project/State/Host/server.hpp> |
| 36 | #include <xyz/openbmc_project/State/PowerOnHours/server.hpp> |
| 37 | |
| 38 | @@ -865,6 +866,38 @@ int initiate_state_transition(State::Host::Transition transition) |
| 39 | return rc; |
| 40 | } |
| 41 | |
| 42 | +//------------------------------------------ |
| 43 | +// Calls into Chassis State Manager Dbus object |
| 44 | +//------------------------------------------ |
| 45 | +int initiateChassisStateTransition(State::Chassis::Transition transition) |
| 46 | +{ |
| 47 | + // OpenBMC Chassis State Manager dbus framework |
| 48 | + constexpr auto chassisStatePath = "/xyz/openbmc_project/state/chassis0"; |
| 49 | + constexpr auto chassisStateIntf = "xyz.openbmc_project.State.Chassis"; |
| 50 | + |
| 51 | + auto service = |
| 52 | + ipmi::getService(*getSdBus(), chassisStateIntf, chassisStatePath); |
| 53 | + |
| 54 | + // Convert to string equivalent of the passed in transition enum. |
| 55 | + auto request = State::convertForMessage(transition); |
| 56 | + |
| 57 | + try |
| 58 | + { |
| 59 | + ipmi::setDbusProperty(*getSdBus(), service, chassisStatePath, |
| 60 | + chassisStateIntf, "RequestedPowerTransition", |
| 61 | + request); |
| 62 | + } |
| 63 | + catch (std::exception& e) |
| 64 | + { |
| 65 | + log<level::ERR>( |
| 66 | + "Failed to initiate transition", |
| 67 | + entry("EXCEPTION=%s, REQUEST=%s", e.what(), request.c_str())); |
| 68 | + return -1; |
| 69 | + } |
| 70 | + |
| 71 | + return 0; |
| 72 | +} |
| 73 | + |
| 74 | //------------------------------------------ |
| 75 | // Set Enabled property to inform NMI source |
| 76 | // handling to trigger a NMI_OUT BSOD. |
| 77 | -- |
| 78 | 2.21.0 |
| 79 | |