Linux TAGS分析

Linux TAGS分析

1. "./arch/arm/kernel/vmlinux.lds.S" 192 行


 

 

 32         .init : {                       /* Init code and data           */

 33                         INIT_TEXT

 34                 _einittext = .;

 35                 __proc_info_begin = .;

 36                         *(.proc.info.init)

 37                 __proc_info_end = .;

 38                 __arch_info_begin = .;

 39                         *(.arch.info.init)

 40                 __arch_info_end = .;

 41                    __tagtable_begin = .;

 42                         *(.taglist.init)               /*内核定义的Tags分析函数所在段*/

 43                    __tagtable_end = .;

 44                 . = ALIGN(16);

 45                 __setup_start = .;

 46                         *(.init.setup)

 47                 __setup_end = .;

 48                 __early_begin = .;

 49                         *(.early_param.init)

 50                 __early_end = .;

 51                 __initcall_start = .;

 52                         INITCALLS

 53                 __initcall_end = .;

 54                 __con_initcall_start = .;

 55                         *(.con_initcall.init)

 56                 __con_initcall_end = .;

 57                 __security_initcall_start = .;


2.__tagtable(tag, fn)的定义

./arch/arm/include/asm/setup.h


 

struct tagtable {

__u32 tag;

int (*parse)(const struct tag *);

};


#define tag_member_present(tag,member) /

((unsigned long)(&((struct tag *)0L)->member + 1) /

<= (tag)->hdr.size * 4)


#define tag_next(t) ((struct tag *)((__u32 *)(t) + (t)->hdr.size))

#define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2)


#define for_each_tag(t,base) /

for (t = base; t->hdr.size; t = tag_next(t))


#ifdef __KERNEL__


#define __tag __used __attribute__((__section__(".taglist.init")))

#define __tagtable(tag, fn) /

static struct tagtable __tagtable_##fn __tag = { tag, fn }


3.分析tags的函数
arch/arm/kernel/setup.c
void __init setup_arch(char **cmdline_p)->parse_tags

 

static int __init parse_tag(const struct tag *tag)

{

extern struct tagtable __tagtable_begin, __tagtable_end;

struct tagtable *t;


for (t = &__tagtable_begin; t < &__tagtable_end; t++)

if (tag->hdr.tag == t->tag) {

t->parse(tag);

break;

}


return t < &__tagtable_end;

}

 

4.Bootloader中通常有如下函数:

 

setup_start_tag();

setup_memory_tags();

setup_commandline_tag(argc, argv);

setup_initrd_tag();

setup_end_tag();


5.Board参数定义

 

 

MACHINE_START(QT2410, "QT2410")

.phys_io = S3C2410_PA_UART,

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

.boot_params = S3C2410_SDRAM_PA + 0x100,

.map_io = qt2410_map_io,

.init_irq = s3c24xx_init_irq,

.init_machine = qt2410_machine_init,

.timer = &s3c24xx_timer,

MACHINE_END


 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值