diff options
-rw-r--r-- | firmware/lib/include/vboot_kernel.h | 9 | ||||
-rw-r--r-- | firmware/lib/vboot_ui.c | 23 | ||||
-rw-r--r-- | firmware/lib/vboot_ui_menu.c | 20 |
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; } |