In Electronic Infomation Category: k | on December 13,2010
Code is compiled into the kernel and AD7226KR datasheet and compiled as a module in the code what is the difference? P>
seen from the modules code is the same. Entry functions are MODULE_init (fun), but the code will compile the macro conditions in the module_init () in compiled into the kernel and AD7226KR price and compiled as modules, replace the case of different code. P>
include / linux / init.h the shows P>
# ifndef MODULE P>
... P>
# define module_init (x) ; __initcall (x); P>
... P>
# else / * MODULE * / P>
... P>
/ * Each module must use one module_init (), or one no_module_init * / P>
# define module_init (initfn) \ < / P>
static inline initcall_t __inittest (void) \ P>
{ return initfn;} \ P>
int init_module (void) __attribute__ ((alias (# initfn)) ); P>
... P>
# endif P>
when the code is compiled into a module, MODULE macros are defined, otherwise not. Because in / usr / src / linux / Makefile can see P>
336 MODFLAGS =-DMODULE P>
337 CFLAGS_MODULE ; = $ (MODFLAGS) P>
338 AFLAGS_MODULE = $ (MODFLAGS) P>
export of these two variables has been a global variable. So now you know, when compiled as a module, the macro will MODULE. P>
by the following code to know P>
# define __initcall (fn) device_initcall (fn) P>
# define device_initcall (fn) __define_initcall ("6", fn) P>
085 # define __define_initcall (level, fn) \ P>
086 static initcall_t __initcall_ # # fn __attribute_used__ \ P>
087 __attribute__ ((__section__ ( ". initcall" level ". init"))) = fn P>
the former is actually compiled into the kernel. initcall6.init this section P>
in P> < P> arch/i386/kernel/vmlinux.lds.S can know: P>
083 __initcall_start =.; P>
084. initcall.init: AT ( ADDR (. initcall.init) - LOAD_OFFSET) { P>
085 * (. initcall1.init) P>
086 * (. initcall2.init) P>
087 * (. initcall3.init ) P>
088 * (. initcall4.init) P>
089 * (. initcall5.init) P>
090 * (. initcall6.init) P>
091 * (. initcall7.init) P>
092} P>
093 __initcall_end =.; P>
arch/i386/kernel/vmlinux.lds.S P>
. initcall6.init Shi . initcall.init part of the P>
execution order: P>
start_kernel-> rest_init P>
system starts in the rest_init created in the init kernel thread P>
init-> do_basic_setup-> do_initcalls P>
do_initcalls in the Council to. initcall.init again in the implementation of the function followed by P>
for (call = __initcall_start; call
... P>
( * call )(); P>
... P>
} P>
then performed module_init (fn) function P>
About IcFull.com | Services | Contact Us | Links
All right reserved:icfull.com © 2010-2016 Certificate