Chinaunix首页 | 论坛 | 博客
  • 博客访问: 242765
  • 博文数量: 49
  • 博客积分: 2591
  • 博客等级: 少校
  • 技术积分: 515
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-15 00:03
文章分类

全部博文(49)

文章存档

2009年(3)

2008年(46)

我的朋友

分类: LINUX

2008-05-12 18:58:25

machine_desc   __mach_desc_##_type结构体的初始化一般都定义在(以arm平台为例)kernel\arch\arm\mach-xxx\xxx.c中,是用宏来定义的(后面有说明)

这是linux启动时的汇编代码中需要使用的

struct machine_desc,定义在asm-arm/mach/arch.h中:
struct machine_desc {
/*
* Note! The first four elements are used
* by assembler code in head-armv.S
*/

unsigned int nr;/* architecture number*/
unsigned int phys_ram;/* start of physical ram */
unsigned int phys_io;/* start of physical io*/
unsigned int io_pg_offst;/* byte offset for io page table entry*/

const char *name;/* architecture name*/
unsigned int param_offset;/* parameter page*/

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 param_struct *, char **,
struct meminfo *);
void(*map_io)(void);/* IO mapping function*/
void(*init_irq)(void);
};

 

结构体的具体定义一般都定义在(以arm平台为例)kernel\arch\arm\mach-xxx\xxx.c中,是用宏来定义的,以mainstone的开发板为例:
定义在kernel\arch\arm\mach-pxa\mainstone.c文件中,如下所示:
MACHINE_START(MAINSTONE, "Intel DBBVA0 Development Platform")
     MAINTAINER("MontaVista Software Inc.")
     BOOT_MEM(0xa0000000, 0x40000000, io_p2v(0x40000000))
     FIXUP(fixup_mainstone)
     MAPIO(mainstone_map_io)
     INITIRQ(mainstone_init_irq)
MACHINE_END
这些宏也定义在kernel/include/asm-arm/mach/arch.h中,以MACHINE_START为例:
#define MACHINE_START(_type,_name)      \
const struct machine_desc __mach_desc_##_type   \
__attribute__((__section__(".arch.info"))) = { \
     .nr     = MACH_TYPE_##_type,    \
     .name       = _name,

展开之后结构的是:
__mach_desc_MAINSTONE = {
 .nr = MACH_TYPE_MAINSTIONE,
 .name = "Intel DBBVA0 Development Platform",

中间的1行__attribute__((__section__(".arch.info"))) = {说明将这个结构放到指定的段.arch.info中,这和前面的
.proc.info是一个意思,__attribute__((__section__的含义参考GNU手册。

阅读(1952) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~