Skip to contentSkip to conversation

Module init for compiled in vs loaded modules

DISCUSSION Fundu 2 participants 2 messages Aug 19, 2008 – Aug 20, 2008

lore
Share & tools
lore

Fundu

author
#0 lore raw
Quoted 26 lines

linux/init.h:

#ifndef MODULE
...
#define module_init(x) __initcall(x);
#define __initcall(fn) device_initcall(fn) #define device_initcall(fn) __define_initcall("6",fn)
#define __define_initcall(level,fn) \
static initcall_t __initcall_##fn __attribute_used__

\
    __attribute__((__section__(".initcall" level

".init"))) = fn
...
#endif

initcalls are processed in do_initcalls function in init/main.c

static void __init do_basic_setup(void)

{
    ....
    do_initcalls();
}
Quoted 1 line
Quoted 3 lines
Quoted 1 line

thanks !

Amol

thanks Rajat and Amol.

One other question,
1) how does the kernel know which module to load first in order to satisfy dependencies issues ?
2) is there a way i could print the module init fn name from do_initcalls. to see in what order compiled in modules are called.

tia.

#1 lore raw
Quoted 26 lines · Fundu
Quoted 26 lines

linux/init.h:

#ifndef MODULE
...
#define module_init(x) __initcall(x);
#define __initcall(fn) device_initcall(fn) #define device_initcall(fn) __define_initcall("6",fn)
#define __define_initcall(level,fn) \
static initcall_t __initcall_##fn __attribute_used__

\
    __attribute__((__section__(".initcall" level

".init"))) = fn
...
#endif

initcalls are processed in do_initcalls function in init/main.c

static void __init do_basic_setup(void)

{
    ....
    do_initcalls();
}
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

thanks !

Amol

thanks Rajat and Amol.

One other question,
1) how does the kernel know which module to load first in order to satisfy dependencies issues ?

By looking at the needed symbols (cfr. depmod).

Quoted 1 line

2) is there a way i could print the module init fn name from do_initcalls. to see in what order compiled in modules are called.

Add `initcall_debug' to the kernel command line (if you would have looked at do_initcalls() and do_one_initcall(), you would have known).

With kind regards,

Geert Uytterhoeven
Software Architect

Sony Techsoft Centre Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium

Phone:    +32 (0)2 700 8453
Fax:      +32 (0)2 700 8622
E-mail:   [email protected]
Internet: http://www.sony-europe.com/

A division of Sony Europe (Belgium) N.V.
VAT BE 0413.825.160 · RPR Brussels
Fortis · BIC GEBABEBB · IBAN BE41293037680010