blob: bbae539d3bd57c5317783e4281df97f5b3b312b7 [file] [log] [blame]
Naveen Mosesa6d4e652022-04-13 19:27:25 +05301
2#pragma once
Naveen Mosesa6d4e652022-04-13 19:27:25 +05303#include "button_factory.hpp"
4#include "button_interface.hpp"
5#include "common.hpp"
Delphine CC Chiu15c60e22024-04-12 13:01:32 -05006#include "config.hpp"
Naveen Mosesa6d4e652022-04-13 19:27:25 +05307#include "gpio.hpp"
8#include "xyz/openbmc_project/Chassis/Buttons/Button/server.hpp"
9#include "xyz/openbmc_project/Chassis/Common/error.hpp"
10
11#include <unistd.h>
12
13#include <phosphor-logging/elog-errors.hpp>
14#include <phosphor-logging/lg2.hpp>
15
16static constexpr std::string_view DEBUG_SELECTOR_BUTTON =
17 "DEBUG_SELECTOR_BUTTON";
18
19class DebugHostSelector final :
20 public sdbusplus::server::object_t<
21 sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Button>,
22 public ButtonIface
23
24{
25 public:
Patrick Williamse3b4e112022-11-26 09:41:58 -060026 DebugHostSelector(sdbusplus::bus_t& bus, const char* path, EventPtr& event,
Delphine CC Chiuccd7db02023-02-09 14:48:53 +080027 ButtonConfig& buttonCfg) :
Naveen Mosesa6d4e652022-04-13 19:27:25 +053028 sdbusplus::server::object_t<
29 sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Button>(
30 bus, path, action::defer_emit),
31 ButtonIface(bus, event, buttonCfg)
32 {
33 init();
34 emit_object_added();
35 }
36
37 ~DebugHostSelector()
38 {
39 deInit();
40 }
41
42 void simPress() override;
43 void simRelease() override;
44 void simLongPress() override;
45 void handleEvent(sd_event_source* es, int fd, uint32_t revents) override;
46
47 static constexpr std::string_view getFormFactorName()
48 {
49 return DEBUG_SELECTOR_BUTTON;
50 }
51
52 static const char* getDbusObjectPath()
53 {
54 return DBG_HS_DBUS_OBJECT_NAME;
55 }
56};