Attention is currently required from: Furquan Shaikh, Aaron Durbin.
Hello Furquan Shaikh, Aaron Durbin,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/52083
to review the following change.
Change subject: cbfs: Simplify cbfs_load_and_decompress() and stop exporting it
......................................................................
cbfs: Simplify cbfs_load_and_decompress() and stop exporting it
With the last external user to cbfs_load_and_decompress() gone, we can
stop exporting this function to the rest of coreboot and make it local
to cbfs.c. Also remove a couple of arguments that no longer really make
a difference and fold the stage-specific code for in-place LZ4
decompression into cbfs_prog_stage_load().
Signed-off-by: Julius Werner <jwerner(a)chromium.org>
Change-Id: I4b459650a28e020c4342a66090f55264fbd26363
---
M src/include/cbfs.h
M src/lib/cbfs.c
2 files changed, 21 insertions(+), 45 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/83/52083/1
diff --git a/src/include/cbfs.h b/src/include/cbfs.h
index 37bac30..9ed5233 100644
--- a/src/include/cbfs.h
+++ b/src/include/cbfs.h
@@ -165,13 +165,6 @@
/* Return mapping of option ROM with revision number. Returns NULL on error. */
void *cbfs_boot_map_optionrom_revision(uint16_t vendor, uint16_t device, uint8_t rev);
-/* Load |in_size| bytes from |rdev| at |offset| to the |buffer_size| bytes large |buffer|,
- decompressing it according to |compression| in the process. Returns the decompressed file
- size, or 0 on error. LZMA files will be mapped for decompression. LZ4 files will be
- decompressed in-place with the buffer size requirements outlined in compression.h. */
-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);
-
/**********************************************************************************************
* INTERNAL HELPERS FOR INLINES, DO NOT USE. *
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c
index 65bb721..9135b2f 100644
--- a/src/lib/cbfs.c
+++ b/src/lib/cbfs.c
@@ -186,19 +186,20 @@
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)
+static size_t cbfs_load_and_decompress(const struct region_device *rdev,
+ void *buffer, size_t buffer_size, uint32_t compression)
{
+ size_t in_size = region_device_sz(rdev);
size_t out_size;
void *map;
- DEBUG("Decompressing %zu bytes to %p with algo %d\n", buffer_size, buffer, compression);
+ DEBUG("Decompressing %zu bytes to %p with algo %d\n", in_size, buffer, compression);
switch (compression) {
case CBFS_COMPRESS_NONE:
if (buffer_size < in_size)
return 0;
- if (rdev_readat(rdev, buffer, offset, in_size) != in_size)
+ if (rdev_readat(rdev, buffer, 0, in_size) != in_size)
return 0;
return in_size;
@@ -206,9 +207,9 @@
if (!cbfs_lz4_enabled())
return 0;
- /* cbfs_stage_load_and_decompress() takes care of in-place LZ4 decompression by
+ /* cbfs_prog_stage_load() takes care of in-place LZ4 decompression by
setting up the rdev to be in memory. */
- map = rdev_mmap(rdev, offset, in_size);
+ map = rdev_mmap_full(rdev);
if (map == NULL)
return 0;
@@ -223,7 +224,7 @@
case CBFS_COMPRESS_LZMA:
if (!cbfs_lzma_enabled())
return 0;
- map = rdev_mmap(rdev, offset, in_size);
+ map = rdev_mmap_full(rdev);
if (map == NULL)
return 0;
@@ -241,33 +242,6 @@
}
}
-static size_t cbfs_stage_load_and_decompress(const struct region_device *rdev, size_t offset,
- size_t in_size, void *buffer, size_t buffer_size, uint32_t compression)
-{
- struct region_device rdev_src;
-
- if (compression == CBFS_COMPRESS_LZ4) {
- if (!cbfs_lz4_enabled())
- return 0;
- /* Load the compressed image to the end of the available memory area for
- in-place decompression. It is the responsibility of the caller to ensure that
- buffer_size is large enough (see compression.h, guaranteed by cbfstool for
- stages). */
- void *compr_start = buffer + buffer_size - in_size;
- if (rdev_readat(rdev, compr_start, offset, in_size) != in_size)
- return 0;
- /* Create a region device backed by memory. */
- rdev_chain(&rdev_src, &addrspace_32bit.rdev, (uintptr_t)compr_start, in_size);
-
- return cbfs_load_and_decompress(&rdev_src, 0, in_size, buffer, buffer_size,
- compression);
- }
-
- /* All other algorithms can use the generic implementation. */
- return cbfs_load_and_decompress(rdev, offset, in_size, buffer, buffer_size,
- compression);
-}
-
static inline int tohex4(unsigned int c)
{
return (c <= 9) ? (c + '0') : (c - 10 + 'a');
@@ -361,8 +335,7 @@
return NULL;
}
- size = cbfs_load_and_decompress(&rdev, 0, region_device_sz(&rdev),
- loc, size, compression);
+ size = cbfs_load_and_decompress(&rdev, loc, size, compression);
if (!size)
return NULL;
@@ -421,8 +394,18 @@
return CB_SUCCESS;
}
- size_t fsize = cbfs_stage_load_and_decompress(&rdev, 0, region_device_sz(&rdev),
- prog_start(pstage), prog_size(pstage), compression);
+ /* LZ4 stages can be decompressed in-place to save mapping scratch space. Load the
+ compressed data to the end of the buffer and point &rdev to that memory location. */
+ if (cbfs_lz4_enabled() && compression == CBFS_COMPRESS_LZ4) {
+ size_t in_size = region_device_sz(&rdev);
+ void *compr_start = prog_start(pstage) + prog_size(pstage) - in_size;
+ if (rdev_readat(&rdev, compr_start, 0, in_size) != in_size)
+ return CB_ERR;
+ rdev_chain(&rdev, &addrspace_32bit.rdev, (uintptr_t)compr_start, in_size);
+ }
+
+ size_t fsize = cbfs_load_and_decompress(&rdev, prog_start(pstage), prog_size(pstage),
+ compression);
if (!fsize)
return CB_ERR;
--
To view, visit https://review.coreboot.org/c/coreboot/+/52083
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I4b459650a28e020c4342a66090f55264fbd26363
Gerrit-Change-Number: 52083
Gerrit-PatchSet: 1
Gerrit-Owner: Julius Werner <jwerner(a)chromium.org>
Gerrit-Reviewer: Aaron Durbin <adurbin(a)chromium.org>
Gerrit-Reviewer: Furquan Shaikh <furquan(a)google.com>
Gerrit-Attention: Furquan Shaikh <furquan(a)google.com>
Gerrit-Attention: Aaron Durbin <adurbin(a)chromium.org>
Gerrit-MessageType: newchange
Attention is currently required from: Furquan Shaikh, Aaron Durbin.
Hello Furquan Shaikh, Aaron Durbin,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/52081
to review the following change.
Change subject: cbfs: Make `mdata` argument to cbfs_allocator_t const
......................................................................
cbfs: Make `mdata` argument to cbfs_allocator_t const
Right before CB:49334 was submitted, I changed the signature of
cbfs_allocator_t function pointers to include another argument passing
in the already loaded CBFS metadata (to allow for the rare edge case of
allocators needing to read CBFS attributes). This interface is not meant
to be able to modify the passed-in metadata, so to clarify that and
prevent potential errors, we should declare the argument const.
Signed-off-by: Julius Werner <jwerner(a)chromium.org>
Change-Id: I7e3756490b9ad7ded91268c61797cef36c4118ee
---
M src/include/cbfs.h
M src/lib/cbfs.c
M src/lib/rmodule.c
3 files changed, 6 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/81/52081/1
diff --git a/src/include/cbfs.h b/src/include/cbfs.h
index b89a13d..37bac30 100644
--- a/src/include/cbfs.h
+++ b/src/include/cbfs.h
@@ -67,7 +67,7 @@
* attributes). Must return a pointer to space of the requested size where the file data should
* be loaded, or NULL to make the operation fail.
*/
-typedef void *(*cbfs_allocator_t)(void *arg, size_t size, union cbfs_mdata *mdata);
+typedef void *(*cbfs_allocator_t)(void *arg, size_t size, const union cbfs_mdata *mdata);
static inline size_t cbfs_load(const char *name, void *buf, size_t size);
static inline size_t cbfs_ro_load(const char *name, void *buf, size_t size);
@@ -183,9 +183,9 @@
void *buf;
size_t buf_size;
};
-void *_cbfs_default_allocator(void *arg, size_t size, union cbfs_mdata *unused);
+void *_cbfs_default_allocator(void *arg, size_t size, const union cbfs_mdata *unused);
-void *_cbfs_cbmem_allocator(void *arg, size_t size, union cbfs_mdata *unused);
+void *_cbfs_cbmem_allocator(void *arg, size_t size, const union cbfs_mdata *unused);
/**********************************************************************************************
* INLINE IMPLEMENTATIONS *
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c
index fbf4531..65bb721 100644
--- a/src/lib/cbfs.c
+++ b/src/lib/cbfs.c
@@ -369,7 +369,7 @@
return loc;
}
-void *_cbfs_default_allocator(void *arg, size_t size, union cbfs_mdata *unused)
+void *_cbfs_default_allocator(void *arg, size_t size, const union cbfs_mdata *unused)
{
struct _cbfs_default_allocator_arg *darg = arg;
if (size > darg->buf_size)
@@ -377,7 +377,7 @@
return darg->buf;
}
-void *_cbfs_cbmem_allocator(void *arg, size_t size, union cbfs_mdata *unused)
+void *_cbfs_cbmem_allocator(void *arg, size_t size, const union cbfs_mdata *unused)
{
return cbmem_add((uintptr_t)arg, size);
}
diff --git a/src/lib/rmodule.c b/src/lib/rmodule.c
index ac9eb0b..31bf141 100644
--- a/src/lib/rmodule.c
+++ b/src/lib/rmodule.c
@@ -192,7 +192,7 @@
}
static void *rmodule_cbfs_allocator(void *rsl_arg, size_t unused,
- union cbfs_mdata *mdata)
+ const union cbfs_mdata *mdata)
{
struct rmod_stage_load *rsl = rsl_arg;
--
To view, visit https://review.coreboot.org/c/coreboot/+/52081
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I7e3756490b9ad7ded91268c61797cef36c4118ee
Gerrit-Change-Number: 52081
Gerrit-PatchSet: 1
Gerrit-Owner: Julius Werner <jwerner(a)chromium.org>
Gerrit-Reviewer: Aaron Durbin <adurbin(a)chromium.org>
Gerrit-Reviewer: Furquan Shaikh <furquan(a)google.com>
Gerrit-Attention: Furquan Shaikh <furquan(a)google.com>
Gerrit-Attention: Aaron Durbin <adurbin(a)chromium.org>
Gerrit-MessageType: newchange
Attention is currently required from: Arthur Heymans, Alexander Couzens, Patrick Rudolph.
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/52072 )
Change subject: nb/intel/sandybridge: Drop `pci_mmio_size`
......................................................................
Patch Set 2:
(1 comment)
Commit Message:
https://review.coreboot.org/c/coreboot/+/52072/comment/7913a5cd_8cab612c
PS1, Line 10:
> Well we know one reason: I increases available DRAM in 32-bit space. […]
Done
--
To view, visit https://review.coreboot.org/c/coreboot/+/52072
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: If585b6044f58b1e5397457f3bfa906aafc7f9297
Gerrit-Change-Number: 52072
Gerrit-PatchSet: 2
Gerrit-Owner: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Alexander Couzens <lynxis(a)fe80.eu>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Patrick Rudolph <siro(a)das-labor.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Attention: Alexander Couzens <lynxis(a)fe80.eu>
Gerrit-Attention: Patrick Rudolph <siro(a)das-labor.org>
Gerrit-Comment-Date: Fri, 02 Apr 2021 22:08:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Nico Huber <nico.h(a)gmx.de>
Gerrit-MessageType: comment
Attention is currently required from: Angel Pons, Arthur Heymans, Alexander Couzens, Patrick Rudolph.
Hello build bot (Jenkins), Nico Huber, Arthur Heymans, Alexander Couzens, Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/52072
to look at the new patch set (#2).
Change subject: nb/intel/sandybridge: Drop `pci_mmio_size`
......................................................................
nb/intel/sandybridge: Drop `pci_mmio_size`
There's no good reason to use values smaller than 2 GiB here. Well, it
increases available DRAM in 32-bit space. However, as this is a 64-bit
platform, it's highly unlikely that 32-bit limitations would cause any
issues anymore. It's more likely to have the allocator give up because
memory-mapped resources in 32-bit space don't fit within the specified
MMIO size, which can easily occur when using a discrete graphics card.
Change-Id: If585b6044f58b1e5397457f3bfa906aafc7f9297
Signed-off-by: Angel Pons <th3fanbus(a)gmail.com>
---
M src/mainboard/google/stout/devicetree.cb
M src/mainboard/lenovo/x131e/devicetree.cb
M src/mainboard/lenovo/x1_carbon_gen1/devicetree.cb
M src/mainboard/lenovo/x230/devicetree.cb
M src/mainboard/samsung/lumpy/devicetree.cb
M src/mainboard/samsung/stumpy/devicetree.cb
M src/northbridge/intel/sandybridge/chip.h
M src/northbridge/intel/sandybridge/raminit_common.c
8 files changed, 3 insertions(+), 36 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/72/52072/2
--
To view, visit https://review.coreboot.org/c/coreboot/+/52072
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: If585b6044f58b1e5397457f3bfa906aafc7f9297
Gerrit-Change-Number: 52072
Gerrit-PatchSet: 2
Gerrit-Owner: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Alexander Couzens <lynxis(a)fe80.eu>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Patrick Rudolph <siro(a)das-labor.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Attention: Alexander Couzens <lynxis(a)fe80.eu>
Gerrit-Attention: Patrick Rudolph <siro(a)das-labor.org>
Gerrit-MessageType: newpatchset
Attention is currently required from: Angel Pons, Arthur Heymans, Alexander Couzens, Patrick Rudolph.
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/52070 )
Change subject: nb/intel/ironlake: Drop `pci_mmio_size`
......................................................................
Patch Set 2:
(1 comment)
Commit Message:
https://review.coreboot.org/c/coreboot/+/52070/comment/59bcf271_7801cb8f
PS1, Line 9: There's no good reason to use values smaller than 2 GiB here.
> Well we know one reason: I increases available DRAM in 32-bit space. […]
Done
--
To view, visit https://review.coreboot.org/c/coreboot/+/52070
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I6cdce5f56bc94cca7065ee3e38af60d1de66e45c
Gerrit-Change-Number: 52070
Gerrit-PatchSet: 2
Gerrit-Owner: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Alexander Couzens <lynxis(a)fe80.eu>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Patrick Rudolph <siro(a)das-labor.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Attention: Alexander Couzens <lynxis(a)fe80.eu>
Gerrit-Attention: Patrick Rudolph <siro(a)das-labor.org>
Gerrit-Comment-Date: Fri, 02 Apr 2021 22:07:46 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Nico Huber <nico.h(a)gmx.de>
Gerrit-MessageType: comment
Attention is currently required from: Angel Pons, Arthur Heymans, Alexander Couzens, Patrick Rudolph.
Hello build bot (Jenkins), Nico Huber, Arthur Heymans, Alexander Couzens, Patrick Rudolph,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/52070
to look at the new patch set (#2).
Change subject: nb/intel/ironlake: Drop `pci_mmio_size`
......................................................................
nb/intel/ironlake: Drop `pci_mmio_size`
There's no good reason to use values smaller than 2 GiB here. Well, it
increases available DRAM in 32-bit space. However, as this is a 64-bit
platform, it's highly unlikely that 32-bit limitations would cause any
issues anymore. It's more likely to have the allocator give up because
memory-mapped resources in 32-bit space don't fit within the specified
MMIO size, which can easily occur when using a discrete graphics card.
Change-Id: I6cdce5f56bc94cca7065ee3e38af60d1de66e45c
Signed-off-by: Angel Pons <th3fanbus(a)gmail.com>
---
M src/mainboard/lenovo/t410/devicetree.cb
M src/mainboard/lenovo/x201/devicetree.cb
M src/mainboard/packardbell/ms2290/devicetree.cb
M src/northbridge/intel/ironlake/chip.h
M src/northbridge/intel/ironlake/raminit.c
5 files changed, 1 insertion(+), 29 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/70/52070/2
--
To view, visit https://review.coreboot.org/c/coreboot/+/52070
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I6cdce5f56bc94cca7065ee3e38af60d1de66e45c
Gerrit-Change-Number: 52070
Gerrit-PatchSet: 2
Gerrit-Owner: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Alexander Couzens <lynxis(a)fe80.eu>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Patrick Rudolph <siro(a)das-labor.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Attention: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Attention: Alexander Couzens <lynxis(a)fe80.eu>
Gerrit-Attention: Patrick Rudolph <siro(a)das-labor.org>
Gerrit-MessageType: newpatchset