Linux Kernel Architecture

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

Appendix D: System Startup


typedef int (*param_get_fn)(char *buffer, struct kernel_param *kp);

struct kernel_param {
const char *name;
param_set_fn set;
param_get_fn get;
union {
void *arg;
const struct kparam_string *str;
const struct kparam_array *arr;
};
};

namegives the name of the parameter, and thesetandgetfunctions set and read the parameter value.
argis an (optional) argument that is also passed to the preceding functions. As expected, it allows the
same function to be used for different parameters. The pointer can also be specifically interpreted as a
string or an array.

Parameters are registered with the kernel by the following macros:module_param,module_param_named,
and so on. They fill an instance ofkernel_paramwith the appropriate values and write them to the
__paramsection of the binary file.

This greatly simplifies parameter interpretation at boot time. All that is needed is a loop that performs
the following actions until all parameters have been processed:


  1. next_argextracts the next name/value pair from the command line provided by the kernel
    in the form of a text string.

  2. parse_oneruns through the list of all registered parameters, compares the value passed with
    thenameelement of thekernel_paraminstances, and invokes thesetfunction when a match
    is found.


InitializingCentral Data Structuresand Caches


As a quick glance at the following kernel sources shows, the most substantial task ofstart_kernelis to
invoke subroutines to initialize almost all important kernel subsystems:

init/main.c
asmlinkage void __init start_kernel(void)
{
...
trap_init();
rcu_init();
init_IRQ();
pidhash_init();
sched_init();
init_timers();
hrtimers_init();
softirq_init();
timekeeping_init();
time_init();
profile_init();
...
Free download pdf