什么是第一次操作Linux内核在启动执行? [英] What are the first operations that the Linux Kernel executes on boot?

查看:155
本文介绍了什么是第一次操作Linux内核在启动执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在引导装载程序执行的手到内核中,会发生什么?我知道汇编程序,那么什么是前几个指令,内核必须做什么呢?还是有,这是否一个C函数?什么是内核前的启动顺序,可以执行任意的二进制?

After the boot loader hands execution over to the kernel, what happens? I know assembler, so what are the first few instructions that a kernel must make? Or is there a C function that does this? What is the startup sequence before the kernel can execute an arbitrary binary?

推荐答案

我会假设你在这里谈论的x86 ...

I'll assume that you're talking about x86 here...

这要看你考虑引导管理器和仁之间的边界是:内核正确的起点是32位保护模式code,但内核本身提供了一些启动code从实模式到那里。

It depends where you consider the boundary between "boot loader" and "kernel" to be: the start of the kernel proper is 32-bit protected mode code, but the kernel itself provides some boot code to get there from real mode.

在实模式code在 弓/ 86的/ boot / start_of_setup 确实对于C环境的一些基本设置和来电的 的main() ,该做一些比较枯燥的东西,与实际跳转到保护模式结束(看到 pmjump.S )。

The real mode code is in arch/x86/boot/: start_of_setup does some basic setup of the environment for C, and calls main(), which does some fairly dull stuff, ending with the actual jump to protected mode (see pmjump.S).

如果你结束了,现在取决于内核是否为COM pressed。如果它是,该条目点实际上是一个自DECOM pression例程。这是相当枯燥的东西为好,基本上是透明的:DECOM pression code和COM pressed内核被移到更高的内存了出来的方法,那么内核pssed到uncom $ P $原来的位置,然后跳进仿佛它已经uncom pressed始终。这code是在<一个href=\"http://lxr.linux.no/linux+v2.6.33/arch/x86/boot/com$p$pssed/\"><$c$c>arch/x86/boot/com$p$pssed/ (入口点是<一个href=\"http://lxr.linux.no/linux+v2.6.33/arch/x86/boot/com$p$pssed/head_32.S#L34\"><$c$c>startup_32在<一个href=\"http://lxr.linux.no/linux+v2.6.33/arch/x86/boot/com$p$pssed/head_32.S\"><$c$c>head_32.S).

Where you end up now depends on whether or not the kernel is compressed. If it is, the entry point is actually a self-decompression routine. This is fairly dull stuff as well, and essentially transparent: the decompression code and compressed kernel are moved higher up in memory out of the way, then the kernel is uncompressed to the original location, and then jumped into as if it had been uncompressed all along. This code is in arch/x86/boot/compressed/ (the entry point is startup_32 in head_32.S).

内核真正得到在 要正确的startup_32 在<一个href=\"http://lxr.linux.no/linux+v2.6.33/arch/x86/kernel/head_32.S\"><$c$c>arch/x86/kernel/head_32.S.在code有通过调用<一结束href=\"http://lxr.linux.no/linux+v2.6.33/arch/x86/kernel/head32.c#L30\"><$c$c>i386_start_kernel()在<一个href=\"http://lxr.linux.no/linux+v2.6.33/arch/x86/kernel/head32.c\"><$c$c>arch/x86/kernel/head32.c,并最终调用 的start_kernel通用内核启动code( )

The kernel really gets going properly at startup_32 in arch/x86/kernel/head_32.S. The code there ends up by calling i386_start_kernel() in arch/x86/kernel/head32.c, which finally calls the generic kernel startup code in start_kernel().

这篇关于什么是第一次操作Linux内核在启动执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆