Skip to contentSkip to conversation

do_initcalls

DISCUSSION ishare 2 participants 6 messages Mar 17, 2013 – Mar 19, 2013

lore
Share & tools
lore

ishare

author
#0 lore raw

for (call = &__initcall_start; call < &__initcall_end; call++)
(*call)();

I want to know where are these function point assigned by specified function ?

thanks!

#1 lore raw
Quoted 7 lines · ishare

for (call = &__initcall_start; call < &__initcall_end; call++)
(*call)();

I want to know where are these function point assigned by specified function ?

thanks!

As per include/asm-generic/vmlinux.lds.h and your arch's vmlinux.lds.S (I actually only looked at x86's), the __initcall_{start,end} variables are the start and end of the __initcall ELF section which contains all the sub-level sections.

Functions can be put into these sections when they are given to one of the *_initcall macros from include/linux/init.h.

Regards,
Tobi

author
#2 lore raw
Quoted 9 lines · Tobias Boege
Quoted 7 lines · ishare

for (call = &__initcall_start; call < &__initcall_end; call++)
(*call)();

I want to know where are these function point assigned by specified function ?

thanks!

Quoted 7 lines

As per include/asm-generic/vmlinux.lds.h and your arch's vmlinux.lds.S (I actually only looked at x86's), the __initcall_{start,end} variables are the start and end of the __initcall ELF section which contains all the sub-level sections.

Functions can be put into these sections when they are given to one of the *_initcall macros from include/linux/init.h.

I have configure kernel supporting rom filesystem ,and register it by module_init(init_romfs_fs) , but why the function : init_romfs_fs not be called from (*call)() ?

thanks!

Quoted 9 lines

Regards,
Tobi

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

#3 lore raw
Quoted 15 lines · ishare
Quoted 14 lines · Tobias Boege
Quoted 7 lines · ishare

for (call = &__initcall_start; call < &__initcall_end; call++)
(*call)();

I want to know where are these function point assigned by specified function ?

thanks!

As per include/asm-generic/vmlinux.lds.h and your arch's vmlinux.lds.S (I actually only looked at x86's), the __initcall_{start,end} variables are the start and end of the __initcall ELF section which contains all the sub-level sections.

Quoted 8 lines
Quoted 2 lines

Functions can be put into these sections when they are given to one of the *_initcall macros from include/linux/init.h.

I have configure kernel supporting rom filesystem ,and register it by module_init(init_romfs_fs) , but why the function : init_romfs_fs not be called from (*call)() ?

thanks!

This is strange - *unless* you build romfs as a module. Have again a look at the aforementioned include/linux/init.h. There's a fairly big comment on the procedure:

/**
* module_init() - driver initialization entry point
* @x: function to be run at kernel boot time or module insertion *
* module_init() will either be called during do_initcalls() (if
* builtin) or at module insertion time (if a module). There can only
* be one per module.
*/

Regards,
Tobi

author
#4 lore raw
Quoted 29 lines · Tobias Boege
Quoted 15 lines · ishare
Quoted 14 lines · Tobias Boege
Quoted 7 lines · ishare

for (call = &__initcall_start; call < &__initcall_end; call++)
(*call)();

I want to know where are these function point assigned by specified function ?

thanks!

As per include/asm-generic/vmlinux.lds.h and your arch's vmlinux.lds.S (I actually only looked at x86's), the __initcall_{start,end} variables are the start and end of the __initcall ELF section which contains all the sub-level sections.

Quoted 8 lines
Quoted 2 lines

Functions can be put into these sections when they are given to one of the *_initcall macros from include/linux/init.h.

I have configure kernel supporting rom filesystem ,and register it by module_init(init_romfs_fs) , but why the function : init_romfs_fs not be called from (*call)() ?

thanks!

This is strange - *unless* you build romfs as a module. Have again a look at the aforementioned include/linux/init.h. There's a fairly big comment on the procedure:

Quoted 8 lines

/**
* module_init() - driver initialization entry point
* @x: function to be run at kernel boot time or module insertion *
* module_init() will either be called during do_initcalls() (if
* builtin) or at module insertion time (if a module). There can only
* be one per module.
*/

Does this mean it chould not be called during do_initcalls if I config it as a module ?

If this ,how to change it to be builtin module?

what is called module insertion time? Is that time I explicitely call some insert function?

thanks!

Quoted 9 lines

Regards,
Tobi

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

#5 lore raw
Quoted 11 lines · ishare
Quoted 8 lines

/**
* module_init() - driver initialization entry point
* @x: function to be run at kernel boot time or module insertion *
* module_init() will either be called during do_initcalls() (if
* builtin) or at module insertion time (if a module). There can only
* be one per module.
*/

Does this mean it chould not be called during do_initcalls if I config it as a module ?

do_initcalls() is done at boot time. If you insert a module into the running kernel, how could its init function be called at boot time?

Quoted 2 lines

If this ,how to change it to be builtin module?

Whether it is compiled as a module or not is a configuration issue. (Please, CMIIW).

Quoted 2 lines

what is called module insertion time? Is that time I explicitely call some insert function?

I hope I got your question right (no, I hope I didn't but anyway here's my answer to it): module insertion time is precisely the time a module is inserted. You'd normally use modprobe or suchlike for this task.

As the comment above states, the function registered via module_init() is called by the kernel's dynamic linker at this point.

I suggest to afford some of the well-known books on the Linux kernel. I believe you can't avoid to do so when trying around with the kernel.

Regards,
Tobi