From 4330d39c35cc44ab1fa5b1e6e1a35207c0635217 Mon Sep 17 00:00:00 2001 From: Evgeniy Alexeev Date: Wed, 12 Oct 2022 13:16:49 +0500 Subject: Add server commands Squashed commit of the following: commit 4ca788c95231709813bbe99220f93b4ef3e9c4ef Author: Evgeniy Alexeev Date: Wed Oct 12 12:19:45 2022 +0500 Add host boot commands, pooulate variant functions commit 21c36beefd0304a600a2f781a60559f647d569fb Author: Evgeniy Alexeev Date: Mon Oct 10 19:07:45 2022 +0500 Begin to add variant type commit b6f6416fa4dfbff9c677c4491fb42c5d3adb9d44 Author: Evgeniy Alexeev Date: Mon Oct 10 14:04:30 2022 +0500 Modify status commands in server commit 72405cee84fbddb8866a8a3d96350010266fc137 Author: Evgeniy Alexeev Date: Mon Oct 10 13:35:37 2022 +0500 Add power&policy status, get sdbus property func commit 81f88de144d6803bf4d53986193bf342772367eb Author: ironcaterpillar Date: Sat Oct 8 13:42:22 2022 +0500 Refactor d_bus_commands to separate file commit 224e5b8317e7e3ffbb04ada342447bf678297002 Author: Evgeniy Alexeev Date: Fri Oct 7 19:18:14 2022 +0500 Add power policy commands, refactor commit 94427ebcf778a2c0cc148c0344002491abdb052c Author: Evgeniy Alexeev Date: Thu Oct 6 18:23:42 2022 +0500 Add server power commands help commit 6888ffd32af65cb984792a47f65983207c00467e Author: Evgeniy Alexeev Date: Thu Oct 6 17:31:26 2022 +0500 Add unknown power command error message commit 5d1b4a2000820de903f10959b499c758eba383e0 Author: Evgeniy Alexeev Date: Thu Oct 6 15:54:37 2022 +0500 Fix host power dbus property name commit 49f8a15abdfb749427bd5769725b3ad54dc0583b Author: Evgeniy Alexeev Date: Thu Oct 6 13:27:37 2022 +0500 Add .gitignore commit 96569d5f9c7f245fd82545919a1910828c1058d9 Author: Evgeniy Alexeev Date: Thu Oct 6 13:27:10 2022 +0500 Add sdbus, server power commands --- src/host_commands.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 src/host_commands.c (limited to 'src/host_commands.c') diff --git a/src/host_commands.c b/src/host_commands.c new file mode 100644 index 0000000..d832ef8 --- /dev/null +++ b/src/host_commands.c @@ -0,0 +1,101 @@ +#include +#include + +#include "host_commands.h" + +static const string_quadruple_t boot_override_type_dbus = { + "xyz.openbmc_project.Settings", + "/xyz/openbmc_project/control/host0/boot", + "xyz.openbmc_project.Control.Boot.Type", + "BootType"}; + +static const string_quadruple_t boot_override_mode_dbus = { + "xyz.openbmc_project.Settings", + "/xyz/openbmc_project/control/host0/boot", + "xyz.openbmc_project.Control.Boot.Mode", + "BootMode"}; + +static const string_quadruple_t boot_override_source_dbus = { + "xyz.openbmc_project.Settings", + "/xyz/openbmc_project/control/host0/boot", + "xyz.openbmc_project.Control.Boot.Source", + "BootSource"}; + +static const string_quadruple_t boot_override_enable_dbus = { + "xyz.openbmc_project.Settings", + "/xyz/openbmc_project/control/host0/boot", + "xyz.openbmc_project.Object.Enable", + "Enabled"}; + +static const string_quadruple_t boot_override_once_dbus = { + "xyz.openbmc_project.Settings", + "/xyz/openbmc_project/control/host0/boot/one_time", + "xyz.openbmc_project.Object.Enable", + "Enabled"}; + +typedef enum +{ + HOST_UNKNOWN=-1, + HOST_CD, + HOST_USB, + HOST_BOOT_OVERRIDE, + HOST_BOOT_NO_OVERRIDE, + HOST_BOOT_REGULAR, + HOST_BOOT_BIOS, + HOST_BOOT_SAFE, + HOST_ONE_TIME, + HOST_CONTINOUS, + HOST_LEGACY, + HOST_UEFI +}host_command_t; + +static universal_command_t host_commands[] = { + { "cd", HOST_CD, "Boot from virtual CD-ROM"}, + { "usb", HOST_USB, "Boot from virtual USB drive"}, + { "override", HOST_BOOT_OVERRIDE, "Override host chosen boot options"}, + { "no-override", HOST_BOOT_NO_OVERRIDE, "Don't override host chosen boot options"}, + { "regular", HOST_BOOT_REGULAR, "Regular boot type"}, + { "bios", HOST_BOOT_BIOS, "Boot into BIOS"}, + { "safe", HOST_BOOT_SAFE, "Boot in safe mode"}, + { "override-once", HOST_ONE_TIME, "Override only next boot"}, + { "override-always", HOST_CONTINOUS, "Override always"}, + { "legacy", HOST_LEGACY, "Legacy type boot"}, + { "uefi", HOST_UEFI, "UEFI boot"}, + { NULL, 0, NULL } +}; + +static const command_dbus_path_t host_command_paths[] = { + { HOST_CD, &boot_override_source_dbus }, + { HOST_USB, &boot_override_source_dbus }, + { HOST_BOOT_OVERRIDE, &boot_override_enable_dbus }, + { HOST_BOOT_NO_OVERRIDE, &boot_override_enable_dbus }, + { HOST_BOOT_REGULAR, &boot_override_mode_dbus }, + { HOST_BOOT_BIOS, &boot_override_mode_dbus }, + { HOST_BOOT_SAFE, &boot_override_mode_dbus }, + { HOST_ONE_TIME, &boot_override_once_dbus }, + { HOST_CONTINOUS, &boot_override_once_dbus }, + { HOST_LEGACY, &boot_override_type_dbus }, + { HOST_UEFI, &boot_override_type_dbus }, + { 0, NULL } +}; + +static const command_dbus_member_t host_command_values[] = { + { HOST_CD, { .type="s", .string="xyz.openbmc_project.Control.Boot.Source.Sources.ExternalMedia"}}, + { HOST_USB, { .type="s", .string="xyz.openbmc_project.Control.Boot.Source.Sources.RemovableMedia"}}, + { HOST_BOOT_OVERRIDE, { .type="b", .boolean=true}}, + { HOST_BOOT_NO_OVERRIDE, { .type="b", .boolean=false}}, + { HOST_BOOT_REGULAR, { .type="s", .string="xyz.openbmc_project.Control.Boot.Mode.Modes.Regular"}}, + { HOST_BOOT_BIOS, { .type="s", .string="xyz.openbmc_project.Control.Boot.Mode.Modes.Setup"}}, + { HOST_BOOT_SAFE,{ .type="s", .string="xyz.openbmc_project.Control.Boot.Mode.Modes.Safe"}}, + { HOST_ONE_TIME, { .type="b", .boolean=true}}, + { HOST_CONTINOUS, { .type="b", .boolean=false}}, + { HOST_LEGACY, { .type="s", .string="xyz.openbmc_project.Control.Boot.Type.Types.Legacy"} }, + { HOST_UEFI, { .type="s", .string="xyz.openbmc_project.Control.Boot.Type.Types.EFI"} }, + { 0, {.type=NULL, .integer=0}} +}; + +int com_boot( char *arg ) +{ + //if(strcmp(arg, "status")==0)return power_status(); + return com_dbus_property(arg, host_commands, host_command_paths, host_command_values); +} -- cgit v1.2.3