本文共 1919 字,大约阅读时间需要 6 分钟。
proc info
__FINIT .text/* * Read processor ID register (CP#15, CR0), and look up in the linker-built * supported processor list. Note that we can't use the absolute addresses * for the __proc_info lists since we aren't running with the MMU on * (and therefore, we are not in the correct address space). We have to * calculate the offset. * * r9 = cpuid * Returns: * r3, r4, r6 corrupted * r5 = proc_info pointer in physical address space * r9 = cpuid (preserved) */__lookup_processor_type: adr r3, __lookup_processor_type_data @ r3 = __lookup_processor_type_data所在行物理地址,adr是基于PC寄存器计算地址值, @ 由于这时候还没有使能MMU,PC寄存器中使用的还是物理地址 ldmia r3, {r4 - r6} @ [r3]->r4,[r3+4]->r5,[r3+8]->r6, @ r4 = __lookup_processor_type_data所在行的虚拟地址,r5 = __proc_info_begin(虚拟地址),r6 = __proc_info_end(虚拟地址) sub r3, r3, r4 @ get offset between virt&phys,r3 = r3 - r7,即物理地址 - 虚拟地址 add r5, r5, r3 @ convert virt addresses to,r5 = __proc_info_begin对应的物理地址 add r6, r6, r3 @ physical address space,r6 = __proc_info_end对应的物理地址1: ldmia r5, {r3, r4} @ value, mask,r3、r4=proc_info_list结构中的cpu_val、cpu_mask and r4, r4, r9 @ mask wanted bits,r9中保存的是从cp15的CR0读到的Main ID,r4 = cpu_mask & Main ID teq r3, r4 @ 比较cpu_val与cpu_mask & Main ID beq 2f @ 如果相等,表示找到匹配的proc_info_list结构,地址就存于r5中,直接跳回 add r5, r5, #PROC_INFO_SZ @ sizeof(proc_info_list)@ 上一步没有找到,r5+PROC_INFO_SZ,试图匹配下一个info cmp r5, r6 @ 与info end比较 blo 1b @ 如果还没有比较到end处,继续跳回比较 mov r5, #0 @ unknown processor,没有匹配到对应的processor,即没有找到proc_info_list结构2: mov pc, lrENDPROC(__lookup_processor_type)
NOTE:
/arch/arm/kernel/asm-offsets.c
DEFINE(PROC_INFO_SZ, sizeof(structproc_info_list));
/include/linux/kbuild.h
#define DEFINE(sym, val) \ asm volatile("\n->" #sym " %0 " #val : : "i" (val))这并不是一个标准宏定义。
转载地址:http://mdsqb.baihongyu.com/