高通LCD lk代码跟踪分析

H文件里面的所有参数都是在Oem_panel.c里面的int init_panel_data函数调用的。接下来跟踪一下代码。Oem_panel.c位于bootable\bootloader\lk\target目录下。

高通LCD lk代码跟踪分析

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
}