浅析armlinux-setup_arch()->setup_processor()函数1
文章来源:http://gliethttp.cublog.cn
建议首先参考《浅析armlinux2_4_19启动程式[head-armv.s文档]》[http://gliethttp.cublog.cn]
//1.arch/arm/kernel/Setup.c->setup_processor()
static void __init setup_processor(void)
{extern struct proc_info_list __proc_info_begin, __proc_info_end;
struct proc_info_list *list;
//++++++++++++++
//processor_id=0x41129200;赋值于arch/arm/kernel/head-armv.s文档[gliethttp]
//__proc_info_begin和__proc_info_end在编译链接脚本arch/arm/vmlinux-armv.lds.in中定义
//...
//__proc_info_begin = .;
//*(.proc.info)
//__proc_info_end = .;
//...
//arch/arm/mm/proc-arm9200.S中定义了该结构体信息
//ENTRY(cpu_arm920_name)
// .ascii "Arm920T"
//#ifndef CONFIG_CPU_ICACHE_DISABLE
// .ascii "i"
//#endif
//#ifndef CONFIG_CPU_DCACHE_DISABLE
// .ascii "d"
//#ifdef CONFIG_CPU_DCACHE_WRITETHROUGH
// .ascii "(wt)"
//#else
// .ascii "(wb)"
//#endif
//#endif
// .ascii "\0"[gliethttp]
// .type cpu_arm920_info, #object
//cpu_arm920_info:
// .long 0
// .long cpu_arm920_name
// .size cpu_arm920_info, . - cpu_arm920_info
// .type cpu_arch_name, #object
//cpu_arch_name:
// .asciz "armv4"
// .size cpu_arch_name, . - cpu_arch_name
//cpu_elf_name:
// .asciz "v4"
// .size cpu_elf_name, . - cpu_elf_name
// .align
// .section ".proc.info", #alloc, #execinstr
// .type __arm920_proc_info,#object
//__arm920_proc_info:
// .long 0x41009200
// .long 0xff00fff0
// .long 0x00000c1e
// b __arm920_setup
// .long cpu_arch_name
// .long cpu_elf_name
// .long HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB
// .long cpu_arm920_info
// .long arm920_processor_functions
// .size __arm920_proc_info, . - __arm920_proc_info
//--------------
for (list = &__proc_info_begin; list &__proc_info_end ; list++)
if ((processor_id & list->cpu_mask) == list->cpu_val)//很明显能够匹配上
break;
//未匹配时halt系统
if (list >= &__proc_info_end) {
printk("CPU configuration botched (ID %08x), unable "
"to continue.\n", processor_id);
while (1);
}
//cpu_name指向"Arm920Tidwb"字符串
cpu_name = list->info->cpu_name;
#ifdef MULTI_CPU
processor = *list->proc;
#endif
printk("CPU: %s revision %d\n", cpu_name, (int)processor_id & 15);
//system_utsname.machine="armv4l"
sprintf(system_utsname.machine, "%s%c", list->arch_name, ENDIANNESS);
//elf_platform="v4l"
sprintf(elf_platform, "%s%c", list->elf_name, ENDIANNESS);
//elf_hwcap=HWCAP_SWP | HWCAP_HALF | HWCAP_THUMB;
elf_hwcap = list->elf_hwcap;
//include/asm-arm/Cpu-single.h中定义如下
//#define cpu_proc_init cpu_fn(CPU_NAME,_proc_init)
//即#define cpu_proc_init arm920_proc_init
cpu_proc_init();
}
//2.include/asm-arm/Cpu-single.h->cpu_proc_init
arch/arm/mm/proc-arm9200.S->arm920_proc_init
ENTRY(cpu_arm920_proc_init)
mov pc, lr
//很简单,不做任何处理,直接返回
综上,setup_processor()对linux系统中使用到的几个全局量进行初始化,同时打印一些cpu信息
阅读(614) | 评论(0) | 转发(0) |