在SMP boot secondary cores的时候,CPU如何知道存放secondary_startup入口的寄存器地址?
本文是原「蜗窝讨论区」的历史存档(2017-03-22),来自版块「Linux kernel技术问答」,共 3 帖。讨论区已停止服务,此处仅供查阅。
Hi Wowo, 看了很多你们的文章,受益匪浅,在bring up多核SoC时,有一点没有弄清楚,以Vexpress为例,在platsmp.c中: static void __init vexpress_smp_dt_prepare_cpus(unsigned int max_cpus) { struct device_node *scu = of_find_matching_node(NULL, vexpress_smp_dt_scu_match);
if (scu)
scu_enable(of_iomap(scu, 0));
/*
- Write the address of secondary startup into the
- system-wide flags register. The boot monitor waits
- until it receives a soft interrupt, and then the
- secondary CPU branches to this address.
*/
vexpress_flags_set(virt_to_phys(versatile_secondary_startup)); //将versatile_secondary_startup地址写到system-wide flags register
} 那么在secondary core收到IPI中断后执行wake up时,如何知道要去system flags这个寄存器去取呢?这是SoC 设计决定的吗?
Robin 写道: Hi Wowo, 看了很多你们的文章,受益匪浅,在bring up多核SoC时,有一点没有弄清楚,以Vexpress为例,在platsmp.c中: static void __init vexpress_smp_dt_prepare_cpus(unsigned int max_cpus) { struct device_node *scu = of_find_matching_node(NULL, vexpress_smp_dt_scu_match);
if (scu)
scu_enable(of_iomap(scu, 0));
/*
- Write the address of secondary startup into the
- system-wide flags register. The boot monitor waits
- until it receives a soft interrupt, and then the
- secondary CPU branches to this address.
*/
vexpress_flags_set(virt_to_phys(versatile_secondary_startup)); //将versatile_secondary_startup地址写到system-wide flags register
} 那么在secondary core收到IPI中断后执行wake up时,如何知道要去system flags这个寄存器去取呢?这是SoC 设计决定的吗?
你之所以有这样的问题,是因为你忽略了boot monitor(The boot monitor waits * until it receives a soft interrupt, and then the * secondary CPU branches to this address) 其实boot monitor也是一段代码(不过很少被大家看到),secondary core醒来之后,会先运行boot monitor,boot monitor会检查system flags。
再换了思路:如果boot monitor直接固话在CPU中了呢? 这也无可厚非,就约定呗~~
到这个级别的时候,软件还是硬件,界限已经很模糊了。唯一清晰的就是逻辑。懂就可以了,别太纠结了~~
因为是我司自己的SoC,所以rom code要自己写,我理解这部分大概流程是Secondary Core wake up from WFI by SGI-->go to run from vector table(usually at 0x00000000)--> handle SGI-->go fetch the entry point from some pre-defined register. 多谢指点!:)
