Re: Regarding module init function
Hi Tobais, On Thu, Jan 10, 2013 at 9:47 AM, Tobias Boege tob...@gambas-buch.de wrote: On Tue, 08 Jan 2013, anish kumar wrote: On Tue, 2013-01-08 at 14:51 +0100, Tobias Boege wrote: ...snip... On Tue, 08 Jan 2013, Rahul Bedarkar wrote: It's, too, in the init.h. There are two definitions of module_init() depending on whether MODULE is declared or not. The first definition is How does the individual driver define this MODULE?I think some macro magic works here. I suppose that this is done through the invocation of the preprocessor, using -DMODULE depending on whether the target is built-in or a module. Exactly. -- Dave Hylands Shuswap, BC, Canada http://www.davehylands.com ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Regarding module init function
On Tue, 08 Jan 2013, anish kumar wrote: On Tue, 2013-01-08 at 14:51 +0100, Tobias Boege wrote: On Tue, 08 Jan 2013, Rahul Bedarkar wrote: Ok. in init/main.c we call do_basic_setup(). Where do_initcalls call each of init functions from __early_initcall_end to __initcall_end. But I don't know from where these values gets initialized. Take a look at include/linux/init.h. There you can find the macros for declaring various init functions. They all go into special sections. The rest is linker magic (e.g. arch/x86/kernel/vmlinux.lds{,.S}). I want to know when one of auxdriver (selected in from menuconfig) is built as built-in module. When and Who calls it's init function ? It's, too, in the init.h. There are two definitions of module_init() depending on whether MODULE is declared or not. The first definition is How does the individual driver define this MODULE?I think some macro magic works here. I suppose that this is done through the invocation of the preprocessor, using -DMODULE depending on whether the target is built-in or a module. Regards, Tobi ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Regarding module init function
I have gone through LDD3 page 31. But it didn't answer my question. It is describing module init and exit when manually loading driver and removing it. I want to know when one of auxdriver (selected in from menuconfig) is built as built-in module. When and Who calls it's init function ? Thanks, Rahul On Fri, Jan 4, 2013 at 6:52 PM, Tobias Boege tob...@gambas-buch.de wrote: On Fri, 04 Jan 2013, Rahul Bedarkar wrote: Hi, This may be stupid question. When we compile external module and insert it, it's init function is called and when we remove it, it's exit function gets called. What happens in case of built-in modules? When it's init and exit is called? May be take example of one of auxdriver. You can find relevant information in LDD3, pp. 31 ff.. Basically, there is no difference in the use of the init function (it's called at kernel startup, I suppose) but exit is simply discarded in this case, because if your module is built-in, it could never be removed. Regards, Tobi ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Regarding module init function
Ok. in init/main.c we call do_basic_setup(). Where do_initcalls call each of init functions from __early_initcall_end to __initcall_end. But I don't know from where these values gets initialized. On Tue, Jan 8, 2013 at 2:10 PM, Rahul Bedarkar rpal...@gmail.com wrote: I have gone through LDD3 page 31. But it didn't answer my question. It is describing module init and exit when manually loading driver and removing it. I want to know when one of auxdriver (selected in from menuconfig) is built as built-in module. When and Who calls it's init function ? Thanks, Rahul On Fri, Jan 4, 2013 at 6:52 PM, Tobias Boege tob...@gambas-buch.dewrote: On Fri, 04 Jan 2013, Rahul Bedarkar wrote: Hi, This may be stupid question. When we compile external module and insert it, it's init function is called and when we remove it, it's exit function gets called. What happens in case of built-in modules? When it's init and exit is called? May be take example of one of auxdriver. You can find relevant information in LDD3, pp. 31 ff.. Basically, there is no difference in the use of the init function (it's called at kernel startup, I suppose) but exit is simply discarded in this case, because if your module is built-in, it could never be removed. Regards, Tobi ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Regarding module init function
Hi, On Tue, Jan 8, 2013 at 11:08 AM, Rahul Bedarkar rpal...@gmail.com wrote: Ok. in init/main.c we call do_basic_setup(). Where do_initcalls call each of init functions from __early_initcall_end to __initcall_end. But I don't know from where these values gets initialized. If you look here: http://lxr.linux.no/#linux+v3.7.1/include/linux/init.h#L279 module_init is mapped to __initcall, which is in turn mapped to device_initcall, which sets up a pointer in a section called .initcall6.init If you then look in the kernel linker script: http://lxr.linux.no/#linux+v3.7.1/arch/arm/kernel/vmlinux.lds.S#L175 INIT_CALLS is defined here: http://lxr.linux.no/#linux+v3.7.1/include/asm-generic/vmlinux.lds.h#L633 and it defines the __initcall_start and __initcall_end symbols. Dave Hylands ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Regarding module init function
Thanks Dave! I just verified that from System.map. Between __early_initcall_end and __initcall_end, there is list of init calls with levels from 0-7. What is significance of these levels. Thanks, Rahul On Tue, Jan 8, 2013 at 7:01 PM, Dave Hylands dhyla...@gmail.com wrote: Hi, On Tue, Jan 8, 2013 at 11:08 AM, Rahul Bedarkar rpal...@gmail.com wrote: Ok. in init/main.c we call do_basic_setup(). Where do_initcalls call each of init functions from __early_initcall_end to __initcall_end. But I don't know from where these values gets initialized. If you look here: http://lxr.linux.no/#linux+v3.7.1/include/linux/init.h#L279http://lxr.linux.no/#linux+v3.7.1/include/linux/init.h%23L279 module_init is mapped to __initcall, which is in turn mapped to device_initcall, which sets up a pointer in a section called .initcall6.init If you then look in the kernel linker script: http://lxr.linux.no/#linux+v3.7.1/arch/arm/kernel/vmlinux.lds.S#L175http://lxr.linux.no/#linux+v3.7.1/arch/arm/kernel/vmlinux.lds.S%23L175 INIT_CALLS is defined here: http://lxr.linux.no/#linux+v3.7.1/include/asm-generic/vmlinux.lds.h#L633http://lxr.linux.no/#linux+v3.7.1/include/asm-generic/vmlinux.lds.h%23L633 and it defines the __initcall_start and __initcall_end symbols. Dave Hylands ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Regarding module init function
On Tue, 08 Jan 2013, Rahul Bedarkar wrote: Ok. in init/main.c we call do_basic_setup(). Where do_initcalls call each of init functions from __early_initcall_end to __initcall_end. But I don't know from where these values gets initialized. Take a look at include/linux/init.h. There you can find the macros for declaring various init functions. They all go into special sections. The rest is linker magic (e.g. arch/x86/kernel/vmlinux.lds{,.S}). I want to know when one of auxdriver (selected in from menuconfig) is built as built-in module. When and Who calls it's init function ? It's, too, in the init.h. There are two definitions of module_init() depending on whether MODULE is declared or not. The first definition is accompanied by a useful comment about where the init function is called in either case. Regards, Tobi ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Regarding module init function
Hi Rahul, On Tue, Jan 8, 2013 at 2:50 PM, Rahul Bedarkar rpal...@gmail.com wrote: Thanks Dave! I just verified that from System.map. Between __early_initcall_end and __initcall_end, there is list of init calls with levels from 0-7. What is significance of these levels. The levels basically just control the order that the initcalls are made. Basically, all level 0 functions are called befor level 1 functions, etc. The meaning behind the levels can be discerned from the macros in init.h http://lxr.linux.no/#linux+v3.7.1/include/linux/init.h#L207 There is also some docs here: http://lxr.linux.no/#linux+v3.7.1/Documentation/DocBook/kernel-hacking.tmpl#L736 Dave Hylands ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Regarding module init function
On Tue, 2013-01-08 at 14:51 +0100, Tobias Boege wrote: On Tue, 08 Jan 2013, Rahul Bedarkar wrote: Ok. in init/main.c we call do_basic_setup(). Where do_initcalls call each of init functions from __early_initcall_end to __initcall_end. But I don't know from where these values gets initialized. Take a look at include/linux/init.h. There you can find the macros for declaring various init functions. They all go into special sections. The rest is linker magic (e.g. arch/x86/kernel/vmlinux.lds{,.S}). I want to know when one of auxdriver (selected in from menuconfig) is built as built-in module. When and Who calls it's init function ? It's, too, in the init.h. There are two definitions of module_init() depending on whether MODULE is declared or not. The first definition is How does the individual driver define this MODULE?I think some macro magic works here. accompanied by a useful comment about where the init function is called in either case. Regards, Tobi ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
Re: Regarding module init function
On Fri, 04 Jan 2013, Rahul Bedarkar wrote: Hi, This may be stupid question. When we compile external module and insert it, it's init function is called and when we remove it, it's exit function gets called. What happens in case of built-in modules? When it's init and exit is called? May be take example of one of auxdriver. You can find relevant information in LDD3, pp. 31 ff.. Basically, there is no difference in the use of the init function (it's called at kernel startup, I suppose) but exit is simply discarded in this case, because if your module is built-in, it could never be removed. Regards, Tobi ___ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies