summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Kitching <kitching@google.com>2020-05-11 15:51:51 +0800
committerCommit Bot <commit-bot@chromium.org>2020-05-18 16:13:14 +0000
commit891fc6e942e5aa035e6fec4103880af91cff24c6 (patch)
tree0735233861ea6a0c29fc30f7ac9b9f34ad5d9bda
parent23f819197799d56824ed5b8fc92a23625fe65348 (diff)
downloadvboot-891fc6e942e5aa035e6fec4103880af91cff24c6.tar.gz
vboot: move VbExGetLocalizationCount to vboot2
Rename VbExGetLocalizationCount to vb2ex_get_locale_count. Change signature to return by value instead of by parameter. BUG=b:146399181, b:156070974 TEST=make clean && make runtests BRANCH=none Change-Id: I4e3986007034724f01c9d42a382398ddacd59f33 Signed-off-by: Joel Kitching <kitching@google.com> Cq-Depend: chromium:2190612 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2193151 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Joel Kitching <kitching@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
-rw-r--r--firmware/2lib/include/2api.h21
-rw-r--r--firmware/include/vboot_api.h8
-rw-r--r--firmware/lib/vboot_display.c9
-rw-r--r--firmware/lib/vboot_ui_legacy_menu.c3
-rw-r--r--tests/vboot_display_tests.c10
-rw-r--r--tests/vboot_legacy_menu_tests.c5
6 files changed, 26 insertions, 30 deletions
diff --git a/firmware/2lib/include/2api.h b/firmware/2lib/include/2api.h
index b1bc2edc..f8a1b4e0 100644
--- a/firmware/2lib/include/2api.h
+++ b/firmware/2lib/include/2api.h
@@ -968,13 +968,6 @@ void vb2ex_abort(void);
*/
vb2_error_t vb2ex_commit_data(struct vb2_context *ctx);
-/**
- * Check that physical presence button is currently pressed by the user.
- *
- * @returns 1 for pressed, 0 for not.
- */
-int vb2ex_physical_presence_pressed(void);
-
/*****************************************************************************/
/* Auxiliary firmware (auxfw) */
@@ -1213,4 +1206,18 @@ vb2_error_t vb2ex_display_ui(enum vb2_screen screen,
uint32_t selected_item,
uint32_t disabled_item_mask);
+/**
+ * Check that physical presence button is currently pressed by the user.
+ *
+ * @returns 1 for pressed, 0 for not.
+ */
+int vb2ex_physical_presence_pressed(void);
+
+/**
+ * Get the number of supported locales.
+ *
+ * @returns Number of locales. 0 if none or on error.
+ */
+uint32_t vb2ex_get_locale_count(void);
+
#endif /* VBOOT_REFERENCE_2API_H_ */
diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h
index a8da9390..4931d59f 100644
--- a/firmware/include/vboot_api.h
+++ b/firmware/include/vboot_api.h
@@ -613,14 +613,6 @@ enum VbAltFwIndex_t {
*/
vb2_error_t VbExLegacy(enum VbAltFwIndex_t altfw_num);
-/**
- * Return number of locales supported
- *
- * @param count Pointer to the number of locales.
- * @return VBERROR_... error, VB2_SUCCESS on success.
- */
-vb2_error_t VbExGetLocalizationCount(uint32_t *count);
-
enum vb_altfw {
VB_ALTFW_COUNT = 9, /* We allow 9 bootloaders, numbered 1-9 */
};
diff --git a/firmware/lib/vboot_display.c b/firmware/lib/vboot_display.c
index e10a421f..9461d5d9 100644
--- a/firmware/lib/vboot_display.c
+++ b/firmware/lib/vboot_display.c
@@ -5,6 +5,7 @@
* Display functions used in kernel selection.
*/
+#include "2api.h"
#include "2common.h"
#include "2misc.h"
#include "2nvstorage.h"
@@ -21,9 +22,8 @@ static uint32_t disp_current_index = 0;
static uint32_t disp_disabled_idx_mask = 0;
__attribute__((weak))
-vb2_error_t VbExGetLocalizationCount(uint32_t *count) {
- *count = 0;
- return VB2_ERROR_UNKNOWN;
+uint32_t vb2ex_get_locale_count(void) {
+ return 0;
}
__attribute__((weak))
@@ -243,7 +243,8 @@ vb2_error_t VbCheckDisplayKey(struct vb2_context *ctx, uint32_t key,
case VB_KEY_DOWN:
/* Arrow keys = change localization */
loc = vb2_nv_get(ctx, VB2_NV_LOCALIZATION_INDEX);
- if (VB2_SUCCESS != VbExGetLocalizationCount(&count))
+ count = vb2ex_get_locale_count();
+ if (count == 0)
loc = 0; /* No localization count (bad GBB?) */
else if (VB_KEY_RIGHT == key || VB_KEY_UP == key)
loc = (loc < count - 1 ? loc + 1 : 0);
diff --git a/firmware/lib/vboot_ui_legacy_menu.c b/firmware/lib/vboot_ui_legacy_menu.c
index 1e1462b8..26de4871 100644
--- a/firmware/lib/vboot_ui_legacy_menu.c
+++ b/firmware/lib/vboot_ui_legacy_menu.c
@@ -700,7 +700,8 @@ static vb2_error_t vb2_init_menus(struct vb2_context *ctx)
int i;
/* Initialize language menu with the correct amount of entries. */
- if (VB2_SUCCESS != VbExGetLocalizationCount(&count) || count == 0)
+ count = vb2ex_get_locale_count();
+ if (count == 0)
count = 1; /* Fall back to 1 language entry on failure */
items = malloc(count * sizeof(struct vb2_menu_item));
diff --git a/tests/vboot_display_tests.c b/tests/vboot_display_tests.c
index b57915fb..c902614a 100644
--- a/tests/vboot_display_tests.c
+++ b/tests/vboot_display_tests.c
@@ -45,13 +45,9 @@ static void ResetMocks(void)
}
/* Mocks */
-vb2_error_t VbExGetLocalizationCount(uint32_t *count) {
+uint32_t vb2ex_get_locale_count(void) {
- if (mock_localization_count == 0xffffffff)
- return VB2_ERROR_UNKNOWN;
-
- *count = mock_localization_count;
- return VB2_SUCCESS;
+ return mock_localization_count;
}
uint32_t VbExGetAltFwIdxMask() {
@@ -113,7 +109,7 @@ static void DisplayKeyTest(void)
/* Reset localization if localization count is invalid */
ResetMocks();
vb2_nv_set(ctx, VB2_NV_LOCALIZATION_INDEX, 1);
- mock_localization_count = 0xffffffff;
+ mock_localization_count = 0;
VbCheckDisplayKey(ctx, VB_KEY_UP, NULL);
TEST_EQ(vb2_nv_get(ctx, VB2_NV_LOCALIZATION_INDEX), 0,
"DisplayKey invalid");
diff --git a/tests/vboot_legacy_menu_tests.c b/tests/vboot_legacy_menu_tests.c
index 80325f85..4a0dfaa0 100644
--- a/tests/vboot_legacy_menu_tests.c
+++ b/tests/vboot_legacy_menu_tests.c
@@ -118,9 +118,8 @@ struct vb2_gbb_header *vb2_get_gbb(struct vb2_context *c)
return &gbb;
}
-vb2_error_t VbExGetLocalizationCount(uint32_t *count) {
- *count = 1;
- return VB2_SUCCESS;
+uint32_t vb2ex_get_locale_count(void) {
+ return 1;
}
uint32_t VbExGetAltFwIdxMask() {