进入了vmlinux内核映像部分,就进入了arch/x86/compressed/head_32.S。这个文件主要工作就是解压了,将真正的内核给释放出来,不过还得把这个文件分析完,内核才能出世。
来自arch/x86/compressed/head_32.S:
........省略了头文件......
__HEAD
ENTRY(startup_32)
cld /*di,si++*/
/*
* Test KEEP_SEGMENTS flag to see if the bootloader is asking
* us to not reload segments
*/
testb $(1<<6), BP_loadflags(%esi) /*esi = boot_params*/
jnz 1f
# esi是之前就设置好了的,boot_params结构体的首地址,而loadflags的位6如果置位,则表示需要将段寄存器重新载入
cli /*close interrupt*/
movl $__BOOT_DS, %eax
movl %eax, %ds
movl %eax, %es
movl %eax, %fs
movl %eax, %gs
movl %eax, %ss
1:
/*
* Calculate the delta between where we were compiled to run
* at and where we were actually loaded at. This can only be done
* with a short local call on x86. Nothing else will tell us what
* address we are running at. The reserved chunk of the real-mode
* data at 0x1e4 (defined as a scratch field) are used as the stack
* for this calculation. Only 4 bytes are needed.
*/
leal (BP_scratch+4)(%esi), %esp /*boot_params->scratch*/
call 1f
1: popl %ebp
subl &nb
linux内核学习(12)启动全过程概述之三
最新推荐文章于 2021-12-19 13:35:36 发布