summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Delco <delco@google.com>2019-02-13 12:31:09 -0800
committerchrome-bot <chrome-bot@chromium.org>2019-03-16 05:23:59 -0700
commitfa656b63a573c50f62ebdce46f70ee2fa2acbd23 (patch)
tree36808a7fdc6a2ad5250b6e7c99e8e62066f8136e
parent26f9bf2e1b2ebc0b9fb76281f22db6ac99db5d7e (diff)
downloadvboot-fa656b63a573c50f62ebdce46f70ee2fa2acbd23.tar.gz
vboot: add power button query functionality
The primary purpose of this change is to add a flag to VbExGetSwitches() so the current user physical presence (via the status of the power button) can be queried. The flags have also been renamed from the historical _INIT_ use to _SWITCH_ to reflect the current/actual API they're used with. BUG=b:124358784 BRANCH=none TEST=Locally built and flashed. Confirmed that the power button status can be queried when the power button is disabled. CQ-DEPEND=CL:1470273 Change-Id: I579ebe657ae35fb866eb30b466e8e8c16f54e584 Signed-off-by: Matt Delco <delco@google.com> Reviewed-on: https://chromium-review.googlesource.com/1471190 Reviewed-by: Julius Werner <jwerner@chromium.org>
-rw-r--r--firmware/include/vboot_api.h9
-rw-r--r--firmware/lib/vboot_ui.c7
-rw-r--r--firmware/lib/vboot_ui_menu.c2
-rw-r--r--tests/vboot_api_kernel2_tests.c6
4 files changed, 13 insertions, 11 deletions
diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h
index 6e738dc4..8dc3f962 100644
--- a/firmware/include/vboot_api.h
+++ b/firmware/include/vboot_api.h
@@ -203,11 +203,12 @@ typedef struct VbCommonParams {
/* Flags for VbExGetSwitches() */
/* Recovery button was pressed at boot time. */
-#define VB_INIT_FLAG_REC_BUTTON_PRESSED 0x00000002
+#define VB_SWITCH_FLAG_REC_BUTTON_PRESSED 0x00000002
+/* Report if user is currently present (typically via power button) */
+#define VB_SWITCH_FLAG_PHYS_PRESENCE_PRESSED 0x00000004
/* Allow USB boot on transition to dev */
-#define VB_INIT_FLAG_ALLOW_USB_BOOT 0x00004000
-/* Mask of deprecated flags */
-#define VB_INIT_FLAG_DEPRECATED 0x0000BFFD
+#define VB_SWITCH_FLAG_ALLOW_USB_BOOT 0x00004000
+
/*
* Output flags for VbInitParams.out_flags. Used to indicate potential boot
diff --git a/firmware/lib/vboot_ui.c b/firmware/lib/vboot_ui.c
index 3fb2ce63..274bf978 100644
--- a/firmware/lib/vboot_ui.c
+++ b/firmware/lib/vboot_ui.c
@@ -144,7 +144,8 @@ int VbUserConfirms(struct vb2_context *ctx, uint32_t confirm_flags)
/* If the recovery button is physical, and is pressed,
* this is also a YES, but must wait for release.
*/
- btn = VbExGetSwitches(VB_INIT_FLAG_REC_BUTTON_PRESSED);
+ btn = VbExGetSwitches(
+ VB_SWITCH_FLAG_REC_BUTTON_PRESSED);
if (!(shared->flags & VBSD_BOOT_REC_SWITCH_VIRTUAL)) {
if (btn) {
VB2_DEBUG("Rec button pressed\n");
@@ -740,7 +741,7 @@ static VbError_t recovery_ui(struct vb2_context *ctx)
if (!(shared->flags &
VBSD_BOOT_REC_SWITCH_VIRTUAL) &&
VbExGetSwitches(
- VB_INIT_FLAG_REC_BUTTON_PRESSED)) {
+ VB_SWITCH_FLAG_REC_BUTTON_PRESSED)) {
/*
* Is the recovery button stuck? In
* any case we don't like this. Beep
@@ -768,7 +769,7 @@ static VbError_t recovery_ui(struct vb2_context *ctx)
VB2_DEBUG("Reboot so it will take "
"effect\n");
if (VbExGetSwitches
- (VB_INIT_FLAG_ALLOW_USB_BOOT))
+ (VB_SWITCH_FLAG_ALLOW_USB_BOOT))
VbAllowUsbBoot(ctx);
return VBERROR_EC_REBOOT_TO_RO_REQUIRED;
case -1:
diff --git a/firmware/lib/vboot_ui_menu.c b/firmware/lib/vboot_ui_menu.c
index a15c8562..17c1137e 100644
--- a/firmware/lib/vboot_ui_menu.c
+++ b/firmware/lib/vboot_ui_menu.c
@@ -366,7 +366,7 @@ static VbError_t to_dev_action(struct vb2_context *ctx)
return VBERROR_TPM_SET_BOOT_MODE_STATE;
/* This was meant for headless devices, shouldn't really matter here. */
- if (VbExGetSwitches(VB_INIT_FLAG_ALLOW_USB_BOOT))
+ if (VbExGetSwitches(VB_SWITCH_FLAG_ALLOW_USB_BOOT))
vb2_nv_set(ctx, VB2_NV_DEV_BOOT_USB, 1);
VB2_DEBUG("Reboot so it will take effect\n");
diff --git a/tests/vboot_api_kernel2_tests.c b/tests/vboot_api_kernel2_tests.c
index c878ce37..006e8812 100644
--- a/tests/vboot_api_kernel2_tests.c
+++ b/tests/vboot_api_kernel2_tests.c
@@ -268,7 +268,7 @@ static void VbUserConfirmsTest(void)
0, "Untrusted keyboard");
ResetMocks();
- mock_switches[0] = VB_INIT_FLAG_REC_BUTTON_PRESSED;
+ mock_switches[0] = VB_SWITCH_FLAG_REC_BUTTON_PRESSED;
TEST_EQ(VbUserConfirms(&ctx,
VB_CONFIRM_SPACE_MEANS_NO |
VB_CONFIRM_MUST_TRUST_KEYBOARD),
@@ -279,7 +279,7 @@ static void VbUserConfirmsTest(void)
mock_keypress[1] = 'y';
mock_keypress[2] = 'z';
mock_keypress[3] = ' ';
- mock_switches[0] = VB_INIT_FLAG_REC_BUTTON_PRESSED;
+ mock_switches[0] = VB_SWITCH_FLAG_REC_BUTTON_PRESSED;
mock_switches_are_stuck = 1;
TEST_EQ(VbUserConfirms(&ctx,
VB_CONFIRM_SPACE_MEANS_NO |
@@ -998,7 +998,7 @@ static void VbBootRecTest(void)
trust_ec = 1;
shutdown_request_calls_left = 100;
mock_keypress[0] = VB_KEY_CTRL('D');
- mock_switches[0] = VB_INIT_FLAG_REC_BUTTON_PRESSED;
+ mock_switches[0] = VB_SWITCH_FLAG_REC_BUTTON_PRESSED;
TEST_EQ(VbBootRecovery(&ctx),
VBERROR_SHUTDOWN_REQUESTED,
"Ctrl+D ignored if phys rec button is still pressed");