summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoredisonhello <edisonhello@google.com>2021-07-21 21:07:05 +0800
committerCommit Bot <commit-bot@chromium.org>2021-07-27 09:32:21 +0000
commit0181eda805c613eccf98e4cf26ec213118898b52 (patch)
treec9e91871a41d5dfd38e1195e74881051b7d8235d
parent8fb3795bf355b8d33ed30b7aa9ad3be7804b4fb9 (diff)
downloadvboot-0181eda805c613eccf98e4cf26ec213118898b52.tar.gz
vboot: Add vb2api_set_locale_id
Add vb2api_set_locale_id to vboot2 API. Replace the direct access to vb2_nv_get and vb2_nv_set in ui functions with vb2api_get_locale_id and vb2api_set_locale_id. BUG=b:172339016 TEST=export CC=x86_64-pc-linux-gnu-clang DEBUG=1 DIAGNOSTIC_UI=1 \ MINIMAL=1; make -j32 test_setup && make -j32 runtests; TEST=Hayato booted into developer mode BRANCH=none Signed-off-by: edisonhello <edisonhello@google.com> Change-Id: I5a92e571eceed6a402d0d80caa567bb9d77341a3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3041506 Commit-Queue: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
-rw-r--r--firmware/2lib/2misc.c5
-rw-r--r--firmware/2lib/2ui.c2
-rw-r--r--firmware/2lib/2ui_screens.c2
-rw-r--r--firmware/2lib/include/2api.h8
4 files changed, 15 insertions, 2 deletions
diff --git a/firmware/2lib/2misc.c b/firmware/2lib/2misc.c
index 75a9f360..e30deb4f 100644
--- a/firmware/2lib/2misc.c
+++ b/firmware/2lib/2misc.c
@@ -459,6 +459,11 @@ uint32_t vb2api_get_locale_id(struct vb2_context *ctx)
return vb2_nv_get(ctx, VB2_NV_LOCALIZATION_INDEX);
}
+void vb2api_set_locale_id(struct vb2_context *ctx, uint32_t locale_id)
+{
+ vb2_nv_set(ctx, VB2_NV_LOCALIZATION_INDEX, locale_id);
+}
+
void vb2api_export_vbsd(struct vb2_context *ctx, void *dest)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
diff --git a/firmware/2lib/2ui.c b/firmware/2lib/2ui.c
index 8b2ebf45..1850b8f7 100644
--- a/firmware/2lib/2ui.c
+++ b/firmware/2lib/2ui.c
@@ -308,7 +308,7 @@ static vb2_error_t ui_loop_impl(
root_info = vb2_get_screen_info(root_screen_id);
if (root_info == NULL)
VB2_DIE("Root screen not found.\n");
- ui.locale_id = vb2_nv_get(ctx, VB2_NV_LOCALIZATION_INDEX);
+ ui.locale_id = vb2api_get_locale_id(ctx);
rv = vb2_ui_screen_change(&ui, root_screen_id);
if (rv && rv != VB2_REQUEST_UI_CONTINUE)
diff --git a/firmware/2lib/2ui_screens.c b/firmware/2lib/2ui_screens.c
index a029d62b..7b48b842 100644
--- a/firmware/2lib/2ui_screens.c
+++ b/firmware/2lib/2ui_screens.c
@@ -185,7 +185,7 @@ static vb2_error_t language_select_action(struct vb2_ui_context *ui)
VB2_DEBUG("Locale changed to %u\n", ui->locale_id);
/* Write locale id back to nvdata. */
- vb2_nv_set(ui->ctx, VB2_NV_LOCALIZATION_INDEX, ui->locale_id);
+ vb2api_set_locale_id(ui->ctx, ui->locale_id);
/* Commit nvdata changes immediately, in case of three-finger salute
reboot. Ignore commit errors in recovery mode. */
diff --git a/firmware/2lib/include/2api.h b/firmware/2lib/include/2api.h
index 2ab2af3b..f59c2494 100644
--- a/firmware/2lib/include/2api.h
+++ b/firmware/2lib/include/2api.h
@@ -871,6 +871,14 @@ uint32_t vb2api_get_recovery_reason(struct vb2_context *ctx);
uint32_t vb2api_get_locale_id(struct vb2_context *ctx);
/**
+ * Set the locale id in nvdata.
+ *
+ * @param ctx Vboot context
+ * @param locale_id The locale id to be set
+ */
+void vb2api_set_locale_id(struct vb2_context *ctx, uint32_t locale_id);
+
+/**
* Whether phone recovery functionality is enabled or not.
*
* @param ctx Vboot context