Aaron Durbin has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/41754 )
Change subject: lib/cbfs: refactor code culling compression checks ......................................................................
lib/cbfs: refactor code culling compression checks
Provide helper functions to determine if a compression algorithm is supposed in a given stage. Future patches can use those functions to amend which algorithms to include in the final link.
BUG=b:155322763,b:150746858,b:152909132
Change-Id: I898c939cec73d1f300ea38b165f379038877f05e Signed-off-by: Aaron Durbin adurbin@chromium.org --- M src/lib/cbfs.c 1 file changed, 23 insertions(+), 9 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/54/41754/1
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c index a3294de..74df3c5 100644 --- a/src/lib/cbfs.c +++ b/src/lib/cbfs.c @@ -91,6 +91,27 @@ return ret; }
+static inline bool cbfs_lz4_enabled(void) +{ + if ((ENV_BOOTBLOCK || ENV_SEPARATE_VERSTAGE) && !CONFIG(COMPRESS_PRERAM_STAGES)) + return false; + + return true; +} + +static inline bool cbfs_lzma_enabled(void) +{ + /* We assume here romstage and postcar are never compressed. */ + if (ENV_BOOTBLOCK || ENV_SEPARATE_VERSTAGE) + return false; + if (ENV_ROMSTAGE && CONFIG(POSTCAR_STAGE)) + return false; + if ((ENV_ROMSTAGE || ENV_POSTCAR) + && !CONFIG(COMPRESS_RAMSTAGE)) + return false; + return true; +} + size_t cbfs_load_and_decompress(const struct region_device *rdev, size_t offset, size_t in_size, void *buffer, size_t buffer_size, uint32_t compression) { @@ -105,8 +126,7 @@ return in_size;
case CBFS_COMPRESS_LZ4: - if ((ENV_BOOTBLOCK || ENV_SEPARATE_VERSTAGE) && - !CONFIG(COMPRESS_PRERAM_STAGES)) + if (!cbfs_lz4_enabled()) return 0;
/* Load the compressed image to the end of the available memory @@ -123,13 +143,7 @@ return out_size;
case CBFS_COMPRESS_LZMA: - /* We assume here romstage and postcar are never compressed. */ - if (ENV_BOOTBLOCK || ENV_SEPARATE_VERSTAGE) - return 0; - if (ENV_ROMSTAGE && CONFIG(POSTCAR_STAGE)) - return 0; - if ((ENV_ROMSTAGE || ENV_POSTCAR) - && !CONFIG(COMPRESS_RAMSTAGE)) + if (!cbfs_lzma_enabled()) return 0; void *map = rdev_mmap(rdev, offset, in_size); if (map == NULL)
Patrick Georgi has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41754 )
Change subject: lib/cbfs: refactor code culling compression checks ......................................................................
Patch Set 1: Code-Review+1
(1 comment)
https://review.coreboot.org/c/coreboot/+/41754/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/41754/1//COMMIT_MSG@10 PS1, Line 10: supposed supported?
Aaron Durbin has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41754 )
Change subject: lib/cbfs: refactor code culling compression checks ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/41754/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/41754/1//COMMIT_MSG@10 PS1, Line 10: supposed
supported?
Done
Hello build bot (Jenkins), Patrick Georgi, Julius Werner,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/41754
to look at the new patch set (#2).
Change subject: lib/cbfs: refactor code culling compression checks ......................................................................
lib/cbfs: refactor code culling compression checks
Provide helper functions to determine if a compression algorithm is supported in a given stage. Future patches can use those functions to amend which algorithms to include in the final link.
BUG=b:155322763,b:150746858,b:152909132
Change-Id: I898c939cec73d1f300ea38b165f379038877f05e Signed-off-by: Aaron Durbin adurbin@chromium.org --- M src/lib/cbfs.c 1 file changed, 23 insertions(+), 9 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/54/41754/2
Furquan Shaikh has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41754 )
Change subject: lib/cbfs: refactor code culling compression checks ......................................................................
Patch Set 2: Code-Review+2
Arthur Heymans has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41754 )
Change subject: lib/cbfs: refactor code culling compression checks ......................................................................
Patch Set 2: Code-Review+2
Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41754 )
Change subject: lib/cbfs: refactor code culling compression checks ......................................................................
Patch Set 2: Code-Review+2
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/41754 )
Change subject: lib/cbfs: refactor code culling compression checks ......................................................................
Patch Set 2: Code-Review+2
Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/41754 )
Change subject: lib/cbfs: refactor code culling compression checks ......................................................................
lib/cbfs: refactor code culling compression checks
Provide helper functions to determine if a compression algorithm is supported in a given stage. Future patches can use those functions to amend which algorithms to include in the final link.
BUG=b:155322763,b:150746858,b:152909132
Change-Id: I898c939cec73d1f300ea38b165f379038877f05e Signed-off-by: Aaron Durbin adurbin@chromium.org Reviewed-on: https://review.coreboot.org/c/coreboot/+/41754 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Furquan Shaikh furquan@google.com Reviewed-by: Arthur Heymans arthur@aheymans.xyz Reviewed-by: Julius Werner jwerner@chromium.org Reviewed-by: Angel Pons th3fanbus@gmail.com --- M src/lib/cbfs.c 1 file changed, 23 insertions(+), 9 deletions(-)
Approvals: build bot (Jenkins): Verified Furquan Shaikh: Looks good to me, approved Julius Werner: Looks good to me, approved Arthur Heymans: Looks good to me, approved Angel Pons: Looks good to me, approved
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c index a3294de..74df3c5 100644 --- a/src/lib/cbfs.c +++ b/src/lib/cbfs.c @@ -91,6 +91,27 @@ return ret; }
+static inline bool cbfs_lz4_enabled(void) +{ + if ((ENV_BOOTBLOCK || ENV_SEPARATE_VERSTAGE) && !CONFIG(COMPRESS_PRERAM_STAGES)) + return false; + + return true; +} + +static inline bool cbfs_lzma_enabled(void) +{ + /* We assume here romstage and postcar are never compressed. */ + if (ENV_BOOTBLOCK || ENV_SEPARATE_VERSTAGE) + return false; + if (ENV_ROMSTAGE && CONFIG(POSTCAR_STAGE)) + return false; + if ((ENV_ROMSTAGE || ENV_POSTCAR) + && !CONFIG(COMPRESS_RAMSTAGE)) + return false; + return true; +} + size_t cbfs_load_and_decompress(const struct region_device *rdev, size_t offset, size_t in_size, void *buffer, size_t buffer_size, uint32_t compression) { @@ -105,8 +126,7 @@ return in_size;
case CBFS_COMPRESS_LZ4: - if ((ENV_BOOTBLOCK || ENV_SEPARATE_VERSTAGE) && - !CONFIG(COMPRESS_PRERAM_STAGES)) + if (!cbfs_lz4_enabled()) return 0;
/* Load the compressed image to the end of the available memory @@ -123,13 +143,7 @@ return out_size;
case CBFS_COMPRESS_LZMA: - /* We assume here romstage and postcar are never compressed. */ - if (ENV_BOOTBLOCK || ENV_SEPARATE_VERSTAGE) - return 0; - if (ENV_ROMSTAGE && CONFIG(POSTCAR_STAGE)) - return 0; - if ((ENV_ROMSTAGE || ENV_POSTCAR) - && !CONFIG(COMPRESS_RAMSTAGE)) + if (!cbfs_lzma_enabled()) return 0; void *map = rdev_mmap(rdev, offset, in_size); if (map == NULL)