#include <linux/libfdt.h>
#define ANDROID_IMAGE_DEFAULT_KERNEL_ADDR 0x10008000
+#define ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR 0x11000000
static char andr_tmp_str[ANDR_BOOT_ARGS_SIZE + 1];
if (!img_data.ramdisk_size)
return -ENOENT;
-
+ /*
+ * Android tools can generate a boot.img with default load address
+ * or 0, even though it doesn't really make a lot of sense, and it
+ * might be valid on some platforms, we treat that address as
+ * the default value for this field, and try to pass ramdisk
+ * in place if possible.
+ */
if (img_data.header_version > 2) {
- ramdisk_ptr = img_data.ramdisk_addr;
+ /* Ramdisk can't be used in-place, copy it to ramdisk_addr_r */
+ if (img_data.ramdisk_addr == ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR) {
+ ramdisk_ptr = env_get_ulong("ramdisk_addr_r", 16, 0);
+ if (!ramdisk_ptr) {
+ printf("Invalid ramdisk_addr_r to copy ramdisk into\n");
+ return -EINVAL;
+ }
+ } else {
+ ramdisk_ptr = img_data.ramdisk_addr;
+ }
+ *rd_data = ramdisk_ptr;
memcpy((void *)(ramdisk_ptr), (void *)img_data.vendor_ramdisk_ptr,
img_data.vendor_ramdisk_size);
ramdisk_ptr += img_data.vendor_ramdisk_size;
img_data.bootconfig_size);
}
} else {
- ramdisk_ptr = img_data.ramdisk_addr;
- memcpy((void *)(ramdisk_ptr), (void *)img_data.ramdisk_ptr,
- img_data.ramdisk_size);
+ /* Ramdisk can be used in-place, use current ptr */
+ if (img_data.ramdisk_addr == 0 ||
+ img_data.ramdisk_addr == ANDROID_IMAGE_DEFAULT_RAMDISK_ADDR) {
+ *rd_data = img_data.ramdisk_ptr;
+ } else {
+ ramdisk_ptr = img_data.ramdisk_addr;
+ *rd_data = ramdisk_ptr;
+ memcpy((void *)(ramdisk_ptr), (void *)img_data.ramdisk_ptr,
+ img_data.ramdisk_size);
+ }
}
printf("RAM disk load addr 0x%08lx size %u KiB\n",
- img_data.ramdisk_addr, DIV_ROUND_UP(img_data.ramdisk_size, 1024));
-
- *rd_data = img_data.ramdisk_addr;
+ *rd_data, DIV_ROUND_UP(img_data.ramdisk_size, 1024));
*rd_len = img_data.ramdisk_size;
return 0;