void main(void) { struct bldr_command_handler handler; blkdev_t *bootdev; u32 addr = 0; char *name; bldr_pre_process(); handler.priv = NULL; handler.attr = 0; handler.cb = bldr_cmd_handler; bldr_handshake(&handler); if (NULL == (bootdev = blkdev_get(CFG_BOOT_DEV))) { print("%s can't find boot device(%d)\n", MOD, CFG_BOOT_DEV); goto error; } #if CFG_LOAD_DSP_ROM /* DSP is no more available in MT6589/MT6583 */ #endif #if CFG_LOAD_MD_FS addr = CFG_MD_FS_MEMADDR; if (bldr_load_part(PART_MD_FS, bootdev, &addr) != 0) goto error; #endif #if CFG_LOAD_MD_ROM if (platform_is_three_g()) { addr = CFG_MD_3G_ROM_MEMADDR; name = PART_MD_3G_ROM; } else { addr = CFG_MD_2G_ROM_MEMADDR; name = PART_MD_2G_ROM; } if (bldr_load_part(name, bootdev, &addr) != 0) goto error; #endif #if CFG_LOAD_AP_ROM addr = CFG_AP_ROM_MEMADDR; if (bldr_load_part(PART_AP_ROM, bootdev, &addr) != 0) goto error; #endif #if CFG_LOAD_UBOOT addr = CFG_UBOOT_MEMADDR; if (bldr_load_part(PART_UBOOT, bootdev, &addr) != 0) goto error; #endif bldr_post_process(); bldr_jump(addr, BOOT_ARGUMENT_ADDR, sizeof(boot_arg_t)); error: platform_error_handler(); }
static int bldr_load_images(u32 *jump_addr) { int ret = 0; blkdev_t *bootdev; u32 addr = 0; char *name; u32 size = 0; u32 spare0 = 0; u32 spare1 = 0; if (NULL == (bootdev = blkdev_get(CFG_BOOT_DEV))) { print("%s can't find boot device(%d)\n", MOD, CFG_BOOT_DEV); /* FIXME, should change to global error code */ return -1; } #if CFG_LOAD_MD_ROM if (1 == aarch64_slt_done()) { /* do not check the correctness */ addr = CFG_MD1_ROM_MEMADDR; //bldr_load_part(PART_MD1_ROM, bootdev, &addr, &size); bldr_load_part("MD1_ROM", bootdev, &addr, &size); addr = CFG_MD2_ROM_MEMADDR; //bldr_load_part(PART_MD2_ROM, bootdev, &addr, &size); bldr_load_part("MD2_ROM", bootdev, &addr, &size); } #endif #if CFG_LOAD_MD_RAMDISK if (1 == aarch64_slt_done()) { /* do not check the correctness */ addr = CFG_MD1_RAMDISK_MEMADDR; bldr_load_part("MD1_RAMDISK", bootdev, &addr, &size); addr = CFG_MD2_RAMDISK_MEMADDR; bldr_load_part("MD2_RAMDISK", bootdev, &addr, &size); } #endif #if CFG_LOAD_MD_DSP if (1 == aarch64_slt_done()) { addr = CFG_MD_DSP_MEMADDR; bldr_load_part("MD_DSP",bootdev, &addr, &size); } #endif #if CFG_LOAD_SLT_MD_RAMDISK if (1 == aarch64_slt_done()) { /* do not check the correctness */ addr = CFG_MD1_RAMDISK_MEMADDR; //bldr_load_part(PART_FDD_MD_RAMDISK, bootdev, &addr, &size); bldr_load_part("FDD_MD_RAMDISK", bootdev, &addr, &size); addr = CFG_MD1_RAMDISK_MEMADDR; //bldr_load_part(PART_TDD_ONLY_MD_RAMDISK, bootdev, &addr, &size); bldr_load_part("TDD_ONLY_MD_RAMDISK", bootdev, &addr, &size); addr = CFG_MD1_RAMDISK_MEMADDR; //bldr_load_part(PART_TDD2G_MD_RAMDISK, bootdev, &addr, &size); bldr_load_part("TDD2G_MD_RAMDISK", bootdev, &addr, &size); } #endif #if CFG_LOAD_SLT_MD_DSP if (1 == aarch64_slt_done()) { addr = CFG_MD_DSP_MEMADDR; //bldr_load_part(PART_FDD_MD_DSP,bootdev, &addr, &size); bldr_load_part("FDD_MD_DSP",bootdev, &addr, &size); addr = CFG_MD_DSP_MEMADDR; //bldr_load_part(PART_TDD_ONLY_MD_DSP,bootdev, &addr, &size); bldr_load_part("TDD_ONLY_MD_DSP",bootdev, &addr, &size); addr = CFG_MD_DSP_MEMADDR; //bldr_load_part(PART_TDD2G_MD_DSP,bootdev, &addr, &size); bldr_load_part("TDD2G_MD_DSP",bootdev, &addr, &size); } #endif #if CFG_LOAD_CONN_SYS if (1 == aarch64_slt_done()) { addr = CFG_CONN_SYS_MEMADDR; //bldr_load_part(PART_CONN_SYS,bootdev, &addr, &size); bldr_load_part("CONN_SYS",bootdev, &addr, &size); } #endif #if CFG_LOAD_SLT_MD if (1 == aarch64_slt_done()) { addr = CFG_FDD_MD_ROM_MEMADDR; //bldr_load_part(PART_HVT_MD_ROM, bootdev, &addr, &size); bldr_load_part("HVT_MD_ROM", bootdev, &addr, &size); addr = CFG_FDD_MD_ROM_MEMADDR; //bldr_load_part(PART_FDD_MD_ROM, bootdev, &addr, &size); bldr_load_part("FDD_MD_ROM", bootdev, &addr, &size); addr = CFG_FDD_MD_ROM_MEMADDR; //bldr_load_part(PART_TDD_ONLY_ROM, bootdev, &addr, &size); bldr_load_part("TDD_ONLY_ROM", bootdev, &addr, &size); addr = CFG_FDD_MD_ROM_MEMADDR; //bldr_load_part(PART_TDD2G_MD_ROM, bootdev, &addr, &size); bldr_load_part("TDD2G_MD_ROM", bootdev, &addr, &size); } #endif #if CFG_LOAD_SLT_MD32 if (1 == aarch64_slt_done()) { u32 p_addr; u32 d_addr; //SPM power on MD32 and MD32 SRAM DRV_WriteReg32(0x10006000, 0x0b160001); DRV_WriteReg32(0x100062c8, 0xfffffff0); p_addr = CFG_MD32P_ROM_MEMADDR; //bldr_load_part(PART_MD32_P,bootdev, &p_addr, &size); bldr_load_part("MD32_P",bootdev, &p_addr, &size); d_addr = CFG_MD32D_ROM_MEMADDR; //bldr_load_part(PART_MD32_D,bootdev, &d_addr, &size); bldr_load_part("MD32_D",bootdev, &d_addr, &size); } #endif #if CFG_LOAD_AP_ROM if (1 == aarch64_slt_done()) { u32 p_addr; addr = CFG_AP_ROM_MEMADDR; //ret = bldr_load_part(PART_AP_ROM, bootdev, &addr, &size); ret = bldr_load_part("AP_ROM", bootdev, &addr, &size); if (ret) return ret; *jump_addr = addr; } #elif CFG_LOAD_UBOOT addr = CFG_UBOOT_MEMADDR; ret = bldr_load_part("lk", bootdev, &addr, &size); if (ret) return ret; *jump_addr = addr; #endif #if CFG_LOAD_SLT_AARCH64_KERNEL if (0 == aarch64_slt_done()) { addr = CFG_BOOTA64_MEMADDR; ret = bldr_load_part("boota64", bootdev, &addr, &size); addr = CFG_DTB_MEMADDR; ret = bldr_load_part("DTB", bootdev, &addr, &size); addr = CFG_IMAGE_AARCH64_MEMADDR; ret = bldr_load_part("Image_aarch64", bootdev, &addr, &size); } #endif #if CFG_ATF_SUPPORT addr = CFG_ATF_ROM_MEMADDR; ret = bldr_load_tee_part("tee1", bootdev, &addr, 0, &size); if (ret) { addr = CFG_ATF_ROM_MEMADDR; ret = bldr_load_tee_part("tee2", bootdev, &addr, 0, &size); if (ret) return ret; } print("%s bldr load tee part ret=0x%x, addr=0x%x\n", MOD, ret, addr); addr = CFG_BOOTIMG_HEADER_MEMADDR; size = 0x100; bldr_load_bootimg_header("boot", bootdev, &addr, 0, &size); // ret = bldr_load_bootimg_header("boot", bootdev, &addr, 0, &size); print("%s part_load_images ret=0x%x\n", MOD, ret); #endif return ret; }
void main(void) { #if !defined(CFG_MEM_PRESERVED_MODE) struct bldr_command_handler handler; #endif blkdev_t *bootdev; u32 addr; char *name; #if defined(CFG_SRAM_PRELOADER_MODE) //jump to mem preloader directly //mem_baseaddr is defined in link_sram_descriptor.ld addr = (u32) &mem_baseaddr; jump(addr, BOOT_ARGUMENT_ADDR, sizeof(boot_arg_t)); #else //#if defined(CFG_SRAM_PRELOADER_MODE) #ifdef PL_PROFILING u32 profiling_time; profiling_time = 0; #endif //Change setting to improve L2 CACHE SRAM access stability //CACHE_MEM_DELSEL: 0x10200014 //bit 3:0 l2data_delsel Adjusts memory marco timing //change setting: default=0xA new=0xB *(volatile unsigned int *)0x10200014 = 0xAAAB; addr = 0; bldr_pre_process(); #ifdef TINY_BOOTLOADER while(1); #endif #if !defined(CFG_MEM_PRESERVED_MODE) handler.priv = NULL; handler.attr = 0; handler.cb = bldr_cmd_handler; #ifdef PL_PROFILING profiling_time = get_timer(0); #endif bldr_handshake(&handler); #ifdef PL_PROFILING printf("#T#bldr_hdshk=%d\n", get_timer(profiling_time)); #endif #endif if (NULL == (bootdev = blkdev_get(CFG_BOOT_DEV))) { print("%s can't find boot device(%d)\n", MOD, CFG_BOOT_DEV); goto error; } #if defined(LOAD_NORMAL_BOOT_PRELOADER) #ifdef PL_PROFILING profiling_time = get_timer(0); #endif { volatile u32 cache_cfg; #define L2C_SIZE_CFG_OFF 5 //enable L2 sram for DA cache_cfg = DRV_Reg(APMCUSYS_CONFIG_BASE); cache_cfg &= ~(0x7 << L2C_SIZE_CFG_OFF); DRV_WriteReg(APMCUSYS_CONFIG_BASE, cache_cfg); //enable audio sysram clk for DA *(volatile unsigned int *)(0x10000084) = 0x02000000; } addr = CFG_UBOOT_MEMADDR; printf("load preloader=0x%x\n",addr); if (bldr_load_part(PART_PRELOADER, bootdev, &addr) != 0) goto error; addr = 0x02007200; printf("memcpy preloader=0x%x\n", addr); memcpy((void *)addr,(void *) CFG_UBOOT_MEMADDR,(int) 0x18E00); #ifdef PL_PROFILING printf("#T#ld_lk=%d\n", get_timer(profiling_time)); #endif addr = 0x02007500; apmcu_disable_dcache(); apmcu_dcache_clean_invalidate(); apmcu_dsb(); apmcu_icache_invalidate(); apmcu_disable_icache(); apmcu_isb(); apmcu_disable_smp(); printf("jump to preloader=0x%x\n", addr); // while( *(volatile unsigned int *)(0x10001428) != 0x000000AA) ; jump((u32) addr, BOOT_ARGUMENT_ADDR, sizeof(boot_arg_t)); #endif #if CFG_LOAD_DSP_ROM /* DSP is no more available in MT6589/MT6583 */ #endif #if CFG_LOAD_MD_FS #ifdef PL_PROFILING profiling_time = get_timer(0); #endif addr = CFG_USE_HEADER_MEMADDR; name = PART_BOOTIMG; if (bldr_load_part(name, bootdev, &addr) != 0) ; //goto error; // MD_FS partition may be empty #ifdef PL_PROFILING printf("#T#ld_MDFS=%d\n", get_timer(profiling_time)); #endif #endif #if CFG_LOAD_MD_ROM #ifdef PL_PROFILING profiling_time = get_timer(0); #endif addr = CFG_USE_HEADER_MEMADDR; name = PART_RECOVERY; if (bldr_load_part(name, bootdev, &addr) != 0) goto error; #ifdef PL_PROFILING printf("#T#ld_MDROM=%d\n", get_timer(profiling_time)); #endif #endif #if CFG_LOAD_AP_ROM #ifdef PL_PROFILING profiling_time = get_timer(0); #endif addr = CFG_USE_HEADER_MEMADDR; name = PART_UBOOT; if (bldr_load_part(name, bootdev, &addr) != 0) goto error; #ifdef PL_PROFILING printf("#T#ld_APROM=%d\n", get_timer(profiling_time)); #endif #endif #if CFG_LOAD_UBOOT #ifdef PL_PROFILING profiling_time = get_timer(0); #endif addr = CFG_UBOOT_MEMADDR; if (bldr_load_part(PART_UBOOT, bootdev, &addr) != 0) goto error; #ifdef PL_PROFILING printf("#T#ld_lk=%d\n", get_timer(profiling_time)); #endif #endif bldr_post_process(); bldr_jump(addr, BOOT_ARGUMENT_ADDR, sizeof(boot_arg_t)); error: platform_error_handler(); #endif //end of #if !defined(CFG_SRAM_PRELOADER_MODE) }