linux aarch64 head.S set_cpu_boot_mode_flag

2022/3/7 7:20:00

本文主要是介绍linux aarch64 head.S set_cpu_boot_mode_flag,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

 

set_cpu_boot_mode_flag

 

使用 el2_setup 的返回值,填充 __boot_cpu_mode 这个全局数组 ,

 

1、__boot_cpu_mode 也在 head.S 里面定义的。初始值如下:

/*
 * We need to find out the CPU boot mode long after boot, so we need to
 * store it in a writable variable.
 *
 * This is not in .bss, because we set it sufficiently early that the boot-time
 * zeroing of .bss would clobber it.
 */
SYM_DATA_START(__boot_cpu_mode)
    .long    BOOT_CPU_MODE_EL2
    .long    BOOT_CPU_MODE_EL1
SYM_DATA_END(__boot_cpu_mode)

 

2、set_cpu_boot_mode_flag 代码

 

/*
 * Sets the __boot_cpu_mode flag depending on the CPU boot mode passed
 * in w0. See arch/arm64/include/asm/virt.h for more info.
 */
SYM_FUNC_START_LOCAL(set_cpu_boot_mode_flag)
    adr_l    x1, __boot_cpu_mode
    cmp    w0, #BOOT_CPU_MODE_EL2
    b.ne    1f
    add    x1, x1, #4
1:    str    w0, [x1]            // This CPU has booted in EL1
    dmb    sy
    dc    ivac, x1            // Invalidate potentially stale cache line
    ret
SYM_FUNC_END(set_cpu_boot_mode_flag)

 

3、set_cpu_boot_mode_flag 代码逻辑

 

 1 running_mode = el2_setup();
 2 
 3 set_cpu_boot_mode_flag(running_mode){
 4 
 5     if(running_mode == #BOOT_CPU_MODE_EL2){
 6         __boot_cpu_mode.field2 = #BOOT_CPU_MODE_EL2
 7     }else{
 8         __boot_cpu_mode.field1 = #BOOT_CPU_MODE_EL1
 9     }
10 }

 

如果running_mode 为EL2, 则 __boot_cpu_mode 的两个field 都为   #BOOT_CPU_MODE_EL2 

如果 running_mode 为EL1, 则 __boot_cpu_mode 的两个field 都为   #BOOT_CPU_MODE_EL1

 



这篇关于linux aarch64 head.S set_cpu_boot_mode_flag的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程