接上文,继续分析TC277多核启动过程
目录
main函数分析
该main函数在Bswinit.c中
main函数包含内容如下:
void BswInit_PreInitPowerOn(void)
{
Os_InitMemory();
Os_Init();
}
Os_InitMemory->Step1
Os_InitMemory最终调用Os_Api_InitMemory
实际里面没有内容,这个是静态代码,不会变的
Os_Init->Os_Api_Init:执行step2
core = Os_CoreGetCurrentCore();//获取当前coreid,根据ID得到核信息,是否为autosar核,是否为自启动核,都在core信息中。
Os_CoreGetCurrentCore->Os_Hal_CoreGetId->Os_Hal_Mfcr(OS_HAL_CORE_ID_REGISTER)
Os_Hal_Mfcr即 _mfcr
# define OS_HAL_CORE_ID_REGISTER 0xFE1CUL(和CSFR中的coreid一致)
systemCfg = Os_SystemGet();//获取OS配置信息,version,核心数,中断信息等
/* #10 If called on the hardware initialization core. */判断是否是硬件初始化核,TC277定义核0为硬件初始化核
if(core->IsHardwareInitCore == TRUE)
{
/* #20 Perform hardware specific initialization on the Hardware Initialization Core. */初始化特殊硬件
/* #30 Initialize system wide interrupt handling */初始化系统中断
/* #40 Initialize system's memory protection. */初始化内存保护
}
/* #50 If called on master core. */判断是否为主核
if(core->Id == OS_CORE_ID_MASTER) /* COV_OS_HALPLATFORMMULTICOREUNSUPPORTED */
{
/* #60 Perform the boot synchronization. */执行引导同步
/* #70 Initialize the system data. */初始化系统数据
Os_SystemInit();
}
/* #100 Perform the boot synchronization on this slave core. */
Os_CoreEmulateSlaveWaitForHardwareInit(core->Id);在此从内核上执行引导同步
/* #110 Perform the boot synchronization on this slave core until StartCore is called by the master. */
Os_CoreEmulateSlaveWaitForStartCore(core->Id);在此从内核上执行引导同步,直到主内核调用StartCore
/* #120 Determine the startup mode. */确定启动模式
Os_CoreDetermineStartStatus(core); /* SBSW_OS_CORE_COREDETERMINESTARTSTATUS_001 */
}
/* #130 Initialize core specific interrupt handling. */初始化核特殊中断处理
Os_CoreInterruptHandlingInit(core);
/* #140 If we are an AUTOSAR core: */判断是否为autosar核
if(core->IsAsrCore == TRUE) /* COV_OS_HALPLATFORMMULTICOREUNSUPPORTED */
{
P2CONST(Os_CoreAsrConfigType, AUTOMATIC, OS_CONST) asrCore;
asrCore = Os_Core2AsrCore(core); /* SBSW_OS_CORE_CORE2ASRCORE_001 */
/* #150 Initialize thread class object */初始化线程类对象
Os_ThreadClassInit(asrCore->ThreadClass); /* SBSW_OS_CORE_THREADCLASSINIT_001 */
/* #160 If we are the master core. */判断是否为主核
if(core->Id == OS_CORE_ID_MASTER)
{
/* #170 Attach to the barrier. */
}
/* #180 Perform reduced initialization that allows usage of interrupt API. */
/* #190 Initialize stacks. */初始化栈区
}
}
以上OS_init()函数就执行完了,Autosar OS相关的配置只有和CORE相关的有部分体现,大部分OS的内容应该在后面才体现。
Basic Runtime System(BRS)
接着:
BswInit_InitializeOne
void BswInit_InitializeOne(void)
{
/* some calls are only necessary on master core */
if(GetCoreID()==ECUM_CORE_ID_STARTUP)
{
# if !defined (_MICROSOFT_C_VTT_)
BrsAsrMainInit();//主初始化例程。*包含BRS模块的初始化和BRS主要特定的初始化
#endif /*!_MICROSOFT_C_VTT_*/
#if !defined (BRS_ENABLE_HLPTEST_SUPPORT)
/* UserDefined ExclusiveArea handling for CAN channels, according to AN-ISC-8-1149_ErrorHook_E_OS_DISABLED_INT.pdf */用户自定义专属区域处理can通道
BrsAsrApplCanInterruptLockCtr = 0u;
#endif
}
}
BswInit_InitializeTwo
实际为空
void BswInit_InitializeTwo(void)
{
//Can be used for additional necessary initialization calls.可以用于其他必要的初始化调用。
}
以上还没有启动其他核的过程。
后面跳转到EcuM_Init
EcuM是ECU状态管理,主要用来ECU上下电的管理。