+struct image_header_table {
+ uint32_t version; /* 0x00 */
+ uint32_t nr_parts; /* 0x04 */
+ uint32_t partition_header_offset; /* 0x08, divided by 4 */
+ uint32_t image_header_offset; /* 0x0c, divided by 4 */
+ uint32_t auth_certificate_offset; /* 0x10 */
+ uint32_t boot_device; /* 0x14 */
+ uint32_t __reserved1[9]; /* 0x18 - 0x38 */
+ uint32_t checksum; /* 0x3c */
+};
+
+#define PART_ATTR_VEC_LOCATION 0x800000
+#define PART_ATTR_BS_BLOCK_SIZE_MASK 0x700000
+#define PART_ATTR_BS_BLOCK_SIZE_DEFAULT 0x000000
+#define PART_ATTR_BS_BLOCK_SIZE_8MB 0x400000
+#define PART_ATTR_BIG_ENDIAN 0x040000
+#define PART_ATTR_PART_OWNER_MASK 0x030000
+#define PART_ATTR_PART_OWNER_FSBL 0x000000
+#define PART_ATTR_PART_OWNER_UBOOT 0x010000
+#define PART_ATTR_RSA_SIG 0x008000
+#define PART_ATTR_CHECKSUM_MASK 0x007000
+#define PART_ATTR_CHECKSUM_NONE 0x000000
+#define PART_ATTR_CHECKSUM_MD5 0x001000
+#define PART_ATTR_CHECKSUM_SHA2 0x002000
+#define PART_ATTR_CHECKSUM_SHA3 0x003000
+#define PART_ATTR_DEST_CPU_SHIFT 8
+#define PART_ATTR_DEST_CPU_MASK 0x000f00
+#define PART_ATTR_DEST_CPU_NONE 0x000000
+#define PART_ATTR_DEST_CPU_A53_0 0x000100
+#define PART_ATTR_DEST_CPU_A53_1 0x000200
+#define PART_ATTR_DEST_CPU_A53_2 0x000300
+#define PART_ATTR_DEST_CPU_A53_3 0x000400
+#define PART_ATTR_DEST_CPU_R5_0 0x000500
+#define PART_ATTR_DEST_CPU_R5_1 0x000600
+#define PART_ATTR_DEST_CPU_R5_L 0x000700
+#define PART_ATTR_DEST_CPU_PMU 0x000800
+#define PART_ATTR_ENCRYPTED 0x000080
+#define PART_ATTR_DEST_DEVICE_SHIFT 4
+#define PART_ATTR_DEST_DEVICE_MASK 0x000070
+#define PART_ATTR_DEST_DEVICE_NONE 0x000000
+#define PART_ATTR_DEST_DEVICE_PS 0x000010
+#define PART_ATTR_DEST_DEVICE_PL 0x000020
+#define PART_ATTR_DEST_DEVICE_PMU 0x000030
+#define PART_ATTR_DEST_DEVICE_XIP 0x000040
+#define PART_ATTR_A53_EXEC_AARCH32 0x000008
+#define PART_ATTR_TARGET_EL_SHIFT 1
+#define PART_ATTR_TARGET_EL_MASK 0x000006
+#define PART_ATTR_TZ_SECURE 0x000001
+
+static const char *dest_cpus[0x10] = {
+ "none", "a5x-0", "a5x-1", "a5x-2", "a5x-3", "r5-0", "r5-1",
+ "r5-lockstep", "pmu", "unknown", "unknown", "unknown", "unknown",
+ "unknown", "unknown", "unknown"
+};
+
+struct partition_header {
+ uint32_t len_enc; /* 0x00, divided by 4 */
+ uint32_t len_unenc; /* 0x04, divided by 4 */
+ uint32_t len; /* 0x08, divided by 4 */
+ uint32_t next_partition_offset; /* 0x0c */
+ uint64_t entry_point; /* 0x10 */
+ uint64_t load_address; /* 0x18 */
+ uint32_t offset; /* 0x20, divided by 4 */
+ uint32_t attributes; /* 0x24 */
+ uint32_t __reserved1; /* 0x28 */
+ uint32_t checksum_offset; /* 0x2c, divided by 4 */
+ uint32_t __reserved2; /* 0x30 */
+ uint32_t auth_certificate_offset; /* 0x34 */
+ uint32_t __reserved3; /* 0x38 */
+ uint32_t checksum; /* 0x3c */
+};
+