How does module_init(jpeg_init) get called

m silverstri michael.j.silverstri at gmail.com
Thu Jan 9 14:00:45 EST 2014


Thanks.  The vmlinx is a binary file, I don't see what you show in
your response.

I have another question is where does the kernel find these driver
modules for it to load?
>From the make file, a driver will compile into a .o file?

As an example

$ more Makefile
s5p-jpeg-objs := jpeg-core.o
obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG) += s5p-jpeg.o



On Thu, Jan 9, 2014 at 8:15 AM, Miles MH Chen <orca.chen at gmail.com> wrote:
> Hello Michael,
>
> The module_init call is defined as device_initcall, which is one of kernel
> inicalls.
> All initcalls are put to initcall section and kernel calls all initcalls at
> boot time.
>
> You can check this in your vmlinux:
>
> ffffffff81765ed8 T __initcall_start
> ffffffff81765ed8 T __setup_end
> ffffffff81765ee0 t __initcall_trace_init_flags_sys_exitearly
> ffffffff81765ee8 t __initcall_trace_init_flags_sys_enterearly
> ffffffff81765ef0 t __initcall_init_hw_perf_eventsearly
> ffffffff81765ef8 t __initcall_register_trigger_all_cpu_backtraceearly
> ffffffff81765f00 t __initcall_spawn_ksoftirqdearly
> ffffffff81765f08 t __initcall_init_workqueuesearly
> ffffffff81765f10 t __initcall_check_cpu_stall_initearly
> ffffffff81765f18 t __initcall_migration_initearly
> ...
>
> kernel calls do_initcalls in do_basic_setup
>
> 783 static void __init do_basic_setup(void)
> 784 {
> 785         cpuset_init_smp();
> 786         usermodehelper_init();
> 787         shmem_init();
> 788         driver_init();
> 789         init_irq_proc();
> 790         do_ctors();
> 791         usermodehelper_enable();
> 792         do_initcalls();
> 793         random_int_secret_init();
> 794 }
>
> Regards,
> MH
>
>
>
> On Thu, Jan 9, 2014 at 10:25 AM, m silverstri
> <michael.j.silverstri at gmail.com> wrote:
>>
>> Hi,
>>
>> In a kernel driver code, I see it has 'module_init(jpeg_init)' and
>> 'module_exit(jpeg_exit)'.  I would like how know how will
>> jpeg_init(void) gets call during kernel bring up.
>>
>> As an example:
>> static int __init jpeg_init(void)
>> {
>> printk(KERN_CRIT "Initialize JPEG driver\n");
>>
>> platform_driver_register(&jpeg_driver);
>>
>> return 0;
>> }
>>
>> static void __exit jpeg_exit(void)
>> {
>> platform_driver_unregister(&jpeg_driver);
>> }
>>
>> module_init(jpeg_init);
>> module_exit(jpeg_exit);
>>
>> Thank you.
>>
>> _______________________________________________
>> Kernelnewbies mailing list
>> Kernelnewbies at kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>



More information about the Kernelnewbies mailing list