linux kernel decompress_kernel 啟動解壓
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 )
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的
---------------------
作者:thegameisfives
來源:CSDN
原文:https://blog.csdn.net/thegameisfives/article/details/9019503
版權宣告:本文為博主原創文章,轉載請附上博文連結!