diff --git a/plat/juno/bl2_plat_setup.c b/plat/juno/bl2_plat_setup.c index 5e98f1d..35683e8 100644 --- a/plat/juno/bl2_plat_setup.c +++ b/plat/juno/bl2_plat_setup.c @@ -177,42 +177,55 @@ * the image into. When this function exits, the RAM layout remains untouched * so the BL2 can load BL3-1 as normal. ******************************************************************************/ -/* - * Juno TODO: revisit, it won't compile. - */ static int load_bl30(void) { meminfo_t *bl2_tzram_layout; - meminfo_t tzram_layout; - meminfo_t *tmp_tzram_layout = &tzram_layout; - unsigned long bl30_base; - unsigned int image_len; + meminfo_t tmp_tzram_layout; + uintptr_t bl30_base; + uint32_t bl30_size; unsigned int bl2_load, bl30_load; - int ret = -1; + int ret; + int e; + image_info_t bl30_image_info; + entry_point_info_t bl30_ep; /* Find out how much free trusted ram remains after BL2 load */ bl2_tzram_layout = bl2_plat_sec_mem_layout(); /* copy the TZRAM layout and use it */ - memcpy(tmp_tzram_layout, bl2_tzram_layout, sizeof(meminfo_t)); + memcpy(&tmp_tzram_layout, bl2_tzram_layout, sizeof(meminfo_t)); /* Work out where to load BL3-0 before transferring to SCP */ - bl2_load = tmp_tzram_layout->attr & LOAD_MASK; + bl2_load = tmp_tzram_layout.attr & LOAD_MASK; assert((bl2_load == TOP_LOAD) || (bl2_load == BOT_LOAD)); bl30_load = (bl2_load == TOP_LOAD) ? BOT_LOAD : TOP_LOAD; - /* Load the BL3-0 image */ - bl30_base = load_image(tmp_tzram_layout, BL30_IMAGE_NAME, - bl30_load, BL30_BASE); + SET_PARAM_HEAD(&bl30_image_info, PARAM_IMAGE_BINARY, VERSION_1, 0); - if (bl30_base != 0) { - image_len = image_size(BL30_IMAGE_NAME); - INFO("BL2: BL3-0 loaded at 0x%lx, len=%d (0x%x)\n\r", bl30_base, - image_len, image_len); - flush_dcache_range(bl30_base, image_len); - ret = scp_bootloader_transfer((void *)bl30_base, image_len); + /* Load the BL3-0 image */ + e = load_image(&tmp_tzram_layout, + BL30_IMAGE_NAME, + bl30_load, + BL30_BASE, + &bl30_image_info, + &bl30_ep); + + /* Panic if it has not been possible to load BL3-0 */ + if (e) { + ERROR("Failed to load BL3-0 image.\n"); + panic(); } + bl30_base = bl30_image_info.image_base; + bl30_size = bl30_image_info.image_size; + assert(bl30_base != 0); + assert(bl30_size != 0); + + INFO("BL2: BL3-0 loaded at 0x%lx, len=%d (0x%x)\n\r", bl30_base, + bl30_size, bl30_size); + flush_dcache_range(bl30_base, bl30_size); + ret = scp_bootloader_transfer((void *)bl30_base, bl30_size); + if (ret == 0) INFO("BL2: BL3-0 loaded and transferred to SCP\n\r"); else