
一、LiteOS-M 初始化内核
在LiteOS-M应用程序中,系统初始化如下:
/**
* @brief This is the ohos entry, and you could call this in your main funciton after the
* necessary hardware has been initialized.
*/
void OHOS_Boot(void)
{
UINT32 ret;
ret = LOS_KernelInit(); //初始化内核
if (ret == LOS_OK) {
...
LOS_Start(); //启动内核任务调度
}
return; // and should never come here
}
二、LOS_KernelInit代码分析
/*****************************************************************************
Function : LOS_KernelInit
Description : System kernel initialization function, configure all system modules
Input : None
Output : None
Return : LOS_OK on success or error code on failure
*****************************************************************************/
LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
{
UINT32 ret;
PRINTK("entering kernel init...\n");
#if (LOSCFG_BACKTRACE_TYPE != 0) //LOSCFG_XXX 宏定义为make menuconfig生成的宏
OsBackTraceInit(); //函数目前用于初始化内存泄漏检查钩子,栈回溯功能
#endif
#ifdef LOSCFG_KERNEL_LMS
OsLmsInit(); //初始化 LMS全称为Lite Memory Sanitizer,是一种实时检测内存操作合法性的调测工具
#endif
ret = OsMemSystemInit(); //系统堆内存初始化
if (ret != LOS_OK) {
PRINT_ERR("OsMemSystemInit error %d\n", ret);
return ret;
}
ArchInit(); //CPU中断向量表初始化,中断接管
ret = OsTickTimerInit(); //系统Tick时钟初始化<

最低0.47元/天 解锁文章
7956

被折叠的 条评论
为什么被折叠?



