Philipp Deppenwiese has uploaded this change for review. ( https://review.coreboot.org/24967
Change subject: commonlib/cbfs: Add hook function ......................................................................
commonlib/cbfs: Add hook function
* Add hook function to access rdev.
Change-Id: Ie5d51c1f5a353fbcdec3ce9b4c051c4621780582 Signed-off-by: zaolin zaolin@das-labor.org --- M src/commonlib/cbfs.c M src/commonlib/include/commonlib/cbfs.h M src/lib/cbfs.c 3 files changed, 24 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/67/24967/1
diff --git a/src/commonlib/cbfs.c b/src/commonlib/cbfs.c index 1db8d31..4518a8e 100644 --- a/src/commonlib/cbfs.c +++ b/src/commonlib/cbfs.c @@ -61,6 +61,11 @@ return 0; }
+void __attribute__((weak)) +hook_cbfs_data(const char *name, const struct region_device *area) +{ +} + int cbfs_for_each_file(const struct region_device *cbfs, const struct cbfsf *prev, struct cbfsf *fh) { diff --git a/src/commonlib/include/commonlib/cbfs.h b/src/commonlib/include/commonlib/cbfs.h index 163bef2..9589380 100644 --- a/src/commonlib/include/commonlib/cbfs.h +++ b/src/commonlib/include/commonlib/cbfs.h @@ -26,6 +26,9 @@ struct region_device data; };
+/* Hook function for access to rdev in locate functions */ +void hook_cbfs_data(const char *name, const struct region_device *area); + /* Locate file by name and optional type. Returns 0 on succcess else < 0 on * error.*/ int cbfs_locate(struct cbfsf *fh, const struct region_device *cbfs, diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c index 596abc5..259704b 100644 --- a/src/lib/cbfs.c +++ b/src/lib/cbfs.c @@ -53,7 +53,12 @@ if (rdev_chain(&rdev, boot_dev, props.offset, props.size)) return -1;
- return cbfs_locate(fh, &rdev, name, type); + if (cbfs_locate(fh, &rdev, name, type)) + return -1; + + hook_cbfs_data(name, fh->data); + + return 0; }
void *cbfs_boot_map_with_leak(const char *name, uint32_t type, size_t *size) @@ -69,6 +74,8 @@ if (size != NULL) *size = fsize;
+ hook_cbfs_data(name, &fh.data); + return rdev_mmap(&fh.data, 0, fsize); }
@@ -83,7 +90,12 @@ return -1; }
- return cbfs_locate(fh, &rdev, name, type); + if (cbfs_locate(fh, &rdev, name, type)) + return -1; + + hook_cbfs_data(name, fh->data); + + return 0; }
size_t cbfs_load_and_decompress(const struct region_device *rdev, size_t offset, @@ -197,6 +209,8 @@ || decompressed_size > buf_size) return 0;
+ hook_cbfs_data(name, &fh.data); + return cbfs_load_and_decompress(&fh.data, 0, region_device_sz(&fh.data), buf, buf_size, compression_algo); }