Linux Kernel Architecture

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

Appendix D: System Startup


}

result = (*call)();
...
}

/* Make sure there is no pending stuff from the initcall sequence */
flush_scheduled_work();
}

Basically, the code iterates through all entries in the.initcallsection whose boundaries are indicated
by the variables defined automatically by the linker. The addresses of the functions are extracted, and the
functions are invoked. Once all initcalls have been executed, the kernel usesflush_scheduled_workto
flush any remainingkeventdwork queue entries that may have been created by the routines.

Removing Initialization Data


Functions to initialize data structures and devices are normally needed only when the kernel is booted
and are never invoked again. To indicate this explicitly, the kernel defines the__initattribute, which
is prefixed to the function declaration as shown previously in the kernel source sections. The attribute is
defined as follows:

<init.h>
#define __init __attribute__ ((__section__ (".init.text"))) __cold
#define __initdata __attribute__ ((__section__ (".init.data")))

The kernel also enables data to be declared as initialization data by means of the__initdataattribute.

The linker writes functions labeled with__initor__initdatato a specific section of the binary file as
follows (linker scripts on other architectures are almost identical to the Alpha version shown here):

arch/alpha/kernel/vmlinux.lds.S
/* Will be freed after init */

. = ALIGN(PAGE_SIZE);
/ Init code and data /
init_begin = .;
.init.text : {
_sinittext = .;
(.init.text)
_einittext = .;
}
.init.data : {
(.init.data)
}
. = ALIGN(16);
.init.setup : {
__setup_start = .;
*(.init.setup)
setup_end = .;
}
. = ALIGN(8);
.initcall.init : {

Free download pdf