1 /** 2 * Copyright © 2017 IBM Corporation 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #include "config.h" 17 18 #include "runtime_monitor.hpp" 19 20 #include "elog-errors.hpp" 21 #include "utility.hpp" 22 23 #include <org/open_power/Witherspoon/Fault/error.hpp> 24 #include <phosphor-logging/log.hpp> 25 26 namespace phosphor 27 { 28 namespace power 29 { 30 31 using namespace phosphor::logging; 32 using namespace sdbusplus::org::open_power::Witherspoon::Fault::Error; 33 34 int RuntimeMonitor::run() 35 { 36 #ifdef DEVICE_ACCESS 37 return DeviceMonitor::run(); 38 #else 39 return EXIT_SUCCESS; 40 #endif 41 } 42 43 void RuntimeMonitor::onPowerLost(sdbusplus::message::message&) 44 { 45 log<level::INFO>("PGOOD failure detected. Checking for faults."); 46 47 try 48 { 49 timer.setEnabled(false); 50 51 #ifdef DEVICE_ACCESS 52 device->onFailure(); 53 #endif 54 // Note: This application only runs when the system has 55 // power, so it will be killed by systemd sometime shortly 56 // after this power off is issued. 57 58 util::powerOff<Shutdown>(bus); 59 } 60 catch (std::exception& e) 61 { 62 // No need to crash 63 log<level::ERR>(e.what()); 64 } 65 } 66 67 } // namespace power 68 } // namespace phosphor 69