示例#1
0
STATIC_PREFIX int fw_load_extl(unsigned por_cfg,unsigned target,unsigned size)
{
    unsigned temp_addr;
#if CONFIG_UCL
    temp_addr=target-0x800000;
#else
    temp_addr=target;
#endif
    int rc=sdio_read(temp_addr,size,por_cfg);   

#if defined(CONFIG_AML_SECU_BOOT_V2)
	if(aml_sec_boot_check((unsigned char *)temp_addr))
	{	
		AML_WATCH_DOG_START();
	}	
#endif //CONFIG_AML_SECU_BOOT_V2

#if CONFIG_UCL
#ifndef CONFIG_IMPROVE_UCL_DEC
	unsigned len;
    if(!rc){
	    serial_puts("ucl decompress...");
	    rc=uclDecompress((char*)target,&len,(char*)temp_addr);
        //serial_puts("decompress finished\n");
        serial_puts(rc?"fail\n":"pass\n");
    }
#endif    
#endif

#ifndef CONFIG_IMPROVE_UCL_DEC
    if(!rc)
        rc=check_sum((unsigned*)target,magic_info->crc[1],size);
#else
    if(!rc)
        rc=check_sum((unsigned*)temp_addr,magic_info->crc[1],size);
#endif        
    return rc;
}
示例#2
0
int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
	ulong		iflag;
	ulong		load_end = 0;
	int		    ret = 0;
	boot_os_fn	*boot_fn;

	AML_LOG_INIT("cmd_bootm");
	AML_LOG_TE("cmd_bootm");
	
#ifdef TEST_UBOOT_BOOT_SPEND_TIME
	bootm_start_time = get_utimer(0);
#endif

#ifdef CONFIG_NEEDS_MANUAL_RELOC
	static int relocated = 0;

	/* relocate boot function table */
	if (!relocated) {
		int i;
		for (i = 0; i < ARRAY_SIZE(boot_os); i++)
			if (boot_os[i] != NULL)
				boot_os[i] += gd->reloc_off;
		relocated = 1;
	}
#endif

	AML_LOG_TE("cmd_bootm");

#ifdef CONFIG_RESET_TO_SYSTEM
    struct aml_pmu_driver *pmu_driver = NULL;
    pmu_driver = aml_pmu_get_driver();
    if (pmu_driver && pmu_driver->pmu_reset_flag_operation) {
        pmu_driver->pmu_reset_flag_operation(RESET_FLAG_SET);
    }
#endif

	AML_LOG_TE("cmd_bootm");

#ifdef CONFIG_M6_SECU_BOOT
#ifdef CONFIG_MESON_TRUSTZONE
	extern int meson_trustzone_boot_check(unsigned char *addr);
	ret = meson_trustzone_boot_check((unsigned char*)load_addr);
#else
	extern int aml_decrypt_kernel_image(void* kernel_image_address);
	ret = aml_decrypt_kernel_image((void*)load_addr);
#endif
	if(ret != 0)
	{
		printf("Error! Illegal kernel image, please check!\n");
		return ret;
	}		
#endif //CONFIG_M6_SECU_BOOT


	AML_LOG_TE("cmd_bootm");

#ifdef CONFIG_AML_SECU_BOOT_V2
#ifdef CONFIG_MESON_TRUSTZONE
	extern int meson_trustzone_boot_check(unsigned char *addr);
	if(!g_nIMGReadFlag)
	ret = meson_trustzone_boot_check(aml_get_kernel_crypto_addr(argc < 2 ? NULL : argv[1]));
#else
	extern int aml_sec_boot_check(unsigned char *pSRC);
	if(!g_nIMGReadFlag)
	ret = aml_sec_boot_check(aml_get_kernel_crypto_addr(argc < 2 ? NULL : argv[1]));
#endif
	if(0 != ret)
		return ret;	
#endif //CONFIG_AML_SECU_BOOT_V2


	AML_LOG_TE("cmd_bootm");

#ifdef CONFIG_AML_GATE_INIT
		extern void gate_init(void);
		gate_init();
#endif

	/* determine if we have a sub command */
	if (argc > 1) {
		char *endp;

		simple_strtoul(argv[1], &endp, 16);
		/* endp pointing to NULL means that argv[1] was just a
		 * valid number, pass it along to the normal bootm processing
		 *
		 * If endp is ':' or '#' assume a FIT identifier so pass
		 * along for normal processing.
		 *
		 * Right now we assume the first arg should never be '-'
		 */
		if ((*endp != 0) && (*endp != ':') && (*endp != '#'))
			return do_bootm_subcommand(cmdtp, flag, argc, argv);
	}

	AML_LOG_TE("cmd_bootm");

	if (bootm_start(cmdtp, flag, argc, argv))
		return 1;

	AML_LOG_TE("cmd_bootm");

	/*
	 * We have reached the point of no return: we are going to
	 * overwrite all exception vector code, so we cannot easily
	 * recover from any failures any more...
	 */
	iflag = disable_interrupts();

#if defined(CONFIG_CMD_USB)
	/*
	 * turn off USB to prevent the host controller from writing to the
	 * SDRAM while Linux is booting. This could happen (at least for OHCI
	 * controller), because the HCCA (Host Controller Communication Area)
	 * lies within the SDRAM and the host controller writes continously to
	 * this area (as busmaster!). The HccaFrameNumber is for example
	 * updated every 1 ms within the HCCA structure in SDRAM! For more
	 * details see the OpenHCI specification.
	 */
	usb_stop();
#endif

	AML_LOG_TE("cmd_bootm");

	ret = bootm_load_os(images.os, &load_end, 1);

	AML_LOG_TE("cmd_bootm");

	if (ret < 0) {
		if (ret == BOOTM_ERR_RESET)
			do_reset (cmdtp, flag, argc, argv);
		if (ret == BOOTM_ERR_OVERLAP) {
			if (images.legacy_hdr_valid) {
				if (image_get_type (&images.legacy_hdr_os_copy) == IH_TYPE_MULTI)
					puts ("WARNING: legacy format multi component "
						"image overwritten\n");
			} else {
				puts ("ERROR: new format image overwritten - "
					"must RESET the board to recover\n");
				show_boot_progress (-113);
				do_reset (cmdtp, flag, argc, argv);
			}
		}
		if (ret == BOOTM_ERR_UNIMPLEMENTED) {
			if (iflag)
				enable_interrupts();
			show_boot_progress (-7);
			return 1;
		}
	}

	AML_LOG_TE("cmd_bootm");

	lmb_reserve(&images.lmb, images.os.load, (load_end - images.os.load));

	AML_LOG_TE("cmd_bootm");

	if (images.os.type == IH_TYPE_STANDALONE) {
		if (iflag)
			enable_interrupts();
		/* This may return when 'autostart' is 'no' */
		bootm_start_standalone(iflag, argc, argv);
		return 0;
	}

	show_boot_progress (8);

#if defined(CONFIG_SILENT_CONSOLE) &&  \
	(defined(CONFIG_SILENT_CONSOLE_LINUX_QUIET) || defined(CONFIG_DEPRECATED_SILENT_LINUX_CONSOLE))
	if (images.os.os == IH_OS_LINUX)
		fixup_silent_linux();
#endif

	AML_LOG_TE("cmd_bootm");

#ifdef CONFIG_AUTO_SET_BOOTARGS_MEM
	mem_size_arg_process();
#endif

	boot_fn = boot_os[images.os.os];

	if (boot_fn == NULL) {
		if (iflag)
			enable_interrupts();
		printf ("ERROR: booting os '%s' (%d) is not supported\n",
			genimg_get_os_name(images.os.os), images.os.os);
		show_boot_progress (-8);
		return 1;
	}

	AML_LOG_TE("cmd_bootm");

	arch_preboot_os();

#ifdef TEST_UBOOT_BOOT_SPEND_TIME
	{   int boot_kernel_start;
	    boot_kernel_start = get_utimer(0);
	    printf("bootm start to prepare boot kernel time:%dus\n",boot_kernel_start-bootm_start_time);
	    printf("from main_loop start to kernel decompress finished time:%dus\n",boot_kernel_start-main_loop_start);
	}
#endif
	ulong	temp_img_addr;

	AML_LOG_TE("cmd_bootm");

	/* use fprintf to always show this print even if console is silenced with GD_FLG_SILENT */
	fprintf(stderr, "uboot time: %d us.\n", get_utimer(0));
	boot_fn(0, argc, argv, &images);

	show_boot_progress (-9);
#ifdef DEBUG
	puts ("\n## Control returned to monitor - resetting...\n");
#endif
	do_reset (cmdtp, flag, argc, argv);

	return 1;
}
示例#3
0
STATIC_PREFIX int fw_load_intl(unsigned por_cfg,unsigned target,unsigned size)
{
    int rc=0;
    unsigned temp_addr;
#if CONFIG_UCL
    temp_addr=target-0x800000;
#else
    temp_addr=target;
#endif

    unsigned * mem;    
    switch(POR_GET_1ST_CFG(por_cfg))
    {
        case POR_1ST_NAND:
        case POR_1ST_NAND_RB:        	
            rc=nf_read(temp_addr,size);            
            break;
        case POR_1ST_SPI :
        case POR_1ST_SPI_RESERVED :
            mem=(unsigned *)(NOR_START_ADDR+READ_SIZE);
            spi_init();
#if CONFIG_UCL==0
            if((rc=check_sum(target,0,0))!=0)
            {
                return rc;
            }
#endif
            serial_puts("Boot From SPI\n");
            memcpy((unsigned*)temp_addr,mem,size);
            break;
        case POR_1ST_SDIO_C:
        	serial_puts("Boot From SDIO C\n");
        	rc=sdio_read(temp_addr,size,POR_2ND_SDIO_C<<3);
        	break;
        case POR_1ST_SDIO_B:
        	rc=sdio_read(temp_addr,size,POR_2ND_SDIO_B<<3);break;
        case POR_1ST_SDIO_A:
           rc=sdio_read(temp_addr,size,POR_2ND_SDIO_A<<3);break;
           break;
        default:
           return 1;
    }

#if defined(CONFIG_AML_SECU_BOOT_V2)
	if(aml_sec_boot_check((unsigned char *)temp_addr))
	{
		AML_WATCH_DOG_START();
	}
#endif //CONFIG_AML_SECU_BOOT_V2

#if CONFIG_UCL    
#ifndef CONFIG_IMPROVE_UCL_DEC
	unsigned len;    
    if(rc==0){
        serial_puts("ucl decompress...");
        rc=uclDecompress((char*)target,&len,(char*)temp_addr);
        serial_puts(rc?"fail\n":"pass\n");
    }
#endif    
#endif    

#ifndef CONFIG_IMPROVE_UCL_DEC
    if(rc==0)    	
        rc=check_sum((unsigned*)target,magic_info->crc[1],size);
#else
    if(rc==0)    	
        rc=check_sum((unsigned*)temp_addr,magic_info->crc[1],size);
#endif              	
    return rc;
}