blob: f1354aad1cba8e65125da3f0771566caa515dfe2 [file] [log] [blame]
Ben Tyner792f32f2020-06-02 08:50:47 -05001#include <attn_handler.hpp>
Ben Tynerb1ebfcb2020-05-08 18:52:48 -05002#include <attn_logging.hpp>
Ben Tyner9ae5ca42020-02-28 13:13:50 -06003#include <sdbusplus/bus.hpp>
Ben Tyner792f32f2020-06-02 08:50:47 -05004#include <ti_handler.hpp>
Ben Tyner9ae5ca42020-02-28 13:13:50 -06005
Ben Tyner9ae5ca42020-02-28 13:13:50 -06006namespace attn
7{
8
9/** @brief Start host diagnostic mode systemd unit */
Ben Tyner792f32f2020-06-02 08:50:47 -050010int tiHandler(TiDataArea* i_tiDataArea)
Ben Tyner9ae5ca42020-02-28 13:13:50 -060011{
Ben Tyner792f32f2020-06-02 08:50:47 -050012 int rc = RC_NOT_HANDLED; // assume TI not handled
Ben Tyner9ae5ca42020-02-28 13:13:50 -060013
Ben Tyner792f32f2020-06-02 08:50:47 -050014 if (0xa1 == i_tiDataArea->command)
15 {
16 // trace message
17 trace<level::INFO>("start host diagnostic mode service");
Ben Tyner9ae5ca42020-02-28 13:13:50 -060018
Ben Tyner792f32f2020-06-02 08:50:47 -050019 // Use the systemd service manager object interface to call the start
20 // unit method with the obmc-host-diagnostic-mode target.
21 auto bus = sdbusplus::bus::new_system();
22 auto method = bus.new_method_call(
23 "org.freedesktop.systemd1", "/org/freedesktop/systemd1",
24 "org.freedesktop.systemd1.Manager", "StartUnit");
Ben Tyner9ae5ca42020-02-28 13:13:50 -060025
Ben Tyner792f32f2020-06-02 08:50:47 -050026 method.append("obmc-host-diagnostic-mode@0.target"); // unit to activate
27 method.append("replace"); // mode = replace conflicting queued jobs
28 bus.call_noreply(method); // start the service
29
30 rc = RC_SUCCESS;
31 }
32
33 return rc;
Ben Tyner9ae5ca42020-02-28 13:13:50 -060034}
35
36} // namespace attn