summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorRaul E Rangel <rrangel@chromium.org>2021-10-08 13:10:38 -0600
committerRaul Rangel <rrangel@chromium.org>2021-10-29 18:29:54 +0000
commit3d7b984f777be61c74ea4c1f2d18b6ca996a7e5a (patch)
tree205951401cedb14a4c0de35c17ffc441635c1f65 /src/lib
parent550bdc9050eb97d1c4ddc8d6890cd1713d65ca89 (diff)
downloadcoreboot-3d7b984f777be61c74ea4c1f2d18b6ca996a7e5a.tar.gz
coreboot-3d7b984f777be61c74ea4c1f2d18b6ca996a7e5a.tar.bz2
coreboot-3d7b984f777be61c74ea4c1f2d18b6ca996a7e5a.zip
lib/cbfs: Enable cbfs_cache for x86
The reason cbfs_cache was disabled on x86 was due to the lack of .data sections in the pre-RAM stages. By using ENV_STAGE_HAS_DATA_SECTION we enable x86 to start using the cbfs_cache. We still need to add a cbfs_cache region into the memlayout for it to be enabled. BUG=b:179699789 TEST=Build guybrush and verify cbfs_cache.size == 0. Suggested-by: Julius Werner <jwerner@chromium.org> Signed-off-by: Raul E Rangel <rrangel@chromium.org> Change-Id: I74434ef9250ff059e7587147b1456aeabbee33aa Reviewed-on: https://review.coreboot.org/c/coreboot/+/56577 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/cbfs.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c
index 52f73736da6c..322f161a0ea6 100644
--- a/src/lib/cbfs.c
+++ b/src/lib/cbfs.c
@@ -18,8 +18,11 @@
#include <symbols.h>
#include <timestamp.h>
-#if CBFS_CACHE_AVAILABLE
+#if ENV_STAGE_HAS_DATA_SECTION
struct mem_pool cbfs_cache = MEM_POOL_INIT(_cbfs_cache, REGION_SIZE(cbfs_cache));
+#else
+struct mem_pool cbfs_cache = MEM_POOL_INIT(NULL, 0);
+#endif
static void switch_to_postram_cache(int unused)
{
@@ -28,7 +31,6 @@ static void switch_to_postram_cache(int unused)
REGION_SIZE(postram_cbfs_cache));
}
ROMSTAGE_CBMEM_INIT_HOOK(switch_to_postram_cache);
-#endif
cb_err_t cbfs_boot_lookup(const char *name, bool force_ro,
union cbfs_mdata *mdata, struct region_device *rdev)
@@ -111,8 +113,7 @@ void cbfs_unmap(void *mapping)
* that requires a free() for the boot_device, they need to implement it via the
* cbfs_cache mem_pool.
*/
- if (CBFS_CACHE_AVAILABLE)
- mem_pool_free(&cbfs_cache, mapping);
+ mem_pool_free(&cbfs_cache, mapping);
}
int cbfs_locate_file_in_region(struct cbfsf *fh, const char *region_name,
@@ -319,8 +320,13 @@ void *_cbfs_alloc(const char *name, cbfs_allocator_t allocator, void *arg,
}
return mapping;
- } else if (!CBFS_CACHE_AVAILABLE) {
- ERROR("Cannot map compressed file %s on x86\n", mdata.h.filename);
+ } else if (!cbfs_cache.size) {
+ /*
+ * In order to use the cbfs_cache you need to add a CBFS_CACHE to your
+ * memlayout. For stages that don't have .data sections (x86 pre-RAM),
+ * it is not possible to add a CBFS_CACHE.
+ */
+ ERROR("Cannot map compressed file %s without cbfs_cache\n", mdata.h.filename);
return NULL;
} else {
loc = mem_pool_alloc(&cbfs_cache, size);