diff options
Diffstat (limited to 'firmware/2lib/2ui_screens.c')
-rw-r--r-- | firmware/2lib/2ui_screens.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/firmware/2lib/2ui_screens.c b/firmware/2lib/2ui_screens.c index ab42f29e..5a766731 100644 --- a/firmware/2lib/2ui_screens.c +++ b/firmware/2lib/2ui_screens.c @@ -895,6 +895,27 @@ static const struct vb2_screen_info developer_to_norm_screen = { /******************************************************************************/ /* VB2_SCREEN_DEVELOPER_BOOT_EXTERNAL */ +static vb2_error_t developer_boot_external_init(struct vb2_ui_context *ui) +{ + vb2_error_t rv; + + if (!(ui->ctx->flags & VB2_CONTEXT_DEVELOPER_MODE) || + !vb2_dev_boot_allowed(ui->ctx) || + !vb2_dev_boot_external_allowed(ui->ctx)) { + VB2_DEBUG("ERROR: Dev mode external boot not allowed\n"); + ui->error_beep = 1; + ui->error_code = VB2_UI_ERROR_EXTERNAL_BOOT_NOT_ENABLED; + return vb2_ui_screen_back(ui); + } + + rv = VbTryLoadKernel(ui->ctx, VB_DISK_FLAG_REMOVABLE); + /* If the status of the external disk doesn't match, skip the screen. */ + if (rv != VB2_ERROR_LK_NO_DISK_FOUND) + return vb2_ui_screen_back(ui); + + return VB2_REQUEST_UI_CONTINUE; +} + static const struct vb2_menu_item developer_boot_external_items[] = { LANGUAGE_SELECT_ITEM, BACK_ITEM, @@ -906,6 +927,8 @@ static const struct vb2_screen_info developer_boot_external_screen = { .name = "Developer boot from external disk", .action = vb2_ui_developer_mode_boot_external_action, .menu = MENU_ITEMS(developer_boot_external_items), + .init = developer_boot_external_init, + .reinit = developer_boot_external_init, }; /******************************************************************************/ @@ -917,11 +940,34 @@ static const struct vb2_menu_item developer_invalid_disk_items[] = { POWER_OFF_ITEM, }; +static vb2_error_t developer_invalid_disk_init(struct vb2_ui_context *ui) +{ + vb2_error_t rv; + + if (!(ui->ctx->flags & VB2_CONTEXT_DEVELOPER_MODE) || + !vb2_dev_boot_allowed(ui->ctx) || + !vb2_dev_boot_external_allowed(ui->ctx)) { + VB2_DEBUG("ERROR: Dev mode external boot not allowed\n"); + ui->error_beep = 1; + ui->error_code = VB2_UI_ERROR_EXTERNAL_BOOT_NOT_ENABLED; + return vb2_ui_screen_back(ui); + } + + rv = VbTryLoadKernel(ui->ctx, VB_DISK_FLAG_REMOVABLE); + /* If the status of the external disk doesn't match, skip the screen. */ + if (rv == VB2_SUCCESS || rv == VB2_ERROR_LK_NO_DISK_FOUND) + return vb2_ui_screen_back(ui); + + return VB2_REQUEST_UI_CONTINUE; +} + static const struct vb2_screen_info developer_invalid_disk_screen = { .id = VB2_SCREEN_DEVELOPER_INVALID_DISK, .name = "Invalid external disk in dev mode", .action = vb2_ui_developer_mode_boot_external_action, .menu = MENU_ITEMS(developer_invalid_disk_items), + .init = developer_invalid_disk_init, + .reinit = developer_invalid_disk_init, }; /******************************************************************************/ |