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?
BIOS POST. The first step of the Linux boot process really has nothing whatever to do with Linux. This is the hardware portion of the boot process and is the same for any operating system. When power is first applied to the computer it runs the POST (Power On Self Test) which is part of the BIOS (Basic I/O System).
Init process is the mother (parent) of all processes on the system, it's the first program that is executed when the Linux system boots up; it manages all other processes on the system. It is started by the kernel itself, so in principle it does not have a parent process.
I'll assume that you're talking about x86 here...
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.
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
).
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
).
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()
.
It's asmlinkage void __init start_kernel(void)
C function in init/main.c
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With