更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
smp.c 文件参考

浏览源代码.

结构体

struct  OsCpuInit
 

函数

VOID reset_vector (VOID)
 
VOID HalArchCpuOn (UINT32 cpuNum, ArchCpuStartFunc func, struct SmpOps *ops, VOID *arg)
 
VOID HalSecondaryCpuStart (VOID)
 

变量

STATIC struct OsCpuInit g_cpuInit [CORE_NUM - 1] = {0}
 

函数说明

◆ HalArchCpuOn()

VOID HalArchCpuOn ( UINT32  cpuNum,
ArchCpuStartFunc  func,
struct SmpOps ops,
VOID *  arg 
)

在文件 smp.c53 行定义.

54{
55 struct OsCpuInit *cpuInit = &g_cpuInit[cpuNum - 1];
56 UINTPTR startEntry = (UINTPTR)&reset_vector - KERNEL_VMM_BASE + SYS_MEM_BASE;
57 INT32 ret;
58
59 cpuInit->cpuStart = func;
60 cpuInit->arg = arg;
61 cpuInit->initFlag = 0;
62
63 DCacheFlushRange((UINTPTR)cpuInit, (UINTPTR)cpuInit + sizeof(struct OsCpuInit));
64
65 LOS_ASSERT(ops != NULL);
66
67
68 ret = ops->SmpCpuOn(cpuNum, startEntry);
69 if (ret < 0) {
70 PRINT_ERR("cpu start failed, cpu num: %u, ret: %d\n", cpuNum, ret);
71 return;
72 }
73
74 while (!LOS_AtomicRead(&cpuInit->initFlag)) {
75 WFE;
76 }
77}
STATIC INLINE INT32 LOS_AtomicRead(const Atomic *v)
Atomic read. | 读取32bit原子数据
Definition: los_atomic.h:123
VOID DCacheFlushRange(UINT32 start, UINT32 end)
Definition: los_hw.c:170
signed int INT32
Definition: los_typedef.h:60
unsigned long UINTPTR
Definition: los_typedef.h:68
VOID reset_vector(VOID)
STATIC struct OsCpuInit g_cpuInit[CORE_NUM - 1]
Definition: smp.c:51
Definition: smp.c:45
Atomic initFlag
Definition: smp.c:48
VOID * arg
Definition: smp.c:47
ArchCpuStartFunc cpuStart
Definition: smp.c:46
INT32(* SmpCpuOn)(UINT32 cpuNum, UINTPTR startEntry)
Definition: smp.h:44
函数调用图:
这是这个函数的调用关系图:

◆ HalSecondaryCpuStart()

VOID HalSecondaryCpuStart ( VOID  )

在文件 smp.c79 行定义.

80{
81 UINT32 cpuid = ArchCurrCpuid();
82 struct OsCpuInit *cpuInit = &g_cpuInit[cpuid - 1];
83
85
86 LOS_AtomicSet(&cpuInit->initFlag, 1);
87 SEV;
88
89#ifdef LOSCFG_KERNEL_MMU
91#endif
92
93 /* store each core's hwid */
94 CPU_MAP_SET(cpuid, OsHwIDGet());
96
97 cpuInit->cpuStart(cpuInit->arg);
98
99 while (1) {
100 WFI;
101 }
102}
VOID HalIrqInitPercpu(VOID)
中断控制器与CPU之间的关系初始化
Definition: gic_v2.c:109
STATIC INLINE VOID LOS_AtomicSet(Atomic *v, INT32 setVal)
Atomic setting.
Definition: los_atomic.h:147
VOID OsArchMmuInitPerCPU(VOID)
STATIC INLINE UINT32 ArchCurrCpuid(VOID)
Definition: los_hw_cpu.h:168
STATIC INLINE UINT64 OsHwIDGet(VOID)
获取CPU硬件ID,每个CPU都有自己的唯一标识
Definition: los_hw_cpu.h:177
STATIC INLINE VOID OsCurrTaskSet(LosTaskCB *task)
注意任务地址由硬件保存,见于 CP15 | TPIDRPRW
LosTaskCB * OsGetMainTask()
Definition: los_task.c:162
unsigned int UINT32
Definition: los_typedef.h:57
函数调用图:

◆ reset_vector()

VOID reset_vector ( VOID  )
这是这个函数的调用关系图:

变量说明

◆ g_cpuInit

STATIC struct OsCpuInit g_cpuInit[CORE_NUM - 1] = {0}

在文件 smp.c51 行定义.