分类: LINUX
2011-03-26 12:10:17
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 }
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