2012-03-09 59 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

它是初始化结构对象的指定初始值设定项。

相关问题