Linux中的MACH定义之MACHINE

1.      定义一个MACH

LINUX中MACHINE定义是用MACHINE_START()/MACHINE_END两个宏来实现的,比如MSM的实现(arch/arm/mach-msm/board-halibut.c):

MACHINE_START(HALIBUT,"Halibut Board (QCT SURF7200A)")            .boot_params      = 0x10000100,            .map_io           = halibut_map_io,            .init_irq         = halibut_init_irq,            .init_machine     = halibut_init,            .timer            = &msm_timer,   MACHINE_END  

2.      MACHINE_START / MACHINE_END定义

上面的定义中,用到了这两个宏MACHINE_START/MACHINE_END,下面是它们具体的定义(在arch/arm/include/asm/mach/arch.h中): 

#defineMACHINE_START(_type,_name)                        \    static const structmachine_desc __mach_desc_##_type      \    __used                                                  \    __attribute__((__section__(".arch.info.init")))= {      \            .nr             = MACH_TYPE_##_type,            \            .name           = _name,       #define MACHINE_END                                      \    };  

struct machine_desc也是定义在arch/arm/include/asm/mach/arch.h

struct machine_desc {            /*            * Note! The firstfour elements are used            * by assembler codein head.S, head-common.S            */            unsigned int            nr;                  /* architecture number  */            unsigned int            phys_io;             /* start of physical io */            unsigned int            io_pg_offst;         /* byte offset for io                                                         * page tabe entry      */                const char              *name;               /* architecture name    */            unsigned long           boot_params;         /* tagged list          */                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                    (*map_io)(void);     /* IO mapping function  */            void                    (*init_irq)(void);            struct sys_timer        *timer;              /* system tick timer    */            void                    (*init_machine)(void);   };  

3.      MACH HALIBUT的定义

把1中定义的MACH展开之后,得到:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwzdgp.html