When looking at the Start.s file of Uboot, the first thing to do is to set the CPU to SVC mode, but the core of s3c2440 CPU is arm920t, there are 7 modes, why should it be set to SVC mode instead of set to other mode? In this, after some verification, the following reasons:
First, the first thing to know about the 7 models of ARM's CPU:
Http://www.docin.com/p-73665362.html
Table 3.1. CPU Mode in arm
Processor Mode |
Description |
Notes |
User (USR) |
Normal program operating mode |
In this mode, the program does not have access to some system resources protected by the operating system, and the application cannot switch directly to processor mode. |
System (SYS) |
Privileged tasks to support the operating system, etc. |
Similar to user mode, but with privileges to switch directly to other modes |
Fast Interrupt (FIQ) |
Support high-speed data transmission and channel processing |
Fiq in this mode when an abnormal response is reached |
Interrupt (IRQ) |
For general interrupt handling |
IRQ Exception response when entering this mode |
Management (SVC) |
Operating System Protection Code |
System reset and software interrupt response when entering this mode |
Abort (ABT) |
Used to support virtual memory and/or memory protection |
There's no big use in ARM7TDMI. |
Undefined (und) |
Software emulation with support for hardware coprocessor |
Enter this mode when an instruction exception response is undefined |
In addition, in 7 modes, other modes are privileged mode except for the user usr mode.
There are two reasons why this is the SVC pattern instead of some other format:
-
Let's briefly analyze those 7 modes:
- The first thing to exclude is that the abort abt and undefined und mode, which are not quite normal mode, where the program is normal operation, so should not set the CPU for any one of the modes, so can be excluded.
- fast interrupt Fiq and interrupt IRQ mode
Second, for fast interrupt Fiq and interrupt IRQ, here Uboot initialization, there is no interruption to deal with and can handle , and even if the Terminal Services program is registered to handle interrupts, the two modes are automatically switched over, so this should not be set to any of these modes.
- user usr mode
Although in theory, the CPU can be set to user usr mode, but because this mode does not directly access a lot of hardware resources, and Uboot initialization , you have to access this type of resource, so you can exclude it and not set it to user usr mode.
- system sys mode vs Managed Svc Mode
First, the SYS mode and the USR mode are the same as the register groups used, But added some access to some resources that are inaccessible in USR mode.
While the SVC mode itself is privileged, it can access the controlled resources itself, and there are more shadow registers in its own mode than the SYS mode, so the ability to access resources is the same as in the SYS mode, but with more hardware resources.
Therefore, theoretically, although it can be set to either SYS and SVC mode, but from the uboot aspect, the thing to do is to initialize the system-related hardware resources, need to obtain as many permissions as possible to operate the hardware, the initialization of hardware. The
is set to SVC mode from the point of view of the Uboot to initialize the hardware, which is more advantageous for its work.
Therefore, the CPU is set to SVC mode here.
Uboot as a bootloader, the ultimate goal is to start the Linux kernel, in the preparation work (that is, the initialization of hardware, ready kernel and ROOTFS, etc.) before jumping to kernel, itself will meet some conditions, one of the conditions, is to require the CPU to be in SVC mode.
Therefore, uboot in the initial initialization phase, the CPU is set to the SVC mode, is also the most appropriate.
|
Tip |
For details on what conditions are met, please refer to ARM Linux Kernel Boot Requirements or Linux kernel documentation: De>kernel_source_root\documentation\arm\bootingde> The same explanation:
The CPU must is in SVC mode
|
Therefore, uboot in the initial initialization phase, the CPU is set to the SVC mode, is also the most appropriate.
In summary, uboot in the initialization phase, the CPU should be set to the SVC mode.
Uboot initialization, why to set the CPU to SVC mode instead of set to other mode