这是linux内核代码中的任何一种宏吗?

时间:2012-03-09 07:49:13

标签: c linux linux-kernel

我在linux内核代码http://gitorious.org/pandroid/kernel-omap/blobs/5ed7607d45b300a37dd13ad1c79adea56f6687ce/arch/arm/mach-omap2/board-omap4panda.c

中找到了这个
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

但我不明白它是如何运作的?

3 个答案:

答案 0 :(得分: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,
};

答案 1 :(得分:2)

<强> MACHINE_START

在以下位置定义为预处理器宏: arch/arm/include/asm/mach/arch.h, line 67

<强> MACHINE_END

在以下位置定义为预处理器宏: arch/arm/include/asm/mach/arch.h, line 74

我将此站点用于Linux内核引用 http://lxr.free-electrons.com/

答案 2 :(得分:0)

这是一个初始化结构对象的指定初始值设定项。