aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2020-12-30 17:30:12 -0800
committerJulius Werner <jwerner@chromium.org>2021-03-08 22:31:29 +0000
commit9b1f3cc6fb129789f1dd28160a83a1ea59dd123a (patch)
tree98347b2285d361fbcaa74892fa75a40a629d4b7f /src/include
parent11075fc80e00186cb5b488e8e0fd280cd4e97823 (diff)
cbfs: Pull handling of the CBFS_CACHE mem_pool into CBFS core
This patch pulls control of the memory pool serving allocations from the CBFS_CACHE memlayout area into cbfs.c and makes it a core part of the CBFS API. Previously, platforms would independently instantiate this as part of boot_device_ro() (mostly through cbfs_spi.c). The new cbfs_cache pool is exported as a global so these platforms can still use it to directly back rdev_mmap() on their boot device, but the cbfs_cache can now also use it to directly make allocations itself. This is used to allow transparent decompression support in cbfs_map(). Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I0d52b6a8f582a81a19fd0fd663bb89eab55a49d9 Reviewed-on: https://review.coreboot.org/c/coreboot/+/49333 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/cbfs.h15
-rw-r--r--src/include/symbols.h6
2 files changed, 17 insertions, 4 deletions
diff --git a/src/include/cbfs.h b/src/include/cbfs.h
index e08af56399..426757d3f5 100644
--- a/src/include/cbfs.h
+++ b/src/include/cbfs.h
@@ -5,6 +5,7 @@
#include <cbmem.h>
#include <commonlib/cbfs.h>
+#include <commonlib/mem_pool.h>
#include <program_loading.h>
#include <types.h>
#include <vb2_sha.h>
@@ -26,7 +27,7 @@ static inline void *cbfs_ro_map(const char *name, size_t *size_out);
/* Removes a previously allocated CBFS mapping. Should try to unmap mappings in strict LIFO
order where possible, since mapping backends often don't support more complicated cases. */
-int cbfs_unmap(void *mapping);
+void cbfs_unmap(void *mapping);
/* Load a file from CBFS into a buffer. Returns amount of loaded bytes on success or 0 on error.
File will get decompressed as necessary. */
@@ -38,11 +39,22 @@ static inline size_t cbfs_ro_load(const char *name, void *buf, size_t buf_size);
/* Load stage into memory filling in prog. Return 0 on success. < 0 on error. */
int cbfs_prog_stage_load(struct prog *prog);
+
/**********************************************************************************************
* BOOT DEVICE HELPER APIs *
**********************************************************************************************/
/*
+ * The shared memory pool for backing mapped CBFS files, and other CBFS allocation needs.
+ * On x86 platforms, this would only be needed to transparently map compressed files, but it
+ * would require a permanent CBMEM carveout to be safe to use during S3 resume. Since it's not
+ * clear whether this feature is necessary or worth the wasted memory, it is currently disabled
+ * but could be added behind a Kconfig later if desired.
+ */
+#define CBFS_CACHE_AVAILABLE (!CONFIG(ARCH_X86))
+extern struct mem_pool cbfs_cache;
+
+/*
* Data structure that represents "a" CBFS boot device, with optional metadata cache. Generally
* we only have one of these, or two (RO and RW) when CONFIG(VBOOT) is set. The region device
* stored here must always be a subregion of boot_device_ro().
@@ -95,6 +107,7 @@ void *cbfs_boot_map_optionrom_revision(uint16_t vendor, uint16_t device, uint8_t
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/include/symbols.h b/src/include/symbols.h
index fe449d9b4f..3e4694b90d 100644
--- a/src/include/symbols.h
+++ b/src/include/symbols.h
@@ -32,9 +32,9 @@ DECLARE_OPTIONAL_REGION(timestamp)
DECLARE_REGION(preram_cbmem_console)
DECLARE_REGION(cbmem_init_hooks)
DECLARE_REGION(stack)
-DECLARE_REGION(preram_cbfs_cache)
-DECLARE_REGION(postram_cbfs_cache)
-DECLARE_REGION(cbfs_cache)
+DECLARE_OPTIONAL_REGION(preram_cbfs_cache)
+DECLARE_OPTIONAL_REGION(postram_cbfs_cache)
+DECLARE_OPTIONAL_REGION(cbfs_cache)
DECLARE_REGION(cbfs_mcache)
DECLARE_REGION(fmap_cache)
DECLARE_REGION(tpm_tcpa_log)