SlideShare a Scribd company logo
Introduction To ARM ExceptionIntroduction To ARM Exception
Handling andHandling and
Software Interrupts (SWI)Software Interrupts (SWI)
By :- Vibrant Technologies &
Computers
Recommended ReadingsRecommended Readings
• Sections 5.1-5.4 (Exceptions) of the ARM Developer Guide
• Chapter 12 (Implementing SWIs) of Jumpstart Programming
Techniques
• Chapters 17 ARM Demon Routines of Jumpstart Reference Manual
Catch up on your readings!
Thought for the DayThought for the Day
I can accept failure.
Everyone fails at something.
But I cannot accept not trying.
- Michael Jordan
Summary of Previous LectureSummary of Previous Lecture
• The ARM Programmer’s Model
• Introduction to ARM Assembly Language
• Assembly Code from C Programs (7 Examples)
• Dealing With Structures
• Interfacing C Code with ARM Assembly
• ARM libraries and armsd
Outline of This LectureOutline of This Lecture
• Frame pointers and backtrace structures
• Normal program flow vs. exceptions
– Exceptions vs. interrupts
• Software Interrupts
– What is an SWI?
– What happens on an SWI?
– Vectoring SWIs
– What happens on SWI completion?
– What do SWIs do?
– A Complete SWI Handler
– A C_SWI_Handler (written in C)
• Loading the Software Interrupt Vector Table
Normal Program FlowNormal Program Flow vs.vs. ExceptionsExceptions
• Normally, programs execute sequentially (with a few branches to make life interesting)
• Normally, programs execute in user mode (see next slide)
• Exceptions and interrupts break the sequential flow of a program, jumping to architecturally­defined
memory locations
• In ARM, SoftWare Interrupt (SWI) is the “system call” exception
• Types of ARM exceptions
– reset when CPU reset pin is asserted
– undefined instruction when CPU tries to execute an undefined op­code
– software interrupt when CPU executes the SWI instruction
– prefetch abort when CPU tries to execute an instruction pre­fetched from an illegal addr
– data abort when data transfer instruction tries to read or write at an illegal address
– IRQ when CPU's external interrupt request pin is asserted
– FIQ when CPU's external fast interrupt request pin is asserted
ARM Processor Modes (of interest to us)ARM Processor Modes (of interest to us)
• User: the “normal” program execution mode.
• IRQ: used for general­purpose interrupt handling.
• Supervisor: a protected mode for the operating system.
– (there are also Abort, FIQ and Undef modes)
The ARM Register Set
• Registers R0-R15 + CPSR (Current Program Status Register)
– R13: Stack Pointer (by convention)
– R14: Link Register (hardwired)
– R15: Program Counter where bits 0:1 are ignored (hardwired)
TerminologyTerminology
• The terms exception and interrupt are often confused
• Exception usually refers to an internal CPU event such as
– floating point overflow
– MMU fault (e.g., page fault)
– trap (SWI)
• Interrupt usually refers to an external I/O event such as
– I/O device request
– reset
• In the ARM architecture manuals, the two terms are mixed together
What do SWIs do?What do SWIs do?
• SWIs (often called software traps) allow a user program to “call” the OS ­­ that is, SWIs
are how system calls are implemented.
• When SWIs execute, the processor changes modes (from User to Supervisor mode on the
ARM) and disables interrupts.
• Types of SWIs in ARM Angel (axd or armsd)
– SWI_WriteC(SWI 0) Write a byte to the debug channel
– SWI_Write0(SWI 2) Write the null­terminated string to debug channel
– SWI_ReadC(SWI 4) Read a byte from the debug channel
– SWI_Exit(SWI 0x11) Halt emulation ­ this is how a program exits
– SWI_EnterOS(SWI 0x16) Put the processor in supervisor mode
– SWI_Clock(SWI 0x61) Return the number of centi­seconds
– SWI_Time(SWI 0x63) Return the number of secs since Jan. 1, 1970
• Read more in Chapter 17 of the JumpStart Reference Manual
– See Recommended Readings
What Happens on anWhat Happens on an SWISWI? (1)? (1)
• The ARM architecture defines a Vector Table indexed by exception type
• One SWI, CPU does the following: PC <­­0x08
• Also, sets LR_svc, SPSR_svc, CPSR (supervisor mode, no IRQ)
ADD r0,r0,r1
SWI 0x10
SUB r2,r2,r0
USER Program
to R_Handler
to U_Handler
to S_Handler
to P_Handler
to D_Handler
...
to I_Handler
to F_Handler
Vector Table (spring board)
starting at 0x00 in memory
0x00
0x04
0x08
0x0c
0x10
0x14
0x18
0x1c
(Reset
(Undef instr.)
(SWI)
(Prefetch abort)
(Data abort)
(Reserved)
(IRQ)
(FIQ)
SWI Handler
1
What Happens on anWhat Happens on an SWISWI? (2)? (2)
• Not enough space in the table (only one instruction per entry) to hold all of the code for the SWI
handler function
• This one instruction must transfer control to appropriate SWI Handler
• Several options are presented in the next slide
ADD r0,r0,r1
SWI 0x10
SUB r2,r2,r0
USER Program to R_Handler
to U_Handler
to S_Handler
to P_Handler
to D_Handler
...
to I_Handler
to F_Handler
Vector Table (spring board)
starting at 0x00 in memory
0x00
0x04
0x08
0x0c
0x10
0x14
0x18
0x1c
(Reset
(Undef instr.)
(SWI)
(Prefetch abort)
(Data abort)
(Reserved)
(IRQ)
(FIQ)
SWI Handler2
““Vectoring” Exceptions to HandlersVectoring” Exceptions to Handlers
• Option of choice: Load PC from jump table (shown below)
• Another option: Direct branch (limited range)
ADD r0,r0,r1
SWI 0x10
SUB r2,r2,r0
USER Program LDR pc, pc, 0x100
LDR pc, pc, 0x100
LDR pc, pc, 0x100
LDR pc, pc, 0x100
LDR pc, pc, 0x100
LDR pc, pc, 0x100
LDR pc, pc, 0x100
LDR pc, pc, 0x100
Vector Table (spring board)
starting at 0x00 in memory
0x00
0x04
0x08
0x0c
0x10
0x14
0x18
0x1c
SWI Handler
(S_Handler)2
&A_Handler
&U_Handler
&S_Handler
&P_Handler
...
“Jump” Table
0x108
0x10c
0x110
0x114
...
Why 0x110?
What Happens onWhat Happens on SWISWI Completion?Completion?
• Vectoring to the S_Handler starts executing the SWI handler
• When the handler is done, it returns to the program ­­ at the instruction following the
SWI
• MOVS restores the original CPSR as well as changing pc
ADD r0,r0,r1
SWI 0x10
SUB r2,r2,r0
USER Program to R_Handler
to U_Handler
to S_Handler
to P_Handler
to D_Handler
...
to I_Handler
to F_Handler
Vector Table (spring board)
starting at 0x00 in memory
0x00
0x04
0x08
0x0c
0x10
0x14
0x18
0x1c
(Reset
(Undef instr.)
(SWI)
(Prefetch abort)
(Data abort)
(Reserved)
(IRQ)
(FIQ)
MOVS pc, lr
SWI Handler
(S_Handler)
How Do We Determine the SWI number?How Do We Determine the SWI number?
• All SWIs go to 0x08
ADD r0,r0,r1
SWI 0x10
SUB r2,r2,r0
USER Program to R_Handler
to U_Handler
to S_Handler
to P_Handler
to D_Handler
...
to I_Handler
to F_Handler
Vector Table (spring board)
starting at 0x00 in memory
0x00
0x04
0x08
0x0c
0x10
0x14
0x18
0x1c
(Reset
(Undef instr.)
(SWI)
(Prefetch abort)
(Data abort)
(Reserved)
(IRQ)
(FIQ)
SWI Handler must
serve as clearing
house for different
SWIs
MOVS pc, lr
SWI Handler
(S_Handler)
24­bit “comment” field (ignored by processor)1 1 1 1
SWISWI Instruction FormatInstruction Format
• Example: SWI 0x18
cond
023242731 28
SWI number
FullFull SWISWI HandlerHandlerS_Handler
SUB sp,sp, #4 ; leave room on stack for SPSR
STMFD sp!, {r0­r12, lr} ; store user's gp registers
MRS r2, spsr[_csxf] ; get SPSR into gp registers
STR r2, [sp, #14*4] ; store SPSR above gp registers
MOV r1, sp ; pointer to parameters on stack
LDR r0, [lr, #­4] ; extract the SWI number
BIC r0,r0,#0xff000000 ; get SWI # by bit­masking
BL C_SWI_handler ; go to handler (see next slide)
LDR r2, [sp, #14*4] ; restore SPSR (NOT “sp!”)
MSR spsr_csxf, r2 ; csxf flags (see XScale QuickRef Card)
LDMFD sp!, {r0­r12, lr} ; unstack user's registers
ADD sp, sp, #4 ; remove space used to store SPSR
MOVS pc, lr ; return from handler
gp = general-purpose
SPSR is stored above gp registers since the registers
may contain system call parameters (sp in r1)
C_SWI_HandlerC_SWI_Handler
void C_SWI_handler(unsigned number, unsigned
*regs)
{
switch (number){
case 0: /* SWI number 0 code */ break;
case 1: /* SWI number 1 code */ break;
...
case XXX: /* SWI number XXX code */ break;
default:
} /* end switch */
} /* end C_SWI_handler() */
spsr_svc
lr_svc
r4
r3
r12
r11
r10
r9
r8
r7
r6
r5
r2
r1
r0
Previous sp_svc
sp_svc
regs[12]
regs[0] (also *regs)
Loading the Vector TableLoading the Vector Table
/* For 18-349, the Vector Table will use the ``LDR PC, PC,
* offset'' springboard approach */
unsigned Install_Handler(unsigned int routine, unsigned int *vector)
{
unsigned int pcload_instr, old_handler, *soft_vector;
pcload_instr = *vector; /* read the Vector Table instr (LDR ...) */
pcload_instr &= 0xfff; /* compute offset of jump table entry */
pcload_instr += 0x8 + (unsigned)vector; /* == offset adjusted by PC
and prefetch */
soft_vector = (unsigned *)pcload_instr; /* address to load pc from */
old_handler = *soft_vector; /* remember the old handler */
*soft_vector = routine; /* set up new handler in jump table */
return (old_handler); /* return old handler address */
} /* end Install_Handler() */
Called as
Install_Handler ((unsigned) C_SWI_Handler, swivec);
where,
unsigned *swivec = (unsigned *) 0x08;
Calling SWIs from C CodeCalling SWIs from C Code
char __swi(4) SWI_ReadC(void);
void readline (char *buffer)
{
char ch;
do {
*buffer++ = ch = SWI_ReadC();
while (ch != 13);
}
*buffer = 0;
} /* end readline() */
readline
STMDF sp!,{lr}
MOV lr, a1
readagain
SWI &4
STRB a1,[lr],#1
CMP a1,#&d
BNE readagain
MOV a1,#0
STRB a1, [lr, #0]
LDMIA sp!, {pc}
Assembly code produced by compiler
User-Level C Source Code
Summary of LectureSummary of Lecture
• Software Interrupts (SWIs)
– What is an SWI?
– What happens on an SWI?
– Vectoring SWIs
– What happens on SWI completion?
– What do SWIs do?
– A Full SWI Handler
– A C_SWI_Handler (written in C)
• Loading Software Interrrupt Vectors
Looking AheadLooking Ahead
• Program Monitor, Loading and Initialization
ThankThank You !!!You !!!
For More Information click below link:
Follow Us on:
http://vibranttechnologies.co.in/embedded-system-
classes-in-mumbai.html

More Related Content

What's hot

Unit II Arm 7 Introduction
Unit II Arm 7 IntroductionUnit II Arm 7 Introduction
Unit II Arm 7 Introduction
Dr. Pankaj Zope
 
ARM- Programmer's Model
ARM- Programmer's ModelARM- Programmer's Model
ARM- Programmer's Model
Ravikumar Tiwari
 
Interrupt handling
Interrupt handlingInterrupt handling
Interrupt handling
maverick2203
 
ARM Micro-controller
ARM Micro-controllerARM Micro-controller
ARM Micro-controller
Ravikumar Tiwari
 
Introduction to arm architecture
Introduction to arm architectureIntroduction to arm architecture
Introduction to arm architecture
Zakaria Gomaa
 
Arm processor
Arm processorArm processor
Arm processor
PrashantSingh056
 
Arm architecture overview
Arm architecture overviewArm architecture overview
Arm architecture overview
Sunil Thorat
 
Arm cortex-m4 programmer model
Arm cortex-m4 programmer modelArm cortex-m4 programmer model
Arm cortex-m4 programmer model
Mohammed Gomaa
 
arm-cortex-a8
arm-cortex-a8arm-cortex-a8
arm-cortex-a8
Andrew Daws
 
Arm architecture chapter2_steve_furber
Arm architecture chapter2_steve_furberArm architecture chapter2_steve_furber
Arm architecture chapter2_steve_furber
asodariyabhavesh
 
ARM architcture
ARM architcture ARM architcture
ARM architcture
Hossam Adel
 
ARM - Advance RISC Machine
ARM - Advance RISC MachineARM - Advance RISC Machine
ARM - Advance RISC Machine
EdutechLearners
 
Arm architecture
Arm architectureArm architecture
Arm architecture
AAQIB PARREY
 
The ARM Architecture: ARM : ARM Architecture
The ARM Architecture: ARM : ARM ArchitectureThe ARM Architecture: ARM : ARM Architecture
The ARM Architecture: ARM : ARM Architecture
sreea4
 
ARM
ARMARM
Arm
ArmArm
Arm architecture
Arm architectureArm architecture
ARM7-ARCHITECTURE
ARM7-ARCHITECTURE ARM7-ARCHITECTURE
ARM7-ARCHITECTURE
Dr.YNM
 
Microprocessors-based systems (under graduate course) Lecture 9 of 9
Microprocessors-based systems (under graduate course) Lecture 9 of 9 Microprocessors-based systems (under graduate course) Lecture 9 of 9
Microprocessors-based systems (under graduate course) Lecture 9 of 9
Randa Elanwar
 
EMBEDDED SYSTEM DESIGN ARM architecture support for operating system by sanj...
 EMBEDDED SYSTEM DESIGN ARM architecture support for operating system by sanj... EMBEDDED SYSTEM DESIGN ARM architecture support for operating system by sanj...
EMBEDDED SYSTEM DESIGN ARM architecture support for operating system by sanj...
D Y PATIL COLLEGE OF ENGINEERING PUNE
 

What's hot (20)

Unit II Arm 7 Introduction
Unit II Arm 7 IntroductionUnit II Arm 7 Introduction
Unit II Arm 7 Introduction
 
ARM- Programmer's Model
ARM- Programmer's ModelARM- Programmer's Model
ARM- Programmer's Model
 
Interrupt handling
Interrupt handlingInterrupt handling
Interrupt handling
 
ARM Micro-controller
ARM Micro-controllerARM Micro-controller
ARM Micro-controller
 
Introduction to arm architecture
Introduction to arm architectureIntroduction to arm architecture
Introduction to arm architecture
 
Arm processor
Arm processorArm processor
Arm processor
 
Arm architecture overview
Arm architecture overviewArm architecture overview
Arm architecture overview
 
Arm cortex-m4 programmer model
Arm cortex-m4 programmer modelArm cortex-m4 programmer model
Arm cortex-m4 programmer model
 
arm-cortex-a8
arm-cortex-a8arm-cortex-a8
arm-cortex-a8
 
Arm architecture chapter2_steve_furber
Arm architecture chapter2_steve_furberArm architecture chapter2_steve_furber
Arm architecture chapter2_steve_furber
 
ARM architcture
ARM architcture ARM architcture
ARM architcture
 
ARM - Advance RISC Machine
ARM - Advance RISC MachineARM - Advance RISC Machine
ARM - Advance RISC Machine
 
Arm architecture
Arm architectureArm architecture
Arm architecture
 
The ARM Architecture: ARM : ARM Architecture
The ARM Architecture: ARM : ARM ArchitectureThe ARM Architecture: ARM : ARM Architecture
The ARM Architecture: ARM : ARM Architecture
 
ARM
ARMARM
ARM
 
Arm
ArmArm
Arm
 
Arm architecture
Arm architectureArm architecture
Arm architecture
 
ARM7-ARCHITECTURE
ARM7-ARCHITECTURE ARM7-ARCHITECTURE
ARM7-ARCHITECTURE
 
Microprocessors-based systems (under graduate course) Lecture 9 of 9
Microprocessors-based systems (under graduate course) Lecture 9 of 9 Microprocessors-based systems (under graduate course) Lecture 9 of 9
Microprocessors-based systems (under graduate course) Lecture 9 of 9
 
EMBEDDED SYSTEM DESIGN ARM architecture support for operating system by sanj...
 EMBEDDED SYSTEM DESIGN ARM architecture support for operating system by sanj... EMBEDDED SYSTEM DESIGN ARM architecture support for operating system by sanj...
EMBEDDED SYSTEM DESIGN ARM architecture support for operating system by sanj...
 

Viewers also liked

Embedded system - introduction to arm7
Embedded system -  introduction to arm7Embedded system -  introduction to arm7
Embedded system - introduction to arm7
Vibrant Technologies & Computers
 
Running Docker on ARM
Running Docker on ARMRunning Docker on ARM
Running Docker on ARM
Dieter Reuter
 
4Plus
4Plus4Plus
4Plus
Rudybobudy
 
Programme 2days business_competition
Programme 2days business_competitionProgramme 2days business_competition
Programme 2days business_competition
Tatjana Strigalova
 
Induccion rrhh 2017 empleados y obreros
Induccion rrhh 2017   empleados y obrerosInduccion rrhh 2017   empleados y obreros
Induccion rrhh 2017 empleados y obreros
Alex Cumbicus Saavedra
 
Composición del cuerpo humano
Composición del cuerpo humanoComposición del cuerpo humano
Composición del cuerpo humano
shirley vanessa
 
Hard-Drawn Copper Conductors for Over Head Power Transmission
Hard-Drawn Copper Conductors for Over Head Power TransmissionHard-Drawn Copper Conductors for Over Head Power Transmission
Hard-Drawn Copper Conductors for Over Head Power Transmission
Chirag vasava
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
Anurag Tomar
 
ARM7TDM
ARM7TDMARM7TDM
ARM7TDM
Ramasubbu .P
 
SWIFT & IntelliMATCH
SWIFT & IntelliMATCHSWIFT & IntelliMATCH
SWIFT & IntelliMATCH
Paramjeet Singh
 
Electronic Toll Tax collection system in india
Electronic Toll Tax collection system in india Electronic Toll Tax collection system in india
Electronic Toll Tax collection system in india
Deepak Chouhan
 
A swift introduction to Swift
A swift introduction to SwiftA swift introduction to Swift
A swift introduction to Swift
Giordano Scalzo
 
Hacking with ARM devices on Linux
Hacking with ARM devices on Linux Hacking with ARM devices on Linux
Hacking with ARM devices on Linux
Netwalker lab kapper
 
Space Based Solar Power (SBSP)
Space Based Solar Power (SBSP)Space Based Solar Power (SBSP)
Space Based Solar Power (SBSP)
Seminar Links
 
Interrupts
InterruptsInterrupts
Interrupts
guest2e9811e
 
Difference between npn and pnp transistor.pptx
Difference between npn and pnp transistor.pptxDifference between npn and pnp transistor.pptx
Difference between npn and pnp transistor.pptx
elprocus
 
Induccion qhse 2017
Induccion qhse 2017Induccion qhse 2017
Induccion qhse 2017
Alex Cumbicus Saavedra
 

Viewers also liked (17)

Embedded system - introduction to arm7
Embedded system -  introduction to arm7Embedded system -  introduction to arm7
Embedded system - introduction to arm7
 
Running Docker on ARM
Running Docker on ARMRunning Docker on ARM
Running Docker on ARM
 
4Plus
4Plus4Plus
4Plus
 
Programme 2days business_competition
Programme 2days business_competitionProgramme 2days business_competition
Programme 2days business_competition
 
Induccion rrhh 2017 empleados y obreros
Induccion rrhh 2017   empleados y obrerosInduccion rrhh 2017   empleados y obreros
Induccion rrhh 2017 empleados y obreros
 
Composición del cuerpo humano
Composición del cuerpo humanoComposición del cuerpo humano
Composición del cuerpo humano
 
Hard-Drawn Copper Conductors for Over Head Power Transmission
Hard-Drawn Copper Conductors for Over Head Power TransmissionHard-Drawn Copper Conductors for Over Head Power Transmission
Hard-Drawn Copper Conductors for Over Head Power Transmission
 
I2C Protocol
I2C ProtocolI2C Protocol
I2C Protocol
 
ARM7TDM
ARM7TDMARM7TDM
ARM7TDM
 
SWIFT & IntelliMATCH
SWIFT & IntelliMATCHSWIFT & IntelliMATCH
SWIFT & IntelliMATCH
 
Electronic Toll Tax collection system in india
Electronic Toll Tax collection system in india Electronic Toll Tax collection system in india
Electronic Toll Tax collection system in india
 
A swift introduction to Swift
A swift introduction to SwiftA swift introduction to Swift
A swift introduction to Swift
 
Hacking with ARM devices on Linux
Hacking with ARM devices on Linux Hacking with ARM devices on Linux
Hacking with ARM devices on Linux
 
Space Based Solar Power (SBSP)
Space Based Solar Power (SBSP)Space Based Solar Power (SBSP)
Space Based Solar Power (SBSP)
 
Interrupts
InterruptsInterrupts
Interrupts
 
Difference between npn and pnp transistor.pptx
Difference between npn and pnp transistor.pptxDifference between npn and pnp transistor.pptx
Difference between npn and pnp transistor.pptx
 
Induccion qhse 2017
Induccion qhse 2017Induccion qhse 2017
Induccion qhse 2017
 

Similar to Embedded system - Introduction To ARM Exception Handling and Software Interrupts (SWI)

Lecture10.ppt
Lecture10.pptLecture10.ppt
Lecture10.ppt
MariusIoacara2
 
arm_exp.ppt
arm_exp.pptarm_exp.ppt
arm_exp.ppt
MariusIoacara2
 
ESD_05_ARM_Instructions set for preparation
ESD_05_ARM_Instructions set for preparationESD_05_ARM_Instructions set for preparation
ESD_05_ARM_Instructions set for preparation
ssuser026e94
 
ARMInst.ppt
ARMInst.pptARMInst.ppt
ARMInst.ppt
MostafaParvin1
 
ARMInst.ppt
ARMInst.pptARMInst.ppt
ARMInst.ppt
baskarA13
 
W10: Interrupts
W10: InterruptsW10: Interrupts
W10: Interrupts
Daniel Roggen
 
W8_1: Intro to UoS Educational Processor
W8_1: Intro to UoS Educational ProcessorW8_1: Intro to UoS Educational Processor
W8_1: Intro to UoS Educational Processor
Daniel Roggen
 
LPC 2148 Instructions Set.ppt
LPC 2148 Instructions Set.pptLPC 2148 Instructions Set.ppt
LPC 2148 Instructions Set.ppt
ProfBadariNathK
 
Arm
ArmArm
Introduction to ARM Architecture
Introduction to ARM ArchitectureIntroduction to ARM Architecture
Introduction to ARM Architecture
Racharla Rohit Varma
 
ARM exceptions and interrupt controls
ARM exceptions and interrupt controlsARM exceptions and interrupt controls
ARM exceptions and interrupt controls
Mahima Shastri
 
Arm architecture overview
Arm architecture overviewArm architecture overview
Arm architecture overview
Sathish Arumugasamy
 
Processor types
Processor typesProcessor types
Processor types
Amr Aboelgood
 
Arm teaching material
Arm teaching materialArm teaching material
Arm teaching material
John Williams
 
Arm teaching material
Arm teaching materialArm teaching material
Arm teaching material
Nilesh Bhandare
 
Linux interrupts
Linux interruptsLinux interrupts
Linux interrupts
mukul bhardwaj
 
Instruction Set Architecture
Instruction Set ArchitectureInstruction Set Architecture
Instruction Set Architecture
Dilum Bandara
 
Lecture8
Lecture8Lecture8
arm
armarm
AAME ARM Techcon2013 002v02 Advanced Features
AAME ARM Techcon2013 002v02 Advanced FeaturesAAME ARM Techcon2013 002v02 Advanced Features
AAME ARM Techcon2013 002v02 Advanced Features
Anh Dung NGUYEN
 

Similar to Embedded system - Introduction To ARM Exception Handling and Software Interrupts (SWI) (20)

Lecture10.ppt
Lecture10.pptLecture10.ppt
Lecture10.ppt
 
arm_exp.ppt
arm_exp.pptarm_exp.ppt
arm_exp.ppt
 
ESD_05_ARM_Instructions set for preparation
ESD_05_ARM_Instructions set for preparationESD_05_ARM_Instructions set for preparation
ESD_05_ARM_Instructions set for preparation
 
ARMInst.ppt
ARMInst.pptARMInst.ppt
ARMInst.ppt
 
ARMInst.ppt
ARMInst.pptARMInst.ppt
ARMInst.ppt
 
W10: Interrupts
W10: InterruptsW10: Interrupts
W10: Interrupts
 
W8_1: Intro to UoS Educational Processor
W8_1: Intro to UoS Educational ProcessorW8_1: Intro to UoS Educational Processor
W8_1: Intro to UoS Educational Processor
 
LPC 2148 Instructions Set.ppt
LPC 2148 Instructions Set.pptLPC 2148 Instructions Set.ppt
LPC 2148 Instructions Set.ppt
 
Arm
ArmArm
Arm
 
Introduction to ARM Architecture
Introduction to ARM ArchitectureIntroduction to ARM Architecture
Introduction to ARM Architecture
 
ARM exceptions and interrupt controls
ARM exceptions and interrupt controlsARM exceptions and interrupt controls
ARM exceptions and interrupt controls
 
Arm architecture overview
Arm architecture overviewArm architecture overview
Arm architecture overview
 
Processor types
Processor typesProcessor types
Processor types
 
Arm teaching material
Arm teaching materialArm teaching material
Arm teaching material
 
Arm teaching material
Arm teaching materialArm teaching material
Arm teaching material
 
Linux interrupts
Linux interruptsLinux interrupts
Linux interrupts
 
Instruction Set Architecture
Instruction Set ArchitectureInstruction Set Architecture
Instruction Set Architecture
 
Lecture8
Lecture8Lecture8
Lecture8
 
arm
armarm
arm
 
AAME ARM Techcon2013 002v02 Advanced Features
AAME ARM Techcon2013 002v02 Advanced FeaturesAAME ARM Techcon2013 002v02 Advanced Features
AAME ARM Techcon2013 002v02 Advanced Features
 

More from Vibrant Technologies & Computers

Buisness analyst business analysis overview ppt 5
Buisness analyst business analysis overview ppt 5Buisness analyst business analysis overview ppt 5
Buisness analyst business analysis overview ppt 5
Vibrant Technologies & Computers
 
SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables  SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables
Vibrant Technologies & Computers
 
SQL- Introduction to MySQL
SQL- Introduction to MySQLSQL- Introduction to MySQL
SQL- Introduction to MySQL
Vibrant Technologies & Computers
 
SQL- Introduction to SQL database
SQL- Introduction to SQL database SQL- Introduction to SQL database
SQL- Introduction to SQL database
Vibrant Technologies & Computers
 
ITIL - introduction to ITIL
ITIL - introduction to ITILITIL - introduction to ITIL
ITIL - introduction to ITIL
Vibrant Technologies & Computers
 
Salesforce - Introduction to Security & Access
Salesforce -  Introduction to Security & Access Salesforce -  Introduction to Security & Access
Salesforce - Introduction to Security & Access
Vibrant Technologies & Computers
 
Data ware housing- Introduction to olap .
Data ware housing- Introduction to  olap .Data ware housing- Introduction to  olap .
Data ware housing- Introduction to olap .
Vibrant Technologies & Computers
 
Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.
Vibrant Technologies & Computers
 
Data ware housing- Introduction to data ware housing
Data ware housing- Introduction to data ware housingData ware housing- Introduction to data ware housing
Data ware housing- Introduction to data ware housing
Vibrant Technologies & Computers
 
Salesforce - classification of cloud computing
Salesforce - classification of cloud computingSalesforce - classification of cloud computing
Salesforce - classification of cloud computing
Vibrant Technologies & Computers
 
Salesforce - cloud computing fundamental
Salesforce - cloud computing fundamentalSalesforce - cloud computing fundamental
Salesforce - cloud computing fundamental
Vibrant Technologies & Computers
 
SQL- Introduction to PL/SQL
SQL- Introduction to  PL/SQLSQL- Introduction to  PL/SQL
SQL- Introduction to PL/SQL
Vibrant Technologies & Computers
 
SQL- Introduction to advanced sql concepts
SQL- Introduction to  advanced sql conceptsSQL- Introduction to  advanced sql concepts
SQL- Introduction to advanced sql concepts
Vibrant Technologies & Computers
 
SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data   SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data
Vibrant Technologies & Computers
 
SQL- Introduction to SQL Set Operations
SQL- Introduction to SQL Set OperationsSQL- Introduction to SQL Set Operations
SQL- Introduction to SQL Set Operations
Vibrant Technologies & Computers
 
Sas - Introduction to designing the data mart
Sas - Introduction to designing the data martSas - Introduction to designing the data mart
Sas - Introduction to designing the data mart
Vibrant Technologies & Computers
 
Sas - Introduction to working under change management
Sas - Introduction to working under change managementSas - Introduction to working under change management
Sas - Introduction to working under change management
Vibrant Technologies & Computers
 
SAS - overview of SAS
SAS - overview of SASSAS - overview of SAS
SAS - overview of SAS
Vibrant Technologies & Computers
 
Teradata - Architecture of Teradata
Teradata - Architecture of TeradataTeradata - Architecture of Teradata
Teradata - Architecture of Teradata
Vibrant Technologies & Computers
 
Teradata - Restoring Data
Teradata - Restoring Data Teradata - Restoring Data
Teradata - Restoring Data
Vibrant Technologies & Computers
 

More from Vibrant Technologies & Computers (20)

Buisness analyst business analysis overview ppt 5
Buisness analyst business analysis overview ppt 5Buisness analyst business analysis overview ppt 5
Buisness analyst business analysis overview ppt 5
 
SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables  SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables
 
SQL- Introduction to MySQL
SQL- Introduction to MySQLSQL- Introduction to MySQL
SQL- Introduction to MySQL
 
SQL- Introduction to SQL database
SQL- Introduction to SQL database SQL- Introduction to SQL database
SQL- Introduction to SQL database
 
ITIL - introduction to ITIL
ITIL - introduction to ITILITIL - introduction to ITIL
ITIL - introduction to ITIL
 
Salesforce - Introduction to Security & Access
Salesforce -  Introduction to Security & Access Salesforce -  Introduction to Security & Access
Salesforce - Introduction to Security & Access
 
Data ware housing- Introduction to olap .
Data ware housing- Introduction to  olap .Data ware housing- Introduction to  olap .
Data ware housing- Introduction to olap .
 
Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.Data ware housing - Introduction to data ware housing process.
Data ware housing - Introduction to data ware housing process.
 
Data ware housing- Introduction to data ware housing
Data ware housing- Introduction to data ware housingData ware housing- Introduction to data ware housing
Data ware housing- Introduction to data ware housing
 
Salesforce - classification of cloud computing
Salesforce - classification of cloud computingSalesforce - classification of cloud computing
Salesforce - classification of cloud computing
 
Salesforce - cloud computing fundamental
Salesforce - cloud computing fundamentalSalesforce - cloud computing fundamental
Salesforce - cloud computing fundamental
 
SQL- Introduction to PL/SQL
SQL- Introduction to  PL/SQLSQL- Introduction to  PL/SQL
SQL- Introduction to PL/SQL
 
SQL- Introduction to advanced sql concepts
SQL- Introduction to  advanced sql conceptsSQL- Introduction to  advanced sql concepts
SQL- Introduction to advanced sql concepts
 
SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data   SQL Inteoduction to SQL manipulating of data
SQL Inteoduction to SQL manipulating of data
 
SQL- Introduction to SQL Set Operations
SQL- Introduction to SQL Set OperationsSQL- Introduction to SQL Set Operations
SQL- Introduction to SQL Set Operations
 
Sas - Introduction to designing the data mart
Sas - Introduction to designing the data martSas - Introduction to designing the data mart
Sas - Introduction to designing the data mart
 
Sas - Introduction to working under change management
Sas - Introduction to working under change managementSas - Introduction to working under change management
Sas - Introduction to working under change management
 
SAS - overview of SAS
SAS - overview of SASSAS - overview of SAS
SAS - overview of SAS
 
Teradata - Architecture of Teradata
Teradata - Architecture of TeradataTeradata - Architecture of Teradata
Teradata - Architecture of Teradata
 
Teradata - Restoring Data
Teradata - Restoring Data Teradata - Restoring Data
Teradata - Restoring Data
 

Recently uploaded

Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdfAI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
Techgropse Pvt.Ltd.
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
David Brossard
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 

Recently uploaded (20)

Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdfAI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
AI-Powered Food Delivery Transforming App Development in Saudi Arabia.pdf
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
OpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - AuthorizationOpenID AuthZEN Interop Read Out - Authorization
OpenID AuthZEN Interop Read Out - Authorization
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 

Embedded system - Introduction To ARM Exception Handling and Software Interrupts (SWI)

  • 1.
  • 2. Introduction To ARM ExceptionIntroduction To ARM Exception Handling andHandling and Software Interrupts (SWI)Software Interrupts (SWI) By :- Vibrant Technologies & Computers
  • 3. Recommended ReadingsRecommended Readings • Sections 5.1-5.4 (Exceptions) of the ARM Developer Guide • Chapter 12 (Implementing SWIs) of Jumpstart Programming Techniques • Chapters 17 ARM Demon Routines of Jumpstart Reference Manual Catch up on your readings!
  • 4. Thought for the DayThought for the Day I can accept failure. Everyone fails at something. But I cannot accept not trying. - Michael Jordan
  • 5. Summary of Previous LectureSummary of Previous Lecture • The ARM Programmer’s Model • Introduction to ARM Assembly Language • Assembly Code from C Programs (7 Examples) • Dealing With Structures • Interfacing C Code with ARM Assembly • ARM libraries and armsd
  • 6. Outline of This LectureOutline of This Lecture • Frame pointers and backtrace structures • Normal program flow vs. exceptions – Exceptions vs. interrupts • Software Interrupts – What is an SWI? – What happens on an SWI? – Vectoring SWIs – What happens on SWI completion? – What do SWIs do? – A Complete SWI Handler – A C_SWI_Handler (written in C) • Loading the Software Interrupt Vector Table
  • 7. Normal Program FlowNormal Program Flow vs.vs. ExceptionsExceptions • Normally, programs execute sequentially (with a few branches to make life interesting) • Normally, programs execute in user mode (see next slide) • Exceptions and interrupts break the sequential flow of a program, jumping to architecturally­defined memory locations • In ARM, SoftWare Interrupt (SWI) is the “system call” exception • Types of ARM exceptions – reset when CPU reset pin is asserted – undefined instruction when CPU tries to execute an undefined op­code – software interrupt when CPU executes the SWI instruction – prefetch abort when CPU tries to execute an instruction pre­fetched from an illegal addr – data abort when data transfer instruction tries to read or write at an illegal address – IRQ when CPU's external interrupt request pin is asserted – FIQ when CPU's external fast interrupt request pin is asserted
  • 8. ARM Processor Modes (of interest to us)ARM Processor Modes (of interest to us) • User: the “normal” program execution mode. • IRQ: used for general­purpose interrupt handling. • Supervisor: a protected mode for the operating system. – (there are also Abort, FIQ and Undef modes) The ARM Register Set • Registers R0-R15 + CPSR (Current Program Status Register) – R13: Stack Pointer (by convention) – R14: Link Register (hardwired) – R15: Program Counter where bits 0:1 are ignored (hardwired)
  • 9. TerminologyTerminology • The terms exception and interrupt are often confused • Exception usually refers to an internal CPU event such as – floating point overflow – MMU fault (e.g., page fault) – trap (SWI) • Interrupt usually refers to an external I/O event such as – I/O device request – reset • In the ARM architecture manuals, the two terms are mixed together
  • 10. What do SWIs do?What do SWIs do? • SWIs (often called software traps) allow a user program to “call” the OS ­­ that is, SWIs are how system calls are implemented. • When SWIs execute, the processor changes modes (from User to Supervisor mode on the ARM) and disables interrupts. • Types of SWIs in ARM Angel (axd or armsd) – SWI_WriteC(SWI 0) Write a byte to the debug channel – SWI_Write0(SWI 2) Write the null­terminated string to debug channel – SWI_ReadC(SWI 4) Read a byte from the debug channel – SWI_Exit(SWI 0x11) Halt emulation ­ this is how a program exits – SWI_EnterOS(SWI 0x16) Put the processor in supervisor mode – SWI_Clock(SWI 0x61) Return the number of centi­seconds – SWI_Time(SWI 0x63) Return the number of secs since Jan. 1, 1970 • Read more in Chapter 17 of the JumpStart Reference Manual – See Recommended Readings
  • 11. What Happens on anWhat Happens on an SWISWI? (1)? (1) • The ARM architecture defines a Vector Table indexed by exception type • One SWI, CPU does the following: PC <­­0x08 • Also, sets LR_svc, SPSR_svc, CPSR (supervisor mode, no IRQ) ADD r0,r0,r1 SWI 0x10 SUB r2,r2,r0 USER Program to R_Handler to U_Handler to S_Handler to P_Handler to D_Handler ... to I_Handler to F_Handler Vector Table (spring board) starting at 0x00 in memory 0x00 0x04 0x08 0x0c 0x10 0x14 0x18 0x1c (Reset (Undef instr.) (SWI) (Prefetch abort) (Data abort) (Reserved) (IRQ) (FIQ) SWI Handler 1
  • 12. What Happens on anWhat Happens on an SWISWI? (2)? (2) • Not enough space in the table (only one instruction per entry) to hold all of the code for the SWI handler function • This one instruction must transfer control to appropriate SWI Handler • Several options are presented in the next slide ADD r0,r0,r1 SWI 0x10 SUB r2,r2,r0 USER Program to R_Handler to U_Handler to S_Handler to P_Handler to D_Handler ... to I_Handler to F_Handler Vector Table (spring board) starting at 0x00 in memory 0x00 0x04 0x08 0x0c 0x10 0x14 0x18 0x1c (Reset (Undef instr.) (SWI) (Prefetch abort) (Data abort) (Reserved) (IRQ) (FIQ) SWI Handler2
  • 13. ““Vectoring” Exceptions to HandlersVectoring” Exceptions to Handlers • Option of choice: Load PC from jump table (shown below) • Another option: Direct branch (limited range) ADD r0,r0,r1 SWI 0x10 SUB r2,r2,r0 USER Program LDR pc, pc, 0x100 LDR pc, pc, 0x100 LDR pc, pc, 0x100 LDR pc, pc, 0x100 LDR pc, pc, 0x100 LDR pc, pc, 0x100 LDR pc, pc, 0x100 LDR pc, pc, 0x100 Vector Table (spring board) starting at 0x00 in memory 0x00 0x04 0x08 0x0c 0x10 0x14 0x18 0x1c SWI Handler (S_Handler)2 &A_Handler &U_Handler &S_Handler &P_Handler ... “Jump” Table 0x108 0x10c 0x110 0x114 ... Why 0x110?
  • 14. What Happens onWhat Happens on SWISWI Completion?Completion? • Vectoring to the S_Handler starts executing the SWI handler • When the handler is done, it returns to the program ­­ at the instruction following the SWI • MOVS restores the original CPSR as well as changing pc ADD r0,r0,r1 SWI 0x10 SUB r2,r2,r0 USER Program to R_Handler to U_Handler to S_Handler to P_Handler to D_Handler ... to I_Handler to F_Handler Vector Table (spring board) starting at 0x00 in memory 0x00 0x04 0x08 0x0c 0x10 0x14 0x18 0x1c (Reset (Undef instr.) (SWI) (Prefetch abort) (Data abort) (Reserved) (IRQ) (FIQ) MOVS pc, lr SWI Handler (S_Handler)
  • 15. How Do We Determine the SWI number?How Do We Determine the SWI number? • All SWIs go to 0x08 ADD r0,r0,r1 SWI 0x10 SUB r2,r2,r0 USER Program to R_Handler to U_Handler to S_Handler to P_Handler to D_Handler ... to I_Handler to F_Handler Vector Table (spring board) starting at 0x00 in memory 0x00 0x04 0x08 0x0c 0x10 0x14 0x18 0x1c (Reset (Undef instr.) (SWI) (Prefetch abort) (Data abort) (Reserved) (IRQ) (FIQ) SWI Handler must serve as clearing house for different SWIs MOVS pc, lr SWI Handler (S_Handler)
  • 16. 24­bit “comment” field (ignored by processor)1 1 1 1 SWISWI Instruction FormatInstruction Format • Example: SWI 0x18 cond 023242731 28 SWI number
  • 17. FullFull SWISWI HandlerHandlerS_Handler SUB sp,sp, #4 ; leave room on stack for SPSR STMFD sp!, {r0­r12, lr} ; store user's gp registers MRS r2, spsr[_csxf] ; get SPSR into gp registers STR r2, [sp, #14*4] ; store SPSR above gp registers MOV r1, sp ; pointer to parameters on stack LDR r0, [lr, #­4] ; extract the SWI number BIC r0,r0,#0xff000000 ; get SWI # by bit­masking BL C_SWI_handler ; go to handler (see next slide) LDR r2, [sp, #14*4] ; restore SPSR (NOT “sp!”) MSR spsr_csxf, r2 ; csxf flags (see XScale QuickRef Card) LDMFD sp!, {r0­r12, lr} ; unstack user's registers ADD sp, sp, #4 ; remove space used to store SPSR MOVS pc, lr ; return from handler gp = general-purpose SPSR is stored above gp registers since the registers may contain system call parameters (sp in r1)
  • 18. C_SWI_HandlerC_SWI_Handler void C_SWI_handler(unsigned number, unsigned *regs) { switch (number){ case 0: /* SWI number 0 code */ break; case 1: /* SWI number 1 code */ break; ... case XXX: /* SWI number XXX code */ break; default: } /* end switch */ } /* end C_SWI_handler() */ spsr_svc lr_svc r4 r3 r12 r11 r10 r9 r8 r7 r6 r5 r2 r1 r0 Previous sp_svc sp_svc regs[12] regs[0] (also *regs)
  • 19. Loading the Vector TableLoading the Vector Table /* For 18-349, the Vector Table will use the ``LDR PC, PC, * offset'' springboard approach */ unsigned Install_Handler(unsigned int routine, unsigned int *vector) { unsigned int pcload_instr, old_handler, *soft_vector; pcload_instr = *vector; /* read the Vector Table instr (LDR ...) */ pcload_instr &= 0xfff; /* compute offset of jump table entry */ pcload_instr += 0x8 + (unsigned)vector; /* == offset adjusted by PC and prefetch */ soft_vector = (unsigned *)pcload_instr; /* address to load pc from */ old_handler = *soft_vector; /* remember the old handler */ *soft_vector = routine; /* set up new handler in jump table */ return (old_handler); /* return old handler address */ } /* end Install_Handler() */ Called as Install_Handler ((unsigned) C_SWI_Handler, swivec); where, unsigned *swivec = (unsigned *) 0x08;
  • 20. Calling SWIs from C CodeCalling SWIs from C Code char __swi(4) SWI_ReadC(void); void readline (char *buffer) { char ch; do { *buffer++ = ch = SWI_ReadC(); while (ch != 13); } *buffer = 0; } /* end readline() */ readline STMDF sp!,{lr} MOV lr, a1 readagain SWI &4 STRB a1,[lr],#1 CMP a1,#&d BNE readagain MOV a1,#0 STRB a1, [lr, #0] LDMIA sp!, {pc} Assembly code produced by compiler User-Level C Source Code
  • 21. Summary of LectureSummary of Lecture • Software Interrupts (SWIs) – What is an SWI? – What happens on an SWI? – Vectoring SWIs – What happens on SWI completion? – What do SWIs do? – A Full SWI Handler – A C_SWI_Handler (written in C) • Loading Software Interrrupt Vectors
  • 22. Looking AheadLooking Ahead • Program Monitor, Loading and Initialization
  • 23. ThankThank You !!!You !!! For More Information click below link: Follow Us on: http://vibranttechnologies.co.in/embedded-system- classes-in-mumbai.html