summaryrefslogtreecommitdiff
path: root/boot
diff options
context:
space:
mode:
authorSafae Ouajih <souajih@baylibre.com>2023-02-06 00:50:15 +0100
committerPraneeth Bajjuri <praneeth@ti.com>2023-04-05 11:40:12 -0500
commite34920ca61555746e47c2eb7277f854293adee92 (patch)
treef5cecdef6aafc3c6134db37b82eab0cdf54cdb4c /boot
parent01f7be0dbbce80750a22e8d975c017ad2bf6afe0 (diff)
android: boot: update android_image_get_dtb_img_addr to support v3, v4
commit 2d0da1972ded075ba783f3ea705662349e77fa61 upstream. Add support for boot image version 3 and 4 in android_image_get_dtb_img_addr(). Since the dtb is now included in vendor_boot image instead of boot image, extract the dtb address from vendor_boot image when a v3 or v4 is used. Signed-off-by: Safae Ouajih <souajih@baylibre.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Tested-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Signed-off-by: Praneeth Bajjuri <praneeth@ti.com>
Diffstat (limited to 'boot')
-rw-r--r--boot/image-android.c47
1 files changed, 33 insertions, 14 deletions
diff --git a/boot/image-android.c b/boot/image-android.c
index a944f0a31a..6be439ed12 100644
--- a/boot/image-android.c
+++ b/boot/image-android.c
@@ -457,6 +457,7 @@ exit:
static bool android_image_get_dtb_img_addr(ulong hdr_addr, ulong vhdr_addr, ulong *addr)
{
const struct andr_boot_img_hdr_v0 *hdr;
+ const struct andr_vnd_boot_img_hdr *v_hdr;
ulong dtb_img_addr;
bool ret = true;
@@ -473,22 +474,40 @@ static bool android_image_get_dtb_img_addr(ulong hdr_addr, ulong vhdr_addr, ulon
goto exit;
}
- if (hdr->dtb_size == 0) {
- printf("Error: dtb_size is 0\n");
- ret = false;
- goto exit;
+ if (hdr->header_version == 2) {
+ if (!hdr->dtb_size) {
+ printf("Error: dtb_size is 0\n");
+ ret = false;
+ goto exit;
+ }
+ /* Calculate the address of DTB area in boot image */
+ dtb_img_addr = hdr_addr;
+ dtb_img_addr += hdr->page_size;
+ dtb_img_addr += ALIGN(hdr->kernel_size, hdr->page_size);
+ dtb_img_addr += ALIGN(hdr->ramdisk_size, hdr->page_size);
+ dtb_img_addr += ALIGN(hdr->second_size, hdr->page_size);
+ dtb_img_addr += ALIGN(hdr->recovery_dtbo_size, hdr->page_size);
+
+ *addr = dtb_img_addr;
}
- /* Calculate the address of DTB area in boot image */
- dtb_img_addr = hdr_addr;
- dtb_img_addr += hdr->page_size;
- dtb_img_addr += ALIGN(hdr->kernel_size, hdr->page_size);
- dtb_img_addr += ALIGN(hdr->ramdisk_size, hdr->page_size);
- dtb_img_addr += ALIGN(hdr->second_size, hdr->page_size);
- dtb_img_addr += ALIGN(hdr->recovery_dtbo_size, hdr->page_size);
-
- *addr = dtb_img_addr;
-
+ if (hdr->header_version > 2) {
+ v_hdr = map_sysmem(vhdr_addr, sizeof(*v_hdr));
+ if (!v_hdr->dtb_size) {
+ printf("Error: dtb_size is 0\n");
+ ret = false;
+ unmap_sysmem(v_hdr);
+ goto exit;
+ }
+ /* Calculate the address of DTB area in boot image */
+ dtb_img_addr = vhdr_addr;
+ dtb_img_addr += v_hdr->page_size;
+ if (v_hdr->vendor_ramdisk_size)
+ dtb_img_addr += ALIGN(v_hdr->vendor_ramdisk_size, v_hdr->page_size);
+ *addr = dtb_img_addr;
+ unmap_sysmem(v_hdr);
+ goto exit;
+ }
exit:
unmap_sysmem(hdr);
return ret;