[Notes: kernel version Linux-2.6.30]
Setup_arch execution is called by start_kernel:
Start_kernel [init/Main. C] --> setup_arch (& command_line) [ARCH/ARM/kernel/setup. C]
void __init setup_arch(char **cmdline_p){struct tag *tags = (struct tag *)&init_tags;struct machine_desc *mdesc;char *from = default_command_line;/* [Voice] configuration in defconfig file */unwind_init();setup_processor();mdesc = setup_machine(machine_arch_type);/* [Voice] This get from include/generated/mach-types.h */machine_name = mdesc->name;if (mdesc->soft_reboot)reboot_setup("s");if (__atags_pointer)/* [Voice] unsigned int __atags_pointer __initdata;*/tags = phys_to_virt(__atags_pointer);else if (mdesc->boot_params)tags = phys_to_virt(mdesc->boot_params);/* * If we have the old style parameters, convert them to * a tag list. */if (tags->hdr.tag != ATAG_CORE)convert_to_tag_list(tags);if (tags->hdr.tag != ATAG_CORE)tags = (struct tag *)&init_tags;if (mdesc->fixup)mdesc->fixup(mdesc, tags, &from, &meminfo);if (tags->hdr.tag == ATAG_CORE) {if (meminfo.nr_banks != 0)squash_mem_tags(tags);save_atags(tags);parse_tags(tags);}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;memcpy(boot_command_line, from, COMMAND_LINE_SIZE);boot_command_line[COMMAND_LINE_SIZE-1] = '\0';parse_cmdline(cmdline_p, from);paging_init(mdesc);request_standard_resources(&meminfo, mdesc);#ifdef CONFIG_SMPsmp_init_cpus();#endifcpu_init();/* * Set up various architecture-specific pointers */init_arch_irq = mdesc->init_irq;system_timer = mdesc->timer;init_machine = mdesc->init_machine;#ifdef CONFIG_VT#if defined(CONFIG_VGA_CONSOLE)conswitchp = &vga_con;#elif defined(CONFIG_DUMMY_CONSOLE)conswitchp = &dummy_con;#endif#endifearly_trap_init();}
Perform a row-by-row analysis as follows:
1. default_command_line
Static char default_command_line [command_line_size] _ initdata = config_cmdline;
Config_cmdline comes from the default configuration options of the Board.
2. setup_processor ();
Read cpuid, read_cpuid_id () --> read_cpuid (cpuid_id), where cpuid_id is 0, while read_cpuid is a compilation code. As follows:
#define read_cpuid(reg) \({ \unsigned int __val; \asm("mrc p15, 0, %0, c0, c0, " __stringify(reg) \: "=r" (__val) \: \: "cc"); \__val; \})
Then run lookup_processor_type (); defined in: [ARCH/ARM/kernel/head-common.S]
Cpu_name, elf_platform, and elf_hwcap variables are assigned values.
Followed by: cacheid_init ()
Read the cachetype and arch structures of the CPU. If the arch structure is smaller than armv6, cacheid = cacheid_vivt.
Last run: cpu_proc_init ()
[Confused here]
3. mdesc = setup_machine (machine_arch_type)
Machine_arch_type from file: Include/generated/mach-types.h [
This file is a generated file]
This only corresponds to a number and then finds the relevant information through this number. Each Board corresponds to a specific number. The related descriptions are described in machine_start and machine_end.
Next: setup_machine --> lookup_machine_type (NR) [defined in head. S]
The machine_name variable is assigned a value.
4. phys_to_virt (mdesc-> bootparams)
Phys_to_virt (mdesc-> bootparams) --> _ phys_to_virt (usigned long) (x) --> (x)-phys_offset + page_offset)
# Ifndef phys_offset
# Define phys_offset (config_dram_base)
# Endif
# Ifndef page_offset
# Define page_offset (phys_offset)
# Endif
5. _ text, _ etext, _ edata, _ end
The four parameters are from the file: [ARCH/ARM/kernel/vmlinux. LDS. S]
Some parameters of init_mm are assigned a value.
6. parse_cmdline (cmdline_p, from)
7. paging_init (mdesc)
Pageing_init () sets up the page tables, initialises the zone Memory maps, and sets up the zero page, bad page and bad page tables.
8. request_standard_resources (& meminfo, mdesc)
9. cpu_init ()
10. config_vt & config_dummy_console
Conswitchp = & dummy_con; [conswitchp ==> Drivers/Char/vt. C; dummy_con ==> driver/Video/console/dummycon. C]
11. early_trap_init () [ARCH/ARM/kernel/traps. C]