Skip to contentSkip to conversation

loader: Support Flattened Image Trees (FIT images)

PATCH Superseded Yongbok Kim 1 participant 1 message Feb 8, 2017

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 6/8 loader: Support Flattened Image Trees (FIT images)

From: Paul Burton <[email protected]>

Introduce support for loading Flattened Image Trees, as used by modern U-Boot. FIT images are essentially flattened device tree files which contain binary images such as kernels, FDTs or ramdisks along with one or more configuration nodes describing boot configurations.

The MIPS Boston board typically boots kernels in the form of FIT images, and will make use of this code.

[[email protected]: fixed potential memory leaks]
---
 hw/core/Makefile.objs   |   1 +
 hw/core/loader-fit.c    | 325 ++++++++++++++++++++++++++++++++++++++++++++++++
 hw/core/loader.c        |   7 +-
 include/hw/loader-fit.h |  41 ++++++
 include/hw/loader.h     |   6 +
 5 files changed, 374 insertions(+), 6 deletions(-)
 create mode 100644 hw/core/loader-fit.c
 create mode 100644 include/hw/loader-fit.h
hw/core/Makefile.objs +1 -0
index 7f8c9dc..ff59512 100644
@@ -13,6 +13,7 @@ common-obj-$(CONFIG_PTIMER) += ptimer.o
 common-obj-$(CONFIG_SOFTMMU) += sysbus.o
 common-obj-$(CONFIG_SOFTMMU) += machine.o
 common-obj-$(CONFIG_SOFTMMU) += loader.o
+common-obj-$(CONFIG_SOFTMMU) += loader-fit.o
 common-obj-$(CONFIG_SOFTMMU) += qdev-properties-system.o
 common-obj-$(CONFIG_SOFTMMU) += register.o
 common-obj-$(CONFIG_SOFTMMU) += or-irq.o
hw/core/loader-fit.c new file +325 -0

325 lines not on this page · raw message

hw/core/loader.c +1 -6
index ee5abd6..8b980e9 100644
@@ -527,12 +527,7 @@ static void zfree(void *x, void *addr)
 
 #define DEFLATED	8
 
-/* This is the usual maximum in uboot, so if a uImage overflows this, it would
- * overflow on real hardware too. */
-#define UBOOT_MAX_GUNZIP_BYTES (64 << 20)
-
-static ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src,
-                      size_t srclen)
+ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src, size_t srclen)
 {
     z_stream s;
     ssize_t dstbytes;
include/hw/loader-fit.h new file +41 -0

41 lines not on this page · raw message

include/hw/loader.h +6 -0
index 0dbd8d6..40c4153 100644
@@ -164,6 +164,8 @@ int load_uimage(const char *filename, hwaddr *ep,
  */
 int load_ramdisk(const char *filename, hwaddr addr, uint64_t max_sz);
 
+ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src, size_t srclen);
+
 ssize_t read_targphys(const char *name,
                       int fd, hwaddr dst_addr, size_t nbytes);
 void pstrcpy_targphys(const char *name,
@@ -214,4 +216,8 @@ void hmp_info_roms(Monitor *mon, const QDict *qdict);
 int rom_add_vga(const char *file);
 int rom_add_option(const char *file, int32_t bootindex);
 
+/* This is the usual maximum in uboot, so if a uImage overflows this, it would
+ * overflow on real hardware too. */
+#define UBOOT_MAX_GUNZIP_BYTES (64 << 20)
+
 #endif
Signature · 1 line
2.7.4