剛學寫程式,都會寫一個"Hello World!",程式法大概會如下:
int main()
{
printf("Hello World!\n");
return 0;
}
當豬在閱讀chrome ec程式碼時,也是先找main() function。
豬的專案,main() function是放在common下的main.c
__keep int main(void)
{
int mpu_pre_init_rv = EC_SUCCESS;
if (IS_ENABLED(CONFIG_PRESERVE_LOGS)) {
/*
* Initialize tx buffer head and tail. This needs to be done
* before any updates of uart tx input because we need to
* verify if the values remain the same after every EC reset.
*/
uart_init_buffer();
/*
* Initialize reset logs. Needs to be done before any updates of
* reset logs because we need to verify if the values remain
* the same after every EC reset.
*/
if (IS_ENABLED(CONFIG_CMD_AP_RESET_LOG))
init_reset_log();
}
/*
* Pre-initialization (pre-verified boot) stage. Initialization at
* this level should do as little as possible, because verified boot
* may need to jump to another image, which will repeat this
* initialization. In particular, modules should NOT enable
* interrupts.
*/
CONFIG_BOARD_PRE_INIT
board_config_pre_init();
........略........
/*
* Print the init time. Not completely accurate because it can't take
* into account the time before timer_init(), but it'll at least catch
* the majority of the time.
*/
CPRINTS("Inits done");
/* Launch task scheduling (never returns) */
return task_start();
}
前半段就是做一些初始化,這邊就先忽略,最後就會呼叫一個task_start() function。從README.md就能發現,是一個task的架構,將各個feature模組化為task,task scheduling會根據priority去執行每一個feature task,每執行一段時間就會中斷,根據當下priority最高的task去run,這就像一個小型OS (or RTOS - Real Time OS)。board/$BOARD/下ec.tasklist可找到其專案有哪些task。可以在console下執行taskinfo會顯示run-time狀態下的每一個task。就如同README.md中提到的下圖.> taskinfo Task Ready Name Events Time (s) StkUsed 0 R << idle >> 00000000 32.975554 196/256 1 R HOOKS 00000000 0.007835 192/488 2 VBOOTHASH 00000000 0.042818 392/488 3 POWERLED 00000000 0.000096 120/256 4 CHARGER 00000000 0.029050 392/488 5 CHIPSET 00000000 0.017558 400/488 6 HOSTCMD 00000000 0.379277 328/488 7 R CONSOLE 00000000 0.042050 348/640 8 KEYSCAN 00000000 0.002988 292/488
沒有留言:
張貼留言