summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-10-19 20:40:17 -0600
committerchrome-bot <chrome-bot@chromium.org>2018-10-26 17:19:12 -0700
commite156d3a3ec014d148009a1fe4e2fe97d5560d66e (patch)
tree60d6297fba443f555d252ec2ade63fd5e1da9379
parent4b5879805ac75dea9ea74a338f0f8a5d7f5edca1 (diff)
downloadvboot-e156d3a3ec014d148009a1fe4e2fe97d5560d66e.tar.gz
Add a parameter to vb2_error_beep()
We have two different types of beep each with its own meaning: - two high beeps: not allowed - single low beep: allowed but it failed Add an enum to cover this and update all callers. In VbTryUsb() there is a delay after the beep but that does not seem to be needed, so drop it. BUG=chromium:837018 BRANCH=none TEST=FEATURES=test emerge-grunt --nodeps vboot_reference Change-Id: I824d088d1a51aeb5a35b5978a05533e8eabcf8f6 Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1292246 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Julius Werner <jwerner@chromium.org>
-rw-r--r--firmware/lib/include/vboot_kernel.h9
-rw-r--r--firmware/lib/vboot_ui.c23
-rw-r--r--firmware/lib/vboot_ui_menu.c20
3 files changed, 32 insertions, 20 deletions
diff --git a/firmware/lib/include/vboot_kernel.h b/firmware/lib/include/vboot_kernel.h
index 37243865..eaddcea5 100644
--- a/firmware/lib/include/vboot_kernel.h
+++ b/firmware/lib/include/vboot_kernel.h
@@ -122,9 +122,14 @@ void vb2_exit_altfw(void);
*/
void vb2_try_alt_fw(int allowed, int altfw_num);
+enum vb2_beep_type {
+ VB_BEEP_FAILED, /* Permitted but the operation failed */
+ VB_BEEP_NOT_ALLOWED, /* Operation disabled by user setting */
+};
+
/**
- * Emit two short beeps to indicate an error
+ * Emit beeps to indicate an error
*/
-void vb2_error_beep(void);
+void vb2_error_beep(enum vb2_beep_type beep);
#endif /* VBOOT_REFERENCE_VBOOT_KERNEL_H_ */
diff --git a/firmware/lib/vboot_ui.c b/firmware/lib/vboot_ui.c
index e2ee0a6e..b7555cd0 100644
--- a/firmware/lib/vboot_ui.c
+++ b/firmware/lib/vboot_ui.c
@@ -73,11 +73,19 @@ static int VbWantShutdown(struct vb2_context *ctx, uint32_t key)
}
/* Two short beeps to notify the user that attempted action was disallowed. */
-void vb2_error_beep(void)
+void vb2_error_beep(enum vb2_beep_type beep)
{
- VbExBeep(120, 400);
- VbExSleepMs(120);
- VbExBeep(120, 400);
+ 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;
+ }
}
int vb2_prepare_alt_fw(int allowed)
@@ -98,7 +106,7 @@ int vb2_prepare_alt_fw(int allowed)
void vb2_exit_altfw(void)
{
- vb2_error_beep();
+ vb2_error_beep(VB_BEEP_FAILED);
}
void vb2_try_alt_fw(int allowed, int altfw_num)
@@ -115,8 +123,7 @@ uint32_t VbTryUsb(struct vb2_context *ctx)
VB2_DEBUG("VbBootDeveloper() - booting USB\n");
} else {
VB2_DEBUG("VbBootDeveloper() - no kernel found on USB\n");
- VbExBeep(250, 200);
- VbExSleepMs(120);
+ vb2_error_beep(VB_BEEP_FAILED);
/*
* Clear recovery requests from failed
* kernel loading, so that powering off
@@ -381,7 +388,7 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx)
"(USB/SD) has not been enabled. Refer "
"to the developer-mode documentation "
"for details.\n");
- vb2_error_beep();
+ vb2_error_beep(VB_BEEP_NOT_ALLOWED);
} else {
/*
* Clear the screen to show we get the Ctrl+U
diff --git a/firmware/lib/vboot_ui_menu.c b/firmware/lib/vboot_ui_menu.c
index 8f610ab9..84bb8e64 100644
--- a/firmware/lib/vboot_ui_menu.c
+++ b/firmware/lib/vboot_ui_menu.c
@@ -107,7 +107,7 @@ static VbError_t boot_disk_action(struct vb2_context *ctx)
{
if (disable_dev_boot) {
vb2_flash_screen(ctx);
- vb2_error_beep();
+ vb2_error_beep(VB_BEEP_NOT_ALLOWED);
return VBERROR_KEEP_LOOPING;
}
VB2_DEBUG("trying fixed disk\n");
@@ -121,7 +121,7 @@ static VbError_t boot_legacy_action(struct vb2_context *ctx)
if (disable_dev_boot) {
vb2_flash_screen(ctx);
- vb2_error_beep();
+ vb2_error_beep(VB_BEEP_NOT_ALLOWED);
return VBERROR_KEEP_LOOPING;
}
@@ -131,7 +131,7 @@ static VbError_t boot_legacy_action(struct vb2_context *ctx)
VbExDisplayDebugInfo("WARNING: Booting legacy BIOS has not "
"been enabled. Refer to the developer"
"-mode documentation for details.\n");
- vb2_error_beep();
+ vb2_error_beep(VB_BEEP_NOT_ALLOWED);
return VBERROR_KEEP_LOOPING;
}
@@ -143,7 +143,7 @@ static VbError_t boot_legacy_action(struct vb2_context *ctx)
vb2_flash_screen(ctx);
VB2_DEBUG(no_legacy);
VbExDisplayDebugInfo(no_legacy);
- VbExBeep(250, 200);
+ vb2_error_beep(VB_BEEP_FAILED);
return VBERROR_KEEP_LOOPING;
}
@@ -154,7 +154,7 @@ static VbError_t boot_usb_action(struct vb2_context *ctx)
if (disable_dev_boot) {
vb2_flash_screen(ctx);
- vb2_error_beep();
+ vb2_error_beep(VB_BEEP_NOT_ALLOWED);
return VBERROR_KEEP_LOOPING;
}
@@ -167,7 +167,7 @@ static VbError_t boot_usb_action(struct vb2_context *ctx)
"(USB/SD) has not been enabled. Refer "
"to the developer-mode documentation "
"for details.\n");
- vb2_error_beep();
+ vb2_error_beep(VB_BEEP_NOT_ALLOWED);
return VBERROR_KEEP_LOOPING;
}
@@ -181,7 +181,7 @@ static VbError_t boot_usb_action(struct vb2_context *ctx)
vb2_flash_screen(ctx);
VB2_DEBUG(no_kernel);
VbExDisplayDebugInfo(no_kernel);
- VbExBeep(250, 200);
+ vb2_error_beep(VB_BEEP_FAILED);
return VBERROR_KEEP_LOOPING;
}
@@ -247,7 +247,7 @@ static VbError_t enter_to_dev_menu(struct vb2_context *ctx)
vb2_flash_screen(ctx);
VB2_DEBUG(dev_already_on);
VbExDisplayDebugInfo(dev_already_on);
- vb2_error_beep();
+ vb2_error_beep(VB_BEEP_NOT_ALLOWED);
return VBERROR_KEEP_LOOPING;
}
vb2_change_menu(VB_MENU_TO_DEV, VB_TO_DEV_CANCEL);
@@ -333,7 +333,7 @@ static VbError_t to_norm_action(struct vb2_context *ctx)
VB2_DEBUG("TONORM rejected by FORCE_DEV_SWITCH_ON\n");
VbExDisplayDebugInfo("WARNING: TONORM prohibited by "
"GBB FORCE_DEV_SWITCH_ON.\n\n");
- vb2_error_beep();
+ vb2_error_beep(VB_BEEP_NOT_ALLOWED);
return VBERROR_KEEP_LOOPING;
}
@@ -411,7 +411,7 @@ static VbError_t vb2_handle_menu_input(struct vb2_context *ctx,
if (current_menu == VB_MENU_TO_DEV &&
!(key_flags & VB_KEY_FLAG_TRUSTED_KEYBOARD)) {
vb2_flash_screen(ctx);
- vb2_error_beep();
+ vb2_error_beep(VB_BEEP_NOT_ALLOWED);
break;
}