- __cpu_setup。定义kernel\arch\arm64\mm\proc.S中。
#define MAIR(attr, mt) ((attr) << ((mt) * 8))
/*
* __cpu_setup
*
* Initialise the processor for turning the MMU on. Return in x0 the
* value of the SCTLR_EL1 register.
*/
ENTRY(__cpu_setup)
ic iallu // I+BTB cache invalidate // 使instruction和BTB cache中的所有的cache line是无效,直到PoU // BTB(Branch Target Buffer)
tlbi vmalle1is // invalidate I + D TLBs // 使TLB内容无效vm-all-e1-is,vmall表示invalidate all TLB entry,e1表示EL1,is表示inner sharebility
dsb ish // dsb 数据同步屏蔽指令,确保前面的指令执行完成,ish表示inner shareable
mov x0, #3 << 20
msr cpacr_el1, x0 // Enable FP/ASIMD // 使能SIMD and floating-point
msr mdscr_el1, xzr // Reset mdscr_el1 // Monitor Debug System Control Register
/*
* Memory region attributes for LPAE:
*
* n = AttrIndx[2:0] // 最重要的memory attributes指向MAIR_ELx中具体的memory attribute
* n MAIR
* DEVICE_nGnRnE 000 00000000 // G:Gathering 表示对多个memory的访问是否可以合并
* DEVICE_nGnRE 001 00000100 // R: Re-ordering 表示是否允许处理器对内存访问指令进行重排
* DEVICE_GRE 010 00001100 // E: Early Write Acknowledgement
* NORMAL_NC 011 01000100 // 前面加n表示不允许
* NORMAL 100 11111111 // C: 表示是否cacheable
*/
ldr x5, =MAIR(0x00, MT_DEVICE_nGnRnE) | \
MAIR(0x04, MT_DEVICE_nGnRE) | \
MAIR(0x0c, MT_DEVICE_GRE) | \
MAIR(0x44, MT_NORMAL_NC) | \</