高通LCD lk代碼跟蹤分析

H文件裏面的所有參數都是在Oem_panel.c裏面的int init_panel_data函數調用的。接下來跟蹤一下代碼。Oem_panel.c位於bootable\bootloader\lk\target目錄下。



Aboot.c:void aboot_init函數解析:

void aboot_init(const struct app_descriptor *app)
{
unsigned reboot_mode = 0;

/* Initialise wdog to catch early lk crashes */
#if WDOG_SUPPORT
msm_wdog_init();
#endif

/* Setup page size information for nv storage */
if (target_is_emmc_boot()) //檢測是emmc還是flash存儲,並設置頁面大小,一般是2048
{
page_size = mmc_page_size();
page_mask = page_size - 1;
mmc_blocksize = mmc_get_device_blocksize();
mmc_blocksize_mask = mmc_blocksize - 1;
}
else
{
page_size = flash_page_size();
page_mask = page_size - 1;
}

ASSERT((MEMBASE + MEMSIZE) > MEMBASE);
//斷言,如果內存基地址+內存大小小於內存基地址,則直接終止錯誤
read_device_info(&device); //從devinfo分區表read data到device結構體
read_allow_oem_unlock(&device); //devinfo分區裏記錄了unlock狀態,從device中讀取此信息
/* Display splash screen if enabled */
#if DISPLAY_SPLASH_SCREEN
#if NO_ALARM_DISPLAY
if (!check_alarm_boot()) {
#endif
dprintf(SPEW, "Display Init: Start\n");
#if ENABLE_WBC
/* Wait if the display shutdown is in progress */
while(pm_app_display_shutdown_in_prgs());
if (!pm_appsbl_display_init_done())
target_display_init(device.display_panel);
//顯示splash,Splash也就是應用程序啓動之前先啓動一個畫面,上面簡單的介紹應用程序的廠商,廠商的LOGO,名稱和版本等信息,多爲一張圖片
else
display_image_on_screen();
#else
target_display_init(device.display_panel);
#endif
dprintf(SPEW, "Display Init: Done\n");
#if NO_ALARM_DISPLAY
}
#endif
#endif

target_serialno((unsigned char *) sn_buf);
dprintf(SPEW,"serial number: %s\n",sn_buf);

memset(display_panel_buf, '\0', MAX_PANEL_BUF_SIZE);

/*
* Check power off reason if user force reset,
* if yes phone will do normal boot.
*/
if (is_user_force_reset())
goto normal_boot; //如果強制重啓,直接進入normal_boot

/* Check if we should do something other than booting up */
if (keys_get_state(KEY_VOLUMEUP) && keys_get_state(KEY_VOLUMEDOWN))
{ //啓動原因是用戶按住了音量上下鍵,進入下載模式
dprintf(ALWAYS,"dload mode key sequence detected\n");
reboot_device(EMERGENCY_DLOAD);
dprintf(CRITICAL,"Failed to reboot into dload mode\n");

boot_into_fastboot = true; //下載模式本質上是進入fastboot
}
if (!boot_into_fastboot) //如果不是通過usb+上下鍵進入下載模式
{
if (keys_get_state(KEY_HOME) || keys_get_state(KEY_VOLUMEUP)) //進入recovery模式
boot_into_recovery = 1;
if (!boot_into_recovery &&
(keys_get_state(KEY_BACK) || keys_get_state(KEY_VOLUMEDOWN)))
boot_into_fastboot = true; //進入fastboot模式
}
#if NO_KEYPAD_DRIVER
if (fastboot_trigger())
boot_into_fastboot = true;
#endif

#if USE_PON_REBOOT_REG
reboot_mode = check_hard_reboot_mode();
#else
reboot_mode = check_reboot_mode(); //檢測開機原因,並且修改相應的標誌位
#endif
if (reboot_mode == RECOVERY_MODE)
{
boot_into_recovery = 1;
}
else if(reboot_mode == FASTBOOT_MODE)
{
boot_into_fastboot = true;
}
else if(reboot_mode == ALARM_BOOT)
{
boot_reason_alarm = true;
}
#if VERIFIED_BOOT
#if !VBOOT_MOTA
else if (reboot_mode == DM_VERITY_ENFORCING)
{
device.verity_mode = 1;
write_device_info(&device);
}
else if (reboot_mode == DM_VERITY_LOGGING)
{
device.verity_mode = 0;
write_device_info(&device);
}
else if (reboot_mode == DM_VERITY_KEYSCLEAR)
{
if(send_delete_keys_to_tz())
ASSERT(0);
}
#endif
#endif

normal_boot:
if (!boot_into_fastboot)
{
if (target_is_emmc_boot())
{
if(emmc_recovery_init())
dprintf(ALWAYS,"error in emmc_recovery_init\n");
if(target_use_signed_kernel())
{
if((device.is_unlocked) || (device.is_tampered))
{
#ifdef TZ_TAMPER_FUSE
set_tamper_fuse_cmd();
#endif
#if USE_PCOM_SECBOOT
set_tamper_flag(device.is_tampered);
#endif
}
}

boot_linux_from_mmc(); //根據boot_into_xxx從對應的分區內讀取相關信息並傳給kernel,然後引導kernel。boot_linux_from_mmc()主要做下面的事情:
1).程序會從boot分區或者recovery分區的header中讀取地址等信息,然後把kernel、ramdisk加載到內存中。
2).程序會從misc分區中讀取bootloader_message結構體,如果有boot-recovery,則進入recovery模式
3).更新cmdline,然後把cmdline寫到tags_addr地址,把參數傳給kernel,kernel起來以後會到這個地址讀取參數。
}
else
{
recovery_init();
#if USE_PCOM_SECBOOT
if((device.is_unlocked) || (device.is_tampered))
set_tamper_flag(device.is_tampered);
#endif
boot_linux_from_flash();
}
dprintf(CRITICAL, "ERROR: Could not do normal boot. Reverting "
"to fastboot mode.\n");
}

/* We are here means regular boot did not happen. Start fastboot. */

/* register aboot specific fastboot commands */
aboot_fastboot_register_commands(); //註冊fastboot命令,建議看下此函數的源碼,此函數是fastboot支持的命令,如flash、erase等等

/* dump partition table for debug info */
partition_dump();

/* initialize and start fastboot */
fastboot_init(target_get_scratch_address(), target_get_max_flash_size()); //初始化fastboot
#if FBCON_DISPLAY_MSG
display_fastboot_menu(); //顯示fastboot界面
#endif
}