summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2015-01-09 17:06:30 -0800
committerAlec Berg <alecaberg@chromium.org>2015-01-10 23:44:44 +0000
commit7f0664777333dc72c3efa4c487f63531964cc4b9 (patch)
treefc73ca60237cd4833cae498b524684d6386b51de
parent347c7313a03fff7f268d17a84d2d65ddd0699e41 (diff)
downloadchrome-ec-7f0664777333dc72c3efa4c487f63531964cc4b9.tar.gz
zinger: pre-compute RW hash
To ensure we respond fast enough to the Discover Identity VDM (which timeout after 30ms), we need to pre-cache the RW hash at startup. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=samus BUG=chrome-os-partner:35327 TEST=plug Zinger to a PD sink and check the PD protocol trace on Twinkie Change-Id: I9decdff358dd1ab9ac373ce8bfdd0402f5e21f04 Reviewed-on: https://chromium-review.googlesource.com/240080 Reviewed-by: Alec Berg <alecaberg@chromium.org> Tested-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org>
-rw-r--r--board/zinger/board.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/board/zinger/board.c b/board/zinger/board.c
index e06da587da..675aaa470f 100644
--- a/board/zinger/board.c
+++ b/board/zinger/board.c
@@ -54,18 +54,14 @@ int is_ro_mode(void)
return (uint32_t)&jump_to_rw < (uint32_t)rw_rst;
}
-static int check_rw_valid(void)
+static int check_rw_valid(void *rw_hash)
{
int good;
- void *rw_hash;
/* Check if we have a RW firmware flashed */
if (*rw_rst == 0xffffffff)
return 0;
- /* calculate hash of RW */
- rw_hash = flash_hash_rw();
-
good = rsa_verify(&pkey, (void *)rw_sig, rw_hash, rsa_workbuf);
if (!good) {
debug_printf("RSA verify FAILED\n");
@@ -79,6 +75,8 @@ extern void pd_task(void);
int main(void)
{
+ void *rw_hash;
+
hardware_init();
debug_printf("Power supply started ... %s\n",
is_ro_mode() ? "RO" : "RW");
@@ -87,8 +85,16 @@ int main(void)
if (!flash_physical_is_permanently_protected())
flash_physical_permanent_protect();
+ /*
+ * calculate the hash of the RW partition
+ *
+ * Also pre-cache it so we can answer Discover Identity VDM
+ * fast enough (in less than 30ms).
+ */
+ rw_hash = flash_hash_rw();
+
/* Verify RW firmware and use it if valid */
- if (is_ro_mode() && check_rw_valid())
+ if (is_ro_mode() && check_rw_valid(rw_hash))
jump_to_rw();
/* background loop for PD events */