Breaking

Saturday, August 10, 2019

Interrupt and Modes are related to each other. Each Interrupt makes the processor goes to different modes.  There are & interrupts and 7 modes in ARM. But 7 interrupts make the processor into 5 different Modes. Because User and System Modes don't require any interrupt. 


SVR:-
Supervisor Mode ARM7 enters this mode on reset. It is used to execute the BIOS program (Booting program). This mode can also be invoked by the programmer by SWI (Software Interrupt). For example.. in our Phone or PC, there are two different privileges. one is called supervisor mode and the other is user mode. These two modes are divided on the basis of protection level. If you are in supervisor mode you can access the system data as well as user data. but if you are in user mode, you only can access the user data. you don't have permission to access the system data because of it's protection level. When you first time starts your phone or PC it directly not going to user mode. It first runs the BIOS which is under the system privilege. The BIOS loads the operating system and allow you to go to the user mode. The time between the micro-controller start and go to the user mode, it works in supervisor mode. After that, the user-mode comes to underplay.

User Mode:-
This is the normal mode in which all user programs are executed. It is the only non-privileged mode. It has limited access to memory, I/O components, and flags. All the other modes can be entered through different kinds of exceptions (interrupts). After the supervisor mode, the micro-controller goes into the user-mode till the time you switch off it. Remember When you start  this is not going directly to the user mode. First, it handles by supervisor mode then the supervisor mode make a switch to user mode. and more than 95% time of its lifetime the ARM processor spends time in user mode. In this mode, you can go to all other modes.

System Mode:-

System Mode This is a Privileged version of the User Mode. The User program can invoke this mode to gain full control over CPSR and Memory. Needless to say, this mode should be used very discretely by the programmer, else the entire protection mechanism may be compromised.  

When you make a system call then you are going to the system mode. EX:- on our phone if we want to change some settings or want to increase or decrease the brightness of our phone. We know that we just have to drag the pointer right and left. But inside that, it makes a system call to adjust the brightness of your phone and after that, it comes back to its user mode.

FRQ:-
These two are the interrupt mode. when got a normal interrupt it goes to the IRQ mode do the execution of the ISR and comes back to the user mode.  If you got First to Interrupt you go to FRQ do the ISR execution come back to user mode. Fast Interrupt Request Mode This mode is entered when a high priority interrupts occurs through nFIQ pin. As this mode is used for high priority interrupts, the ISR should be executed with minimum latency (delay). Normally when we begin an ISR the original value of all GPRs of the parent program must be saved and before completion of the ISR these values must be restored into the GPRS for the proper continuation of the main program. This wastes a lot of time and therefore increases Interrupt Latency. But when a fast Interrupt request occurs, a new copy of R8-R14 is used. This completely eliminates the need for storing and restoring these registers and hence executes the ISR much faster. Therefore it is called Fast Interrupt Mode. By default nested interrupts are disabled in FIQ mode.

IRQ :-

Interrupt Request Mode This is a normal Interrupt Mode get invoked when a low priority interrupts occurs on the nIRO pin. Here Interrupt latency is the mode and nested interrupts are allowed.

Abort Mode:-
Abort Mode This mode is entered when an unsuccessful attempt is made to access a memory location. Due to the protection mechanism, some locations are not accessible in some of the modes.  When an attempt is made to access such a location, the processor enters Abort mode and the program that tried to access this location is aborted. The simple word when we are going to supervisor mode from user mode and try to access the system data or system program which doesn't have permission to access by the user then it goes to abort mode kill the operation and come back to the user mode.

Undefined:-
Undefined Mode This mode is used to enter undefined instructions.  This generally occurs when a co-processor instruction is encountered but a co-processor is not present in the system. The processor then enters Undefined mode and the program attempting that instruction is terminated.

When you fetch an instruction which is doesn't exist. That means in an ARM you fetch the instruction then go for decode. at the time of decode, it doesn't understand the upcode. This upcode is doesn't belong to ARM7. For example, you write a method or function or some code assuming that there are an ARM processor and a co-processor let's say a math processor or a floating-point processor. By the time Assembler make the upcode for both the main processor and coprocessor when it goes for execution it fetch the upcode and try to decode it but in reality, there is no coprocessor. So it can't decode the upcode and go to undefined mode and kill the operation and come back to user mode.

Also, Read👇

INTRODUCTION TO ARM 7

close