2012-03-09 56 views
3

我發現這個Linux內核代碼http://gitorious.org/pandroid/kernel-omap/blobs/5ed7607d45b300a37dd13ad1c79adea56f6687ce/arch/arm/mach-omap2/board-omap4panda.c這是Linux內核代碼中的任何一種宏嗎?

MACHINE_START(OMAP4_PANDA, "OMAP4430 Panda Board") 
    .phys_io = 0x48000000, 
    .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc, 
    .boot_params = 0x80000100, 
    .map_io  = omap_panda_map_io, 
    .init_irq = omap_panda_init_irq, 
    .init_machine = omap_panda_init, 
    .timer  = &omap_timer, 
MACHINE_END 

我沒有得到這算什麼..?這是一個宏或結構或什麼..?

定義說

/* 
* Set of macros to define architecture features. This is built into 
* a table by the linker. 
*/ 
#define MACHINE_START(_type,_name)   \ 
static const struct machine_desc __mach_desc_##_type \ 
__used       \ 
__attribute__((__section__(".arch.info.init"))) = { \ 
    .nr  = MACH_TYPE_##_type,  \ 
    .name  = _name, 

#define MACHINE_END    \ 
}; 

#endif 

,但我不理解最近怎麼工作的?

+4

搜索「#define MACHINE_START」需要多長時間? – 2012-03-09 07:51:12

+0

@Damien_The_Unbeliever「大約19,100個結果(** 0.30秒**)」;-)) – 2012-03-09 07:57:30

+3

您應該學習如何獲取源代碼的預處理形式。在編譯命令中將'gcc'替換爲'gcc -C -E',您將得到* stdout *上的預處理表單。 – 2012-03-09 08:14:40

回答

4

designated structure initialization是一個GNU GCC擴展,如果你習慣ANSI C編譯器,看起來有點奇怪。這與宏大的宏觀相結合使得它在很多方面看起來像一門外語。擴展的源代碼是:

static const struct machine_desc __mach_desc_OMAP4_PANDA 
__used __attribute__((__section__(".arch.info.init"))) = { 
    .nr  = MACH_TYPE_OMAP4_PANDA, 
    .name   = "OMAP4430 Panda Board", 
    .phys_io  = 0x48000000, 
    .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc, 
    .boot_params = 0x80000100, 
    .map_io  = omap_panda_map_io, 
    .init_irq  = omap_panda_init_irq, 
    .init_machine = omap_panda_init, 
    .timer  = &omap_timer, 
}; 
0

它是初始化結構對象的指定初始值設定項。