blob: 17431d4422fbed2fb7aa8cb7989b2c2b99549eb0 [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
Rush Chen31ce3752024-11-08 14:57:27 +080016static constexpr auto DEBUG_SELECTOR_BUTTON = "DEBUG_SELECTOR_BUTTON";
Naveen Mosesa6d4e652022-04-13 19:27:25 +053017
18class DebugHostSelector final :
19 public sdbusplus::server::object_t<
20 sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Button>,
21 public ButtonIface
22
23{
24 public:
Patrick Williamse3b4e112022-11-26 09:41:58 -060025 DebugHostSelector(sdbusplus::bus_t& bus, const char* path, EventPtr& event,
Delphine CC Chiuccd7db02023-02-09 14:48:53 +080026 ButtonConfig& buttonCfg) :
Naveen Mosesa6d4e652022-04-13 19:27:25 +053027 sdbusplus::server::object_t<
28 sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Button>(
29 bus, path, action::defer_emit),
30 ButtonIface(bus, event, buttonCfg)
31 {
32 init();
33 emit_object_added();
34 }
35
36 ~DebugHostSelector()
37 {
38 deInit();
39 }
40
41 void simPress() override;
42 void simRelease() override;
43 void simLongPress() override;
44 void handleEvent(sd_event_source* es, int fd, uint32_t revents) override;
45
Rush Chen31ce3752024-11-08 14:57:27 +080046 static constexpr std::string getFormFactorName()
Naveen Mosesa6d4e652022-04-13 19:27:25 +053047 {
48 return DEBUG_SELECTOR_BUTTON;
49 }
50
Rush Chen31ce3752024-11-08 14:57:27 +080051 static constexpr std::string getDbusObjectPath()
Naveen Mosesa6d4e652022-04-13 19:27:25 +053052 {
53 return DBG_HS_DBUS_OBJECT_NAME;
54 }
55};