コード例 #1
0
ファイル: kmalloc.c プロジェクト: thetlk/YAUKernel
void *kmalloc_ksbrk(unsigned int n)
{
    unsigned int i;
    void *page;
    struct kmalloc_chunk *chunk;

    if(((unsigned int) kernel_heap + (n * PAGE_SIZE)) > KERNEL_HEAP_MAX)
    {
        video_printf("kmalloc_ksbrk(): no virtual memory left for the kernel heap\n");
        return (void *) -1;
    }

    chunk = (struct kmalloc_chunk *) kernel_heap;
    for(i=0; i<n; i++)
    {
        page = memory_get_unused_page();
        if((int) page == -1)
        {
            video_printf("kmalloc_ksbrk(): no physical memory left for the kernel heap\n");
            return (void *) -1;
        }

        pagemem_pagedirectory0_add_page(kernel_heap, page);

        kernel_heap = (void*) (((unsigned int) kernel_heap) + PAGE_SIZE);
    }

    chunk->size = PAGE_SIZE * n;
    chunk->used = 0;

    return 0;
}
コード例 #2
0
void sw_env()
{
    int dl_status = 0;

#ifdef LK_DL_CHECK
#ifdef MTK_EMMC_SUPPORT
    dl_status = mmc_get_dl_info();
    printf("mt65xx_sw_env--dl_status: %d\n", dl_status);
    if (dl_status != 0)
    {
        video_printf("=> TOOL DL image Fail!\n");
        printf("TOOL DL image Fail\n");
#ifdef LK_DL_CHECK_BLOCK_LEVEL
        printf("uboot is blocking by dl info\n");
        while (1) ;
#endif
    }
#endif
#endif

#ifndef USER_BUILD
    switch (g_boot_mode)
    {
      case META_BOOT:
          video_printf(" => META MODE\n");
          break;
      case FACTORY_BOOT:
          video_printf(" => FACTORY MODE\n");
          break;
      case RECOVERY_BOOT:
          video_printf(" => RECOVERY MODE\n");
          break;
      case SW_REBOOT:
          //video_printf(" => SW RESET\n");
          break;
      case NORMAL_BOOT:
          video_printf(" => NORMAL BOOT\n");
          break;
      case ADVMETA_BOOT:
          video_printf(" => ADVANCED META MODE\n");
          break;
      case ATE_FACTORY_BOOT:
          video_printf(" => ATE FACTORY MODE\n");
          break;
      case ALARM_BOOT:
          video_printf(" => ALARM BOOT\n");
          break;
      case FASTBOOT:
          video_printf(" => FASTBOOT mode...\n");
          break;
      default:
          video_printf(" => UNKNOWN BOOT\n");
    }
    return 0;
#endif

}
コード例 #3
0
int fastboot_oem_lock(const char *arg, void *data, unsigned sz)
{
    int ret = B_OK;
    char msg[128] = {0};
    int inFactory = 0;
    int requireConfirmation = 0;

    ret = sec_is_in_factory(&inFactory);
    if (ret)
        return ret;

    requireConfirmation = inFactory ? 0 : 1;

    lock_warranty();

    while(1)
    {
        if(mtk_detect_key(MT65XX_MENU_SELECT_KEY) || !requireConfirmation) //VOL_UP
        {
            fastboot_info("Start lock flow\n");
            //Invoke security check after confiming "yes" by user
            ret = fastboot_oem_lock_chk();
            if(ret != B_OK)
            {
                sprintf(msg, "\nlock failed - Err:0x%x \n", ret);
                video_printf("lock failed...return to fastboot in 3s\n");
                mdelay(3000);
                fastboot_boot_menu();
                fastboot_fail(msg);
            }
            else
            {
                video_printf("lock Pass...return to fastboot in 3s\n");
                mdelay(3000);
                fastboot_boot_menu();
                fastboot_okay("");
            }
            break;
        }
        else if(mtk_detect_key(MT65XX_MENU_OK_KEY))//VOL_DOWN
        {
            video_printf("return to fastboot in 3s\n");
            mdelay(3000);
            fastboot_boot_menu();
            fastboot_okay("");
            break;
        }
        else
        {
            //If we press other keys, discard it.
        }
    }
    return ret;
}
コード例 #4
0
void vo_show_progress(int sizeM)
{
    video_set_cursor((video_get_rows() / 4) * 3, (video_get_colums() - 22)/ 2);
    video_printf("=====================\n");
    video_set_cursor((video_get_rows() / 4) * 3 + 1, (video_get_colums() - 22)/ 2);
    video_printf(">>> Written %4dM <<<\n", sizeM);
    video_set_cursor((video_get_rows() / 4) * 3 + 2, (video_get_colums() - 22)/ 2);
    video_printf("=====================\n");
    video_set_cursor(video_get_rows() - 1, 0);

    dprintf(CRITICAL,"... Written %dM\n", sizeM);
}
コード例 #5
0
ファイル: multiboot.c プロジェクト: thetlk/YAUKernel
void multiboot_display(struct multiboot_info *mbi)
{
    video_printf("multiboot infos :\n");
    video_printf("\t- flags = 0x%x\n", mbi->flags);

    if(CHECK_FLAG(mbi->flags, FLAG_MEM))
    {
        video_printf("\t- mem_lower = %uKB, mem_upper = %uKB\n", mbi->mem_lower, mbi->mem_upper);
    }

    if(CHECK_FLAG(mbi->flags, FLAG_BOOT_DEVICE))
    {
        video_printf("\t- boot_device = 0x%x\n", mbi->boot_device);
    }

    if(CHECK_FLAG(mbi->flags, FLAG_CMDLINE))
    {
        video_printf("\t- cmdline = %s\n", (char *) mbi->cmdline);
    }

    if(CHECK_FLAG(mbi->flags, FLAG_MODS))
    {
        struct multiboot_module *mod = (struct multiboot_module *) mbi->mods_addr;
        unsigned int i;
        video_printf("\t- mods_count = %d, mods_addr = %p\n", mbi->mods_count, mbi->mods_addr);

        for(i=0; i<mbi->mods_count; i++)
        {
            video_printf("\t\t- mod_start = 0x%x, mod_end = 0x%x, cmdline = %s\n",
                mod->mod_start,
                mod->mod_end,
                mod->cmdline);
            mod++;
        }
    }

    if(CHECK_FLAG(mbi->flags, FLAG_MMAP))
    {
        struct multiboot_memory_map *mmap = (struct multiboot_memory_map *) mbi->mmap_addr;

        video_printf("\t- memory map :\n");
        while((unsigned int) mmap < mbi->mmap_addr + mbi->mmap_length)
        {
            video_printf("\t\t- 0x%lx -- 0x%lx (0x%lx) %s (0x%x)\n",
                mmap->base,
                mmap->base + mmap->length,
                mmap->length,
                (mmap->type == 1) ? "RAM" : "reserved",
                mmap->type);

            mmap = (struct multiboot_memory_map *) ((unsigned int) mmap + mmap->size + sizeof(mmap->size));
        }
    }

}
コード例 #6
0
static void voprintf(char type, const char *msg, va_list ap)
{
    char msgbuf[128], *p;

    p = msgbuf;
    if (msg[0] == '\r') {
        *p++ = msg[0];
        msg++;
    }

    *p++ = type;
    *p++ = ':';
    vsnprintf(p, sizeof(msgbuf) - (p - msgbuf), msg, ap);
    switch (type) {
    case 'I':
    case 'W':
    case 'E':
        video_printf("%s", msgbuf);
        break;
    }

    dprintf(CRITICAL,"%s", msgbuf);
    
    /* Write log buffer */
    p = msgbuf;
    while ((*p != 0) && (cblock_result->log_size < sizeof(cblock_result->log_buf))) {
	cblock_result->log_buf[cblock_result->log_size] = *p++;
	cblock_result->log_size++;
    }
}
コード例 #7
0
static void display_info(const char* msg)
{
#if defined(DISPLAY_INFO_ON_LCM)
	if(msg == 0)
	{
		return;
	}
	video_printf("%s\n", msg);
#endif
}
コード例 #8
0
void unlock_warranty(void)
{
  const char* title_msg = "Unlock bootloader?\n\n";
  video_clean_screen();
  video_set_cursor(video_get_rows()/2, 0);
  video_printf(title_msg);
  video_printf("If you unlock the bootloader,you will be able to install custom operating\n");
  video_printf("system software on this phone.\n\n");

  video_printf("A custom OS is not subject to the same testing as the original OS, and can\n");
  video_printf("cause your phone and installed applications to stop working properly.\n\n");

  video_printf("To prevent unauthorized access to your personal data,unlocking the bootloader\n");
  video_printf("will also delete all personal data from your phone(a \"factory data reset\").\n\n");

  video_printf("Press the Volume UP/Down buttons to select Yes or No. \n\n");
  video_printf("Yes (Volume UP):Unlock(may void warranty).\n\n");
  video_printf("No (Volume Down):Do not unlock bootloader.\n\n");

}
コード例 #9
0
ファイル: init.c プロジェクト: ramgar/mt6577_kernel_3.4.67
/* Do any target specific intialization needed before entering fastboot mode */
void target_fastboot_init(void)
{
//                               
	#if defined (FASTBOOT_USERDEBUG) /* jjm_l10 */
	mt_disp_show_black_screen();
	video_clean_screen();
	video_set_cursor(video_get_rows()/4, 0);
	video_printf("[Fastboot Mode Entered!]\n");
	#endif
//                               
}
コード例 #10
0
void lock_warranty(void)
{
  const char* title_msg = "lock bootloader?\n\n";
  video_clean_screen();
  video_set_cursor(video_get_rows()/2, 0);
  video_printf(title_msg);
  video_printf("If you lock the bootloader,you will need to install official operating\n");
  video_printf("system software on this phone.\n\n");


  video_printf("To prevent unauthorized access to your personal data,locking the bootloader\n");
  video_printf("will also delete all personal data from your phone(a \"factory data reset\").\n\n");

  video_printf("Press the Volume UP/Down buttons to select Yes or No. \n\n");
  video_printf("Yes (Volume UP):Lock bootloader.\n\n");
  video_printf("No (Volume Down):Do not lock bootloader.\n\n");
}
コード例 #11
0
static void display_speed_info(const char* msg_prefix, unsigned size)
{
#if defined(DISPLAY_INFO_ON_LCM)
	unsigned vel = 0;
	unsigned time = TIME_ELAPSE;

	if(msg_prefix == 0)
	{
		msg_prefix = "Unknown";
	}

	if(time != 0)
	{
		vel = (unsigned)(size / time); //approximate  1024/1000
	}
	video_printf("%s  Time:%dms Vel:%dKB/s \n", msg_prefix, time, vel);
#endif
}
コード例 #12
0
void fastboot_boot_menu(void)
{
          const char* title_msg = "Select Boot Mode:\n[VOLUME_UP to select.  VOLUME_DOWN is OK.]\n\n";
          video_clean_screen();
          video_set_cursor(video_get_rows()/2, 0);
          video_printf(title_msg);
          video_printf("[Recovery    Mode]             \n");
#ifdef MTK_FASTBOOT_SUPPORT
          video_printf("[Fastboot    Mode]         <<==\n");
#endif
          video_printf("[Normal      Boot]             \n");
#ifndef USER_BUILD
          video_printf("[Normal      Boot +ftrace]    \n");
          video_printf("[Normal      slub debug off]     \n");
#endif
          video_printf(" => FASTBOOT mode...\n");
}
コード例 #13
0
ファイル: graphics.c プロジェクト: coreboot/depthcharge
int graphics_print_single_text_block(const char *msg,
				     const struct rgb_color *clr_scr_params,
				     int fg, int bg,
				     enum video_printf_align align)
{
	assert(msg);
	assert(clr_scr_params);

	if (clear_screen(clr_scr_params)) {
		printf("ERROR: Failed to clear screen\n");
		return -1;
	}

	unsigned int rows, cols;

	video_get_rows_cols(&rows, &cols);
	video_console_set_cursor(0, rows/2);
	video_printf(fg, bg, align, msg);

	return 0;
}
コード例 #14
0
ファイル: mt6575.c プロジェクト: HiRolland/alps-fairphone-gpl
/**********************************************************
 * Routine: mt6573_sw_env
 * Description: this function is called to init mt6516 sw enviroment
 * Notice: DO NOT this function or system might crash
 **********************************************************/
int mt65xx_sw_env (void)
{  
#ifdef CFG_RECOVERY_MODE
  if(g_boot_mode != META_BOOT && g_boot_mode != FACTORY_BOOT && recovery_detection() == TRUE)
  {    
      
  }
#endif   

    //**************************************
    //* CHECK BOOT MODE
    //**************************************
    #ifndef USER_BUILD
    switch(g_boot_mode)
    {        
         case META_BOOT :
	         video_printf(" => META MODE\n");
	         break;
	     case FACTORY_BOOT :
	         video_printf(" => FACTORY MODE\n");
	         break;
	     case RECOVERY_BOOT :
	         video_printf(" => RECOVERY MODE\n");
	         break;
	     case SW_REBOOT :
	         //video_printf(" => SW RESET\n");
	         break;
	     case NORMAL_BOOT :
	         video_printf(" => NORMAL BOOT\n");
	         break;
         case ADVMETA_BOOT:
            video_printf(" => ADVANCED META MODE\n");
            break;
		   case ATE_FACTORY_BOOT:
            video_printf(" => ATE FACTORY MODE\n");
		        break;     
	     default :
                 video_printf(" => UNKNOWN BOOT\n");
    }
    return 0;
#endif    
}
コード例 #15
0
static void display_progress(const char* msg_prefix, unsigned size, unsigned totle_size)
{
#if defined(DISPLAY_INFO_ON_LCM)
	unsigned vel = 0;
	unsigned prog = 0;
	unsigned time = TIME_ELAPSE;

	if(msg_prefix == 0)
	{
		msg_prefix = "Unknown";
	}

	if(time != 0)
	{
		vel = (unsigned)(size / time); //approximate  1024/1000
		time /= 1000;
	}
	if(totle_size != 0)
	{
		prog = (unsigned)((size*100.0f)/totle_size);
	}
	video_printf("%s > %3d%% Time:%4ds Vel:%5dKB/s", msg_prefix, prog, time, vel);
#endif
}
コード例 #16
0
ファイル: platform.c プロジェクト: kuailexs/iq451_mt6589
void platform_init(void)
{

    /* init timer */
    //mtk_timer_init();
#ifdef LK_PROFILING
    unsigned int time_nand_emmc;
    unsigned int time_load_logo;
    unsigned int time_bat_init;
    unsigned int time_backlight;
    unsigned int time_show_logo;
    unsigned int time_boot_mode;
    unsigned int time_sw_env;
    unsigned int time_platform_init;
    unsigned int time_env;
    time_platform_init = get_timer(0);
    time_nand_emmc = get_timer(0);
#endif
    dprintf(INFO, "platform_init()\n");

#ifdef MTK_MT8193_SUPPORT
	mt8193_init();
#endif

#ifdef MTK_EMMC_SUPPORT
    mmc_legacy_init(1);
#else
    nand_init();
    nand_driver_test();
#endif
#ifdef MTK_KERNEL_POWER_OFF_CHARGING
	if((g_boot_arg->boot_reason == BR_USB) && (upmu_is_chr_det() == KAL_FALSE))
	{
		printf("[%s] Unplugged Charger/Usb between Pre-loader and Uboot in Kernel Charging Mode, Power Off \n", __func__);
		mt6575_power_off();
	}
#endif

#ifdef LK_PROFILING
    printf("[PROFILE] ------- NAND/EMMC init takes %d ms -------- \n", get_timer(time_nand_emmc));
    time_env = get_timer(0);
#endif
	env_init();
	print_env();
#ifdef LK_PROFILING
	printf("[PROFILE] ------- ENV init takes %d ms -------- \n", get_timer(time_env));
	time_load_logo = get_timer(0);
#endif
    mboot_common_load_logo((unsigned long)mt_get_logo_db_addr(), "logo");
#if ((!defined(MTK_NCP1851_SUPPORT)) && (!defined(MTK_BQ24196_SUPPORT)))    
    mt_disp_power(TRUE);           //power on display related modules
#endif    
    dprintf(INFO, "Show BLACK_PICTURE\n");
    mt_disp_fill_rect(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT, 0x0);
    mt_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
    mt_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
#ifdef LK_PROFILING
    printf("[PROFILE] ------- load_logo takes %d ms -------- \n", get_timer(time_load_logo));
    time_backlight = get_timer(0);
#endif

    /*for kpd pmic mode setting*/
    set_kpd_pmic_mode();
#if ((!defined(MTK_NCP1851_SUPPORT)) && (!defined(MTK_BQ24196_SUPPORT)))
    //mt65xx_backlight_on();
#endif    
#ifdef LK_PROFILING
    printf("[PROFILE] ------- backlight takes %d ms -------- \n", get_timer(time_backlight));
    time_boot_mode = get_timer(0);
#endif    
    enable_PMIC_kpd_clock();
    boot_mode_select();   
	
#ifdef LK_PROFILING
    printf("[PROFILE] ------- boot mode select takes %d ms -------- \n", get_timer(time_boot_mode));
#endif

    /* initialize security library */
#ifdef MTK_EMMC_SUPPORT
    sec_func_init(1);
#else
    sec_func_init(0);
#endif

    /*Show download logo & message on screen */
    if (g_boot_arg->boot_mode == DOWNLOAD_BOOT)
    {
	printf("[LK] boot mode is DOWNLOAD_BOOT\n");
	/* verify da before jumping to da*/
	if (sec_usbdl_enabled()) {
	    u8  *da_addr = g_boot_arg->da_info.addr;
	    u32 da_sig_len = DRV_Reg32(SRAMROM_BASE + 0x54);
	    u32 da_len   = da_sig_len >> 10;
	    u32 sig_len  = da_sig_len & 0x3ff;
	    u8  *sig_addr = (unsigned char *)da_addr + (da_len - sig_len);

	    if (da_len == 0 || sig_len == 0) {
		printf("[LK] da argument is invalid\n");
		printf("da_addr = 0x%x\n", da_addr);
		printf("da_len  = 0x%x\n", da_len);
		printf("sig_len = 0x%x\n", sig_len);
	    }

	    if (sec_usbdl_verify_da(da_addr, (da_len - sig_len), sig_addr, sig_len)) {
		/* da verify fail */    
                video_printf(" => Not authenticated tool, download stop...\n");
		DRV_WriteReg32(SRAMROM_BASE + 0x54, 0x0);
		while(1); /* fix me, should not be infinite loop in lk */
	    }
	}
	else {
コード例 #17
0
void boot_mode_menu_select()
{
          int select = 0;  // 0=recovery mode, 1=fastboot.  2=normal boot 3=normal boot + ftrace.4=slub debug off
          const char* title_msg = "Select Boot Mode:\n[VOLUME_UP to select.  VOLUME_DOWN is OK.]\n\n";
          video_clean_screen();
          video_set_cursor(video_get_rows()/2, 0);
          video_printf(title_msg);
          video_printf("[Recovery    Mode]         <<==\n");
#ifdef MTK_FASTBOOT_SUPPORT
          video_printf("[Fastboot    Mode]             \n");
#endif
          video_printf("[Normal      Boot]             \n");
#ifndef USER_BUILD
          video_printf("[Normal      Boot +ftrace]    \n");
          video_printf("[Normal      slub debug off]     \n");
#endif
          while(1)
          {
             if(mtk_detect_key(MT65XX_MENU_SELECT_KEY))//VOL_UP
             {
                    g_boot_menu = true;
                    switch(select) {

                        case 0:
#ifdef MTK_FASTBOOT_SUPPORT
                            select = 1;

                            video_set_cursor(video_get_rows()/2, 0);
                            video_printf(title_msg);
                            video_printf("[Recovery    Mode]             \n");
                            video_printf("[Fastboot    Mode]         <<==\n");
                            video_printf("[Normal      Boot]             \n");
#ifndef USER_BUILD
                            video_printf("[Normal      Boot +ftrace]     \n");
                            video_printf("[Normal      slub debug off]     \n");
#endif
                        break;
#endif
                        case 1:
                            select = 2;

                            video_set_cursor(video_get_rows()/2, 0);
                            video_printf(title_msg);
                            video_printf("[Recovery    Mode]             \n");
#ifdef MTK_FASTBOOT_SUPPORT
                            video_printf("[Fastboot    Mode]             \n");
#endif
                            video_printf("[Normal      Boot]         <<==\n");
#ifndef USER_BUILD
                            video_printf("[Normal      Boot +ftrace]     \n");
                            video_printf("[Normal      slub debug off]     \n");
#endif
                        break;

                        case 2:
#ifdef USER_BUILD
                            select = 0;
#else
                            select = 3;
#endif
    
                            video_set_cursor(video_get_rows()/2, 0);
                            video_printf(title_msg);
#ifdef USER_BUILD
                            video_printf("[Recovery    Mode]         <<==\n");
#ifdef MTK_FASTBOOT_SUPPORT
                            video_printf("[Fastboot    Mode]             \n");
#endif
                            video_printf("[Normal      Boot]             \n");
#else
                            video_printf("[Recovery    Mode]             \n");
#ifdef MTK_FASTBOOT_SUPPORT
                            video_printf("[Fastboot    Mode]             \n");
#endif
                            video_printf("[Normal      Boot]             \n");
                            video_printf("[Normal      Boot +ftrace] <<==\n");
                            video_printf("[Normal      slub debug off]     \n");
#endif
                        break;

#ifndef USER_BUILD
                        case 3:
                            select = 4;
                            video_set_cursor(video_get_rows()/2, 0);
                            video_printf(title_msg);
                            video_printf("[Recovery    Mode]             \n");
#ifdef MTK_FASTBOOT_SUPPORT
                            video_printf("[Fastboot    Mode]             \n");
#endif
                            video_printf("[Normal      Boot]             \n");
                            video_printf("[Normal      Boot +ftrace]     \n");
                            video_printf("[Normal      slub debug off] <<==\n");
                            
                        break;
#endif


#ifndef USER_BUILD
                        case 4:
                            select = 0;
                            video_set_cursor(video_get_rows()/2, 0);
                            video_printf(title_msg);
                            video_printf("[Recovery    Mode]         <<==\n");
#ifdef MTK_FASTBOOT_SUPPORT
                            video_printf("[Fastboot    Mode]             \n");
#endif
                            video_printf("[Normal      Boot]             \n");
                            video_printf("[Normal      Boot +ftrace]     \n");
                            video_printf("[Normal      slub debug off]     \n");                            
                        break;
#endif

                        default: 
                        break;
                    }
                    dprintf(CRITICAL,  "[VOL_UP]Key Detect, current select:%d\n", select);
                    mdelay(300);
             }
             else if(mtk_detect_key(MT65XX_MENU_OK_KEY))//VOL_DOWN,
             {
                 //use for OK
                 break;
             }
             else
             {
                //pass
             }
          }
          if(select == 0)
          {
               g_boot_mode = RECOVERY_BOOT;
          }
          else if(select == 1)
          {
                g_boot_mode = FASTBOOT;
          }
          else if(select == 2)
          {
                g_boot_mode = NORMAL_BOOT;
          }
          else if(select == 3)
          {
                sprintf(g_CMDLINE, "%s trace_buf_size=11m boot_time_ftrace", g_CMDLINE);
                g_boot_mode = NORMAL_BOOT;
          }
          else if (select == 4)
          {
                sprintf(g_CMDLINE, "%s slub_debug=-", g_CMDLINE);
                g_boot_mode = NORMAL_BOOT;
          }
          else{
                //pass
          }
          video_printf("\n");
          return;
}
コード例 #18
0
ファイル: platform.c プロジェクト: ferhung/p201-mediatek
void platform_init(void)
{
#ifdef LK_PROFILING
    unsigned int time_nand_emmc;
    unsigned int time_load_logo;
    unsigned int time_bat_init;
    unsigned int time_backlight;
    unsigned int time_show_logo;
    unsigned int time_boot_mode;
    unsigned int time_sw_env;
    unsigned int time_platform_init;
    unsigned int time_env;
    unsigned int time_disp_init;
    unsigned int time_security_init;
    unsigned int time_RTC_boot_Check;

    time_platform_init = get_timer(0);
    time_nand_emmc = get_timer(0);
#endif

    dprintf(INFO, "platform_init()\n");

#ifdef DUMMY_AP
	dummy_ap_entry();
#endif

#ifdef MTK_EMMC_SUPPORT
    mmc_legacy_init(1);
#else
#ifndef MACH_FPGA
    nand_init();
    nand_driver_test();

#endif
#endif

#ifdef MTK_KERNEL_POWER_OFF_CHARGING
	if((g_boot_arg->boot_reason == BR_USB) && (upmu_is_chr_det() == KAL_FALSE))
	{
		printf("[%s] Unplugged Charger/Usb between Pre-loader and Uboot in Kernel Charging Mode, Power Off \n", __func__);
		mt6575_power_off();
	}
#endif

#ifdef LK_PROFILING
    printf("[PROFILE] ------- NAND/EMMC init takes %d ms -------- \n", get_timer(time_nand_emmc));
    time_env = get_timer(0);
#endif
	env_init();
	print_env();
#ifdef LK_PROFILING
	dprintf(INFO,"[PROFILE] ------- ENV init takes %d ms -------- \n", (int)get_timer(time_env));
#endif

#ifdef LK_PROFILING
		time_disp_init = get_timer(0);
#endif

	//FIXME: Disable for MT6582 FPGA Ealry Porting
 #ifndef DISABLE_DISPLAY_IN_LK_FOR_82_BRINGUP
    if(lcm_params->type==LCM_TYPE_DSI && lcm_params->dsi.mode ==CMD_MODE)
	 mt_disp_init((void *)g_fb_base);
 #endif
#ifdef LK_PROFILING
	 dprintf(INFO,"[PROFILE] ------- disp init takes %d ms -------- \n", (int)get_timer(time_disp_init));
#endif


#ifdef LK_PROFILING
                time_load_logo = get_timer(0);
#endif

#ifdef CONFIG_CFB_CONSOLE
		//FIXME: Disable for MT6582 FPGA Ealry Porting
    #ifndef DISABLE_DISPLAY_IN_LK_FOR_82_BRINGUP
		drv_video_init();
    #endif
#endif

    //#endif
    #ifndef DISABLE_DISPLAY_IN_LK_FOR_82_BRINGUP
    mboot_common_load_logo((unsigned long)mt_get_logo_db_addr(), "logo");
    dprintf(INFO, "Show BLACK_PICTURE\n");
    #endif

    //FIXME: Disable for MT6582 FPGA Ealry Porting
    #ifndef DISABLE_DISPLAY_IN_LK_FOR_82_BRINGUP
#ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
    if(!is_low_battery(0))
    {
#endif
    mt_disp_fill_rect(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT, 0x0);
    mt_disp_power(TRUE);
    mt_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
    mt_disp_wait_idle();
    mt_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
    mt_disp_wait_idle();
    mt_disp_power(1);           //power on display related modules
#ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
    }
#endif
    #endif

#ifdef LK_PROFILING
    printf("[PROFILE] ------- load_logo takes %d ms -------- \n", get_timer(time_load_logo));
    time_backlight = get_timer(0);
#endif

    /*for kpd pmic mode setting*/
    set_kpd_pmic_mode();

    //FIXME: Disable for MT6582 FPGA Ealry Porting
    //#ifndef DISABLE_DISPLAY_IN_LK_FOR_82_BRINGUP
#ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
    if(!is_low_battery(0))
    {
#endif
		/*some lcm panel need more time to start show picture*/	
		msleep(50);
    	mt65xx_backlight_on();
#ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
    }
#endif
    //#endif

#ifdef LK_PROFILING
    printf("[PROFILE] ------- backlight takes %d ms -------- \n", get_timer(time_backlight));
    time_boot_mode = get_timer(0);
#endif

    boot_mode_select();

#ifdef LK_PROFILING
    printf("[PROFILE] ------- boot mode select takes %d ms -------- \n", get_timer(time_boot_mode));
#endif


#ifdef MTK_SECURITY_SW_SUPPORT
    #ifdef LK_PROFILING
        time_security_init = get_timer(0);
    #endif
    /* initialize security library */
#ifdef MTK_EMMC_SUPPORT
    sec_func_init(1);
#else
    sec_func_init(0);
#endif
    #ifdef LK_PROFILING
    dprintf(INFO,"[PROFILE] ------- Security init takes %d ms -------- \n", (int)get_timer(time_security_init));
    #endif
#endif


    /*Show download logo & message on screen */
    if (g_boot_arg->boot_mode == DOWNLOAD_BOOT)
    {
	printf("[LK] boot mode is DOWNLOAD_BOOT\n");

#ifdef MTK_SECURITY_SW_SUPPORT
	/* verify da before jumping to da*/
	if (sec_usbdl_enabled()) {
	    u8  *da_addr = (u8 *)g_boot_arg->da_info.addr;
	    u32 da_len   = g_boot_arg->da_info.len;
	    u32 sig_len  = g_boot_arg->da_info.sig_len;
	    u8  *sig_addr = (unsigned char *)da_addr + (da_len - sig_len);

	    if (da_len == 0 || sig_len == 0) {
		printf("[LK] da argument is invalid\n");
		printf("da_addr = 0x%x\n", da_addr);
		printf("da_len  = 0x%x\n", da_len);
		printf("sig_len = 0x%x\n", sig_len);
	    }

	    if (sec_usbdl_verify_da(da_addr, (da_len - sig_len), sig_addr, sig_len)) {
		/* da verify fail */
                video_printf(" => Not authenticated tool, download stop...\n");
		while(1); /* fix me, should not be infinite loop in lk */
	    }
	}
	else
#endif
	{
	    printf(" DA verification disabled...\n");
	}
        mt_disp_show_boot_logo();
        video_printf(" => Downloading...\n");
        mt65xx_backlight_on();
        mtk_wdt_disable();//Disable wdt before jump to DA
        platform_uninit();
#ifdef HAVE_CACHE_PL310
        l2_disable();
#endif

#ifdef ENABLE_L2_SHARING
        config_shared_SRAM_size();
#endif
        arch_disable_cache(UCACHE);
        arch_disable_mmu();
        jump_da(g_boot_arg->da_info.addr, g_boot_arg->da_info.arg1, g_boot_arg->da_info.arg2);
    }

#ifdef LK_PROFILING
    time_bat_init = get_timer(0);
#endif

    mt65xx_bat_init();

#ifdef LK_PROFILING
    printf("[PROFILE] ------- battery init takes %d ms -------- \n", get_timer(time_bat_init));
#endif

#ifndef CFG_POWER_CHARGING
    #ifdef LK_PROFILING
    time_RTC_boot_Check = get_timer(0);
    #endif
    /* NOTE: if define CFG_POWER_CHARGING, will rtc_boot_check() in mt65xx_bat_init() */
    rtc_boot_check(false);
    #ifdef LK_PROFILING
    dprintf(INFO,"[PROFILE] ------- RTC boot check Init  takes %d ms -------- \n", (int)get_timer(time_RTC_boot_Check));
    #endif
#endif

#ifdef LK_PROFILING
    time_show_logo = get_timer(0);
#endif

#ifdef MTK_KERNEL_POWER_OFF_CHARGING
	if(kernel_charging_boot() == 1)
	{
#ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
		CHARGER_TYPE CHR_Type_num = CHARGER_UNKNOWN;
		charging_get_charger_type(&CHR_Type_num);
		if ((g_boot_mode != LOW_POWER_OFF_CHARGING_BOOT) ||
		((CHR_Type_num != STANDARD_HOST) && (CHR_Type_num != NONSTANDARD_CHARGER)))
		{
			dprintf(INFO, "[PROFILE] ------- g_boot_mode = %d -------- \n", g_boot_mode);
#endif
		mt_disp_power(TRUE);
		mt_disp_show_low_battery();
		mt_disp_wait_idle();
		mt65xx_leds_brightness_set(6, 110);
#ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
		}
#endif
	}
	else if(g_boot_mode != KERNEL_POWER_OFF_CHARGING_BOOT && g_boot_mode != LOW_POWER_OFF_CHARGING_BOOT)
	{
#ifndef DISABLE_DISPLAY_IN_LK_FOR_82_BRINGUP
		if (g_boot_mode != ALARM_BOOT && (g_boot_mode != FASTBOOT))
		{
			mt_disp_show_boot_logo();
		}
#endif
	}
#else
#ifndef DISABLE_DISPLAY_IN_LK_FOR_82_BRINGUP
	if (g_boot_mode != ALARM_BOOT && (g_boot_mode != FASTBOOT))
	{
		mt_disp_show_boot_logo();
	}
#endif
#endif

#ifdef LK_PROFILING
    printf("[PROFILE] ------- show logo takes %d ms -------- \n", get_timer(time_show_logo));
    time_sw_env= get_timer(0);
#endif

    //sw_env();

#ifdef LK_PROFILING
    printf("[PROFILE] ------- sw_env takes %d ms -------- \n", get_timer(time_sw_env));
    printf("[PROFILE] ------- platform_init takes %d ms -------- \n", get_timer(time_platform_init));
#endif
}
コード例 #19
0
ファイル: platform.c プロジェクト: ferhung/p201-mediatek
void sw_env()
{

#ifdef LK_DL_CHECK
#ifdef MTK_EMMC_SUPPORT
		int dl_status = 0;
    dl_status = mmc_get_dl_info();
    printf("mt65xx_sw_env--dl_status: %d\n", dl_status);
    if (dl_status != 0)
    {
        video_printf("=> TOOL DL image Fail!\n");
        printf("TOOL DL image Fail\n");
#ifdef LK_DL_CHECK_BLOCK_LEVEL
        printf("uboot is blocking by dl info\n");
        while (1) ;
#endif
    }
#endif
#endif

#ifndef USER_BUILD
    switch (g_boot_mode)
    {
      case META_BOOT:
          video_printf(" => META MODE\n");
          break;
      case FACTORY_BOOT:
          video_printf(" => FACTORY MODE\n");
          break;
      case RECOVERY_BOOT:
          video_printf(" => RECOVERY MODE\n");
          break;
      case SW_REBOOT:
          //video_printf(" => SW RESET\n");
          break;
      case NORMAL_BOOT:
          //if(g_boot_arg->boot_reason != BR_RTC && get_env("hibboot") != NULL && atoi(get_env("hibboot")) == 1)
          if(get_env("hibboot") != NULL && atoi(get_env("hibboot")) == 1)
              video_printf(" => HIBERNATION BOOT\n");
          else
              video_printf(" => NORMAL BOOT\n");
          break;
      case ADVMETA_BOOT:
          video_printf(" => ADVANCED META MODE\n");
          break;
      case ATE_FACTORY_BOOT:
          video_printf(" => ATE FACTORY MODE\n");
          break;
#if defined (MTK_KERNEL_POWER_OFF_CHARGING)
	case KERNEL_POWER_OFF_CHARGING_BOOT:
		video_printf(" => POWER OFF CHARGING MODE\n");
		break;
	case LOW_POWER_OFF_CHARGING_BOOT:
		video_printf(" => LOW POWER OFF CHARGING MODE\n");
		break;
#endif
      case ALARM_BOOT:
          video_printf(" => ALARM BOOT\n");
          break;
      case FASTBOOT:
          video_printf(" => FASTBOOT mode...\n");
          break;
      default:
          video_printf(" => UNKNOWN BOOT\n");
    }
    return;
#endif

#ifdef USER_BUILD
    if(g_boot_mode == FASTBOOT)
        video_printf(" => FASTBOOT mode...\n");
#endif
}
コード例 #20
0
ファイル: boot_mode.c プロジェクト: xfzlgy/iq450_H2_mt6589
// check the boot mode : (1) meta mode or (2) recovery mode ...
void boot_mode_select(void)
{
//Ivan    
    ulong begin;
    
    if (meta_detection())
    {
      return;
    }

#if defined (HAVE_LK_TEXT_MENU)
    if(Check_RTC_PDN1_bit13())
    {
      printf("[FASTBOOT] reboot to boot loader\n");
      g_boot_mode = FASTBOOT;
      Set_Clr_RTC_PDN1_bit13(false);
   	  return;
    }
//Ivan
#ifdef MENU_BOOT_ENABLE
    boot_mode_dkey_check();
    if (g_boot_mode == MENU_BOOT)
    {
	    /* clean console screen */
	video_clean_screen();
//	mt65xx_disp_fill_rect(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT, 0x0);

	video_set_cursor(2,0);
	video_printf("Recovery Mode: Volume Up\r\n");
	video_set_cursor(4,0);
	video_printf("Factory Mode: Volume Down\r\n");
//	mt65xx_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
	mt65xx_backlight_on();
	video_set_cursor(49,0);

	while (mt65XX_get_key() != 0xFFFF);
	printf(" > Key release!!!\n");
        mdelay(500);
	
//Ivan added 
	mtk_wdt_restart();
	begin = get_timer(0);
	
	while (g_boot_mode == MENU_BOOT)
	{
	    if (factory_detection())
	    {
		video_clean_screen();
		return;
	    }
	    if(boot_menu_detection())//recovery, fastboot, normal boot.
	    {
		video_clean_screen();
		return;
	    }
//Ivan add 20s time limit
	    if (get_timer(begin) < 20000)
		mtk_wdt_restart();
	}

//	video_clean_screen();
//	mt65xx_disp_fill_rect(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT, 0x0);
//	mt65xx_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
//	video_set_cursor(49,0);
//	mt65xx_disp_wait_idle();
    }

    if(Check_RTC_Recovery_Mode())
    {	
	    g_boot_mode = RECOVERY_BOOT;
    }

    recovery_check_command_trigger();
    
#else  //MENU_BOOT_ENABLE
    
    if (factory_detection())
    {
      return;
    }
    if(boot_menu_detection())//recovery, fastboot, normal boot.
    {
        return;
    }
    recovery_detection();
#endif //MENU_BOOT_ENABLE
#else	//HAVE_LK_TEXT_MENU
#ifdef MTK_FASTBOOT_SUPPORT
    if(fastboot_trigger())
    {
      return;
    }
#endif	//MTK_FASTBOOT_SUPPORT
    if (factory_detection())
    {
      return;
    }
    if(recovery_detection())
    {
      //**************************************
  		//* CHECK IMAGE
  		//**************************************
  		if(DRV_Reg32(0x40002300)==0xE92D4800)
  		{
  		  printf(" > do recovery_check\n");
  			//jump(0x40002300);
  		}
  		else
  		{
  		  printf(" > bypass recovery_check\n");
  		}
    	return;
    }
#endif
#ifdef MTK_KERNEL_POWER_OFF_CHARGING
	if(kernel_power_off_charging_detection())
	{
		printf(" < Kernel Power Off Charging Detection Ok> \n");
		return;
	}
	else
	{
		printf("< Kernel Enter Normal Boot > \n");
	}
#endif
}
コード例 #21
0
/**********************************************************
 * Routine: mt6573_sw_env
 * Description: this function is called to init mt6516 sw enviroment
 * Notice: DO NOT this function or system might crash
 **********************************************************/
int mt65xx_sw_env (void)
{  
	int dl_status = 0;
#ifdef CFG_RECOVERY_MODE
  if(g_boot_mode != META_BOOT && g_boot_mode != FACTORY_BOOT /*&& recovery_detection() == TRUE*/)	//Ivan
  {    
      
  }
#endif   

#ifdef UBOOT_DL_CHECK
#ifdef CONFIG_MMC	
		dl_status = mmc_get_dl_info();
		printf("mt65xx_sw_env--dl_status: %d\n",dl_status);
		if(dl_status!=0){
			video_printf("=> TOOL DL image Fail!\n");
			printf("TOOL DL image Fail\n");
#ifdef UBOOT_DL_CHECK_BLOCK_LEVEL
			printf("uboot is blocking by dl info\n");
			while(1);
#endif
		}
#endif
#endif
    //**************************************
    //* CHECK BOOT MODE
    //**************************************
    #ifndef USER_BUILD
    switch(g_boot_mode)
    {        
         case META_BOOT :
	         video_printf(" => META MODE\n");
	         break;
	     case FACTORY_BOOT :
	         video_printf(" => FACTORY MODE\n");
	         break;
	     case RECOVERY_BOOT :
	         video_printf(" => RECOVERY MODE\n");
	         break;
	     case SW_REBOOT :
	         //video_printf(" => SW RESET\n");
	         break;
	     case NORMAL_BOOT :
	         video_printf(" => NORMAL BOOT\n");
	         break;
         case ADVMETA_BOOT:
            video_printf(" => ADVANCED META MODE\n");
            break;
		   case ATE_FACTORY_BOOT:
            video_printf(" => ATE FACTORY MODE\n");
            break;     
          case ALARM_BOOT:
            video_printf(" => ALARM BOOT\n");
            break;
	  default :
            video_printf(" => UNKNOWN BOOT\n");
    }
    return 0;
#endif 
  
}
コード例 #22
0
int do_nand_boot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
	DECLARE_GLOBAL_DATA_PTR;
	int ret;
	bd_t *bd = gd->bd;
	ulong addr, data, len, initrd_start, initrd_end;
    void (*theKernel)(int zero, int arch, uint params);
    int strlen;


#ifdef CONFIG_CMDLINE_TAG
    char *commandline = getenv ("bootargs");
#endif

#ifdef CFG_UBOOT_PROFILING
      extern unsigned int boot_time;
      unsigned int time_do_nand_boot= get_timer(0);
      unsigned int time_rootfs;
      unsigned int time_load_bootimg;
      unsigned int ubt;
#endif


#if defined (CONFIG_SETUP_MEMORY_TAGS) || \
    defined (CONFIG_CMDLINE_TAG) || \
    defined (CONFIG_INITRD_TAG) || \
    defined (CONFIG_SERIAL_TAG) || \
    defined (CONFIG_REVISION_TAG) || \
    defined (CONFIG_LCD) || \
    defined (CONFIG_VFD)
	setup_start_tag (bd);
#ifdef CONFIG_SERIAL_TAG
	setup_serial_tag (&params);
#endif
#ifdef CONFIG_REVISION_TAG
	setup_revision_tag (&params);
#endif
#ifdef CONFIG_SETUP_MEMORY_TAGS
	if(g_boot_mode == FACTORY_BOOT)
	{
	  setup_memory_tags_factory(bd);
	}
	else
	{
	setup_memory_tags (bd);
	}  
#endif

//#ifdef CONFIG_CMDLINE_TAG
	//****************
	//* according to current boot mode to set boot tag and related boot args
	//*
	switch(g_boot_mode)
	{
		//********************************************************************
		//* NORMAL BOOT
		//********************************************************************		
		case NORMAL_BOOT:
#if defined(CFG_NAND_BOOT)
      strlen += sprintf(commandline, "%s%s%x%s%x", 
                commandline, NAND_MANF_CMDLINE, nand_flash_man_code, NAND_DEV_CMDLINE, nand_flash_dev_id);
#endif

	  setup_boot_tag(NORMAL_BOOT);

      ret = mboot_android_load_bootimg_hdr(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
      if (ret < 0) {
			 	msg_header_error("Android Boot Image");
      }
      
#ifdef CFG_UBOOT_PROFILING
      time_load_bootimg= get_timer(0);
#endif      
      ret = mboot_android_load_bootimg(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
#ifdef CFG_UBOOT_PROFILING
        printf("[PROFILE] ------- load boot.img takes %d ms -------- \n", get_timer(time_load_bootimg));
#endif

      if (ret < 0) {
	  		msg_img_error("Android Boot Image");
      }          
			break;

		//********************************************************************
		//* META
		//********************************************************************		
		case META_BOOT:
		#ifdef CFG_META_MODE
			printf("[META] - Old bootargs : %s\n",commandline);		
			commandline=strcat(commandline,META_BOOTARGS);
			printf("[META] - New bootargs : %s\n",commandline);	
			setup_boot_tag(META_BOOT);
		#endif
      ret = mboot_android_load_bootimg_hdr(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
      if (ret < 0) {
			  msg_header_error("Android Boot Image");
      }
      ret = mboot_android_load_bootimg(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
      if (ret < 0) {
		    msg_img_error("Android Boot Image");
      }            
			break;						

      //********************************************************************
      //* ADVANCED META MODE
	  //********************************************************************
	  case ADVMETA_BOOT:
        printf("[META] - Old bootargs : %s\n",commandline);
        commandline=strcat(commandline, ADV_META_BOOTARGS);
        printf("[META] - New bootargs : %s\n",commandline);	
        setup_boot_tag(ADVMETA_BOOT);
        ret = mboot_android_load_bootimg_hdr(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
        if (ret < 0) {
			  msg_header_error("Android Boot Image");
        }
        ret = mboot_android_load_bootimg(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
        if (ret < 0) {
		  msg_img_error("Android Boot Image");
        }
      break;
      
		//********************************************************************
		//* ANDROID RECOVERY
		//********************************************************************		
		case RECOVERY_BOOT:
			#ifdef CFG_RECOVERY_MODE
				setup_boot_tag(RECOVERY_BOOT);
			#endif	
        ret = mboot_android_load_recoveryimg_hdr(PART_RECOVERY, CFG_BOOTIMG_LOAD_ADDR);            
        if (ret < 0) {
			  	msg_header_error("Android Recovery Image");
        }   
        ret = mboot_android_load_recoveryimg(PART_RECOVERY, CFG_BOOTIMG_LOAD_ADDR);            
        if (ret < 0) {
			  	msg_img_error("Android Recovery Image");
        }
			break;

		//********************************************************************
		//* FACTORY
		//********************************************************************
		case FACTORY_BOOT:
      #if defined(CFG_NAND_BOOT)
      strlen += sprintf(commandline, "%s%s%x%s%x", 
                commandline, NAND_MANF_CMDLINE, nand_flash_man_code, NAND_DEV_CMDLINE, nand_flash_dev_id);
      #endif
      
			#ifdef CFG_FACTORY_MODE
				setup_boot_tag(FACTORY_BOOT);
			#endif

      //*************
      //* parse recovery image header
      //* 
      ret = mboot_android_load_factoryimg_hdr(CFG_FACTORY_NAME, CFG_BOOTIMG_LOAD_ADDR);
            
      if (ret < 0) {
				printf("factory image doesn't exist in SD card\n");	
			  // load boot image from nand
	      ret = mboot_android_load_bootimg_hdr(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
	      if (ret < 0) {
				  msg_header_error("Android Boot Image");
	      }            
	      ret = mboot_android_load_bootimg(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
        if (ret < 0) {
					msg_img_error("Android Boot Image");
	      }          
      }            
      else
      {	
	    // load the factory image
	      ret = mboot_android_load_factoryimg(CFG_FACTORY_NAME, CFG_BOOTIMG_LOAD_ADDR);            
    	  if (ret < 0) {
				  msg_img_error("Android Factory Image");
        }
      }
			break;			
		//********************************************************************
		//* ATE_FACTORY_BOOT
		//********************************************************************
		case ATE_FACTORY_BOOT:
      #if defined(CFG_NAND_BOOT)
      strlen += sprintf(commandline, "%s%s%x%s%x", 
                commandline, NAND_MANF_CMDLINE, nand_flash_man_code, NAND_DEV_CMDLINE, nand_flash_dev_id);
      #endif
      
			#ifdef CFG_FACTORY_MODE
				setup_boot_tag(ATE_FACTORY_BOOT);
			#endif

      //*************
      //* parse recovery image header
      //* 
      ret = mboot_android_load_factoryimg_hdr(CFG_FACTORY_NAME, CFG_BOOTIMG_LOAD_ADDR);
            
      if (ret < 0) {
				printf("factory image doesn't exist in SD card\n");	
			  // load boot image from nand
	      ret = mboot_android_load_bootimg_hdr(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
	      if (ret < 0) {
				  msg_header_error("Android Boot Image");
	      }            
	      ret = mboot_android_load_bootimg(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
        if (ret < 0) {
					msg_img_error("Android Boot Image");
	      }          
      }            
      else
      {	
	    // load the factory image
	      ret = mboot_android_load_factoryimg(CFG_FACTORY_NAME, CFG_BOOTIMG_LOAD_ADDR);            
    	  if (ret < 0) {
				  msg_img_error("Android Factory Image");
        }
      }
			break;		
		//********************************************************************
		//* SW BOOT
		//********************************************************************		
		case SW_REBOOT:
			setup_boot_tag(SW_REBOOT);
      ret = mboot_android_load_bootimg_hdr(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);          
      if (ret < 0) {
			  msg_header_error("Android Boot Image");
      }
      ret = mboot_android_load_bootimg(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
      if (ret < 0) {
			  msg_img_error("Android Boot Image");
      }       
			break;        
		//********************************************************************
		//* ALARM BOOT
		//********************************************************************		
		case ALARM_BOOT:
#if defined(CFG_NAND_BOOT)
      strlen += sprintf(commandline, "%s%s%x%s%x", 
                commandline, NAND_MANF_CMDLINE, nand_flash_man_code, NAND_DEV_CMDLINE, nand_flash_dev_id);
#endif

	  setup_boot_tag(ALARM_BOOT);

      ret = mboot_android_load_bootimg_hdr(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
      if (ret < 0) {
			 	msg_header_error("Android Boot Image");
      }
      
#ifdef CFG_UBOOT_PROFILING
      time_load_bootimg= get_timer(0);
#endif      
      ret = mboot_android_load_bootimg(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
#ifdef CFG_UBOOT_PROFILING
        printf("[PROFILE] ------- load boot.img takes %d ms -------- \n", get_timer(time_load_bootimg));
#endif

      if (ret < 0) {
	  		msg_img_error("Android Boot Image");
      }          
			break;	    
	}

//*************
//* relocate rootfs (ignore rootfs header)
//*
#ifdef CFG_UBOOT_PROFILING
    time_rootfs = get_timer(0);
#endif
    //if(g_boot_mode == RECOVERY_BOOT)
    //{
      memcpy((char *)CFG_RAMDISK_LOAD_ADDR, (char *)(g_rmem_off), g_rimg_sz);
    //}
    g_rmem_off = CFG_RAMDISK_LOAD_ADDR;
#ifdef CFG_UBOOT_PROFILING
    printf("[PROFILE] ------- reloate rootfs takes %d ms -------- \n", get_timer(time_rootfs));
#endif
    
          strlen += sprintf(commandline, "%s%s%s",
                                      commandline, 
                                      " uboot_ver=" UBOOT_VERSION_CLI,
                                      " uboot_build_ver=" BUILD_VERSION_CLI
                                      );
#ifdef CFG_UBOOT_PROFILING
        ubt = ((unsigned int)get_timer(boot_time)) + 810;
        strlen += sprintf(commandline, "%s%s%d", commandline, ".ubt.", ubt);
#endif    
	
    custom_port_in_kernel(g_boot_mode, commandline);
	strlen += sprintf(commandline, "%s lcm=%1d-%s", commandline, DISP_IsLcmFound(), mt65xx_disp_get_lcm_id());
    setup_commandline_tag (bd, commandline);
  
//#endif //CONFIG_CMDLINE_TAG

//*************
//* dump some starting instruction for debug
//* 
//printf(" theKernel (0x%x)\n",g_kmem_off);
//printf(" theKernel (0x%x) = 0x%x\n",g_kmem_off,DRV_Reg32(g_kmem_off));
//printf(" theKernel (0x%x) = 0x%x\n",g_kmem_off+0x4,DRV_Reg32(g_kmem_off+0x4));
//printf(" theKernel (0x%x) = 0x%x\n",g_kmem_off+0x8,DRV_Reg32(g_kmem_off+0x8));  



//*************
//* dump some starting instruction for debug
//* 
//printf("\n rootfs (0x%x)\n",g_rmem_off);
//printf(" rootfs (0x%x) = 0x%x\n",g_rmem_off,DRV_Reg32(g_rmem_off));
//printf(" rootfs (0x%x) = 0x%x\n",g_rmem_off+0x4,DRV_Reg32(g_rmem_off+0x4));
//printf(" rootfs (0x%x) = 0x%x\n",g_rmem_off+0x8,DRV_Reg32(g_rmem_off+0x8)); 


//*************
//* specify the kernel jumping address
//* 
  theKernel = (void (*)(int, int, uint)) (g_kmem_off);
//printf("\n > kernel mem offset (not include header) = 0x%x\n",theKernel);


//*************
//* specify the rootfs starting address
//* 
  initrd_start = g_rmem_off;
  initrd_end = initrd_start + g_rimg_sz;  
//printf(" > rootfs mem offset (not include header) = 0x%x\n\n",initrd_start);


#ifdef CONFIG_INITRD_TAG
	if (initrd_start && initrd_end)
	  setup_initrd_tag (bd, initrd_start, initrd_end);
#endif
#if CONFIG_VIDEOLFB_TAG
	setup_videolfb_tag ((gd_t *) gd);
#endif
	setup_end_tag (bd);
#endif


#ifdef CFG_UBOOT_PROFILING
  printf("[PROFILE] ------- do_nand_boot takes %d ms -------- \n", get_timer(time_do_nand_boot));
  printf("[MBOOT] ------- UBoot boot kernel takes %d ms -------- \n", get_timer(boot_time));
#endif

  printf("NAND BOOT\n");
#ifdef CONFIG_LCD
  video_printf("NAND BOOT\n");
  video_printf("Boot Linux Kernel\n");   	
#endif

	//*****************
	//* to centralize deinit process, moving 
	//* "Uboot_power_saving" to "cleanup_before_linux"
	//*
	cleanup_before_linux();

	printf(" > kernel mem offset (not include header) = 0x%x\n",theKernel);


	//*****************
	//* jump to kernel
	//*
	theKernel (0, bd->bi_arch_number, bd->bi_boot_params);
	return 0;
} 
コード例 #23
0
void platform_init(void)
{
    dprintf(INFO, "platform_init()\n");

#ifdef LK_PROFILING
    unsigned int time_nand_emmc;
    unsigned int time_load_logo;
    unsigned int time_bat_init;
    unsigned int time_backlight;
    unsigned int time_show_logo;
    unsigned int time_boot_mode;
    unsigned int time_sw_env;
    unsigned int time_platform_init;
    time_platform_init = get_timer(0);
    time_nand_emmc = get_timer(0);
#endif

#ifdef MTK_EMMC_SUPPORT
    mmc_legacy_init(1);
#else
    nand_init();
    nand_driver_test();
#endif

#ifdef LK_PROFILING
    printf("[PROFILE] ------- NAND/EMMC init takes %d ms -------- \n", get_timer(time_nand_emmc));
    time_load_logo = get_timer(0);
#endif
    mboot_common_load_logo((unsigned long)mt_get_logo_db_addr(), "logo");
    dprintf(INFO, "Show BLACK_PICTURE\n");
    mt_disp_fill_rect(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT, 0x0);
    mt_disp_power(TRUE);
//<2012/11/14-Yuting Shih-[BU2SC00137502]Add for LOGO display.
#if 1
    mt_disp_show_boot_logo();
#else
    mt_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
    mt_disp_power(1);           //power on display related modules
#endif
//>2012/11/14-Yuting Shih-[BU2SC00137502].
#ifdef LK_PROFILING
    printf("[PROFILE] ------- load_logo takes %d ms -------- \n", get_timer(time_load_logo));
    time_backlight = get_timer(0);
#endif

    mt65xx_backlight_on();
#ifdef LK_PROFILING
    printf("[PROFILE] ------- backlight takes %d ms -------- \n", get_timer(time_backlight));
    time_boot_mode = get_timer(0);
#endif

    boot_mode_select();
#ifdef LK_PROFILING
    printf("[PROFILE] ------- boot mode select takes %d ms -------- \n", get_timer(time_boot_mode));
#endif
    /*Show download logo & message on screen */
    if (g_boot_arg->boot_mode == DOWNLOAD_BOOT)
    {
        mt_disp_show_boot_logo();
        video_printf(" => Downloading...\n");
        mt65xx_backlight_on();
        mtk_wdt_disable();//Disable wdt before jump to DA
        platform_uninit();
#ifdef HAVE_CACHE_PL310
        l2_disable();
#endif
        arch_disable_cache(UCACHE);
        arch_disable_mmu();
        jump_da(g_boot_arg->da_info.addr, g_boot_arg->da_info.arg1, g_boot_arg->da_info.arg2);
    }

#ifdef LK_PROFILING
    time_bat_init = get_timer(0);
#endif
    mt65xx_bat_init();
#ifdef LK_PROFILING
    printf("[PROFILE] ------- battery init takes %d ms -------- \n", get_timer(time_bat_init));
#endif

    /* NOTE: if define CFG_POWER_CHARGING, will rtc_boot_check() in mt65xx_bat_init() */
#ifndef CFG_POWER_CHARGING
    rtc_boot_check(false);
#endif

#ifdef LK_PROFILING
    time_show_logo = get_timer(0);
#endif
    if ((g_boot_mode != ALARM_BOOT) && (g_boot_mode != FASTBOOT))
    {
     printf("show log disable\n");
     mt_disp_show_boot_logo();
     printf("show log end\n");
    }
#ifdef LK_PROFILING
    printf("[PROFILE] ------- show logo takes %d ms -------- \n", get_timer(time_show_logo));
    time_sw_env= get_timer(0);
#endif

    sw_env();
#ifdef LK_PROFILING
    printf("[PROFILE] ------- sw_env takes %d ms -------- \n", get_timer(time_sw_env));
#endif
#ifdef LK_PROFILING
    printf("[PROFILE] ------- platform_init takes %d ms -------- \n", get_timer(time_platform_init));
#endif

}
コード例 #24
0
ファイル: boot_mode_menu.c プロジェクト: freelinux-zs/linux
void boot_mode_menu_select()
{
	int select = 0;  // 0=recovery mode, 1=fastboot.  2=normal boot 3=normal boot + ftrace.4=slub debug off
	const char* title_msg = "Select Boot Mode:\n[VOLUME_UP to select.  VOLUME_DOWN is OK.]\n\n";
	mt65xx_backlight_on();
	video_clean_screen();
	video_set_cursor(video_get_rows()/2, 0);
	video_printf(title_msg);
	video_printf("[Recovery    Mode]         <<==\n");
#ifdef MTK_FASTBOOT_SUPPORT
	video_printf("[Fastboot    Mode]             \n");
#endif
	video_printf("[Normal      Boot]             \n");
#if !defined(USER_BUILD) || defined(MTK_BUILD_ROOT)
	video_printf("[Normal      Boot +ftrace]    \n");
	video_printf("[Normal      slub debug off]     \n");
#endif
	while (1) {
		if (mtk_detect_key(MT65XX_MENU_SELECT_KEY)) { //VOL_UP
			g_boot_menu = true;
			switch (select) {

				case 0:
#ifdef MTK_FASTBOOT_SUPPORT
					select = 1;

					video_set_cursor(video_get_rows()/2, 0);
					video_printf(title_msg);
					video_printf("[Recovery    Mode]             \n");
					video_printf("[Fastboot    Mode]         <<==\n");
					video_printf("[Normal      Boot]             \n");
#if !defined(USER_BUILD) || defined(MTK_BUILD_ROOT)
					video_printf("[Normal      Boot +ftrace]     \n");
					video_printf("[Normal      slub debug off]     \n");
#endif
					break;
#endif
				case 1:
					select = 2;

					video_set_cursor(video_get_rows()/2, 0);
					video_printf(title_msg);
					video_printf("[Recovery    Mode]             \n");
#ifdef MTK_FASTBOOT_SUPPORT
					video_printf("[Fastboot    Mode]             \n");
#endif
					video_printf("[Normal      Boot]         <<==\n");
#if !defined(USER_BUILD) || defined(MTK_BUILD_ROOT)
					video_printf("[Normal      Boot +ftrace]     \n");
					video_printf("[Normal      slub debug off]     \n");
#endif
					break;

				case 2:
#if defined(USER_BUILD) && !defined(MTK_BUILD_ROOT)
					select = 0;
#else
					select = 3;
#endif

					video_set_cursor(video_get_rows()/2, 0);
					video_printf(title_msg);
#if defined(USER_BUILD) && !defined(MTK_BUILD_ROOT)
					video_printf("[Recovery    Mode]         <<==\n");
#ifdef MTK_FASTBOOT_SUPPORT
					video_printf("[Fastboot    Mode]             \n");
#endif
					video_printf("[Normal      Boot]             \n");
#else
					video_printf("[Recovery    Mode]             \n");
#ifdef MTK_FASTBOOT_SUPPORT
					video_printf("[Fastboot    Mode]             \n");
#endif
					video_printf("[Normal      Boot]             \n");
					video_printf("[Normal      Boot +ftrace] <<==\n");
					video_printf("[Normal      slub debug off]     \n");
#endif
					break;

#if !defined(USER_BUILD) || defined(MTK_BUILD_ROOT)
				case 3:
					select = 4;
					video_set_cursor(video_get_rows()/2, 0);
					video_printf(title_msg);
					video_printf("[Recovery    Mode]             \n");
#ifdef MTK_FASTBOOT_SUPPORT
					video_printf("[Fastboot    Mode]             \n");
#endif
					video_printf("[Normal      Boot]             \n");
					video_printf("[Normal      Boot +ftrace]     \n");
					video_printf("[Normal      slub debug off] <<==\n");

					break;
#endif


#if !defined(USER_BUILD) || defined(MTK_BUILD_ROOT)
				case 4:
					select = 0;
					video_set_cursor(video_get_rows()/2, 0);
					video_printf(title_msg);
					video_printf("[Recovery    Mode]         <<==\n");
#ifdef MTK_FASTBOOT_SUPPORT
					video_printf("[Fastboot    Mode]             \n");
#endif
					video_printf("[Normal      Boot]             \n");
					video_printf("[Normal      Boot +ftrace]     \n");
					video_printf("[Normal      slub debug off]     \n");
					break;
#endif

				default:
					break;
			}
			dprintf(0,  "[VOL_UP]Key Detect, current select:%d\n", select);
			mdelay(300);
		} else if (mtk_detect_key(MT65XX_MENU_OK_KEY)) { //VOL_DOWN,
			//use for OK
			break;
		} else {
			//pass
		}
	}
	if (select == 0) {
		g_boot_mode = RECOVERY_BOOT;
	} else if (select == 1) {
		g_boot_mode = FASTBOOT;
	} else if (select == 2) {
		g_boot_mode = NORMAL_BOOT;
	} else if (select == 3) {
                cmdline_append("boot_trace");
		g_boot_mode = NORMAL_BOOT;
	} else if (select == 4) {
		cmdline_append("slub_debug=-");
		g_boot_mode = NORMAL_BOOT;
	} else {
		//pass
	}

	video_set_cursor(video_get_rows()/2 +8, 0);
	return;
}