summaryrefslogtreecommitdiffstats
path: root/util/cbfstool/cbfs-mkpayload.c
diff options
context:
space:
mode:
authorPatrick Rudolph <patrick.rudolph@9elements.com>2018-04-26 09:35:13 +0200
committerPatrick Georgi <pgeorgi@google.com>2018-06-15 09:13:24 +0000
commit7ee05eddf184764de8aa1e015936a42d069893f2 (patch)
treebab7d92178e35e35b4f60f496243b0f58099beab /util/cbfstool/cbfs-mkpayload.c
parent31ff06a2da7380ecfe56365992d013b8ad0f7760 (diff)
downloadcoreboot-7ee05eddf184764de8aa1e015936a42d069893f2.tar.gz
coreboot-7ee05eddf184764de8aa1e015936a42d069893f2.tar.bz2
coreboot-7ee05eddf184764de8aa1e015936a42d069893f2.zip
util/cbfstool: Support FIT payloads
In order to support booting a GNU/Linux payload on non x86, the FIT format should be used, as it is the defacto standard on ARM. Due to greater complexity of FIT it is not converted to simple ELF format. Add support for autodecting FIT payloads and add them as new CBFS_TYPE 'fit'. The payload is included as is, with no special header. The code can determine the type at runtime using the CBFS_TYPE field. Support for parsing FIT payloads in coreboot is added in a follow on commit. Compression of FIT payloads is not supported, as the FIT sections might be compressed itself. Starting at this point a CBFS payload/ can be either of type FIT or SELF. Tested on Cavium SoC. Change-Id: Ic5fc30cd5419eb76c4eb50cca3449caea60270de Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com> Reviewed-on: https://review.coreboot.org/25860 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'util/cbfstool/cbfs-mkpayload.c')
-rw-r--r--util/cbfstool/cbfs-mkpayload.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/util/cbfstool/cbfs-mkpayload.c b/util/cbfstool/cbfs-mkpayload.c
index fd2c4ca0117b..6dc163433d02 100644
--- a/util/cbfstool/cbfs-mkpayload.c
+++ b/util/cbfstool/cbfs-mkpayload.c
@@ -24,6 +24,7 @@
#include "cbfs.h"
#include "fv.h"
#include "coff.h"
+#include "fdt.h"
/* serialize the seg array into the buffer.
* The buffer is assumed to be large enough.
@@ -416,3 +417,39 @@ int parse_fv_to_payload(const struct buffer *input, struct buffer *output,
return 0;
}
+
+int parse_fit_to_payload(const struct buffer *input, struct buffer *output,
+ enum comp_algo algo)
+{
+ struct fdt_header *fdt_h;
+
+ DEBUG("start: parse_fit_to_payload\n");
+
+ fdt_h = buffer_get(input);
+ if (be32toh(fdt_h->magic) != FDT_HEADER_MAGIC) {
+ INFO("Not a FIT payload.\n");
+ return -1;
+ }
+
+ /**
+ * For developers:
+ * Compress the kernel binary you're sourcing in your its-script
+ * manually with LZ4 or LZMA and add 'compression = "lz4"' or "lzma" to
+ * the kernel@1 node in the its-script before assembling the image with
+ * mkimage.
+ */
+ if (algo != CBFS_COMPRESS_NONE) {
+ ERROR("FIT images don't support whole-image compression,"
+ " compress the kernel component instead!\n")
+ return -1;
+ }
+
+ if (buffer_create(output, buffer_size(input), input->name) != 0)
+ return -1;
+
+ memcpy(buffer_get(output), buffer_get(input), buffer_size(input));
+
+ DEBUG("done\n");
+
+ return 0;
+}