- Macros exist that are used to mark some functions or intialized data as 'initialization functions'.
N.B. This does not apply to uninitialized data.
- The kernel can take this as hint that the function is used only during the initialization
phase and free up used memory resources after usage.
1) For functions:
You should add __init immediately before the function name, like:
static void __init initme(int x, int y)
{
extern int z; z = x * y;
}
If the function has a prototype somewhere, you can also add
__init between closing brace of the prototype and semicolon:
extern int initialize_foobar_device(int, int, int) __init;
2) For initialized data:
You should insert __initdata between the variable name and equal
sign followed by value, e.g.:
static int init_variable __initdata = 0;
static char linux_logo[] __initdata = { 0x32, 0x36, ... };
IMP!! Don't forget to initialize data not at file scope, i.e. within a function,
as gcc otherwise puts the data into the bss section and not into the init
section.
IMP!! Also note, that this data cannot be "const".
Source : Linux Kernel Documentation
Refer file include/linux/init.h
Line No. 8
Search This Blog
Wednesday, September 9, 2009
Subscribe to:
Post Comments (Atom)
1 comments:
Hey nice blog ! Very Informative :)
Keep writing :)
Post a Comment