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
标签:__,head,set,aarch64,boot,CPU,mode,cpu 来源: https://www.cnblogs.com/zhangzhiwei122/p/15971300.html