Is this some kind of macro in the 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 don't understand what is it? is it a macro or structure or what .. ???

definition

/*
 * 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 don't understand how it works?

+3


source to share


3 answers


the designated struct initialization is a GNU GCC extension that looks a little odd if you're used to ANSI C compilers. This, combined with an ambitious macro, makes it look a lot like a foreign language. Extended source code:



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

      

+4


source


MACHINE_START

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

MACHINE_END



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

I use this site for Linux kernel links http://lxr.free-electrons.com/

+1


source


It is a notation initializer that initializes the struct object.

0


source







All Articles