This adds support for v3/v4 boot image format by adding
the following structures:

- andr_boot_img_hdr_v3_v4 : describes boot image header
- andr_vendor_boot_img_hdr_v3_v4 : describes vendor boot image header

These definitions have been copied over from the AOSP documentation at
[1] and [2]

Boot arg sizes are taken from [3]:
`35fb6262bc3fe2280c37047a92d79953789760e5`

[1] 
https://source.android.com/docs/core/architecture/bootloader/boot-image-header
[2] 
https://source.android.com/docs/core/architecture/bootloader/partitions/vendor-boot-partitions#vendor-boot-header
[3] https://android.googlesource.com/platform/external/u-boot

Signed-off-by: Safae Ouajih <soua...@baylibre.com>
---
 include/android_image.h | 47 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/include/android_image.h b/include/android_image.h
index bf9b8c6f0955..ec36e6512ad6 100644
--- a/include/android_image.h
+++ b/include/android_image.h
@@ -14,11 +14,58 @@
 #include <linux/compiler.h>
 #include <linux/types.h>
 
+#define ANDR_GKI_PAGE_SIZE 4096
 #define ANDR_BOOT_MAGIC "ANDROID!"
 #define ANDR_BOOT_MAGIC_SIZE 8
 #define ANDR_BOOT_NAME_SIZE 16
 #define ANDR_BOOT_ARGS_SIZE 512
 #define ANDR_BOOT_EXTRA_ARGS_SIZE 1024
+#define VENDOR_BOOT_MAGIC "VNDRBOOT"
+#define ANDR_VENDOR_BOOT_MAGIC_SIZE 8
+#define ANDR_VENDOR_BOOT_ARGS_SIZE 2048
+#define ANDR_VENDOR_BOOT_NAME_SIZE 16
+
+struct andr_boot_img_hdr_v3_v4 {
+       u8 magic[ANDR_BOOT_MAGIC_SIZE];
+
+       u32 kernel_size;    /* size in bytes */
+       u32 ramdisk_size;   /* size in bytes */
+
+       u32 os_version;
+
+       u32 header_size;    /* size of boot image header in bytes */
+       u32 reserved[4];
+       u32 header_version; /* offset remains constant for version check */
+
+       u8 cmdline[ANDR_BOOT_ARGS_SIZE + ANDR_BOOT_EXTRA_ARGS_SIZE];
+       /* for boot image header v4 only */
+       u32 signature_size; /* size in bytes */
+};
+
+struct andr_vendor_boot_img_hdr_v3_v4 {
+       u8 magic[ANDR_VENDOR_BOOT_MAGIC_SIZE];
+       u32 header_version;
+       u32 page_size;           /* flash page size we assume */
+
+       u32 kernel_addr;         /* physical load addr */
+       u32 ramdisk_addr;        /* physical load addr */
+
+       u32 vendor_ramdisk_size; /* size in bytes */
+
+       u8 cmdline[ANDR_VENDOR_BOOT_ARGS_SIZE];
+
+       u32 tags_addr;           /* physical addr for kernel tags */
+
+       u8 name[ANDR_VENDOR_BOOT_NAME_SIZE]; /* asciiz product name */
+       u32 header_size;         /* size of vendor boot image header in bytes */
+       u32 dtb_size;            /* size of dtb image */
+       u64 dtb_addr;            /* physical load address */
+       /* for boot image header v4 only */
+       u32 vendor_ramdisk_table_size; /* size in bytes for the vendor ramdisk 
table */
+       u32 vendor_ramdisk_table_entry_num; /* number of entries in the vendor 
ramdisk table */
+       u32 vendor_ramdisk_table_entry_size; /* size in bytes for a vendor 
ramdisk table entry */
+       u32 bootconfig_size; /* size in bytes for the bootconfig section */
+};
 
 /* The bootloader expects the structure of andr_boot_img_hdr_v0_v1_v2 with 
header
  * version 0 to be as follows: */
-- 
2.25.1

Reply via email to