Linux machine_desc 体系特征



Linux machine_desc 体系特征

一.ARM S3C2410中,linux描述其主要架构特征的是数据结构:

 

struct machine_desc

{

unsigned int           nr;          /*architecture number   */

       unsignedint           phys_io;  /* start of physical io     */

       unsignedint           io_pg_offst;    /* byte offset for io

                                           * page tabe entry  */

 

       constchar              *name;           /* architecture name      */

       unsignedlong        boot_params;  /* tagged list          */

 

       unsignedint           video_start;     /* start of video RAM    */

       unsignedint           video_end;      /* end of video RAM     */

 

       unsignedint           reserve_lp0 :1;       /* never has lp0      */

       unsignedint           reserve_lp1 :1;       /* never has lp1      */

       unsignedint           reserve_lp2 :1;       /* never has lp2      */

       unsignedint           soft_reboot :1;       /* soft reboot         */

       void               (*fixup)(struct machine_desc *,

                                    struct tag *, char **,

                                    struct meminfo *);

       void               (*map_io)(void);/* IO mappingfunction     */

       void               (*init_irq)(void);

       structsys_timer      *timer;           /* system tick timer       */

       void               (*init_machine)(void);

}

 

二.用到的宏

#define MACHINE_START(_type,_name)                 \//suyi mach-smdk2410.c

static const struct machine_desc __mach_desc_##_type       \

 __used                                             \

 __attribute__((__section__(".arch.info.init")))= {    \

       .nr          = MACH_TYPE_##_type,           \

       .name             = _name,

 

#define MACHINE_END                          \

};

 

三.S3C2410linux-2.6.26.5上的具体实现

MACHINE_START(SMDK2410,"SMDK2410")

       .phys_io  = S3C2410_PA_UART,          //串口物理地址

       .io_pg_offst    = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,

       .boot_params  = S3C2410_SDRAM_PA+ 0x100,// u-boot传入的参数的地址

       .map_io          = smdk2410_map_io,

       .init_irq   = s3c24xx_init_irq,  

       .init_machine  = smdk2410_init,  

.timer             = &s3c24xx_timer,

MACHINE_END

 

3.1 map_io

setup_arch-> paging_init ->devicemaps_init

|------ mdesc->map_io(); 

 

static void __init smdk2410_map_io(void)

{

       s3c24xx_init_io(smdk2410_iodesc,ARRAY_SIZE(smdk2410_iodesc));//IO静态映射

       s3c24xx_init_clocks(0); //时钟初始化

       s3c24xx_init_uarts(smdk2410_uartcfgs,ARRAY_SIZE(smdk2410_uartcfgs));

}

3.2 init_irq

Setup_arch()

{

………

init_arch_irq =mdesc->init_irq;

system_timer =mdesc->timer;

init_machine =mdesc->init_machine;

………

}

 

 

void __init init_IRQ(void)//start_kernel()中调用

{

……..

init_arch_irq()

……..

}

3.3 init_machine

static void (*init_machine)(void)__initdata;

 

static int __init customize_machine(void) {

              if(init_machine)

              init_machine();

       return0;

}

 

arch_initcall(customize_machine);

 

do_basic_setup()

      |-------do_initcalls()中调用

 

static void __initsmdk2410_init(void)

{

  s3c24xx_fb_set_platdata(&smdk2410_fb_info);

platform_add_devices(smdk2410_devices, ARRAY_SIZE(smdk2410_devices));

//初始化平台设备

smdk_machine_init();

}

3.4 timer

void __init time_init(void)//start_kernel()中调用,初始化时钟

{

………….

       system_timer->init();

………….

}

 

你可能感兴趣的:(Linux machine_desc 体系特征)