每一个machine,都要定义一个自己的machine_desc结构,该结构定义了该machine的一些最基本的特性。
struct machine_desc { unsigned int nr; /* architecture number */ const char *name; /* architecture name */ unsigned long boot_params; /* tagged list */ const char **dt_compat; /* array of device tree * ‘compatible‘ strings */ unsigned int nr_irqs; /* number of IRQs */ unsigned int video_start; /* start of video RAM */ unsigned int video_end; /* end of video RAM */ unsigned int reserve_lp0 :1; /* never has lp0 */ unsigned int reserve_lp1 :1; /* never has lp1 */ unsigned int reserve_lp2 :1; /* never has lp2 */ unsigned int soft_reboot :1; /* soft reboot */ void (*fixup)(struct machine_desc *, struct tag *, char **, struct meminfo *); void (*reserve)(void);/* reserve mem blocks */ void (*map_io)(void);/* IO mapping function */ void (*init_early)(void); void (*init_irq)(void); struct sys_timer *timer; /* system tick timer */ void (*init_machine)(void); };
在arch/arm/include/asm/mach/arch.h中有下面的宏,用于声明处理器相关的machine_desc结构体,并将该结构体放入vmlinux.lds中指定的段中。
#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 \ };
在arch/arm/mach-s3c64xx/mach-smdk6410.c中使用上述宏声明machine_desc结构体,
MACHINE_START(SMDK6410, "SMDK6410") /* Maintainer: Ben Dooks <ben-linux@fluff.org> */ //.phys_io = S3C_PA_UART & 0xfff00000, //.io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc, .boot_params = S3C64XX_PA_SDRAM + 0x100, .init_irq = s3c6410_init_irq, .map_io = smdk6410_map_io, .init_machine = smdk6410_machine_init, .timer = &s3c24xx_timer, MACHINE_END
上面的宏展开得到:
static const struct machine_desc __mach_desc_SMDK6410 __used __attribute__((__section__(".arch.info.init"))) = { .nr = MACH_TYPE_SMDK6410, .name = "SMDK6410", .boot_params = S3C64XX_PA_SDRAM + 0x100, //0x5000_0100 .init_irq = s3c6410_init_irq, .map_io = smdk6410_map_io, .init_machine = smdk6410_machine_init, .timer = &s3c24xx_timer, }