1a9d39e30SKuiying Wang /* 2a9d39e30SKuiying Wang // Copyright (c) 2018 Intel Corporation 3a9d39e30SKuiying Wang // 4a9d39e30SKuiying Wang // Licensed under the Apache License, Version 2.0 (the "License"); 5a9d39e30SKuiying Wang // you may not use this file except in compliance with the License. 6a9d39e30SKuiying Wang // You may obtain a copy of the License at 7a9d39e30SKuiying Wang // 8a9d39e30SKuiying Wang // http://www.apache.org/licenses/LICENSE-2.0 9a9d39e30SKuiying Wang // 10a9d39e30SKuiying Wang // Unless required by applicable law or agreed to in writing, software 11a9d39e30SKuiying Wang // distributed under the License is distributed on an "AS IS" BASIS, 12a9d39e30SKuiying Wang // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a9d39e30SKuiying Wang // See the License for the specific language governing permissions and 14a9d39e30SKuiying Wang // limitations under the License. 15a9d39e30SKuiying Wang */ 16a9d39e30SKuiying Wang 17a9d39e30SKuiying Wang #pragma once 18a1af329fSNaveen Moses #include "button_factory.hpp" 19a1af329fSNaveen Moses #include "button_interface.hpp" 20a9d39e30SKuiying Wang #include "common.hpp" 21*15c60e2fSDelphine CC Chiu #include "config.hpp" 22a9d39e30SKuiying Wang #include "gpio.hpp" 230d9377d2SPatrick Venture #include "xyz/openbmc_project/Chassis/Buttons/Reset/server.hpp" 240d9377d2SPatrick Venture #include "xyz/openbmc_project/Chassis/Common/error.hpp" 250d9377d2SPatrick Venture 260d9377d2SPatrick Venture #include <unistd.h> 270d9377d2SPatrick Venture 280d9377d2SPatrick Venture #include <phosphor-logging/elog-errors.hpp> 29a9d39e30SKuiying Wang 30a1af329fSNaveen Moses static constexpr std::string_view RESET_BUTTON = "RESET_BUTTON"; 31a9d39e30SKuiying Wang 325b98f4dbSGeorge Liu class ResetButton : 339a529a69SPatrick Williams public sdbusplus::server::object_t< 34a1af329fSNaveen Moses sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Reset>, 35a1af329fSNaveen Moses public ButtonIface 36a9d39e30SKuiying Wang { 37a1af329fSNaveen Moses public: ResetButton(sdbusplus::bus_t & bus,const char * path,EventPtr & event,ButtonConfig & buttonCfg)389a529a69SPatrick Williams ResetButton(sdbusplus::bus_t& bus, const char* path, EventPtr& event, 39ccd7db05SDelphine CC Chiu ButtonConfig& buttonCfg) : 409a529a69SPatrick Williams sdbusplus::server::object_t< 41a9d39e30SKuiying Wang sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Reset>( 42a9d39e30SKuiying Wang bus, path), 43a1af329fSNaveen Moses ButtonIface(bus, event, buttonCfg) 44a9d39e30SKuiying Wang { 45a1af329fSNaveen Moses init(); 46a9d39e30SKuiying Wang } 47a9d39e30SKuiying Wang ~ResetButton()48a9d39e30SKuiying Wang ~ResetButton() 49a9d39e30SKuiying Wang { 50a1af329fSNaveen Moses deInit(); 51a9d39e30SKuiying Wang } 52a9d39e30SKuiying Wang 53a9d39e30SKuiying Wang void simPress() override; 54a9d39e30SKuiying Wang getFormFactorName()55a1af329fSNaveen Moses static constexpr std::string_view getFormFactorName() 568605bdffSMatt Spinler { 578605bdffSMatt Spinler return RESET_BUTTON; 588605bdffSMatt Spinler } 598605bdffSMatt Spinler getDbusObjectPath()60a1af329fSNaveen Moses static constexpr const char* getDbusObjectPath() 61a9d39e30SKuiying Wang { 62a1af329fSNaveen Moses return RESET_DBUS_OBJECT_NAME; 63a9d39e30SKuiying Wang } 64a9d39e30SKuiying Wang 65a1af329fSNaveen Moses void handleEvent(sd_event_source* es, int fd, uint32_t revents) override; 66a9d39e30SKuiying Wang }; 67