1 /* 2 // Copyright (c) 2018 Intel 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 17 #pragma once 18 #include "button_factory.hpp" 19 #include "button_interface.hpp" 20 #include "common.hpp" 21 #include "gpio.hpp" 22 #include "xyz/openbmc_project/Chassis/Buttons/Reset/server.hpp" 23 #include "xyz/openbmc_project/Chassis/Common/error.hpp" 24 25 #include <unistd.h> 26 27 #include <phosphor-logging/elog-errors.hpp> 28 29 static constexpr std::string_view RESET_BUTTON = "RESET_BUTTON"; 30 31 class ResetButton : 32 public sdbusplus::server::object::object< 33 sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Reset>, 34 public ButtonIface 35 { 36 public: 37 ResetButton(sdbusplus::bus::bus& bus, const char* path, EventPtr& event, 38 buttonConfig& buttonCfg) : 39 sdbusplus::server::object::object< 40 sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Reset>( 41 bus, path), 42 ButtonIface(bus, event, buttonCfg) 43 { 44 init(); 45 } 46 47 ~ResetButton() 48 { 49 deInit(); 50 } 51 52 void simPress() override; 53 54 static constexpr std::string_view getFormFactorName() 55 { 56 return RESET_BUTTON; 57 } 58 59 static constexpr const char* getDbusObjectPath() 60 { 61 return RESET_DBUS_OBJECT_NAME; 62 } 63 64 void handleEvent(sd_event_source* es, int fd, uint32_t revents) override; 65 }; 66