summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2016-05-12 23:09:07 (GMT)
committerchrome-bot <chrome-bot@chromium.org>2016-05-18 01:35:23 (GMT)
commitbc81edff82fb19a7b905efd415847d3476e2661f (patch)
treec6ad4432ead993f340b345e2243b86ae11b2969e
parentb51140b10374b74e2be19439dde2f2de8d42594e (diff)
downloaddepthcharge-release-R52-8350.B.tar.gz
depthcharge-release-R52-8350.B.tar.xz
cbfs: Adapt to new libpayload CBFS APIstabilize-8350.68.Bstabilize-8350.21.Brelease-R52-8350.B
This patch accommodates the removal of cbfs_get_file() and the introduction of the new cbfs_handle API in libpayload. In particular, it makes sure that VbExEcGetExpectedImageHash() no longer maps in the whole EC-RW image. CQ-DEPEND=CL:344459 BRANCH=None BUG=None TEST=Booted Oak. Observed ~125ms faster boot time. Change-Id: I793f99ad3b4d1519f114e829ea08ab2be5ac1ed1 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/344602 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
-rw-r--r--src/debug/cli/cbfs.c2
-rw-r--r--src/vboot/callbacks/ec.c34
2 files changed, 19 insertions, 17 deletions
diff --git a/src/debug/cli/cbfs.c b/src/debug/cli/cbfs.c
index dd112f6..f0da062 100644
--- a/src/debug/cli/cbfs.c
+++ b/src/debug/cli/cbfs.c
@@ -11,7 +11,7 @@ static int do_cbfs_dump(char * const name)
{
struct cbfs_file *file;
- file = cbfs_get_file(CBFS_DEFAULT_MEDIA, name);
+ file = cbfs_find(name);
if (file == NULL) {
printf("File '%s' not found\n", name);
return CMD_RET_FAILURE;
diff --git a/src/vboot/callbacks/ec.c b/src/vboot/callbacks/ec.c
index f07f55f..fb40050 100644
--- a/src/vboot/callbacks/ec.c
+++ b/src/vboot/callbacks/ec.c
@@ -44,7 +44,7 @@ static const char *get_fw_filename(int devidx, int select)
return devidx == 0 ? "ecrw" : "pdrw";
}
-static struct cbfs_file *get_file_from_cbfs(
+static struct cbfs_handle *find_file_in_cbfs(
const char *filename, enum VbSelectFirmware_t select)
{
if (!IS_ENABLED(CONFIG_DRIVER_CBFS_FLASH))
@@ -54,25 +54,25 @@ static struct cbfs_file *get_file_from_cbfs(
printf("Trying to locate '%s' in RO CBFS\n", filename);
if (ro_cbfs == NULL)
ro_cbfs = cbfs_ro_media();
- return cbfs_get_file(ro_cbfs, filename);
+ return cbfs_get_handle(ro_cbfs, filename);
}
printf("Trying to locate '%s' in CBFS\n", filename);
- return cbfs_get_file(CBFS_DEFAULT_MEDIA, filename);
+ return cbfs_get_handle(CBFS_DEFAULT_MEDIA, filename);
}
static const uint8_t *get_file_hash_from_cbfs(
const char *filename, int *hash_size, enum VbSelectFirmware_t select)
{
printf("Trying to fetch hash for '%s'\n", filename);
- struct cbfs_file *file = get_file_from_cbfs(filename, select);
+ struct cbfs_handle *handle = find_file_in_cbfs(filename, select);
- if (file == NULL) {
+ if (handle == NULL) {
printf("%s not found\n", filename);
return NULL;
}
- struct cbfs_file_attribute *attr = cbfs_file_find_attr(file,
+ struct cbfs_file_attr_hash *attr = cbfs_get_attr(handle,
CBFS_FILE_ATTR_TAG_HASH);
if (attr == NULL) {
@@ -80,14 +80,12 @@ static const uint8_t *get_file_hash_from_cbfs(
return NULL;
}
- struct cbfs_file_attr_hash *hash = (struct cbfs_file_attr_hash *)attr;
-
- if (ntohl(hash->hash_type) != VB2_HASH_SHA256) {
+ if (ntohl(attr->hash_type) != VB2_HASH_SHA256) {
printf("hash is not SHA256\n");
return NULL;
}
- *hash_size = ntohl(hash->len) - sizeof(*hash);
- return hash->hash_data;
+ *hash_size = ntohl(attr->len) - sizeof(*attr);
+ return attr->hash_data;
}
int VbExTrustEC(int devidx)
@@ -160,13 +158,17 @@ VbError_t VbExEcGetExpectedImage(int devidx, enum VbSelectFirmware_t select,
printf("Didn't find section %s in the fmap.\n", name);
/* It may be gone in favor of CBFS based RW sections,
* so look there, too. */
+ size_t size;
const char *filename = get_fw_filename(devidx, select);
- struct cbfs_file *file = get_file_from_cbfs(filename, select);
- if (file == NULL)
+ struct cbfs_handle *h = find_file_in_cbfs(filename, select);
+ if (h == NULL)
+ return VBERROR_UNKNOWN;
+ *image = cbfs_get_contents(h, &size, 0);
+ free(h);
+ if (*image == NULL)
return VBERROR_UNKNOWN;
- printf("found '%s', sized 0x%x\n", filename, ntohl(file->len));
- *image = CBFS_SUBHEADER(file);
- *image_size = ntohl(file->len);
+ *image_size = size;
+ printf("found '%s', sized 0x%zx\n", filename, size);
return VBERROR_SUCCESS;
}