__lookup_processor_type

proc info

http://blog.csdn.net/coldsnow33/article/details/37936433

	__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, lr
ENDPROC(__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))


这并不是一个标准宏定义。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值