[Zedboard Linux System porting]-starting from Machine_start

Source: Internet
Author: User

Go from: http://www.cnblogs.com/lknlfy/archive/2012/05/06/2486479.html
kernel startup process?
3) The boot process of the kernel?
Arch/arm/kernel/head. S-> boot assembly for the kernel
R0 = 0, R1 = machine nr, r2 = atags pointer. Computer code startup parameter address, machines are from the U-boot, where the U-boot machine code is defined in the
"U- Boot-digilent-dev-master/arch/arm/include/asm/mach-types.h "in

head below. s in
B secondary_start_kernel-> jump to the C language entry function
//linux kernel's machine code list file: Arch/arm/tools/mach-types
INIT/MAIN.C-&G T Start_kernel//C Program Entry
//operating System Management ideas: memory management, task management, device management, file Management
Setup_arch (&command_line);//system initialization, Arch/ar M/kernel/setup.c Setup_command_line (command_line);
arch/arm/kernel/setup.c–> setup_arch ()
Mdesc = Setup_machine (Machine_arch_type);//Configure the current machine type, Machine_ Arch_type is the type of machine code, here is the assignment mach_xilinx_ep107
mach_xilinx_ep107 in this macro in/arch/arm/tools/mach-types

SMDK2410 Where is the initialization code? --Traversal to find the initialization file for the corresponding machine code in the Arch/arm directory---\LINUX-DIGILENT-DEV-MASTER\ARCH\ARM\MACH-ZYNQ\ARM\COMMON.C
// List of device initialization functions that correspond to this machine code:

Dt_machine_start (xilinx_ep107,"Xilinx Zynq Platform")/ * 64KB to size, 8-way associativity, parity disabled * /    . L2c_aux_val =0x00000000,. L2c_aux_mask =0xFFFFFFFF,. SMP= Smp_ops (Zynq_smp_ops),. Map_io = Zynq_map_io,. Init_IRQ = Zynq_irq_init,. Init_machine = Zynq_init_machine,. Init_late = Zynq_init_late,. Init_time = Zynq_timer_init,. DT_compat = Zynq_dt_match,. Reserve= Zynq_memory_init,. Restart= Zynq_system_reset,machine_end
    zynq_init_machine--->  当前的zybo的机器初始化主函数。如需上点后初始化该板子的其他外设,可以在本函数内添加相应的初始化功能。

Have played or transplanted arm-linux should know in the/arch/arm directory has a lot of specific processor-related directories, of course, for ZYNQ the corresponding directory is MACH-ZYNQ, in the inside to find the specific board related files \ LINUX-DIGILENT-DEV-MASTER\ARCH\ARM\MACH-ZYNQ\ARMCOMMON.C, yes, that's it. Whether you want to migrate to a new kernel or if you want to learn more about an arm, the study of this file is essential. Most of the content of this file is the structure of the platform device initialization, at the end of this file has a very important macro:

Dt_machine_start (xilinx_ep107,"Xilinx Zynq Platform")/ * 64KB to size, 8-way associativity, parity disabled * /    . L2c_aux_val =0x00000000,. L2c_aux_mask =0xFFFFFFFF,. SMP= Smp_ops (Zynq_smp_ops),. Map_io = Zynq_map_io,. Init_IRQ = Zynq_irq_init,. Init_machine = Zynq_init_machine,. Init_late = Zynq_init_late,. Init_time = Zynq_timer_init,. DT_compat = Zynq_dt_match,. Reserve= Zynq_memory_init,. Restart= Zynq_system_reset,machine_end

Dt_:qmachine_start is defined in ARCH/ARM/INCLUDE/ASM/MACH/ARCH.H, as follows:

#define DT_MACHINE_START(_name, _namestr)               \staticconststruct machine_desc __mach_desc_##_name    \ __used                                                  __attribute__((__section__(".arch.info.init"))) = {            .nr             = ~0,                                   .name           = _namestr,#endif

Well, it's actually defining a struct MACHINE_DESC type struct variable, which also defines some other members, followed by a focus on. Init_machine This member, which is a function pointer with a value of Zynq_init_machine, This function is also defined in COMMON.C. What is the content? Hehe, because here only gives the general flow, the concrete content first does not analyze. What is most concerned now is where the struct variable is called to invoke its members and member functions? First look at the Setup_arch () function inside/ARCH/ARM/KERNEL/SETUP.C:

void__init Setup_arch (Char**cmdline_p) {const struct MACHINE_DESC*Mdesc;    Setup_processor (); Mdesc=SETUP_MACHINE_FDT (__atags_pointer);if(!MDESC) Mdesc=Setup_machine_tags (__atags_pointer, __machine_arch_type); Machine_desc=Mdesc; Machine_Name=Mdesc -Nameif(Mdesc -Reboot_mode!=Reboot_hard) Reboot_mode=Mdesc -Reboot_mode; 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;/ * 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 ();    Early_paging_init (Mdesc, Lookup_processor_type (read_cpuid_id ()));    Setup_dma_zone (MDESC);    Sanity_check_meminfo ();    Arm_memblock_init (MDESC);    Paging_init (MDESC); Request_standard_resources (MDESC);if(Mdesc -Restart) Arm_pm_restart=Mdesc -Restart    Unflatten_device_tree ();    Arm_dt_init_cpu_maps (); Psci_init ();......................

This function is called in the Start_kernel () function of/INIT/MAIN.C. See line 10th, where the Setup_machine () function is to find the variable of the struct MACHINE_DESC type we want, that is, to define that variable in COMMON.C. What is the value of the parameter machine_arch_type of the function? Keep looking:

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

[Zedboard Linux System porting]-starting from Machine_start

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.