* Regarding module init function @ 2013-01-04 11:18 Rahul Bedarkar 2013-01-04 13:22 ` Tobias Boege 0 siblings, 1 reply; 11+ messages in thread From: Rahul Bedarkar @ 2013-01-04 11:18 UTC (permalink / raw) To: kernelnewbies 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. Thanks, Rahul -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130104/21e50c31/attachment.html ^ permalink raw reply [flat|nested] 11+ messages in thread
* Regarding module init function 2013-01-04 11:18 Regarding module init function Rahul Bedarkar @ 2013-01-04 13:22 ` Tobias Boege 2013-01-08 8:40 ` Rahul Bedarkar 0 siblings, 1 reply; 11+ messages in thread From: Tobias Boege @ 2013-01-04 13:22 UTC (permalink / raw) To: kernelnewbies 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Regarding module init function 2013-01-04 13:22 ` Tobias Boege @ 2013-01-08 8:40 ` Rahul Bedarkar 2013-01-08 10:08 ` Rahul Bedarkar 0 siblings, 1 reply; 11+ messages in thread From: Rahul Bedarkar @ 2013-01-08 8:40 UTC (permalink / raw) To: kernelnewbies 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 <tobias@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 at kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130108/13c6cabf/attachment.html ^ permalink raw reply [flat|nested] 11+ messages in thread
* Regarding module init function 2013-01-08 8:40 ` Rahul Bedarkar @ 2013-01-08 10:08 ` Rahul Bedarkar 2013-01-08 13:31 ` Dave Hylands 2013-01-08 13:51 ` Tobias Boege 0 siblings, 2 replies; 11+ messages in thread From: Rahul Bedarkar @ 2013-01-08 10:08 UTC (permalink / raw) To: kernelnewbies 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 <rpal143@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 <tobias@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 at kernelnewbies.org >> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130108/421e4244/attachment.html ^ permalink raw reply [flat|nested] 11+ messages in thread
* Regarding module init function 2013-01-08 10:08 ` Rahul Bedarkar @ 2013-01-08 13:31 ` Dave Hylands 2013-01-08 13:50 ` Rahul Bedarkar 2013-01-08 13:51 ` Tobias Boege 1 sibling, 1 reply; 11+ messages in thread From: Dave Hylands @ 2013-01-08 13:31 UTC (permalink / raw) To: kernelnewbies Hi, On Tue, Jan 8, 2013 at 11:08 AM, Rahul Bedarkar <rpal143@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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130108/d5cff252/attachment.html ^ permalink raw reply [flat|nested] 11+ messages in thread
* Regarding module init function 2013-01-08 13:31 ` Dave Hylands @ 2013-01-08 13:50 ` Rahul Bedarkar 2013-01-08 14:33 ` Dave Hylands 0 siblings, 1 reply; 11+ messages in thread From: Rahul Bedarkar @ 2013-01-08 13:50 UTC (permalink / raw) To: kernelnewbies 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 <dhylands@gmail.com> wrote: > Hi, > > > > On Tue, Jan 8, 2013 at 11:08 AM, Rahul Bedarkar <rpal143@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<http://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#L175<http://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#L633<http://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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130108/826c71e7/attachment-0001.html ^ permalink raw reply [flat|nested] 11+ messages in thread
* Regarding module init function 2013-01-08 13:50 ` Rahul Bedarkar @ 2013-01-08 14:33 ` Dave Hylands 0 siblings, 0 replies; 11+ messages in thread From: Dave Hylands @ 2013-01-08 14:33 UTC (permalink / raw) To: kernelnewbies Hi Rahul, On Tue, Jan 8, 2013 at 2:50 PM, Rahul Bedarkar <rpal143@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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130108/cacb7960/attachment.html ^ permalink raw reply [flat|nested] 11+ messages in thread
* Regarding module init function 2013-01-08 10:08 ` Rahul Bedarkar 2013-01-08 13:31 ` Dave Hylands @ 2013-01-08 13:51 ` Tobias Boege 2013-01-08 16:44 ` anish kumar 1 sibling, 1 reply; 11+ messages in thread From: Tobias Boege @ 2013-01-08 13:51 UTC (permalink / raw) To: kernelnewbies 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Regarding module init function 2013-01-08 13:51 ` Tobias Boege @ 2013-01-08 16:44 ` anish kumar 2013-01-10 8:47 ` Tobias Boege 0 siblings, 1 reply; 11+ messages in thread From: anish kumar @ 2013-01-08 16:44 UTC (permalink / raw) To: kernelnewbies 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 at kernelnewbies.org > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies ^ permalink raw reply [flat|nested] 11+ messages in thread
* Regarding module init function 2013-01-08 16:44 ` anish kumar @ 2013-01-10 8:47 ` Tobias Boege 2013-01-12 5:49 ` Dave Hylands 0 siblings, 1 reply; 11+ messages in thread From: Tobias Boege @ 2013-01-10 8:47 UTC (permalink / raw) To: kernelnewbies 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 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Regarding module init function 2013-01-10 8:47 ` Tobias Boege @ 2013-01-12 5:49 ` Dave Hylands 0 siblings, 0 replies; 11+ messages in thread From: Dave Hylands @ 2013-01-12 5:49 UTC (permalink / raw) To: kernelnewbies Hi Tobais, On Thu, Jan 10, 2013 at 9:47 AM, Tobias Boege <tobias@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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130112/df760e60/attachment.html ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2013-01-12 5:49 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-01-04 11:18 Regarding module init function Rahul Bedarkar 2013-01-04 13:22 ` Tobias Boege 2013-01-08 8:40 ` Rahul Bedarkar 2013-01-08 10:08 ` Rahul Bedarkar 2013-01-08 13:31 ` Dave Hylands 2013-01-08 13:50 ` Rahul Bedarkar 2013-01-08 14:33 ` Dave Hylands 2013-01-08 13:51 ` Tobias Boege 2013-01-08 16:44 ` anish kumar 2013-01-10 8:47 ` Tobias Boege 2013-01-12 5:49 ` Dave Hylands
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).