linux smp arm,BootingARMLinuxSMPonMPCore

《BootingARMLinuxSMPonMPCore》由会员分享,可在线阅读,更多相关《BootingARMLinuxSMPonMPCore(17页珍藏版)》请在人人文库网上搜索。

1、http:/ Please go to http:/ where you can download million word documents . Contribution: This work is part of my master thesis work at NXP Semiconductors. I also This word document was downloaded from the website: http:/ please remain this link information when you reproduce , copy, or use it. word 。

2、documents thank Catalin Marinas from ARM for reviewing and acknowledging this article. Booting ARM Linux SMP on MPCore It is important to understand what happens from the time the power button is switched on until the popup of the command shell environment with all the 4 CPU cores running. The boot 。

3、process of an embedded Linux kernel differs from the PC environment, typically because the environment setting and the available hardware change from one platform to another. For example, an embedded system doesnt have a hard disk or a PC BIOS, but include a boot monitor and flash memories. So basic。

4、ally, the main difference between each architectures boot process is in the application used to find and load the kernel. Once the kernel is in the memory, the same sequence of events occurs for all the CPU architectures, with some overloaded functionalities specific to each of them. The Linux boot 。

5、process can be represented in 3 stages as shown in Figure 1: Figure 1 Linux boot process When we press the system power on, a Boot Monitor code executes from a predefined address location from the NOR flash memory (0 x00000000). The Boot Monitor initializes the PB11MPCore hardware peripherals, and t。

6、hen launches the real bootloader U-Boot in case an automatic script is provided; else the user runs U-Boot manually by entering the appropriate command in the Boot Monitor command shell. U-Boot initializes the main memory and copies the compressed Linux kernel image (uImage), which is located either。

7、 on the on-board NOR flash memory, MMC, CompactFlash or on a host PC, to the main memory to be executed by the ARM11 MPCore, after passing some initialization parameters to the kernel. Then the Linux kernel image decompresses itself, starts initializing its data structures, creates some user process。

8、es, boots all the CPU cores and finally runs the command shell environment in the user-space. http:/ Please go to http:/ where you can download million word documents . This was a brief introduction to the whole boot process. In the next sections, we will explain each stage in details and highlight 。

9、the Linux source code that is executing the corresponding stage. a) System startup (Boot Monitor) When the system is powered on or reset, all CPUs of the ARM11 MPCore fetch the next instruction from the reset vector address to their PC register. In our case, it is the first address in the NOR flash 。

10、memory (0 x00000000), where the Boot Monitor program exists. Only CPU0 continues to execute the Boot Monitor code and the secondary CPUs (CPU1, CPU2, and CPU3) execute a WFI instruction, which is actually a loop that checks the value of SYS_FLAGS register. The secondary CPUs start executing meaningf。

11、ul code during Linux Kernel boot process, which is explained in details later in this section in paragraph ARM Linux. The Boot Monitor is the standard ARM application that runs when the system is booted and is built with the ARM platform library. On reset, the Boot Monitor performs the following act。

12、ions: ? Executes on CPU0 the main code and on the secondary CPUs the WFI instruction ? Initialize the memory controllers and configure the main board peripherals ? Set up a stack in memory ? Copy itself to the main memory DRAM ? Reset the boot memory remapping ? Remap and redirect the C library I/O 。

13、routines depending on the settings of the switches on the front panel of the PB11MPCore (output: UART0 or LCD input: UART0 or keyboard) ? Run a bootscript automatically, if it exists in the NOR flash memory and the corresponding switch is ON on the front panel of the PB11MPCore. Else, the Boot Monit。

14、or command shell is prompted So basically, the Boot Monitor application shipped with the board is similar to BIOS in the PC. It has limited functionalities and cannot boot a Linux kernel image. So, another bootloader is needed to complete the booting process, which is U-Boot. The U-Boot code is cros。

15、s-compiled to the ARM platform and flashed to the NOR flash memory. The final step is to launch U-Boot image from the Boot Monitor command line. This can be done using a script or manually by entering the appropriate command. http:/ Please go to http:/ where you can download million word documents .。

16、 b) Bootloader (U-Boot) When the bootloader is called by the Boot Monitor, it is located in the NOR flash memory without access to system RAM because the memory controller is not initialized properly as U-Boot expects. So how U-Boot moves itself from the flash memory to the main memory? In order to 。

17、get the C environment working properly and run the initialization code, U-Boot needs to allocate a minimal stack. In case of the ARM11 MPCore, this is done in a locked part of the L1 data cache memory. In this way, the cache memory is used as temporary data storage to initialize U-Boot before the SD。

18、RAM controller is setup. Then, U-Boot initializes the ARM11 MPCore, its caches and the SCU. Next, all available memory banks are mapped using a preliminary mapping and a simple memory test is run to determine the size of the SDRAM banks. Finally, the bootloader installs itself at the upper end of th。

19、e SDRAM area and allocates memory for use by malloc() and for the global board info data. In the low memory, the exception vector code is copied. Now, the final stack is set up. At this stage, the 2nd bootloader U-Boot is in the main memory and a C environment is set up. The bootloader is ready to l。

20、aunch the Linux kernel image from a pre-specified location after passing some boot parameters to it. In addition, it initializes a serial or video console for the kernel. Finally, it calls the kernel image by jumping directly to the start label in arch/arm/boot/compressed/head.S assembly file, which。

21、 is the start header of the Linux kernel decompressor. The bootloader can perform lot of functionalities; however a minimal set of requirements should be always achieved: - Configure the systems main memory: The Linux kernel does not have the knowledge of the setup or configuration of the RAM within。

22、 a system. This is the task of the bootloader to find and initialize the entire RAM that the kernel will use for volatile data storage in a machine dependent manner, and then passes the physical memory layout to the kernel using ATAG_MEM parameter, which will be explained later. - Load the kernel im。

23、age at the correct memory address: The uImage encapsulates a compressed Linux kernel image with header information that is marked by a special magic number and a data portion. Both the header and data are secured against corruption by a CRC32 checksum. In the data field, the start and end offsets of。

24、 the size of the image are stored. They are used to determine the length of the compressed image in order to know how much memory can be allocated. The ARM Linux kernel expects to be loaded at address 0 x7fc0 in the main memory. - Initialize a console: Since a serial console is essential on all the 。

25、platforms in order to allow communication with the target and early kernel debugging facilities, the bootloader should initialize and enable one serial port on the target. Then it passes the relevant console parameter option to the kernel in order to inform it of the already enabled port. http:/ Ple。

26、ase go to http:/ where you can download million word documents . - Initialize the boot parameters to pass to the kernel: The bootloader must pass parameters to the kernel in form of tags, to describe the setup it has performed, the size and shape of memory in the system and, optionally, numerous oth。

27、er values as described in Table 1: Table 1 Linux kernel parameter list Tag name Description ATAG_NONE Empty tag used to end list ATAG_CORE First tag used to start list ATAG_MEM Describes a physical area of memory ATAG_VIDEOTEXT Describes a VGA text display ATAG_RAMDISK Describes how the ramdisk will。

28、 be used in kernel ATAG_INITRD2 Describes where the compressed ramdisk image is placed in memory ATAG_SERIAL 64 bit board serial number ATAG_REVISION 32 bit board revision number ATAG_VIDEOLFB Initial values for vesafb-type framebuffers ATAG_CMDLINE Command line to pass to kernel - Obtain the ARM Li。

29、nux machine type: The bootloader should provide the machine type of the ARM system, which is a simple unique number that identifies the platform. It can be hard coded in the source code since it is pre-defined, or read from some board registry. The machine type number can be fetched from ARM-Linux p。

30、roject website. - Enter the kernel with the appropriate register values: Finally, and before starting execution of the Linux kernel image, the ARM11 MPCore registers must be set in an appropriate way: ? Supervisor (SVC) mode ? IRQ and FIQ interrupts disabled ? MMU off (no translation of memory addre。

31、sses is required) ? Data cache off ? Instruction cache may be either on or off ? CPU register0 = 0 ? CPU register1 = ARM Linux machine type ? CPU register2 = physical address of the parameter list http:/ Please go to http:/ where you can download million word documents . c) ARM Linux As mentioned ea。

32、rlier, the bootloader jumped to the compressed kernel image code and passed some initialization parameters denoted by ATAG. The beginning of the compressed Linux kernel image is the start label in arch/arm/boot/compressed/head.S assembly file. From this stage, the boot process comprises of 3 main st。

33、ages. First the kernel decompresses itself. Then, the processor-dependent (ARM11 MPCore) kernel code executes which initializes the CPU and memory. And finally, the processor-independent kernel code executes which startup the ARM Linux SMP kernel by booting up all the ARM11 cores and initializes all。

34、 the kernel components and data structures. The flowchart in Figure 2 summarizes the boot process of the ARM Linux kernel: Figure 2 ARM Linux kernel boot http:/ Please go to http:/ where you can download million word documents . In the Linux SMP environment, CPU0 is responsible for initializing all 。

35、resources just as in a uniprocessor environment. Once configured, access to a resource is tightly controlled using synchronization rules such as a spinlock. CPU0 will configure the boot page translation so secondary cores boot from a dedicated section of Linux rather than the default reset vector. W。

36、hen secondary cores boot the same Linux image, they will enter Linux at a specific location so they simply initialize resources specific only to their core (caches, MMU) and dont reinitialize resources that have already been configured, and then execute the idle process with PID 0. A step-by-step wa。

37、lkthrough for the Linux kernel boot process is provided below: This appendix will provide a walkthrough in the Linux kernel boot process for the ARM-based systems, specifically the ARM11 MPCore, by highlighting the source code of the kernel that executes each step. The boot process comprises of 3 ma。

38、in stages: Image decompression: ? U-Boot jumps at the start label in arch/arm/boot/compressed/head.S ? The parameters passed by U-Boot in r0 (CPU architecture ID) and r1 (ATAG parameter list pointer) are saved ? Execute architecture specific code, then turn off the cache and MMU ? Setup the C enviro。

39、nment properly ? Assign the appropriate values to the registers and stack pointer. i.e: r4= kernel physical start address sp=decompressor code ? Turn on the cache memory again by calling cache_on procedure which walk through proc_types list and find the corresponding ARM architecture. For the ARM11 。

40、MPCore (ARM v6), _armv4_mmu_cache_on, _armv4_mmu_cache_off, and _armv6_mmu_cache_flush procedures are called to turn on, off, and flush the cache memory to RAM respectively ? Check if the decompressed image will overwrite the compressed image and jump to the appropriate routine ? Call the decompress。

41、or routine decompress_kernel() which is located in arch/arm/boot/compressed/misc.c. The decompress_kernel() will display the “Uncompressing Linux.” message on the output terminal, followed by calling gunzip() function, then displaying “ done, booting the kernel” message. ? Flush the cache memory con。

42、tents to RAM using _armv6_mmu_cache_flush ? Turn off the cache using _armv4_mmu_cache_off, because the kernel initialization routines expects that the cache memory is off at the beginning ? Jump to start of kernel in RAM, where its address is stored in r4 register. The kernel start address is specif。

43、ic for ? Each platform architecture. For the PB11MPCore, it is stored in arch/arm/mach-realview/Makefile.boot in zreladdr-y variable (zreladdr-y := 0 x00008000) Processor dependent (ARM) specific kernel code: http:/ Please go to http:/ where you can download million word documents . The kernel start。

44、up entry point is in stext procedure in arch/arm/kernel/head.S file, where the decompressor has jumped after turning off the MMU and cache memory and setting the appropriate registers. At this stage, the following sequence of events is done in stext: (arch/arm/kernel/head.S) ? Ensure that the CPU ru。

45、ns in Supervisor mode and disable all the interrupts ? Lookup for the processor type using _lookup_processor_type procedure defined in arch/arm/kernel/head-common.S. This will return a pointer to a proc_info_list defined in arch/arm/mm/proc-v6.S for the ARM11 MPCore ? Lookup for the machine type usi。

46、ng _lookup_machine_type procedure defined in arch/arm/kernel/head-common.S. This will return a pointer to a machine_desc struct defined for the PB11MPCore ? Create the page table using _create_page_tables procedure, which will setup the barest amount of page tables required to get the kernel running。

47、; in other words to map in the kernel code ? Jump to _v6_setup procedure in arch/arm/mm/proc-v6.S, which will initialize the TLB, cache and MMU state of CPU0 ? Enable the MMU using _enable_mmu procedure, which will setup some configuration bits and then call _turn_mmu_on (arch/arm/kernel/head.S) ? I。

48、n _turn_mmu_on, the appropriate control registers are set and then it jumps to _switch_data which will execute the first procedure _mmap_switched (arch/arm/kernel/head-common.S) ? In _mmap_switched procedure, the data segment is copied to RAM and the BSS segment is cleared. Finally, it jumps to star。

49、t_kernel() routine in the init/main.c source code where the Linux kernel starts Processor independent kernel code From this stage on, it is a common sequence of events for the boot process of the Linux Kernel independent of the hardware architecture. Well some functions are still hardware dependent,。

50、 and they actually override the independent implementation. We will concentrate mainly on how the SMP part of Linux will boot and how the CPUs in the ARM11 MPCore are initialized. In start_kernel(): (init/main.c) ? Disable the interrupts on CPU0 using local_irq_disable() (include/linux/irqflags.h) ?。

51、 Lock the kernel using lock_kernel() to prevent from being interrupted or preempted from high priority interrupts (include/linux/smp-lock.h) ? Activate the first processor (CPU0) using boot_cpu_init() (init/main.c) ? Initialize the kernel tick control using tick_init() (kernel/time/tick-common.c) ? 。

52、Initialize the memory subsystem using page_address_init() (mm/highmem.c) ? Display the kernel version on the console using printk(linux_banner) (init/version.c) ? Setup architecture specific subsystems such as memory, I/O, processors, etcby using setup_arch( o Inform the secondary processor that it 。

53、can start booting its part of the kernel o Wake the secondary core up using smp_cross_call(mask_cpu), which will send a soft interrupt (include/asm-arm/mach-realview/smp.h) o Wait for the secondary core to finish its booting and calibrations that are done using secondary_start_kernel function (expla。

54、ined before) ? Repeat this process for every secondary CPU ? Display the kernel message on the console “SMP: Total of 4 processors activated (334.02 BogoMIPS), using smp_cpus_done(max_cpus) (arch/arm/kernel/smp. ? Call sched_init_smp() (kernel/sched.c) ? Build the scheduler domains using arch_init_s。

55、ched_domains( run_init_process(/etc/init); run_init_process(/bin/init); run_init_process(/bin/sh); /sbin/init process executes and displays lot of messages on the console, and finally it transfers the control to the console and stays alive. VOILA! This word document was downloaded from the website: http:/ please remain this link information when you reproduce , copy, or use it. word documents http:/ Please go to http:/ where you can download million word documents .。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值