设为首页 加入收藏

TOP

MACHINE_START and MACHINE_END Macro define(一)
2014-11-24 14:21:35 来源: 作者: 【 】 浏览:2
Tags:MACHINE_START and MACHINE_END Macro define

在linux-2.6.38中,/arch/arm/mach-w90x900/mach-nuc950evb.c文件的最后部分,有如下宏定义:



MACHINE_START(W90P950EVB, "W90P950EVB")
.phys_io = W90X900_PA_UART,
.io_pg_offst = (((u32)W90X900_VA_UART) >> 18) & 0xfffc,
.boot_params = 0x100,
.map_io = nuc950evb_map_io,
.init_irq = nuc900_init_irq,
.init_machine = nuc950evb_init,
.timer = &nuc900_timer,
MACHINE_END



而MACHINE_START和MACHINE_END宏定义在arch/arm/include/asm/mach/arch.h,如下:

struct machine_desc {
/*
* Note! The first four elements are used
* by assembler code in 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);
};


/*
* 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



将前面定义的MACHINE_START和MACHINE_END展开后得到:
static const struct machine_desc __mach_desc_W90P950EVB __used __attribute__((__section__(".arch.info.init"))) = {
.nr = MACH_TYPE_W90P950EVB, /* architecture number */
.name = "W90P950EVB"", /* architecture name */
.phys_io = W90X900_PA_UART, /* start of physical io */
.io_pg_offst = (((u32)W90X900_VA_UART) >> 18) & 0xfffc,
.boot_params = 0x100, /* tagged list */
.map_io = nuc950evb_map_io, /* IO mapping function */
.init_irq = nuc900_init_irq,
.init_machine = nuc950evb_init,
.timer = &nuc900_timer,
}


MACH_TYPE_W90P950EVB定义在arch/arm/include/asm/mach-types.h内,值为1860 十六进制为:0x744.
#define MACH_TYPE_W90P950EVB 1860


这个值是机器的类型值,编译时由arch/arm/tool/mach- types里面定义的数据生成的。
/* arch/arm/tool/mach-types */
w90x900 MACH_W90X900 W90X900 1860


而在arch/arm/kernel/head-common.S文件中的__lookup_machine_type函数中有如下的定义:


/*
* linux/arch/arm/kernel/head-common.S
*
* Copyright (C) 1994-2002 Russell King
* Copyright (c) 2003 ARM Limited
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/


#define ATAG_CORE 0x54410001
#define ATAG_CORE_SIZE ((2*4 + 3*4) >> 2)
#define ATAG_CORE_SIZE_EMPTY ((2*4) >> 2)


.align 2
.type __switch_data, %object
__switch_data:
...................中间省略


.long processor_id @ r4
.long __machine_arch_type @ r5
.long __atags_pointer @ r6
.long cr_alignment @ r7
.long init_thread_union + THREAD_START_SP @ sp


...................

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Android游戏开发教程:手教你写跳.. 下一篇S3C2410支持64M到1GB的NAND FLASH

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: