From 09f4e561ace5897aa7294ad9c23f5a48a94e3fdf Mon Sep 17 00:00:00 2001 From: Joseph Chen Date: Wed, 25 Jul 2018 16:22:38 +0800 Subject: [PATCH] android: update android image header to support new version mainly to support android P. Change-Id: I34a49e4eedcde06a9e40792c7c908737dc10b426 Signed-off-by: Joseph Chen --- common/image-android.c | 11 +++++++++++ include/android_image.h | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/common/image-android.c b/common/image-android.c index a61d37177e..ab877016fc 100644 --- a/common/image-android.c +++ b/common/image-android.c @@ -141,6 +141,9 @@ ulong android_image_get_end(const struct andr_img_hdr *hdr) end += ALIGN(hdr->ramdisk_size, hdr->page_size); end += ALIGN(hdr->second_size, hdr->page_size); + if (hdr->header_version >= 1) + end += ALIGN(hdr->recovery_dtbo_size, hdr->page_size); + return end; } @@ -300,6 +303,7 @@ void android_print_contents(const struct andr_img_hdr *hdr) /* os_version = ver << 11 | lvl */ u32 os_ver = hdr->os_version >> 11; u32 os_lvl = hdr->os_version & ((1U << 11) - 1); + u32 header_version = hdr->header_version; printf("%skernel size: %x\n", p, hdr->kernel_size); printf("%skernel address: %x\n", p, hdr->kernel_addr); @@ -309,6 +313,7 @@ void android_print_contents(const struct andr_img_hdr *hdr) printf("%ssecond address: %x\n", p, hdr->second_addr); printf("%stags address: %x\n", p, hdr->tags_addr); printf("%spage size: %x\n", p, hdr->page_size); + printf("%sheader_version: %x\n", p, header_version); /* ver = A << 14 | B << 7 | C (7 bits for each of A, B, C) * lvl = ((Y - 2000) & 127) << 4 | M (7 bits for Y, 4 bits for M) */ printf("%sos_version: %x (ver: %u.%u.%u, level: %u.%u)\n", @@ -317,5 +322,11 @@ void android_print_contents(const struct andr_img_hdr *hdr) (os_lvl >> 4) + 2000, os_lvl & 0x0F); printf("%sname: %s\n", p, hdr->name); printf("%scmdline: %s\n", p, hdr->cmdline); + + if (header_version >= 1) { + printf("%srecovery dtbo size: %x\n", p, hdr->recovery_dtbo_size); + printf("%srecovery dtbo offset: %llx\n", p, hdr->recovery_dtbo_offset); + printf("%sheader size: %x\n", p, hdr->header_size); + } } #endif diff --git a/include/android_image.h b/include/android_image.h index dfd4d9d72c..3c3319765b 100644 --- a/include/android_image.h +++ b/include/android_image.h @@ -34,7 +34,8 @@ struct andr_img_hdr { u32 tags_addr; /* physical addr for kernel tags */ u32 page_size; /* flash page size we assume */ - u32 unused; /* reserved for future expansion: MUST be 0 */ + + u32 header_version; /* operating system version and security patch level; for * version "A.B.C" and patch level "Y-M-D": @@ -52,6 +53,10 @@ struct andr_img_hdr { /* Supplemental command line data; kept here to maintain * binary compatibility with older versions of mkbootimg */ char extra_cmdline[ANDR_BOOT_EXTRA_ARGS_SIZE]; + + uint32_t recovery_dtbo_size; /* size of recovery dtbo image */ + uint64_t recovery_dtbo_offset; /* offset in boot image */ + uint32_t header_size; /* size of boot image header in bytes */ } __attribute__((packed)); /*