diff options
author | Atish Patra <atish.patra@wdc.com> | 2020-03-05 16:24:22 -0800 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-04-17 12:32:36 -0400 |
commit | 155d6a3575470c1a735b8cf368d9e987930910a8 (patch) | |
tree | 102854264876f6bbee25449bea7cbad36cd145a8 /include/image.h | |
parent | 2a2119e10ca364d7c1539a9103b9fd3839dbe6ac (diff) |
image: Add a common compression type detection function.
Currently, there is no method that can detect compression types
given a file. This is very useful where a compressed kernel image
is loaded directly to the memory.
Inspect initial few bytes to figure out compression type of the
image. It will be used in booti method for now but can be reused
any other function in future as well.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'include/image.h')
-rw-r--r-- | include/image.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/include/image.h b/include/image.h index 2388c1f204..de55b2fb57 100644 --- a/include/image.h +++ b/include/image.h @@ -453,6 +453,15 @@ typedef struct table_entry { } table_entry_t; /* + * Compression type and magic number mapping table. + */ +struct comp_magic_map { + int comp_id; + const char *name; + unsigned char magic[2]; +}; + +/* * get_table_entry_id() scans the translation table trying to find an * entry that matches the given short name. If a matching entry is * found, it's id is returned to the caller. @@ -869,6 +878,18 @@ static inline int image_check_target_arch(const image_header_t *hdr) #endif /* USE_HOSTCC */ /** + * image_decomp_type() - Find out compression type of an image + * + * @buf: Address in U-Boot memory where image is loaded. + * @len: Length of the compressed image. + * @return compression type or IH_COMP_NONE if not compressed. + * + * Note: Only following compression types are supported now. + * lzo, lzma, gzip, bzip2 + */ +int image_decomp_type(const unsigned char *buf, ulong len); + +/** * image_decomp() - decompress an image * * @comp: Compression algorithm that is used (IH_COMP_...) |