void __init setup_arch(char **cmdline_p)
{
定义变量
-
struct tag *tags = (struct tag *)&init_tags;
-
struct machine_desc *mdesc;
-
char *from = default_command_line;
unwind_init();
再次检测cpu
setup_processor();
再次检测Machine_ID 并返回board的结构体 struct machine_desc
-
mdesc = setup_machine(machine_arch_type);
-
machine_desc = mdesc;
-
machine_name = mdesc->name;
if (mdesc->soft_reboot)
reboot_setup("s");
if (__atags_pointer)
/* __atags_pointer undefined */
tags = phys_to_virt(__atags_pointer);
else if (mdesc->boot_params)
/* 执行 */
tags = phys_to_virt(mdesc->boot_params);
#if defined(CONFIG_DEPRECATED_PARAM_STRUCT)
if (tags->hdr.tag != ATAG_CORE)
convert_to_tag_list(tags);
#endif
if (tags->hdr.tag != ATAG_CORE)
tags = (struct tag *)&init_tags;
if (mdesc->fixup)
mdesc->fixup(mdesc, tags, &from, &meminfo);
解析uboot传递进来的tags 在setup.h中有
#define __tag __used __attribute__((__section__(".taglist.init")))
#define __tagtable(tag, fn) \
static struct tagtable __tagtable_##fn __tag = { tag, fn }
setup.c中 有
-
static int __init parse_tag_mem32(const struct tag *tag)
-
{
-
return arm_add_memory(tag->u.mem.start, tag->u.mem.size);
-
}
-
___tagtable(ATAG_MEM, parse_tag_mem32);
宏替换后得到:
static struct tagtable __tagtable_parse_tag_cmdline
__used __attribute__((__section__(".taglist.init"))) //强制到taglist属性段
={ATAG_MEM, parse_tag_mem32 }
解析uboot传进来的tags
-
if (tags->hdr.tag == ATAG_CORE) {
-
if (meminfo.nr_banks != 0)
-
squash_mem_tags(tags);
-
save_atags(tags);
-
parse_tags(tags);// go
-
}
-
-
static void __init parse_tags(const struct tag *t)
-
{
-
for (; t->hdr.size; t = tag_next(t))
-
if (!parse_tag(t))
-
printk(KERN_WARNING
-
"Ignoring unrecognised tag 0x%08x\n",
-
t->hdr.tag);
-
}
-
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;
-
}
init_mm.start_code = (unsigned long) _text;
init_mm.end_code = (unsigned long) _etext;
init_mm.end_data = (unsigned long) _edata;
init_mm.brk = (unsigned long) _end;
/* parse_early_param needs a boot_command_line */
strlcpy(boot_command_line, from, COMMAND_LINE_SIZE);
/* populate cmd_line too for later use, preserving boot_command_line */
strlcpy(cmd_line, boot_command_line, COMMAND_LINE_SIZE);
*cmdline_p = cmd_line;
/* *****执行一些先期命令 *******/
parse_early_param();
-
struct obs_kernel_param {
-
const char *str;
-
int (*setup_func)(char *);
-
int early; //是否为早期处理函数
-
};
关于early和非early的函数
-
#define __setup_param(str, unique_id, fn, early) \
-
static const char __setup_str_##unique_id[] __initconst \
-
__aligned(1) = str; \
-
static struct obs_kernel_param __setup_##unique_id \
-
__used __section(.init.setup) \
-
__attribute__((aligned((sizeof(long))))) \
-
= { __setup_str_##unique_id, fn, early }
-
-
#define __setup(str, fn) \
-
__setup_param(str, fn, fn, 0)
-
-
#define early_param(str, fn) \
-
__setup_param(str, fn, fn, 1)
-
对下面函数
-
static int __init init_setup(char *str)
-
{unsigned int i;
-
execute_command = str;
-
for (i = 1; i < MAX_INIT_ARGS; i++)
-
argv_init[i] = NULL;return 1;}
-
__setup("init=", init_setup);
-
宏替换得:
-
static const char __setup_str_init_setup[] __initconst __aligned(1) = "init=";
-
static struct obs_kernel_param __setup_init_setup
-
__used __section(.init.setup) __attribute__((aligned((sizeof(long)))))
-
= { __setup_str_init_setup, init_setup, 0 }
-
-
对下面函数:
-
static int __init nosmp(char *str)
-
{
-
setup_max_cpus = 0;
-
arch_disable_smp_support();
-
return 0;
-
}
-
early_param("nosmp", nosmp);
-
宏替换得:
-
static const char __setup_str_nosmp[] __initconst __aligned(1) = nosmp;
-
static struct obs_kernel_param __setup_nosmp
-
__used __section(.init.setup) __attribute__((aligned((sizeof(long)))))
-
= { __setup_str_nosmp, nosmp, 1 }
arm_memblock_init(&meminfo, mdesc);
/******最终调用了medesc->map_io()*****/
paging_init(mdesc);
/****paging_init(mdesc)--> devicemaps_init(mdesc)-->mdesc->map_io()
如果平台为smdk2440的board则相当于调用了smdk2440_map_io在mach-smdk2440.c中定义****/
request_standard_resources(mdesc);
#ifdef CONFIG_SMP
if (is_smp())
smp_init_cpus();
#endif
reserve_crashkernel();
cpu_init();
tcm_init();
#ifdef CONFIG_MULTI_IRQ_HANDLER
handle_arch_irq = mdesc->handle_irq;
#endif
#ifdef CONFIG_VT
#if defined(CONFIG_VGA_CONSOLE)
conswitchp = &vga_con;
#elif defined(CONFIG_DUMMY_CONSOLE)
conswitchp = &dummy_con;
#endif
#endif
early_trap_init();
/*如果设备描述结构体定义了init_early函数(应该是早期初始化之意),则在这里调用。*/
if (mdesc->init_early)
mdesc->init_early();
}
阅读(2245) | 评论(0) | 转发(0) |