MACH_START

在友善mini2440提供的linux2.6.32.2内核中,有如下定义:
MACHINE_START(MINI2440, "FriendlyARM Mini2440 developmentboard")
.phys_io = S3C2410_PA_UART,
.io_pg_offst = (((u32)S3C24XX_VA_UART)>> 18) &0xfffc,
.boot_params = S3C2410_SDRAM_PA + 0x100,

.init_irq = s3c24xx_init_irq,
.map_io = mini2440_map_io,
.init_machine = mini2440_machine_init,
.timer = &s3c24xx_timer,
MACHINE_END

下面分析一下:
include/asm-arm/mach/arch.h中,有定义
#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 \
};

列出 machine_desc的定义:
struct machine_desc {
unsigned int nr;
unsigned int phys_io;
unsigned int io_pg_offst;

const char *name;
unsigned long boot_params;

unsigned int video_start;
unsigned int video_end;

unsigned int reserve_lp0 :1;
unsigned int reserve_lp1 :1;
unsigned int reserve_lp2 :1;
unsigned int soft_reboot :1;
void (*fixup)(struct machine_desc *,
struct tag *, char **,
struct meminfo *);
void (*map_io)(void);
void (*init_irq)(void);
struct sys_timer *timer;
void (*init_machine)(void);
};


按定义展开后:
static const struct machine_desc __mach_desc_MINI2440\
 __used \
 __attribute__((__section__(".arch.info.init")))= {
.nr = MACH_TYPE_MINI2440,
.name = "FriendlyARM Mini2440 developmentboard",
.phys_io = S3C2410_PA_UART,
.io_pg_offst = (((u32)S3C24XX_VA_UART)>> 18) &0xfffc,
.boot_params = S3C2410_SDRAM_PA + 0x100,
.init_irq = s3c24xx_init_irq,
.map_io = mini2440_map_io,
.init_machine = mini2440_machine_init,
.timer = &s3c24xx_timer,
};
MACH_TYPE_MINI2440是mini2440开发板在linux中的机器号。
"FriendlyARMMini2440 development board"是开发板信息,在终端输入cat/proc/cpuinfo可以查看。

MACHINE_START主要是定义了"structmachine_desc"的类型,放在 section(".arch.info.init"),是初始化数据,Kernel起来之后将被丢弃。
其余各个成员函数在setup_arch()中被赋值到内核结构体,在不同时期被调用:
1. .init_machine 在 arch/arm/kernel/setup.c 中被customize_machine 调用,放在 arch_initcall() 段里面,会自动按顺序被调用。
2. .init_irq在start_kernel() --> init_IRQ()--> init_arch_irq()中被调用
3. .map_io 在 setup_arch() --> paging_init()--> devicemaps_init()中被调用
4..timer是定义系统时钟,定义TIMER4为系统时钟,在arch/arm/plat-s3c/time.c中体现。在start_kernel()--> time_init()中被调用。
5..boot_params是bootloader向内核传递的参数的位置,这要和bootloader中参数的定义要一致。

其他主要都在 setup_arch() 中用到。

你可能感兴趣的:(c,timer,linux,struct,IO,video)