IT技术互动交流平台

mtkrda从bootload开始分析如何加载lcd驱动

来源:IT165收集  发布日期:2014-03-11 21:28:45
#define BOOT_SECTOR_NAND_SECTION_START __attribute__((section (".boot_sector_nand_start")))
#define BOOT_SECTOR_SECTION_START __attribute__((section (".boot_sector_start")))
1.boot_sector_nand.c PROTECTED VOID BOOT_SECTOR_NAND_SECTION_START boot_Sector_Nand(UINT32 param)

2.boot_sector.c PROTECTED VOID BOOT_SECTOR_SECTION_START boot_Sector(UINT32 param)
2 .1 /// Initialize flash memory and RAM memory. // Copy booting code & data from ROM space to internal SRAM. boot_MemInit : Initialize flash memory and RAM memory. 3. boot_loader.c //// Real implementation of the boot loader, loading code after the stack has been reseted in #boot_LoaderEnter(); PROTECTED VOID boot_Loader(UINT32 param)
bootloader 做了几件重要的事情
3.1 把ROM里面的数据copy到内部sram里面 3.2加载驱动 hal_Open(tgt_GetHalConfig()); tgt_GetHalConfig PROTECTED CONST HAL_CFG_CONFIG_T g_tgtHalCfg = TGT_HAL_CONFIG; tgt_board_cfg.h//加载各部分驱动配置 #define TGT_HAL_CONFIG
{
.chipVersion = TGT_HAL_CHIP_VERSION,
.rfClkFreq = TGT_HAL_RF_CLK_FREQ,
.useLpsCo1 = FALSE,
.keyInMask = 0x1f,
.keyOutMask = 0x1f,
.pwmCfg = TGT_HAL_PWM_CFG,
.useUsbBackup = FALSE,
.useClk32k = FALSE,
.i2cCfg = TGT_HAL_I2C_CFG,
.i2c1UseCamPins = FALSE,
.i2sCfg = TGT_HAL_I2S_CFG,
.ebcCfg = TGT_HAL_EBC_CFG,
.uartCfg = TGT_HAL_UART_CFG,
.spiCfg = TGT_HAL_SPI_CFG,
.useSdmmc = TRUE,
.useSdmmc2 = FALSE,
.spi2UseCamPins = FALSE,
.camCfg = TGT_HAL_CAM_CFG,
.goudaCfg = TGT_HAL_GOUDA_CFG,
.noConnectGpio = TGT_HAL_NO_CONNECT_GPIO,
.usedGpio = TGT_HAL_USED_GPIO,
.usedGpo = TGT_HAL_USED_GPO,
.usedTco = TGT_HAL_USED_TCO,
.ioDrive = TGT_HAL_IO_DRIVE
}

3.3 进入main函数
4. sap_main.c int main (int argc, char *argv[]) main做了几件重要的事情
4.1 分配heap 堆
4.2 开启进程 sxs_StartAll (); 4.3 检测任务和任务调度
sxr_CheckTask // Never return sxr_StartScheduling ();

5. sap_main.c void sxs_StartAll (void) 5.1对各种进程初始化 5.2 新建任务 sxr_NewTask 5.3 开启任务 sxr_StartTask u8 TaskId = sxs_usrInitTaskId [i] = sxr_NewTask (&sxs_UsrInitTaskCfg [i].TaskDesc); sxr_StartTask (TaskId, (void *)sxs_UsrInitTaskCfg [i].UsrInitTask); const sxs_UsrInitTaskCfg_t sxs_UsrInitTaskCfg [] =
{
#ifdef __DISPLAY_POWERON_LOGO__
{
{
(void(*)(void *))sxs_UsrInitTask,
0,
"USR INIT: Power-on LOGO",
USR_INIT_POWER_ON_LOGO_TASK_STACK_SIZE,
USR_INIT_POWER_ON_LOGO_TASK_PRIORITY
},
(void(*)(void))&lcd_present_CS_log
},
#endif //__DISPLAY_POWERON_LOGO__ { { (void(*)(void *))sxs_UsrInitTask, 0, "USR_INIT: BAL Init Task", USR_INIT_BAL_INIT_TASK_STACK_SIZE, USR_INIT_BAL_INIT_TASK_PRIORITY }, (void(*)(void))&BAL_TaskInit }, { { (void(*)(void *))sxs_UsrInitTask, 0, "USR_INIT: Decompress Task", USR_INIT_DECOMPRESS_TASK_STACK_SIZE, USR_INIT_DECOMPRESS_TASK_PRIORITY }, (void(*)(void))&BAL_DecompressCode }, };




 
6. bal_init.c BOOL BAL_TaskInit() taskinit做了几件重要的事情 6.1 csw_MemIint(); //初始化内存分配 tgt_app VDS_Init DSM_DevInit // describes the DSM(Data Storage Mangage) configuration REG_Init CFW_CfgInit SMS_DM_Init FS_PowerOn FS_GetDeviceInfo // // Get FS device table. // Check the state of root device ,if not format, format it. // Mount root device.
//文件系统建立好之后 开始开启任务 // Start application tasks for(i = 0; i< MAX_BAL_TASK_NUM; i++) g_BalTasks[i] = HNULL; g_BalTasks[BAL_TASK_NUM(BAL_SYS_TASK_PRIORITY)] = COS_CreateTask_Prv(BAL_SysTask, NULL, NULL, BAL_SYS_TASK_STACK_SIZE, BAL_SYS_TASK_PRIORITY, COS_CREATE_DEFAULT, 0, "BAL_SysTask");
#ifdef CFW_TCPIP_SUPPORT g_BalTasks[BAL_TASK_NUM(BAL_CFW_ADV_TASK_PRIORITY)] = COS_CreateTask_Prv(BAL_CFWApsTask, NULL, NULL, BAL_CFW_ADV_TASK_STACK_SIZE, BAL_CFW_ADV_TASK_PRIORITY, COS_CREATE_DEFAULT, 0, "BAL_CFWApsTask"); #endif
g_BalTasks[BAL_TASK_NUM(BAL_DEV_MONITOR_TASK_PRIORITY)] = COS_CreateTask_Prv(BAL_DevMonitorTask, NULL, NULL, BAL_DEV_MONITOR_TASK_STACK_SIZE, BAL_DEV_MONITOR_TASK_PRIORITY, COS_CREATE_DEFAULT, 0, "BAL_DevMonitorTask");
g_BalTasks[3] = COS_CreateTask_Prv(BAL_BackgroundTask, NULL, NULL, BAL_BG_TASK_STACK_SIZE, COS_BK_TASK_PRI, COS_CREATE_DEFAULT, 0, "BAL_BackgroundTask"); BAL_ApplicationInit();
#ifdef WIFI_SUPPORT wifi_task_init(); #endif
7. TaskInit.c //应用层任务建立初始化
BOOL BAL_ApplicationInit ( VOID ) 1. // Require mmi clk csw_SetResourceActivity(CSW_LP_RESOURCE_MMIACTIVE, CSW_SYS_FREQ_104M); 7.2 COS_CreateTask //创建任务 7.3 COS_StartTask //开启任务
eg:
hTask = COS_CreateTask(BAL_MmiMainTaskEntry,
NULL, NULL,
MMI_TASK_STACK_SIZE,
MMI_TASK_PRIORITY,
COS_CREATE_SUSPENDED, 0, "MMI Main Task");
ASSERT(hTask != HNULL);
SetMmiTaskHandle(MOD_MMI, hTask);
COS_StartTask((TASK_HANDLE*)GetMmiTaskHandle(MOD_MMI), NULL);

 


8. MMITask.c void BAL_MmiMainTaskEntry(void *pData)
BAL_MmiMainTaskEntry做了四件事情 8.1 StartTimer(TIMER_REAL_TIME_CLOCK, 1000, DateTimerProc); //开启定时器 8.2 switch (ppower_on->poweron_mode) // 注册开机
POWER_ON_KEYPAD 0
POWER_ON_ALARM 1
POWER_ON_CHARGER_IN 2
POWER_ON_EXCEPTION 3

InitializeResourceVariables(); MMICheckDiskDisplay(); //display logo /*Guojian Add End For 10810 Ver: GreenStone on 2008-12-19 13:59 */
ResetAbnormalReset();
InitializeAll();
/**************************************
* To initialize nvram data
***************************************/
InitNvramData();
TurnOnBacklight(1);
8.3 注册耳机gpio事件//
8.4
ProtocolEventHandler(Message->msg_id,(void*)Message->local_para_ptr,(int)Message->src_mod_id, (void*) Message); // 处理其他消息事件
 

9. MMITask.c
void MMICheckDiskDisplay(void)
/* init graphic library. including lcd and all drawing related modules */
gdi_init();

10. gdi.c gdi_init
11. gdi_lcd.c gdi_lcd_init lcd_init(MAIN_LCD, DRV_MAINLCD_INIT_COLOR); 12. lcd_if.c
void lcd_init(kal_uint8 lcd_id, kal_uint16 background_color) //This function is used to initialize the LCD interface and LCD module


13. drv_lcd_chip.c
VOID Init_DI(UINT32 background, VOID** unused)
{
mci_LcdInit(background);
}
14. mci_lcd.c VOID mci_LcdInit(UINT32 background)
{ static VOLATILE BOOL visitFlag = 0; UINT32 status = hal_SysEnterCriticalSection(); if (!visitFlag) { visitFlag = 1; g_mciLcdBypassFunction=NULL; hal_SysExitCriticalSection(status);
MCI_TRACE(MCI_LCD_TRC_LVL,0,"mci_LcdInit"); lcdd_Open(); lcdd_GetScreenInfo(&g_mciLcdScreenInfo); mci_LcdClearScreen(background); } else { hal_SysExitCriticalSection(status); } }
15. lcdd.c
/// Open the LCDD driver.
/// It must be called before any call to any other function of this driver.
/// This function is to be called only once.
 
PUBLIC LCDD_ERR_T lcdd_Open(VOID)
{
LCDD_ERR_T ret = LCDD_ERR_NO;
 
// Allow access to other LCD functions
 
if (lcdd_LoadDrv())
{
if (g_lcddDrv->lcdd_Open != NULL)
{
lcdd_SetBrightness(0);
ret = g_lcddDrv->lcdd_Open();
if (ret == LCDD_ERR_NO)
{
// Allow access
g_lcddLock = 1;
}
}
}
else
{
LCDD_TRACE(LCDD_INFO_TRC, 0, "Lcdd load error");
}
//if not find lcdd ,must return LCDD_ERR_NO for produce
g_lcddOpened = TRUE;
return ret;
} 做了两件重要的事情 15.1 lcdd_LoadDrv g_lcddDrv->lcdd_Open()


 
16. 以 ili9163c 为例: drv_lcd_ili9163c.c PUBLIC BOOL lcdd_ili9163c_RegInit(LCDD_REG_T *pLcdDrv)
{
if( lcddp_CheckProductId())
{
pLcdDrv->lcdd_Open=lcddp_Open;
pLcdDrv->lcdd_Close=lcddp_Close;
pLcdDrv->lcdd_SetContrast=lcddp_SetContrast;
 
pLcdDrv->lcdd_SetStandbyMode=lcddp_SetStandbyMode;
pLcdDrv->lcdd_PartialOn=lcddp_PartialOn;
pLcdDrv->lcdd_PartialOff=lcddp_PartialOff;
pLcdDrv->lcdd_Blit16=lcddp_Blit16;
pLcdDrv->lcdd_Busy=lcddp_Busy;
pLcdDrv->lcdd_FillRect16=lcddp_FillRect16;
pLcdDrv->lcdd_GetScreenInfo=lcddp_GetScreenInfo;
pLcdDrv->lcdd_WakeUp=lcddp_WakeUp;
pLcdDrv->lcdd_SetPixel16=lcddp_SetPixel16;
pLcdDrv->lcdd_Sleep=lcddp_Sleep;
pLcdDrv->lcdd_SetDirRotation=lcddp_SetDirRotation;
pLcdDrv->lcdd_SetDirDefault=lcddp_SetDirDefault;
pLcdDrv->lcdd_GetStringId=lcdd_get_id_string;
 
return TRUE;
}
 
return FALSE;
}
....


延伸阅读:

  • 专题推荐

About IT165 - 广告服务 - 隐私声明 - 版权申明 - 免责条款 - 网站地图 - 网友投稿 - 联系方式
本站内容来自于互联网,仅供用于网络技术学习,学习中请遵循相关法律法规