[coreboot-gerrit] Change in coreboot[master]: util/cbfstool: Support FIT payloads
Patrick Rudolph (Code Review)
gerrit at coreboot.org
Thu Apr 26 10:37:35 CEST 2018
Patrick Rudolph has uploaded this change for review. ( https://review.coreboot.org/25860
Change subject: util/cbfstool: Support FIT payloads
......................................................................
util/cbfstool: Support FIT payloads
Add support for autodecting FIT (uImage) payloads and add them as new
CBFS_TYPE 'fit'. The payload is included as is, with no special header.
Support for parsing FIT payloads in coreboot is added in a follow on
commit.
Make cbfsf_file_type public to detect the payload type.
Tested on Cavium SoC.
Change-Id: Ic5fc30cd5419eb76c4eb50cca3449caea60270de
Signed-off-by: Patrick Rudolph <patrick.rudolph at 9elements.com>
---
M payloads/libpayload/include/cbfs_core.h
M src/commonlib/include/commonlib/cbfs_serialized.h
M util/cbfstool/cbfs-mkpayload.c
M util/cbfstool/cbfs.h
M util/cbfstool/cbfstool.c
M util/cbfstool/common.h
M util/nvramtool/cbfs.h
7 files changed, 47 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/60/25860/1
diff --git a/payloads/libpayload/include/cbfs_core.h b/payloads/libpayload/include/cbfs_core.h
index 1f155df..4864989 100644
--- a/payloads/libpayload/include/cbfs_core.h
+++ b/payloads/libpayload/include/cbfs_core.h
@@ -68,6 +68,7 @@
#define CBFS_TYPE_STAGE 0x10
#define CBFS_TYPE_PAYLOAD 0x20
+#define CBFS_TYPE_FIT 0x21
#define CBFS_TYPE_OPTIONROM 0x30
#define CBFS_TYPE_BOOTSPLASH 0x40
#define CBFS_TYPE_RAW 0x50
diff --git a/src/commonlib/include/commonlib/cbfs_serialized.h b/src/commonlib/include/commonlib/cbfs_serialized.h
index 9273b35..1a090ff 100644
--- a/src/commonlib/include/commonlib/cbfs_serialized.h
+++ b/src/commonlib/include/commonlib/cbfs_serialized.h
@@ -68,6 +68,7 @@
#define CBFS_TYPE_DELETED2 0xffffffff
#define CBFS_TYPE_STAGE 0x10
#define CBFS_TYPE_PAYLOAD 0x20
+#define CBFS_TYPE_FIT 0x21
#define CBFS_TYPE_OPTIONROM 0x30
#define CBFS_TYPE_BOOTSPLASH 0x40
#define CBFS_TYPE_RAW 0x50
diff --git a/util/cbfstool/cbfs-mkpayload.c b/util/cbfstool/cbfs-mkpayload.c
index fd2c4ca..02d321d1 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,35 @@
return 0;
}
+
+int parse_fit_to_payload(const struct buffer *input, struct buffer *output,
+ enum comp_algo algo)
+{
+ comp_func_ptr compress;
+ int len = 0;
+ struct fdt_header *fdt_h;
+
+ compress = compression_function(algo);
+ if (!compress)
+ return -1;
+
+ DEBUG("start: parse_fit_to_payload\n");
+
+ fdt_h = (struct fdt_header *)input->data;
+ if (be32toh(fdt_h->magic) != FDT_HEADER_MAGIC) {
+ INFO("Not a FIT payload.\n");
+ return -1;
+ }
+
+ if (buffer_create(output, input->size, input->name) != 0)
+ return -1;
+
+ if (!compress(input->data, input->size, output->data, &len) &&
+ (unsigned int)len < input->size)
+ return -1;
+
+ DEBUG("done\n");
+
+ output->size = len;
+ return 0;
+}
diff --git a/util/cbfstool/cbfs.h b/util/cbfstool/cbfs.h
index 2964304..8cfd13e 100644
--- a/util/cbfstool/cbfs.h
+++ b/util/cbfstool/cbfs.h
@@ -172,6 +172,7 @@
#define CBFS_COMPONENT_CBFSHEADER 0x02
#define CBFS_COMPONENT_STAGE 0x10
#define CBFS_COMPONENT_PAYLOAD 0x20
+#define CBFS_COMPONENT_FIT 0x21
#define CBFS_COMPONENT_OPTIONROM 0x30
#define CBFS_COMPONENT_BOOTSPLASH 0x40
#define CBFS_COMPONENT_RAW 0x50
@@ -205,6 +206,7 @@
{CBFS_COMPONENT_CBFSHEADER, "cbfs header"},
{CBFS_COMPONENT_STAGE, "stage"},
{CBFS_COMPONENT_PAYLOAD, "payload"},
+ {CBFS_COMPONENT_FIT, "fit"},
{CBFS_COMPONENT_OPTIONROM, "optionrom"},
{CBFS_COMPONENT_BOOTSPLASH, "bootsplash"},
{CBFS_COMPONENT_RAW, "raw"},
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c
index 7156e00..e0a565d 100644
--- a/util/cbfstool/cbfstool.c
+++ b/util/cbfstool/cbfstool.c
@@ -631,6 +631,13 @@
/* per default, try and see if payload is an ELF binary */
ret = parse_elf_to_payload(buffer, &output, param.compression);
+ /* If it's not an ELF, see if it's a FIT */
+ if (ret != 0) {
+ ret = parse_fit_to_payload(buffer, &output, param.compression);
+ if (ret == 0)
+ header->type = htonl(CBFS_COMPONENT_FIT);
+ }
+
/* If it's not an ELF, see if it's a UEFI FV */
if (ret != 0)
ret = parse_fv_to_payload(buffer, &output, param.compression);
diff --git a/util/cbfstool/common.h b/util/cbfstool/common.h
index 8bae63e..baefc1c 100644
--- a/util/cbfstool/common.h
+++ b/util/cbfstool/common.h
@@ -188,6 +188,8 @@
enum comp_algo algo);
int parse_fv_to_payload(const struct buffer *input, struct buffer *output,
enum comp_algo algo);
+int parse_fit_to_payload(const struct buffer *input, struct buffer *output,
+ enum comp_algo algo);
int parse_bzImage_to_payload(const struct buffer *input,
struct buffer *output, const char *initrd,
char *cmdline, enum comp_algo algo);
diff --git a/util/nvramtool/cbfs.h b/util/nvramtool/cbfs.h
index 3a5bddb..60d95ed 100644
--- a/util/nvramtool/cbfs.h
+++ b/util/nvramtool/cbfs.h
@@ -68,6 +68,7 @@
#define CBFS_TYPE_STAGE 0x10
#define CBFS_TYPE_PAYLOAD 0x20
+#define CBFS_TYPE_FIT 0x21
#define CBFS_TYPE_OPTIONROM 0x30
#define CBFS_TYPE_BOOTSPLASH 0x40
#define CBFS_TYPE_RAW 0x50
--
To view, visit https://review.coreboot.org/25860
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic5fc30cd5419eb76c4eb50cca3449caea60270de
Gerrit-Change-Number: 25860
Gerrit-PatchSet: 1
Gerrit-Owner: Patrick Rudolph <patrick.rudolph at 9elements.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180426/e08bb9d4/attachment-0001.html>
More information about the coreboot-gerrit
mailing list