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/lg2.hpp> 25 26 namespace phosphor 27 { 28 namespace power 29 { 30 31 using namespace sdbusplus::org::open_power::Witherspoon::Fault::Error; 32 33 int RuntimeMonitor::run() 34 { 35 #ifdef DEVICE_ACCESS 36 return DeviceMonitor::run(); 37 #else 38 return EXIT_SUCCESS; 39 #endif 40 } 41 42 void RuntimeMonitor::onPowerLost(sdbusplus::message_t&) 43 { 44 lg2::info("PGOOD failure detected. Checking for faults."); 45 46 try 47 { 48 timer.setEnabled(false); 49 50 #ifdef DEVICE_ACCESS 51 device->onFailure(); 52 #endif 53 // Note: This application only runs when the system has 54 // power, so it will be killed by systemd sometime shortly 55 // after this power off is issued. 56 57 util::powerOff<Shutdown>(bus); 58 } 59 catch (const std::exception& e) 60 { 61 // No need to crash 62 lg2::error( 63 "Exception occurred while checking for PGOOD faults in onPowerLost: {ERROR}", 64 "ERROR", e); 65 } 66 } 67 68 } // namespace power 69 } // namespace phosphor 70