diff options
author | Hsuan Ting Chen <roccochen@chromium.org> | 2020-01-21 14:40:15 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-02-12 11:46:20 +0000 |
commit | f15845a77700a03ee89fa064b796d95ff5fa5406 (patch) | |
tree | 645e1eacd40949811df1c23e95c6a250beddb807 /firmware/lib/vboot_ui_legacy_common.c | |
parent | a3bfabdc4e4cd1c20625c8407fb1511ff4ca2eff (diff) | |
download | vboot-f15845a77700a03ee89fa064b796d95ff5fa5406.tar.gz |
vboot: Rename legacy UIs
According to crbug.com/1033815, rename files and entry point functions
for two legacy UIs. Ideally, these UIs will be deprecated after the
detachable UI revamp (b:146399181) is done.
common:
- rename vboot_ui_common.{c,h} to vboot_ui_legacy_common.{c,h}
LEGACY_CLAMSHELL_UI:
- rename vboot_ui.c to vboot_ui_legacy_clamshell.c
- rename vboot_ui_wilco.c to vboot_ui_legacy_wilco.c
- rename VbBootRecovery() to VbBootRecoveryLegacyClamshell()
- rename VbBootDiagnostic() to VbBootDiagnosticLegacyClamshell()
- rename VbBootDeveloper() to VbBootDeveloperLegacyClamshell()
LEGACY_MENU_UI:
- rename vboot_ui_menu.c to vboot_ui_legacy_menu.c
- rename vboot_ui_menu_private.h to vboot_ui_legacy_menu_private.h
- rename VbBootRecoveryMenu() to VbBootRecoveryLegacyMenu()
- rename VbBootDeveloperMenu() to VbBootDeveloperLegacyMenu()
BRANCH=none
BUG=b:146399181,chromium:1033815
TEST=USE="legacy_clamshell_ui" emerge-nami vboot_reference
TEST=USE="legacy_menu_ui" emerge-nami vboot_reference
Change-Id: I70dafbab0070b19ed963d2a4ba63a95f4a0f3224
Signed-off-by: Hsuan Ting Chen <roccochen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2008980
Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-by: Joel Kitching <kitching@chromium.org>
Diffstat (limited to 'firmware/lib/vboot_ui_legacy_common.c')
-rw-r--r-- | firmware/lib/vboot_ui_legacy_common.c | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/firmware/lib/vboot_ui_legacy_common.c b/firmware/lib/vboot_ui_legacy_common.c new file mode 100644 index 00000000..8b6a1799 --- /dev/null +++ b/firmware/lib/vboot_ui_legacy_common.c @@ -0,0 +1,113 @@ +/* Copyright 2018 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + * + * High-level firmware wrapper API - user interface for RW firmware + */ + +#include "2common.h" +#include "2misc.h" +#include "2sysincludes.h" +#include "vboot_api.h" +#include "vboot_kernel.h" +#include "vboot_test.h" +#include "vboot_ui_legacy_common.h" + +static enum { + POWER_BUTTON_HELD_SINCE_BOOT = 0, + POWER_BUTTON_RELEASED, + POWER_BUTTON_PRESSED, /* Must have been previously released */ +} power_button_state; + +void vb2_reset_power_button(void) { + power_button_state = POWER_BUTTON_HELD_SINCE_BOOT; +} + +void vb2_error_beep(enum vb2_beep_type beep) +{ + switch (beep) { + case VB_BEEP_FAILED: + VbExBeep(250, 200); + break; + default: + case VB_BEEP_NOT_ALLOWED: + VbExBeep(120, 400); + VbExSleepMs(120); + VbExBeep(120, 400); + break; + } +} + +void vb2_error_notify(const char *print_msg, + const char *log_msg, + enum vb2_beep_type beep) +{ + if (print_msg) + VbExDisplayDebugInfo(print_msg, 0); + if (!log_msg) + log_msg = print_msg; + if (log_msg) + VB2_DEBUG(log_msg); + vb2_error_beep(beep); +} + +void vb2_error_no_altfw(void) +{ + VB2_DEBUG("Legacy boot is disabled\n"); + VbExDisplayDebugInfo("WARNING: Booting legacy BIOS has not been " + "enabled. Refer to the developer-mode " + "documentation for details.\n", 0); + vb2_error_beep(VB_BEEP_NOT_ALLOWED); +} + +void vb2_try_altfw(struct vb2_context *ctx, int allowed, + enum VbAltFwIndex_t altfw_num) +{ + if (!allowed) { + vb2_error_no_altfw(); + return; + } + + if (vb2_commit_data(ctx)) { + vb2_error_notify("Error committing data on legacy boot.\n", + NULL, VB_BEEP_FAILED); + return; + } + + /* Will not return if successful */ + VbExLegacy(altfw_num); + + vb2_error_notify("Legacy boot failed. Missing BIOS?\n", NULL, + VB_BEEP_FAILED); +} + +int vb2_want_shutdown(struct vb2_context *ctx, uint32_t key) +{ + struct vb2_gbb_header *gbb = vb2_get_gbb(ctx); + uint32_t shutdown_request = VbExIsShutdownRequested(); + + /* + * Ignore power button push until after we have seen it released. + * This avoids shutting down immediately if the power button is still + * being held on startup. After we've recognized a valid power button + * push then don't report the event until after the button is released. + */ + if (shutdown_request & VB_SHUTDOWN_REQUEST_POWER_BUTTON) { + shutdown_request &= ~VB_SHUTDOWN_REQUEST_POWER_BUTTON; + if (power_button_state == POWER_BUTTON_RELEASED) + power_button_state = POWER_BUTTON_PRESSED; + } else { + if (power_button_state == POWER_BUTTON_PRESSED) + shutdown_request |= VB_SHUTDOWN_REQUEST_POWER_BUTTON; + power_button_state = POWER_BUTTON_RELEASED; + } + + if (key == VB_BUTTON_POWER_SHORT_PRESS) + shutdown_request |= VB_SHUTDOWN_REQUEST_POWER_BUTTON; + + /* If desired, ignore shutdown request due to lid closure. */ + if (gbb->flags & VB2_GBB_FLAG_DISABLE_LID_SHUTDOWN) + shutdown_request &= ~VB_SHUTDOWN_REQUEST_LID_CLOSED; + + return shutdown_request; +} |