[U-Boot] [PATCH 34/45] cros_ec: Update cros_ec_read_hash() to specify the image
Simon Glass
sjg at chromium.org
Mon Oct 1 18:22:38 UTC 2018
Allow selection of which EC image to hash.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
cmd/cros_ec.c | 2 +-
drivers/misc/cros_ec.c | 7 ++++---
include/cros_ec.h | 4 +++-
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/cmd/cros_ec.c b/cmd/cros_ec.c
index 3ac4f3b235d..9e2f1b06f3c 100644
--- a/cmd/cros_ec.c
+++ b/cmd/cros_ec.c
@@ -149,7 +149,7 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
struct ec_response_vboot_hash hash;
int i;
- if (cros_ec_read_hash(dev, &hash)) {
+ if (cros_ec_read_hash(dev, EC_VBOOT_HASH_OFFSET_ACTIVE, &hash)) {
debug("%s: Could not read KBC hash\n", __func__);
return 1;
}
diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index 2deed0e839f..d2543f8ddc0 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -444,13 +444,14 @@ static int cros_ec_wait_on_hash_done(struct udevice *dev,
return 0;
}
-
-int cros_ec_read_hash(struct udevice *dev, struct ec_response_vboot_hash *hash)
+int cros_ec_read_hash(struct udevice *dev, uint hash_offset,
+ struct ec_response_vboot_hash *hash)
{
struct ec_params_vboot_hash p;
int rv;
p.cmd = EC_VBOOT_HASH_GET;
+ p.offset = hash_offset;
if (ec_command(dev, EC_CMD_VBOOT_HASH, 0, &p, sizeof(p),
hash, sizeof(*hash)) < 0)
return -1;
@@ -473,7 +474,7 @@ int cros_ec_read_hash(struct udevice *dev, struct ec_response_vboot_hash *hash)
p.cmd = EC_VBOOT_HASH_START;
p.hash_type = EC_VBOOT_HASH_TYPE_SHA256;
p.nonce_size = 0;
- p.offset = EC_VBOOT_HASH_OFFSET_ACTIVE;
+ p.offset = hash_offset;
if (ec_command(dev, EC_CMD_VBOOT_HASH, 0, &p, sizeof(p),
hash, sizeof(*hash)) < 0)
diff --git a/include/cros_ec.h b/include/cros_ec.h
index 5576bcf32ee..4771e6b7d1c 100644
--- a/include/cros_ec.h
+++ b/include/cros_ec.h
@@ -96,10 +96,12 @@ int cros_ec_read_current_image(struct udevice *dev,
* Read the hash of the CROS-EC device firmware.
*
* @param dev CROS-EC device
+ * @param hash_offset Offset in flash to read from
* @param hash Destination for hash information
* @return 0 if ok, <0 on error
*/
-int cros_ec_read_hash(struct udevice *dev, struct ec_response_vboot_hash *hash);
+int cros_ec_read_hash(struct udevice *dev, uint hash_offset,
+ struct ec_response_vboot_hash *hash);
/**
* Send a reboot command to the CROS-EC device.
--
2.19.0.605.g01d371f741-goog
More information about the U-Boot
mailing list