SlideShare ist ein Scribd-Unternehmen logo
1 von 30
By: Abhishek Pande
13BEI0004
Submitted to: Prof. V
Ramesh
 Processor modes refer to the various ways that
the processor creates an operating environment for itself.
Specifically, the processor mode controls how
the processor sees and manages the system memory
and the tasks that use it.
 In the old days, you had a processor and it executed
instructions. When an interrupt occured, the processor
would save its current state and then branch to a specific
place in order to service the interrupt. Thus, essentially,
the processor had just two 'modes' - dealing with an
interrupt, and not.
 But now the processors are much more capable and
ARM processors support different processor modes,
depending on the architecture version:-
Processor mode Architectures Mode number
User All 0b10000
FIQ - Fast
Interrupt Request
All 0b10001
IRQ - Interrupt
Request
All 0b10010
Supervisor All 0b10011
Abort All 0b10111
Undefined All 0b11011
System
ARMv4 and
above
0b11111
Monitor
Security
Extensions only
0b10110
• User mode: It is the usual ARM program execution
state, and is used for executing most application
programs.
• Fast Interrupt (FIQ): This mode supports a data
transfer or channel process.
• Interrupt (IRQ) mode is used for general-purpose
interrupt handling.
• Supervisor mode is a protected mode for the operating
system.
• Abort mode is entered after a data or instruction
• System mode is a privileged user mode for the
operating system.
• Undefined mode is entered when an undefined
instruction is executed.
Mode Mode identifier
User usr
Fast interrupt fiq
Interrupt irq
Supervisor svc
Abort abt
System sys
Undefined und
Table : Register mode identifiers
• It is the unprivileged mode under which most tasks run.
Unprivileged mode means that it doesn’t have access to
the full system resources and cannot change the mode
freely.
• It has access to the base register set i.e. at any time all
the 16 registers from R0 to R15(pc) can be accessed.
• CPSR (Current Program Status Register) is a 32-bit
wide register used in the ARM architecture to record
various pieces of information and flags regarding the
state of the program being executed by the processor
and the state of the processor. This register’s values can
be read from the User mode.
• Every processor mode except user mode can change
mode by writing directly to the mode bits of the CPSR.
• A banked register maps one-to-one onto a user mode
register.
• SPSR (Saved Program Status Register) is not available
in this mode.
• It is a privileged mode unlike the User mode but uses
the same set of registers as the User mode.
• All regular application tasks can be performed in this
mode. Also all the files except the kernel files can be
accessed through this mode. Both R/W is possible.
• We can only enter System mode from another
privileged mode by modifying the mode bit of
the Current Program Status Register (CPSR) and it
cannot be entered by an exception.
• System mode doesn’t have a set of associated banked
registers which all the other privileged modes have.
• A problem with the original design of the ARM is that as
processor vectors modify R14 with the return address, an
exception handler (for example, IRQ) that calls
subroutines cannot act in a re-entrant way; for if the IRQ
handler is taken while in the IRQ handler and having
called a subroutine to handle the (first) IRQ, the return
address in R14 will be trashed by the second IRQ
exception. Ways around this involve clever coding to
avoid an exception of the same type occurring, or to
avoid taking subroutine calls, or switching to USR mode.
Or in the case of interrupts, disabling them completely
during the interrupt process.
• But as of ARMv4, an alternative is proposed viz.
the System mode. It is like a cross between SVC and
USR. System mode offers the privileges of SVC mode,
however it uses the USR registers. An exception handler
can safely deal with R14 and CPSR and so re-entrancy is
possible. This deals with the corruption of the link
registers.
• This is a privileged mode which can be entered by
pressing RESET when a software interrupt instruction is
executed.
• Being in this mode we can breach the kernel files.
Updating these kernel files and even modifying them is
also possible but the warranty of the OS is rendered void
if it’s done.
• For e.g: Modifying the kernel files to install a new OS in
devices such as cell phones is done by entering into this
mode. This process is more popularly called “rooting” for
Android OS wherein we can access various privileged
• It’s basically a protected mode for the Operating
System which is uniquely reserved for it.
• In this mode R13(sp), R14(lr) and CPSR registers are
banked.
• OS calls the SWI to enter into SVC mode and then
processor jumps to &FFFF0008 location. After
subsystem reset, the ARM begins processing at address
&FFFF0000(for high vector config.) viz. the reset vector
address with interrupts disabled.
• To handle the problem of link register corruption, Linux
kernel does it this way: whenever any interrupt occurs in
• When power is supplied to the core, it starts in the SVC
mode.
• A Software Interrupt (SWI) exception occurs when the
SWI instruction is executed and none of the other higher-
priority exceptions have been flagged. On entry to the
handler, the CPSR will be automatically set to the
supervisor mode.
• FIQ or Fast Interrupt mode is a privileged mode which
can be entered when a high priority interrupt is raised.
• This mode is useful for digital data processors that have
the ability to handle multiple interrupts.
• When a fast interrupt request is received a flag is set
and the program counter(pc or R15) and condition code
registers are stored on a stack.
• FIQ is just a higher priority interrupt request, that is
prioritized by disabling IRQ and other FIQ handlers during
request servicing. Therefore, no other interrupts can
occur during the processing of the active FIQ interrupt.
• At the end of the ISR the return from interrupt
instructions retrieves the condition code register which
contains the status of the digital data processor and
checks to see whether the flag has been set or not. If the
flag is set it indicates that a fast interrupt was serviced
and therefore only the program counter(R15) is
unstacked.
• It is based on the same concept of a two-level interrupt
system where a more important interrupt can interrupt an
interrupt!
• FIQ mode provides a large number of banked registers
(R8 to R14, CPSR) and is useful for things that must
• The original (8MHz) ARM used FIQ for networking and
floppy disc which had to be serviced as soon as data
was available. Modern ARMs would probably use FIQ
for high speed DMA-style transfers.
• CPSR bit 6/F controls the masking of FIQ.
• FIQ vectors are similar to IRQ vectors but they are
reserved for hardware requiring faster response times.
• IRQ or Interrupt mode is a privileged mode which can
be entered when a low priority interrupt is raised.
• This is the other, regular, interrupt mode. Only R13,
R14, and CPSR registers are banked.
• Since IRQ has a lower priority than FIQ. This means
that when the core takes an FIQ exception, it
automatically masks out IRQs. An IRQ cannot interrupt
the FIQ handler.
• All interrupts that don't require extreme speed (clock
ticks, screen VSync, keyboard, etc...) will use IRQ
• When the processor is in the IRQ mode, the instructions
you execute still access registers R13 and R14. However,
these registers are the banked registers r13_irq and
r14_irq. The user mode registers r13_usr and r14_usr are
not affected by the instructions referencing these registers.
The program still has normal access to other registers R0
to R12.
• The following figure shows mode change from User to
IRQ when an interrupt request occurs due to an external
device raising interrupt to the processor core. This change
causes user registers R13 and R14 to be banked. The
user registers are replaced with registers r13_irq and
r14_irq, respectively. Note r14_irq contains the return
• The fig also shows a new register appearing in interrupt
request mode: the Saved Program Status Register
(SPSR), which stores the previous mode’s CPSR. You
can see in the diagram the cpsr being copied into
spsr_irq.
• CPSR bit 7/I controls the IRQ masking.
• So why do many systems use IRQ and not FIQ?
It’s because all of the interrupt controller hardware is
typically on the IRQ pin and using FIQ only makes sense
if you have a single highest priority interrupt source
connected to the nFIQ input and many systems do not
• This privileged mode is used to handle memory
access violations.
• An abort is signalled by the memory system as a result
of a failure to load either an instruction (Prefetch Abort)
or data (Data abort).
• A Prefetch Abort occurs if the processor attempts
to execute a failed instruction load (note - no abort
happens if the processor fails to load an instruction, but
said instruction is not executed due to a branch or
suchlike).
In ARMv5 a Prefetch Abort can be generated
• A Data Abort occurs if the processor attempts to fetch
data but the memory system says it is unable to due to
incorrect access permissions. The abort occurs before
the failed instruction alters the processor state.
• In both cases, interrupts are disabled and the branch
is taken.
• When we acess data through protected memory, we
can go into Abort mode.
• We can reserve any amount of data in protected
memory but it’s in ‘read only’ form so if a user tries to
write data into the protected memory, the system goes
• It’s not a working mode as such but a warning mode
which if triggered, the processor cannot perform any other
task.
• In general, a processor enters abort mode when there is
a failed attempt to access memory.
• This mode has R13, R14 and SPSR as banked registers.
• It’s underlying mechanism is that whenever an abort
signal is routed to the processor core, it responds to this
signal by taking an exception and vectoring to the abort
handler. The abort handler then determines the abort type
as either a prefetch or a data abort, and based on the
• It’s a privileged mode and not a working mode as such.
It’s also an error mode.
• When the processor tries to execute an invalid or
undefined instruction, it automatically goes to the
undefined mode.
• An Undefined instruction vector is used when the
processor cannot decode an instruction. Since this is an
ARM exception so instead of loading regular
instructions, some special instructions are loaded from
the exception vector table. Each vector table entry
contains a form of branch instruction pointing to the start
• When an undefined instruction is encountered, the
ARM will wait for a coprocessor to acknowledge that it
can deal with the instruction (if in co-processor
instruction space). If no coprocessor responds, or the
instruction is one that is not defined, then the undefined
instruction vector is taken. This will branch to
&FFFF0004 address to allow such things as software
emulation of coprocessors, or other extensions to the
instruction set.
• An Undefined Instruction exception occurs when an
instruction not in the ARM or Thumb instruction set
reaches the execute stage of the pipeline and none of
• Since coprocessors follow the pipeline, instruction
identification can take place in the execute stage of the
core. If none of the coprocessors claims the
instruction, an Undefined Instruction exception is
raised.
• Both the SWI instruction and Undefined instruction
have the same level of priority.
• If this mode is triggered, then the processing is
stalled like the Abort mode.
• Unlike the yesteryears processors, today’s competetive
market requires higher level of functionality and much
greater freedom to the developer or even the end user to
use a system in his/her on personalised manner.
• Multitasking or the ability to run various programs at
the same time is of great importance today.
• Moreover these multiple modes provide some
banked registers. These extra registers allow us
to write much less complicated exception routines.
Without them the function return address in LR
register would blow up everytime an interrupt
taken!
• With these extra registers at our disposal, we have the
option of not having to save and restore more processor
context in software which in turn speeds up the interrupt
handling process.
• Furthermore, with such high level of complexity in the
instuction set used, it should be made sure that none of
the mere programs should be able to mess around with
the OS or the machine's hardware. This is managed, in
part,
by the use of an MMU or other memory
management system, and in part by the use
of privilege. It is the various processor modes
Arm modes

Weitere ähnliche Inhalte

Was ist angesagt?

Hardware Software Codesign
Hardware Software CodesignHardware Software Codesign
Hardware Software Codesign
destruck
 
Embedded system design process
Embedded system design processEmbedded system design process
Embedded system design process
Rayees CK
 

Was ist angesagt? (20)

Unit II arm 7 Instruction Set
Unit II arm 7 Instruction SetUnit II arm 7 Instruction Set
Unit II arm 7 Instruction Set
 
Hardware Software Codesign
Hardware Software CodesignHardware Software Codesign
Hardware Software Codesign
 
Design challenges in embedded systems
Design challenges in embedded systemsDesign challenges in embedded systems
Design challenges in embedded systems
 
Rtos by shibu
Rtos by shibuRtos by shibu
Rtos by shibu
 
Embedded firmware
Embedded firmwareEmbedded firmware
Embedded firmware
 
Device drivers and interrupt service mechanism
Device drivers and interrupt service mechanismDevice drivers and interrupt service mechanism
Device drivers and interrupt service mechanism
 
Introduction to Digital Signal processors
Introduction to Digital Signal processorsIntroduction to Digital Signal processors
Introduction to Digital Signal processors
 
Introduction to arm processor
Introduction to arm processorIntroduction to arm processor
Introduction to arm processor
 
Embedded system
Embedded systemEmbedded system
Embedded system
 
Communication protocols - Embedded Systems
Communication protocols - Embedded SystemsCommunication protocols - Embedded Systems
Communication protocols - Embedded Systems
 
Introduction to Embedded Architecture
Introduction to Embedded Architecture Introduction to Embedded Architecture
Introduction to Embedded Architecture
 
Introduction to embedded system design
Introduction to embedded system designIntroduction to embedded system design
Introduction to embedded system design
 
SoC Design
SoC DesignSoC Design
SoC Design
 
Embedded system design process
Embedded system design processEmbedded system design process
Embedded system design process
 
Interrupt in real time system
Interrupt in real time system Interrupt in real time system
Interrupt in real time system
 
UART
UARTUART
UART
 
Arm organization and implementation
Arm organization and implementationArm organization and implementation
Arm organization and implementation
 
Arm instruction set
Arm instruction setArm instruction set
Arm instruction set
 
Hardware-Software Codesign
Hardware-Software CodesignHardware-Software Codesign
Hardware-Software Codesign
 
ARM 32-bit Microcontroller Cortex-M3 introduction
ARM 32-bit Microcontroller Cortex-M3 introductionARM 32-bit Microcontroller Cortex-M3 introduction
ARM 32-bit Microcontroller Cortex-M3 introduction
 

Andere mochten auch (7)

ARM- Programmer's Model
ARM- Programmer's ModelARM- Programmer's Model
ARM- Programmer's Model
 
Memory organization
Memory organizationMemory organization
Memory organization
 
Memory Organization
Memory OrganizationMemory Organization
Memory Organization
 
Memory Organization
Memory OrganizationMemory Organization
Memory Organization
 
04 cache memory
04 cache memory04 cache memory
04 cache memory
 
Programming The Arm Microprocessor For Embedded Systems
Programming The Arm Microprocessor For Embedded SystemsProgramming The Arm Microprocessor For Embedded Systems
Programming The Arm Microprocessor For Embedded Systems
 
Memory organisation
Memory organisationMemory organisation
Memory organisation
 

Ähnlich wie Arm modes

Section01 overview (1)
Section01 overview (1)Section01 overview (1)
Section01 overview (1)
Vimarsh Padha
 

Ähnlich wie Arm modes (20)

Arm
ArmArm
Arm
 
ARM exceptions and interrupt controls
ARM exceptions and interrupt controlsARM exceptions and interrupt controls
ARM exceptions and interrupt controls
 
Chapter 8
Chapter 8Chapter 8
Chapter 8
 
Introduction to ARM Architecture
Introduction to ARM ArchitectureIntroduction to ARM Architecture
Introduction to ARM Architecture
 
Arm cm3 architecture_and_programmer_model
Arm cm3 architecture_and_programmer_modelArm cm3 architecture_and_programmer_model
Arm cm3 architecture_and_programmer_model
 
MPU Chp2.pptx
MPU Chp2.pptxMPU Chp2.pptx
MPU Chp2.pptx
 
Kernel mode vs user mode in linux
Kernel mode vs user mode in linuxKernel mode vs user mode in linux
Kernel mode vs user mode in linux
 
Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and Architecture
 
Computer_Organization and architecture _unit 1.pptx
Computer_Organization and architecture _unit 1.pptxComputer_Organization and architecture _unit 1.pptx
Computer_Organization and architecture _unit 1.pptx
 
E.s unit 4 and 5
E.s unit 4 and 5E.s unit 4 and 5
E.s unit 4 and 5
 
Windows kernel
Windows kernelWindows kernel
Windows kernel
 
Section01 overview (1)
Section01 overview (1)Section01 overview (1)
Section01 overview (1)
 
Section01 overview
Section01 overviewSection01 overview
Section01 overview
 
Embedded systems 101 final
Embedded systems 101 finalEmbedded systems 101 final
Embedded systems 101 final
 
Section01-Overview.ppt
Section01-Overview.pptSection01-Overview.ppt
Section01-Overview.ppt
 
Lect 3 ARM PROCESSOR ARCHITECTURE
Lect 3  ARM PROCESSOR ARCHITECTURE Lect 3  ARM PROCESSOR ARCHITECTURE
Lect 3 ARM PROCESSOR ARCHITECTURE
 
Unit2 p1 io organization-97-2003
Unit2 p1 io organization-97-2003Unit2 p1 io organization-97-2003
Unit2 p1 io organization-97-2003
 
Arm architecture
Arm architectureArm architecture
Arm architecture
 
Chapter01 (1).ppt
Chapter01 (1).pptChapter01 (1).ppt
Chapter01 (1).ppt
 
ARM7TDMI-S_CPU.ppt
ARM7TDMI-S_CPU.pptARM7TDMI-S_CPU.ppt
ARM7TDMI-S_CPU.ppt
 

Kürzlich hochgeladen

Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Kürzlich hochgeladen (20)

Unit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdfUnit 2- Effective stress & Permeability.pdf
Unit 2- Effective stress & Permeability.pdf
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
(INDIRA) Call Girl Meerut Call Now 8617697112 Meerut Escorts 24x7
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 

Arm modes

  • 2.  Processor modes refer to the various ways that the processor creates an operating environment for itself. Specifically, the processor mode controls how the processor sees and manages the system memory and the tasks that use it.  In the old days, you had a processor and it executed instructions. When an interrupt occured, the processor would save its current state and then branch to a specific place in order to service the interrupt. Thus, essentially, the processor had just two 'modes' - dealing with an interrupt, and not.  But now the processors are much more capable and
  • 3. ARM processors support different processor modes, depending on the architecture version:- Processor mode Architectures Mode number User All 0b10000 FIQ - Fast Interrupt Request All 0b10001 IRQ - Interrupt Request All 0b10010 Supervisor All 0b10011 Abort All 0b10111 Undefined All 0b11011 System ARMv4 and above 0b11111 Monitor Security Extensions only 0b10110
  • 4. • User mode: It is the usual ARM program execution state, and is used for executing most application programs. • Fast Interrupt (FIQ): This mode supports a data transfer or channel process. • Interrupt (IRQ) mode is used for general-purpose interrupt handling. • Supervisor mode is a protected mode for the operating system. • Abort mode is entered after a data or instruction
  • 5. • System mode is a privileged user mode for the operating system. • Undefined mode is entered when an undefined instruction is executed. Mode Mode identifier User usr Fast interrupt fiq Interrupt irq Supervisor svc Abort abt System sys Undefined und Table : Register mode identifiers
  • 6.
  • 7. • It is the unprivileged mode under which most tasks run. Unprivileged mode means that it doesn’t have access to the full system resources and cannot change the mode freely. • It has access to the base register set i.e. at any time all the 16 registers from R0 to R15(pc) can be accessed. • CPSR (Current Program Status Register) is a 32-bit wide register used in the ARM architecture to record various pieces of information and flags regarding the state of the program being executed by the processor and the state of the processor. This register’s values can be read from the User mode.
  • 8. • Every processor mode except user mode can change mode by writing directly to the mode bits of the CPSR. • A banked register maps one-to-one onto a user mode register. • SPSR (Saved Program Status Register) is not available in this mode.
  • 9. • It is a privileged mode unlike the User mode but uses the same set of registers as the User mode. • All regular application tasks can be performed in this mode. Also all the files except the kernel files can be accessed through this mode. Both R/W is possible. • We can only enter System mode from another privileged mode by modifying the mode bit of the Current Program Status Register (CPSR) and it cannot be entered by an exception. • System mode doesn’t have a set of associated banked registers which all the other privileged modes have.
  • 10. • A problem with the original design of the ARM is that as processor vectors modify R14 with the return address, an exception handler (for example, IRQ) that calls subroutines cannot act in a re-entrant way; for if the IRQ handler is taken while in the IRQ handler and having called a subroutine to handle the (first) IRQ, the return address in R14 will be trashed by the second IRQ exception. Ways around this involve clever coding to avoid an exception of the same type occurring, or to avoid taking subroutine calls, or switching to USR mode. Or in the case of interrupts, disabling them completely during the interrupt process.
  • 11. • But as of ARMv4, an alternative is proposed viz. the System mode. It is like a cross between SVC and USR. System mode offers the privileges of SVC mode, however it uses the USR registers. An exception handler can safely deal with R14 and CPSR and so re-entrancy is possible. This deals with the corruption of the link registers.
  • 12. • This is a privileged mode which can be entered by pressing RESET when a software interrupt instruction is executed. • Being in this mode we can breach the kernel files. Updating these kernel files and even modifying them is also possible but the warranty of the OS is rendered void if it’s done. • For e.g: Modifying the kernel files to install a new OS in devices such as cell phones is done by entering into this mode. This process is more popularly called “rooting” for Android OS wherein we can access various privileged
  • 13. • It’s basically a protected mode for the Operating System which is uniquely reserved for it. • In this mode R13(sp), R14(lr) and CPSR registers are banked. • OS calls the SWI to enter into SVC mode and then processor jumps to &FFFF0008 location. After subsystem reset, the ARM begins processing at address &FFFF0000(for high vector config.) viz. the reset vector address with interrupts disabled. • To handle the problem of link register corruption, Linux kernel does it this way: whenever any interrupt occurs in
  • 14. • When power is supplied to the core, it starts in the SVC mode. • A Software Interrupt (SWI) exception occurs when the SWI instruction is executed and none of the other higher- priority exceptions have been flagged. On entry to the handler, the CPSR will be automatically set to the supervisor mode.
  • 15. • FIQ or Fast Interrupt mode is a privileged mode which can be entered when a high priority interrupt is raised. • This mode is useful for digital data processors that have the ability to handle multiple interrupts. • When a fast interrupt request is received a flag is set and the program counter(pc or R15) and condition code registers are stored on a stack. • FIQ is just a higher priority interrupt request, that is prioritized by disabling IRQ and other FIQ handlers during request servicing. Therefore, no other interrupts can occur during the processing of the active FIQ interrupt.
  • 16. • At the end of the ISR the return from interrupt instructions retrieves the condition code register which contains the status of the digital data processor and checks to see whether the flag has been set or not. If the flag is set it indicates that a fast interrupt was serviced and therefore only the program counter(R15) is unstacked. • It is based on the same concept of a two-level interrupt system where a more important interrupt can interrupt an interrupt! • FIQ mode provides a large number of banked registers (R8 to R14, CPSR) and is useful for things that must
  • 17. • The original (8MHz) ARM used FIQ for networking and floppy disc which had to be serviced as soon as data was available. Modern ARMs would probably use FIQ for high speed DMA-style transfers. • CPSR bit 6/F controls the masking of FIQ. • FIQ vectors are similar to IRQ vectors but they are reserved for hardware requiring faster response times.
  • 18. • IRQ or Interrupt mode is a privileged mode which can be entered when a low priority interrupt is raised. • This is the other, regular, interrupt mode. Only R13, R14, and CPSR registers are banked. • Since IRQ has a lower priority than FIQ. This means that when the core takes an FIQ exception, it automatically masks out IRQs. An IRQ cannot interrupt the FIQ handler. • All interrupts that don't require extreme speed (clock ticks, screen VSync, keyboard, etc...) will use IRQ
  • 19. • When the processor is in the IRQ mode, the instructions you execute still access registers R13 and R14. However, these registers are the banked registers r13_irq and r14_irq. The user mode registers r13_usr and r14_usr are not affected by the instructions referencing these registers. The program still has normal access to other registers R0 to R12. • The following figure shows mode change from User to IRQ when an interrupt request occurs due to an external device raising interrupt to the processor core. This change causes user registers R13 and R14 to be banked. The user registers are replaced with registers r13_irq and r14_irq, respectively. Note r14_irq contains the return
  • 20.
  • 21. • The fig also shows a new register appearing in interrupt request mode: the Saved Program Status Register (SPSR), which stores the previous mode’s CPSR. You can see in the diagram the cpsr being copied into spsr_irq. • CPSR bit 7/I controls the IRQ masking. • So why do many systems use IRQ and not FIQ? It’s because all of the interrupt controller hardware is typically on the IRQ pin and using FIQ only makes sense if you have a single highest priority interrupt source connected to the nFIQ input and many systems do not
  • 22. • This privileged mode is used to handle memory access violations. • An abort is signalled by the memory system as a result of a failure to load either an instruction (Prefetch Abort) or data (Data abort). • A Prefetch Abort occurs if the processor attempts to execute a failed instruction load (note - no abort happens if the processor fails to load an instruction, but said instruction is not executed due to a branch or suchlike). In ARMv5 a Prefetch Abort can be generated
  • 23. • A Data Abort occurs if the processor attempts to fetch data but the memory system says it is unable to due to incorrect access permissions. The abort occurs before the failed instruction alters the processor state. • In both cases, interrupts are disabled and the branch is taken. • When we acess data through protected memory, we can go into Abort mode. • We can reserve any amount of data in protected memory but it’s in ‘read only’ form so if a user tries to write data into the protected memory, the system goes
  • 24. • It’s not a working mode as such but a warning mode which if triggered, the processor cannot perform any other task. • In general, a processor enters abort mode when there is a failed attempt to access memory. • This mode has R13, R14 and SPSR as banked registers. • It’s underlying mechanism is that whenever an abort signal is routed to the processor core, it responds to this signal by taking an exception and vectoring to the abort handler. The abort handler then determines the abort type as either a prefetch or a data abort, and based on the
  • 25. • It’s a privileged mode and not a working mode as such. It’s also an error mode. • When the processor tries to execute an invalid or undefined instruction, it automatically goes to the undefined mode. • An Undefined instruction vector is used when the processor cannot decode an instruction. Since this is an ARM exception so instead of loading regular instructions, some special instructions are loaded from the exception vector table. Each vector table entry contains a form of branch instruction pointing to the start
  • 26. • When an undefined instruction is encountered, the ARM will wait for a coprocessor to acknowledge that it can deal with the instruction (if in co-processor instruction space). If no coprocessor responds, or the instruction is one that is not defined, then the undefined instruction vector is taken. This will branch to &FFFF0004 address to allow such things as software emulation of coprocessors, or other extensions to the instruction set. • An Undefined Instruction exception occurs when an instruction not in the ARM or Thumb instruction set reaches the execute stage of the pipeline and none of
  • 27. • Since coprocessors follow the pipeline, instruction identification can take place in the execute stage of the core. If none of the coprocessors claims the instruction, an Undefined Instruction exception is raised. • Both the SWI instruction and Undefined instruction have the same level of priority. • If this mode is triggered, then the processing is stalled like the Abort mode.
  • 28. • Unlike the yesteryears processors, today’s competetive market requires higher level of functionality and much greater freedom to the developer or even the end user to use a system in his/her on personalised manner. • Multitasking or the ability to run various programs at the same time is of great importance today. • Moreover these multiple modes provide some banked registers. These extra registers allow us to write much less complicated exception routines. Without them the function return address in LR register would blow up everytime an interrupt taken!
  • 29. • With these extra registers at our disposal, we have the option of not having to save and restore more processor context in software which in turn speeds up the interrupt handling process. • Furthermore, with such high level of complexity in the instuction set used, it should be made sure that none of the mere programs should be able to mess around with the OS or the machine's hardware. This is managed, in part, by the use of an MMU or other memory management system, and in part by the use of privilege. It is the various processor modes