diff options
author | Julius Werner <jwerner@chromium.org> | 2016-08-19 15:43:06 -0700 |
---|---|---|
committer | Julius Werner <jwerner@chromium.org> | 2016-08-27 01:16:22 +0200 |
commit | f975e55dcdbeb31e39449d22a9c04ff861dae8dd (patch) | |
tree | 7a677a6f71a26d2d9c19d98d12c13cb5e5244a0b /src/include | |
parent | 71885a49600db1df58060406c0bb8a5b976c554c (diff) |
cbfs: Add "struct" file type and associated helpers
This patch adds functionality to compile a C data structure into a raw
binary file, add it to CBFS and allow coreboot to load it at runtime.
This is useful in all cases where we need to be able to have several
larger data sets available in an image, but will only require a small
subset of them at boot (a classic example would be DRAM parameters) or
only require it in certain boot modes. This allows us to load less data
from flash and increase boot speed compared to solutions that compile
all data sets into a stage.
Each structure has to be defined in a separate .c file which contains no
functions and only a single global variable. The data type must be
serialization safe (composed of only fixed-width types, paying attention
to padding). It must be added to CBFS in a Makefile with the 'struct'
file processor.
Change-Id: Iab65c0b6ebea235089f741eaa8098743e54d6ccc
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://review.coreboot.org/16272
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/cbfs.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/include/cbfs.h b/src/include/cbfs.h index 6d9dd42d72..6063dd6f9e 100644 --- a/src/include/cbfs.h +++ b/src/include/cbfs.h @@ -34,6 +34,10 @@ int cbfs_boot_locate(struct cbfsf *fh, const char *name, uint32_t *type); * leaking mappings are a no-op. Returns NULL on error, else returns * the mapping and sets the size of the file. */ void *cbfs_boot_map_with_leak(const char *name, uint32_t type, size_t *size); +/* Load a struct file from CBFS into a buffer. Returns amount of loaded + * bytes on success or 0 on error. File will get decompressed as necessary. + * Same decompression requirements as cbfs_load_and_decompress(). */ +size_t cbfs_boot_load_struct(const char *name, void *buf, size_t buf_size); /* Load |in_size| bytes from |rdev| at |offset| to the |buffer_size| bytes * large |buffer|, decompressing it according to |compression| in the process. |