diff options
author | Hsuan Ting Chen <roccochen@chromium.org> | 2020-03-10 14:47:38 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-03-23 11:11:41 +0000 |
commit | b7b419d2fe421aff64fff31f785da8e26f5bf867 (patch) | |
tree | f91b24fdd1d2ba53abe309cf98690aee555fc4dd /firmware/2lib/2ui.c | |
parent | 5c9328cdc8603e7634f3942af02912357e877ef6 (diff) | |
download | vboot-stabilize-12997.B.tar.gz |
vboot: Implement dev mode boot options for menu UIstabilize-12997.B
Add dev default boot retrieval and dev boot related allowance check api in 2misc
along with their tests in vb2_misc_tests:
- vb2_get_dev_boot_target
- vb2_dev_boot_allowed
- vb2_dev_boot_legacy_allowed
- vb2_dev_boot_usb_allowed
Implement parts of vb2_developer_menu functionalities along with tests:
- Retrieve the default boot option.
- Try to boot with the specified option.
BRANCH=none
BUG=b:146399181, chromium:1033815
TEST=USE="menu_ui" emerge-nami vboot_reference depthcharge
TEST=make runtests
Change-Id: Ie82076f93b86ba5abe26a9e3e25076892684855d
Signed-off-by: Hsuan Ting Chen <roccochen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2094508
Reviewed-by: Joel Kitching <kitching@chromium.org>
Diffstat (limited to 'firmware/2lib/2ui.c')
-rw-r--r-- | firmware/2lib/2ui.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/firmware/2lib/2ui.c b/firmware/2lib/2ui.c index b6892cb9..25037c94 100644 --- a/firmware/2lib/2ui.c +++ b/firmware/2lib/2ui.c @@ -7,19 +7,42 @@ #include "2api.h" #include "2common.h" +#include "2misc.h" +#include "2nvstorage.h" +#include "2return_codes.h" +#include "2secdata.h" #include "2ui.h" +#include "vboot_kernel.h" /*****************************************************************************/ /* Entry points */ vb2_error_t vb2_developer_menu(struct vb2_context *ctx) { + enum vb2_dev_default_boot default_boot; + /* TODO(roccochen): Init, wait for user, and boot. */ vb2ex_display_ui(VB2_SCREEN_BLANK, 0); - while (1); + /* If dev mode was disabled, loop forever. */ + if (!vb2_dev_boot_allowed(ctx)) + while (1); - return VB2_SUCCESS; + /* Boot from the default option. */ + default_boot = vb2_get_dev_boot_target(ctx); + + /* Boot legacy does not return on success */ + if (default_boot == VB2_DEV_DEFAULT_BOOT_LEGACY && + vb2_dev_boot_legacy_allowed(ctx) && + VbExLegacy(VB_ALTFW_DEFAULT) == VB2_SUCCESS) + return VB2_SUCCESS; + + if (default_boot == VB2_DEV_DEFAULT_BOOT_USB && + vb2_dev_boot_usb_allowed(ctx) && + VbTryLoadKernel(ctx, VB_DISK_FLAG_REMOVABLE) == VB2_SUCCESS) + return VB2_SUCCESS; + + return VbTryLoadKernel(ctx, VB_DISK_FLAG_FIXED); } vb2_error_t vb2_broken_recovery_menu(struct vb2_context *ctx) |