Jee*_*tel 3 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
Run Code Online (Sandbox Code Playgroud)
我不明白这是什么..?这是一个宏或结构还是什么..???
定义说
/*
* 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
Run Code Online (Sandbox Code Playgroud)
但我不明白它是如何工作的?
指定的结构初始化是一个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,
};
Run Code Online (Sandbox Code Playgroud)