summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Kitching <kitching@google.com>2018-10-02 20:54:07 +0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-10-09 16:03:27 +0000
commit64d7369976b88b21d8d8a860252023776a2f119e (patch)
tree21237133d999ef28d21b6097e805d4fe7a5fd50e
parent5119789d52e5179b24bf35a7cec9090c40a616bd (diff)
downloadvboot-64d7369976b88b21d8d8a860252023776a2f119e.tar.gz
vboot: create NVRAM flag to pause after EC software sync
Previously, it is impossible to programmatically enable/disable Alt OS mode in eve. This is because only EC-RW supports the kbatboot keyboard matrix functionality. But, as part of the campfire boot flow, the keyboard matrix is retrieved *immediately* after jumping into EC-RW. We need to insert a small pause in order to allow for some entity (autotest/servo) to send a kbatboot command, simulating the Alt OS keyboard press hotkey. BUG=b:117140648 TEST=Manually use crossystem to set post_ec_sync_delay=1 Reboot, and wait for the delay to begin Run `kbatboot 1 4 1` in EC console Check that AP console contains: "vb2_post_ec_sync_hooks: post_ec_sync_delay 5000 ms..." TEST=make clean && make runtests Change-Id: I1305357199d87b80b4edc4e311015106ab07de65 Reviewed-on: https://chromium-review.googlesource.com/c/1256644 Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Trybot-Ready: Joel Kitching <kitching@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--firmware/2lib/2nvstorage.c8
-rw-r--r--firmware/2lib/include/2nvstorage.h5
-rw-r--r--firmware/2lib/include/2nvstorage_fields.h3
-rw-r--r--firmware/include/vboot_nvstorage.h5
-rw-r--r--firmware/lib/vboot_api_kernel.c25
-rw-r--r--firmware/lib/vboot_nvstorage.c13
-rw-r--r--host/lib/crossystem.c4
-rw-r--r--tests/vb2_nvstorage_tests.c1
-rw-r--r--utility/crossystem.c2
9 files changed, 64 insertions, 2 deletions
diff --git a/firmware/2lib/2nvstorage.c b/firmware/2lib/2nvstorage.c
index 424567a0..98ee9d06 100644
--- a/firmware/2lib/2nvstorage.c
+++ b/firmware/2lib/2nvstorage.c
@@ -181,6 +181,10 @@ uint32_t vb2_nv_get(struct vb2_context *ctx, enum vb2_nv_param param)
case VB2_NV_DISABLE_ALT_OS_REQUEST:
return GETBIT(VB2_NV_OFFS_MISC, VB2_NV_MISC_DISABLE_ALT_OS);
+
+ case VB2_NV_POST_EC_SYNC_DELAY:
+ return GETBIT(VB2_NV_OFFS_MISC,
+ VB2_NV_MISC_POST_EC_SYNC_DELAY);
}
/*
@@ -370,6 +374,10 @@ void vb2_nv_set(struct vb2_context *ctx,
case VB2_NV_DISABLE_ALT_OS_REQUEST:
SETBIT(VB2_NV_OFFS_MISC, VB2_NV_MISC_DISABLE_ALT_OS);
break;
+
+ case VB2_NV_POST_EC_SYNC_DELAY:
+ SETBIT(VB2_NV_OFFS_MISC, VB2_NV_MISC_POST_EC_SYNC_DELAY);
+ break;
}
/*
diff --git a/firmware/2lib/include/2nvstorage.h b/firmware/2lib/include/2nvstorage.h
index 7a8f4d95..b7a28fd5 100644
--- a/firmware/2lib/include/2nvstorage.h
+++ b/firmware/2lib/include/2nvstorage.h
@@ -102,6 +102,11 @@ enum vb2_nv_param {
VB2_NV_ENABLE_ALT_OS_REQUEST,
/* Disable AltOS Mode on next boot. */
VB2_NV_DISABLE_ALT_OS_REQUEST,
+ /*
+ * Add a short delay after EC software sync for any interaction
+ * with EC-RW (persistent).
+ */
+ VB2_NV_POST_EC_SYNC_DELAY,
};
/* Set default boot in developer mode */
diff --git a/firmware/2lib/include/2nvstorage_fields.h b/firmware/2lib/include/2nvstorage_fields.h
index 4459703d..d37f4fcb 100644
--- a/firmware/2lib/include/2nvstorage_fields.h
+++ b/firmware/2lib/include/2nvstorage_fields.h
@@ -70,12 +70,13 @@ enum vb2_nv_offset {
#define VB2_NV_TPM_CLEAR_OWNER_DONE 0x02
#define VB2_NV_TPM_REBOOTED 0x04
-/* Fields in VB2_NV_OFFS_MISC (unused = 0xc0) */
+/* Fields in VB2_NV_OFFS_MISC (unused = 0x80) */
#define VB2_NV_MISC_UNLOCK_FASTBOOT 0x01
#define VB2_NV_MISC_BOOT_ON_AC_DETECT 0x02
#define VB2_NV_MISC_TRY_RO_SYNC 0x04
#define VB2_NV_MISC_BATTERY_CUTOFF 0x08
#define VB2_NV_MISC_ENABLE_ALT_OS 0x10
#define VB2_NV_MISC_DISABLE_ALT_OS 0x20
+#define VB2_NV_MISC_POST_EC_SYNC_DELAY 0x40
#endif /* VBOOT_REFERENCE_VBOOT_2NVSTORAGE_FIELDS_H_ */
diff --git a/firmware/include/vboot_nvstorage.h b/firmware/include/vboot_nvstorage.h
index e41d92c3..0823ea37 100644
--- a/firmware/include/vboot_nvstorage.h
+++ b/firmware/include/vboot_nvstorage.h
@@ -128,6 +128,11 @@ typedef enum VbNvParam {
VBNV_ENABLE_ALT_OS_REQUEST,
/* Disable AltOS Mode on next boot. */
VBNV_DISABLE_ALT_OS_REQUEST,
+ /*
+ * Add a short delay after EC software sync for any interaction
+ * with EC-RW (persistent).
+ */
+ VBNV_POST_EC_SYNC_DELAY,
} VbNvParam;
/* Set default boot in developer mode */
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
index 08254a47..4145e3d0 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -406,6 +406,25 @@ static void vb2_kernel_cleanup(struct vb2_context *ctx, VbCommonParams *cparams)
shared->timer_vb_select_and_load_kernel_exit = VbExGetTimer();
}
+VbError_t vb2_post_ec_sync_hooks(struct vb2_context *ctx,
+ VbCommonParams *cparams) {
+ /*
+ * Pause for any events to be sent to EC-RW, after it is guaranteed
+ * to be running. Can be used for simulating boot hotkeys.
+ *
+ * TODO(b/117140648): Accept keyboard input to skip/disable the delay.
+ */
+ const int post_ec_sync_delay_msec = 5 * 1000;
+ if (vb2_nv_get(ctx, VB2_NV_POST_EC_SYNC_DELAY)) {
+ VB2_DEBUG("vb2_post_ec_sync_hooks: "
+ "post_ec_sync_delay %d ms...\n",
+ post_ec_sync_delay_msec);
+ VbExSleepMs(post_ec_sync_delay_msec);
+ }
+
+ return VBERROR_SUCCESS;
+}
+
int VbAltOSForceChromeOS(void) {
return 0;
}
@@ -519,11 +538,15 @@ VbError_t VbSelectAndLoadKernel(VbCommonParams *cparams,
/*
* Do EC software sync if necessary. This has UI, but it's just a
- * single non-interactive WAIT screen.
+ * single non-interactive WAIT screen. Perform any post-EC software
+ * sync hooks, if early interaction with EC-RW is necessary.
*/
retval = ec_sync_all(&ctx, cparams);
if (retval)
goto VbSelectAndLoadKernel_exit;
+ retval = vb2_post_ec_sync_hooks(&ctx, cparams);
+ if (retval)
+ goto VbSelectAndLoadKernel_exit;
/*
* Check whether confirmation screen or picker screen need to be
diff --git a/firmware/lib/vboot_nvstorage.c b/firmware/lib/vboot_nvstorage.c
index c060b27a..4e3138a4 100644
--- a/firmware/lib/vboot_nvstorage.c
+++ b/firmware/lib/vboot_nvstorage.c
@@ -67,6 +67,7 @@
#define MISC_BATTERY_CUTOFF_REQUEST 0x08
#define MISC_ENABLE_ALT_OS_REQUEST 0x10
#define MISC_DISABLE_ALT_OS_REQUEST 0x20
+#define MISC_POST_EC_SYNC_DELAY 0x40
#define KERNEL_FIELD_OFFSET 11
#define CRC_OFFSET 15
@@ -249,6 +250,11 @@ int VbNvGet(VbNvContext *context, VbNvParam param, uint32_t *dest)
? 1 : 0;
return 0;
+ case VBNV_POST_EC_SYNC_DELAY:
+ *dest = (raw[MISC_OFFSET] & MISC_POST_EC_SYNC_DELAY)
+ ? 1 : 0;
+ return 0;
+
default:
return 1;
}
@@ -495,6 +501,13 @@ int VbNvSet(VbNvContext *context, VbNvParam param, uint32_t value)
raw[MISC_OFFSET] &= ~MISC_DISABLE_ALT_OS_REQUEST;
break;
+ case VBNV_POST_EC_SYNC_DELAY:
+ if (value)
+ raw[MISC_OFFSET] |= MISC_POST_EC_SYNC_DELAY;
+ else
+ raw[MISC_OFFSET] &= ~MISC_POST_EC_SYNC_DELAY;
+ break;
+
default:
return 1;
}
diff --git a/host/lib/crossystem.c b/host/lib/crossystem.c
index 7aeb161a..51cda89f 100644
--- a/host/lib/crossystem.c
+++ b/host/lib/crossystem.c
@@ -583,6 +583,8 @@ int VbGetSystemPropertyInt(const char *name)
value = VbGetNvStorage(VBNV_ENABLE_ALT_OS_REQUEST);
} else if (!strcasecmp(name, "disable_alt_os_request")) {
value = VbGetNvStorage(VBNV_DISABLE_ALT_OS_REQUEST);
+ } else if (!strcasecmp(name, "post_ec_sync_delay")) {
+ value = VbGetNvStorage(VBNV_POST_EC_SYNC_DELAY);
}
return value;
@@ -732,6 +734,8 @@ int VbSetSystemPropertyInt(const char *name, int value)
return VbSetNvStorage(VBNV_ENABLE_ALT_OS_REQUEST, value);
} else if (!strcasecmp(name, "disable_alt_os_request")) {
return VbSetNvStorage(VBNV_DISABLE_ALT_OS_REQUEST, value);
+ } else if (!strcasecmp(name, "post_ec_sync_delay")) {
+ return VbSetNvStorage(VBNV_POST_EC_SYNC_DELAY, value);
}
return -1;
diff --git a/tests/vb2_nvstorage_tests.c b/tests/vb2_nvstorage_tests.c
index 836282f0..4a2e2794 100644
--- a/tests/vb2_nvstorage_tests.c
+++ b/tests/vb2_nvstorage_tests.c
@@ -58,6 +58,7 @@ static struct nv_field nvfields[] = {
{VB2_NV_TRY_RO_SYNC, 0, 1, 0, "try read only software sync"},
{VB2_NV_ENABLE_ALT_OS_REQUEST, 0, 1, 0, "enable alt-os request"},
{VB2_NV_DISABLE_ALT_OS_REQUEST, 0, 1, 0, "disable alt-os request"},
+ {VB2_NV_POST_EC_SYNC_DELAY, 0, 1, 0, "enable post-ec sync delay"},
{0, 0, 0, 0, NULL}
};
diff --git a/utility/crossystem.c b/utility/crossystem.c
index 0e80b81a..6d293683 100644
--- a/utility/crossystem.c
+++ b/utility/crossystem.c
@@ -58,6 +58,8 @@ const Param sys_param_list[] = {
{"ecfw_act", IS_STRING, "Active EC firmware"},
{"enable_alt_os_request", CAN_WRITE,
"Enable AltOS mode on next boot (writable)"},
+ {"post_ec_sync_delay", CAN_WRITE,
+ "Short delay after EC software sync (persistent, writable)"},
{"fmap_base", 0, "Main firmware flashmap physical address", "0x%08x"},
{"fwb_tries", CAN_WRITE, "Try firmware B count (writable)"},
{"fw_vboot2", 0, "1 if firmware was selected by vboot2 or 0 otherwise"},