linux 解压后会跳转到,kernel执行地址: head.S中入口执行。解压之前的操作流程呢?
1. linux kernel 被uboot load到内存后的入口函数
arch/arm/boot/compressed/vmlinux.lds.in中定义了linux 入口:
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
{
....
这里的start定义在 arch/arm/boot/compressed/head.s中
start:
.type start,#function
.rept 7
mov r0, r0
.endr
ARM( mov r0, r0 )
ARM( b 1f )
THUMB( adr r12, BSYM(1f) )
THUMB( bx r12 )
.word 0x016f2818 @ Magic numbers to help the loader
.word start @ absolute load/run zImage address
.word _edata @ zImage end address
THUMB( .thumb )
1: mov r7, r1 @ save architecture ID
mov r8, r2 @ save atags pointer
......
*
* The C runtime environment should now be setup sufficiently.
* Set up some pointers, and start decompressing.
* r4 = kernel execution address
* r7 = architecture ID
* r8 = atags pointer
*/
mov r0, r4
mov r1, sp @ malloc space above stack
add r2, sp, #0x10000 @ 64k max
mov r3, r7
bl decompress_kernel
bl cache_clean_flush
bl cache_off
mov r0, #0 @ must be zero
mov r1, r7 @ restore architecture number
mov r2, r8 @ restore atags pointer
mov pc, r4 @ call kernel
decompress_kernel实现在misc.c中,可以看到,misc中同样定义了
unsigned int __machine_arch_type; 这个在kernel的setup.c中已经有定义了?unsigned int __machine_arch_type __read_mostly;
因此, 可以看到arch\arm\boot\compressed中代码编译是独立于kernel image的