app: aboot: Update the kernel/ramdisk/tags addr to use sane values
Use sane values for kernel/ramdisk/tags address if the boot image
header contains default values. These default values come from
mkbootimg when the kernel & ramdisk are flashed using fastboot
flash:raw
Change-Id: I9b2d5b9c04337f3b942fd6483ec03cad200ce7fc
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index 7d42713..3e17f06 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -132,6 +132,29 @@
extern int fastboot_trigger(void);
#endif
+static void update_ker_tags_rdisk_addr(struct boot_img_hdr *hdr)
+{
+ /* overwrite the destination of specified for the project */
+ /*
+ * Update the value to sane values only when the boot image
+ * header does not have sane values, this is added to make sure
+ * that we always use values from boot.img header and use the
+ * force values when boot image header has default values.
+ */
+#ifdef ABOOT_FORCE_KERNEL_ADDR
+ if (hdr->kernel_addr == ABOOT_DEFAULT_KERNEL_ADDR)
+ hdr->kernel_addr = ABOOT_FORCE_KERNEL_ADDR;
+#endif
+#ifdef ABOOT_FORCE_RAMDISK_ADDR
+ if (hdr->ramdisk_addr == ABOOT_DEFAULT_RAMDISK_ADDR)
+ hdr->ramdisk_addr = ABOOT_FORCE_RAMDISK_ADDR;
+#endif
+#ifdef ABOOT_FORCE_TAGS_ADDR
+ if (hdr->tags_addr == ABOOT_DEFAULT_TAGS_ADDR)
+ hdr->tags_addr = ABOOT_FORCE_TAGS_ADDR;
+#endif
+}
+
static void ptentry_to_tag(unsigned **ptr, struct ptentry *ptn)
{
struct atag_ptbl_entry atag_ptn;
@@ -517,6 +540,13 @@
page_mask = page_size - 1;
}
+ /*
+ * Update the kernel/ramdisk/tags address if the boot image header
+ * has default values, these default values come from mkbootimg when
+ * the boot image is flashed using fastboot flash:raw
+ */
+ update_ker_tags_rdisk_addr(hdr);
+
/* Get virtual addresses since the hdr saves physical addresses. */
hdr->kernel_addr = VA((addr_t)(hdr->kernel_addr));
hdr->ramdisk_addr = VA((addr_t)(hdr->ramdisk_addr));
@@ -804,6 +834,13 @@
return -1;
}
+ /*
+ * Update the kernel/ramdisk/tags address if the boot image header
+ * has default values, these default values come from mkbootimg when
+ * the boot image is flashed using fastboot flash:raw
+ */
+ update_ker_tags_rdisk_addr(hdr);
+
/* Get virtual addresses since the hdr saves physical addresses. */
hdr->kernel_addr = VA(hdr->kernel_addr);
hdr->ramdisk_addr = VA(hdr->ramdisk_addr);
@@ -1224,16 +1261,12 @@
kernel_actual = ROUND_TO_PAGE(hdr->kernel_size, page_mask);
ramdisk_actual = ROUND_TO_PAGE(hdr->ramdisk_size, page_mask);
- /* overwrite the destination of specified for the project */
-#ifdef ABOOT_FORCE_KERNEL_ADDR
- hdr->kernel_addr = ABOOT_FORCE_KERNEL_ADDR;
-#endif
-#ifdef ABOOT_FORCE_RAMDISK_ADDR
- hdr->ramdisk_addr = ABOOT_FORCE_RAMDISK_ADDR;
-#endif
-#ifdef ABOOT_FORCE_TAGS_ADDR
- hdr->tags_addr = ABOOT_FORCE_TAGS_ADDR;
-#endif
+ /*
+ * Update the kernel/ramdisk/tags address if the boot image header
+ * has default values, these default values come from mkbootimg when
+ * the boot image is flashed using fastboot flash:raw
+ */
+ update_ker_tags_rdisk_addr(hdr);
/* Get virtual addresses since the hdr saves physical addresses. */
hdr->kernel_addr = VA(hdr->kernel_addr);