aboutsummaryrefslogtreecommitdiff
path: root/util/cbfstool/common.h
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2020-03-13 16:43:34 -0700
committerJulius Werner <jwerner@chromium.org>2020-12-03 00:00:33 +0000
commitd477565dbd6e9b6467f49c84a4f05047ffa22682 (patch)
tree864556875c6b3e15b5cb35193db29af542ae7e8e /util/cbfstool/common.h
parent9d0cc2aea918eced42dc3825c1ac94d0d4fbc380 (diff)
cbfstool: Use cbfs_serialized.h and standard vboot helpers
This patch reduces some code duplication in cbfstool by switching it to use the CBFS data structure definitions in commonlib rather than its own private copy. In addition, replace a few custom helpers related to hash algorithms with the official vboot APIs of the same purpose. Signed-off-by: Julius Werner <jwerner@chromium.org> Change-Id: I22eae1bcd76d85fff17749617cfe4f1de55603f4 Reviewed-on: https://review.coreboot.org/c/coreboot/+/41117 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Wim Vervoorn <wvervoorn@eltan.com>
Diffstat (limited to 'util/cbfstool/common.h')
-rw-r--r--util/cbfstool/common.h36
1 files changed, 9 insertions, 27 deletions
diff --git a/util/cbfstool/common.h b/util/cbfstool/common.h
index 7dbc1f575d..f1287e299f 100644
--- a/util/cbfstool/common.h
+++ b/util/cbfstool/common.h
@@ -9,10 +9,10 @@
#include <string.h>
#include <assert.h>
+#include <commonlib/bsd/cbfs_serialized.h>
#include <commonlib/helpers.h>
#include <console/console.h>
-/* Endianness */
#include "swab.h"
#define IS_TOP_ALIGNED_ADDRESS(x) ((uint32_t)(x) > 0x80000000)
@@ -147,47 +147,29 @@ typedef int (*comp_func_ptr) (char *in, int in_len, char *out, int *out_len);
typedef int (*decomp_func_ptr) (char *in, int in_len, char *out, int out_len,
size_t *actual_size);
-enum comp_algo {
- CBFS_COMPRESS_NONE = 0,
- CBFS_COMPRESS_LZMA = 1,
- CBFS_COMPRESS_LZ4 = 2,
-};
-
-struct typedesc_t {
- uint32_t type;
- const char *name;
-};
-
-static const struct typedesc_t types_cbfs_compression[] = {
- {CBFS_COMPRESS_NONE, "none"},
- {CBFS_COMPRESS_LZMA, "LZMA"},
- {CBFS_COMPRESS_LZ4, "LZ4"},
- {0, NULL},
-};
-
-comp_func_ptr compression_function(enum comp_algo algo);
-decomp_func_ptr decompression_function(enum comp_algo algo);
+comp_func_ptr compression_function(enum cbfs_compression algo);
+decomp_func_ptr decompression_function(enum cbfs_compression algo);
uint64_t intfiletype(const char *name);
/* cbfs-mkpayload.c */
int parse_elf_to_payload(const struct buffer *input, struct buffer *output,
- enum comp_algo algo);
+ enum cbfs_compression algo);
int parse_fv_to_payload(const struct buffer *input, struct buffer *output,
- enum comp_algo algo);
+ enum cbfs_compression algo);
int parse_fit_to_payload(const struct buffer *input, struct buffer *output,
- enum comp_algo algo);
+ enum cbfs_compression algo);
int parse_bzImage_to_payload(const struct buffer *input,
struct buffer *output, const char *initrd,
- char *cmdline, enum comp_algo algo);
+ char *cmdline, enum cbfs_compression algo);
int parse_flat_binary_to_payload(const struct buffer *input,
struct buffer *output,
uint32_t loadaddress,
uint32_t entrypoint,
- enum comp_algo algo);
+ enum cbfs_compression algo);
/* cbfs-mkstage.c */
int parse_elf_to_stage(const struct buffer *input, struct buffer *output,
- enum comp_algo algo, uint32_t *location,
+ enum cbfs_compression algo, uint32_t *location,
const char *ignore_section);
/* location is TOP aligned. */
int parse_elf_to_xip_stage(const struct buffer *input, struct buffer *output,