Linux Kernel Architecture

(Jacob Rumans) #1
Mauerer app04.tex V1 - 09/04/2008 6:12pm Page 1239

Appendix D: System Startup


is held inexecute_commandwhen the command line is parsed). If none of the options functions, a kernel
panic is triggered because the system is unusable, as shown here:

init/main.c
static int noinline init_post(void)
{
if (execute_command) {
run_init_process(execute_command);
printk(KERN_WARNING "Failed to execute %s. Attempting "
"defaults...\n", execute_command);
}
run_init_process("/sbin/init");
run_init_process("/etc/init");
run_init_process("/bin/init");
run_init_process("/bin/sh");

panic("No init found. Try passing init= option to kernel.");
}

run_init_postsets up a minimal environment for theinitprocessasfollows:

init/main.c
static char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };

static void run_init_process(char *init_filename)
{
argv_init[0] = init_filename;
kernel_execve(init_filename, argv_init, envp_init);
}

kernel_execveis a wrapper for thesys_execvesystem call, which must be provided by each
architecture.

D.3 Summary


Booting the Linux kernel is a highly architecture-specific process, at least for the initial stages. This
chapter introduced you to some of the intricacies toget a kernel up and running on IA-32 systems. Addi-
tionally, this chapter discussed the higher-level startup process in which the kernel sets up the hardware
step-by-step until it can finally invoke the first userland process (usually/sbin/init) and can commence
its regular execution.
Free download pdf