Jeegar Patel
Jeegar Patel

Reputation: 27240

Is this any kind of macro in linux kernel code?

i found this in linux kernel code 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

i am not getting what is this..? is this a macro or structure or what..???

definition says

/*
 * 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

but i am not understanding how's it work?

Upvotes: 3

Views: 2731

Answers (3)

wallyk
wallyk

Reputation: 57794

The designated structure initialization is a GNU GCC extension which looks a bit strange if you are used to ANSI C compilers. That combined with an ambitious macro makes it look like a foreign language in many respects. The expanded source code is:

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,
};

Upvotes: 5

Pavan Manjunath
Pavan Manjunath

Reputation: 28565

MACHINE_START

Defined as a preprocessor macro in: arch/arm/include/asm/mach/arch.h, line 67

MACHINE_END

Defined as a preprocessor macro in: arch/arm/include/asm/mach/arch.h, line 74

I use this site for Linux Kernel references http://lxr.free-electrons.com/

Upvotes: 2

ouah
ouah

Reputation: 145899

It's a designation initializer that initializes a structure object.

Upvotes: 0

Related Questions