summaryrefslogtreecommitdiff
path: root/firmware/lib/vboot_ui.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/lib/vboot_ui.c')
-rw-r--r--firmware/lib/vboot_ui.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/firmware/lib/vboot_ui.c b/firmware/lib/vboot_ui.c
index 217090ad..289e0009 100644
--- a/firmware/lib/vboot_ui.c
+++ b/firmware/lib/vboot_ui.c
@@ -25,6 +25,14 @@
#include "vboot_display.h"
#include "vboot_kernel.h"
+/* Global variables */
+static int power_button_released;
+
+static void vb2_init_ui(void)
+{
+ power_button_released = 0;
+}
+
static void VbAllowUsbBoot(struct vb2_context *ctx)
{
VB2_DEBUG(".");
@@ -42,6 +50,18 @@ static int VbWantShutdown(struct vb2_context *ctx, uint32_t key)
struct vb2_shared_data *sd = vb2_get_sd(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.
+ */
+ if (shutdown_request & VB_SHUTDOWN_REQUEST_POWER_BUTTON) {
+ if (!power_button_released)
+ shutdown_request &= ~VB_SHUTDOWN_REQUEST_POWER_BUTTON;
+ } else {
+ power_button_released = 1;
+ }
+
if (key == VB_BUTTON_POWER_SHORT_PRESS)
shutdown_request |= VB_SHUTDOWN_REQUEST_POWER_BUTTON;
@@ -402,6 +422,7 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx)
VbError_t VbBootDeveloper(struct vb2_context *ctx)
{
+ vb2_init_ui();
VbError_t retval = vb2_developer_ui(ctx);
VbDisplayScreen(ctx, VB_SCREEN_BLANK, 0);
return retval;
@@ -552,6 +573,7 @@ static VbError_t recovery_ui(struct vb2_context *ctx)
VbError_t VbBootRecovery(struct vb2_context *ctx)
{
+ vb2_init_ui();
VbError_t retval = recovery_ui(ctx);
VbDisplayScreen(ctx, VB_SCREEN_BLANK, 0);
return retval;