linux内核自解压分析
linux内核自解压分析
在嵌入式中一般使用压缩内核,所以在bootloader把压缩的内核移到SDRAM中时,先进行自解压
解压以后在调用arch/arm/kernel/head.S,而内核zImage的生成:先生成Image,然后经由gunzip压缩
成piggy.gz,然后和vmlinux.ld.S和head.S链接成zImage
#include
/*
* Debugging stuff
*
* Note that these macros must not contain any code which is not
* 100% relocatable. Any attempt to do so will result in a crash.
* Please select one of the following when turning on debugging.
*/
#ifdef DEBUG
#if defined(CONFIG_DEBUG_ICEDCC)
#ifdef CONFIG_CPU_V6
.macroloadsp, rb
.endm
.macrowriteb, ch, rb
mcrp14, 0, \ch, c0, c5, 0
.endm
#elif defined(CONFIG_CPU_XSCALE)
.macroloadsp, rb
.endm
.macrowriteb, ch, rb
mcrp14, 0, \ch, c8, c0, 0
.endm
#else
.macroloadsp, rb
.endm
.macrowriteb, ch, rb
mcrp14, 0, \ch, c1, c0, 0
.endm
#endif
#else /* CONFIG_DEBUG_ICEDCC */
#include
.macrowriteb,ch, rb
senduart \ch, \rb
.endm
#if defined(CONFIG_ARCH_SA1100)
.macroloadsp, rb
mov\rb, #0@ physical base address
#ifdef CONFIG_DEBUG_LL_SER3
add\rb, \rb, #0@ Ser3
#else
add\rb, \rb, #0@ Ser1
#endif
.endm
#elif defined(CONFIG_ARCH_S3C2410)
.macro loadsp, rb
mov\rb, #0add\rb, \rb, #0x4000 * CONFIG_S3C_LOWLEVEL_UART_PORT
.endm
#else
.macroloadsp,rb
addruart \rb
.endm
#endif
#endif
#endif
.macrokputc,val
movr0, \val
blputc
.endm
.macrokphex,val,len
movr0, \val
movr1, #\len
blphex
.endm
.macrodebug_reloc_start
#ifdef DEBUG
kputc#'\n'
kphexr6, 8/* processor id */
kputc#':'
kphexr7, 8/* architecture id */
#ifdef CONFIG_CPU_CP15
kputc#':'
mrcp15, 0, r0, c1, c0
kphexr0, 8/* control reg */
#endif
kputc#'\n'
kphexr5, 8/* decompressed kernel start */
kputc#'-'
kphexr9, 8/* decompressed kernel end */
kputc#'>'
kphexr4, 8/* kernel execution address */
kputc#'\n'
#endif
.endm
.macrodebug_reloc_end
#ifdef DEBUG
kphexr5, 8/* end of kernel */
kputc