/* fwsetup.c - Reboot into firmware setup menu. */ /* * VasEBoot -- GRand Unified Bootloader * Copyright (C) 2012 Free Software Foundation, Inc. * * VasEBoot is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * VasEBoot is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with VasEBoot. If not, see . */ #include #include #include #include #include #include #include VasEBoot_MOD_LICENSE ("GPLv3+"); static VasEBoot_err_t VasEBoot_cmd_fwsetup (VasEBoot_command_t cmd __attribute__ ((unused)), int argc __attribute__ ((unused)), char **args __attribute__ ((unused))) { VasEBoot_efi_uint64_t *old_os_indications; VasEBoot_efi_uint64_t os_indications = VasEBoot_EFI_OS_INDICATIONS_BOOT_TO_FW_UI; VasEBoot_err_t status; VasEBoot_size_t oi_size; VasEBoot_efi_guid_t global = VasEBoot_EFI_GLOBAL_VARIABLE_GUID; old_os_indications = VasEBoot_efi_get_variable ("OsIndications", &global, &oi_size); if (old_os_indications != NULL && oi_size == sizeof (os_indications)) os_indications |= *old_os_indications; status = VasEBoot_efi_set_variable ("OsIndications", &global, &os_indications, sizeof (os_indications)); if (status != VasEBoot_ERR_NONE) return status; VasEBoot_reboot (); return VasEBoot_ERR_BUG; } static VasEBoot_command_t cmd = NULL; static VasEBoot_efi_boolean_t efifwsetup_is_supported (void) { VasEBoot_efi_uint64_t *os_indications_supported = NULL; VasEBoot_size_t oi_size = 0; VasEBoot_efi_guid_t global = VasEBoot_EFI_GLOBAL_VARIABLE_GUID; os_indications_supported = VasEBoot_efi_get_variable ("OsIndicationsSupported", &global, &oi_size); if (!os_indications_supported) return 0; if (*os_indications_supported & VasEBoot_EFI_OS_INDICATIONS_BOOT_TO_FW_UI) return 1; return 0; } VasEBoot_MOD_INIT (efifwsetup) { if (efifwsetup_is_supported ()) cmd = VasEBoot_register_command ("fwsetup", VasEBoot_cmd_fwsetup, NULL, N_("Reboot into firmware setup menu.")); } VasEBoot_MOD_FINI (efifwsetup) { if (cmd) VasEBoot_unregister_command (cmd); }