SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Downloaden Sie, um offline zu lesen
Embedded system -  introduction to arm7
ARM Exception Handling andARM Exception Handling and
Software Interrupts (SWI)Software Interrupts (SWI)
Designed 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
o Exceptions vs. interrupts
• Software Interrupts
o What is an SWI?
o What happens on an SWI?
o Vectoring SWIs
o What happens on SWI completion?
o What do SWIs do?
o A Complete SWI Handler
o A C_SWI_Handler (written in C)
• Loading the Software Interrupt Vector Table
The Frame PointerThe Frame Pointer
• fp points to top of the stack area for the
current function
o Or zero if not being used
• By using the frame pointer and storing it at
the same offset for every function call, it
creates a singly-linked list of activation
records
o The fp register points to the stack
backtrace structure for the currently
executing function.
o The saved fp value is (zero or) a
pointer to a stack backtrace structure
created by the function which called
the current function.
o The saved fp value in this structure is a
pointer to the stack backtrace
structure for the function that called
the function that called the current
function; and so on back until the first
function.
(saved) pc
(saved) lr
(saved) sb
SPbefore
address
0x90
0x8c
0x88
0x84
0x80
0x7c
0x78
0x74
0x70
0x6c
0x68
0x64
0x60
0x5c
0x58
0x54
0x50
(saved) ip
(saved) fp
v7
v6
v5
v4
v3
v2
v1
a4
a3
a2
a1
SPcurrent
FPcurrent
Creating the “backtrace”Creating the “backtrace”
structurestructure
MOV ip, sp
STMFD sp!,{a1­a4,v1­
v5,sb,fp,ip,lr,pc}
SUB fp, ip, #4
…
…
LDMFD fp, {fp,sp,sb,pc}
(saved) pc
(saved) lr
(saved) sb
SPbefore
address
0x90
0x8c
0x88
0x84
0x80
0x7c
0x78
0x74
0x70
0x6c
0x68
0x64
0x60
0x5c
0x58
0x54
0x50
(saved) ip
(saved) fp
v7
v6
v5
v4
v3
v2
v1
a4
a3
a2
a1
SPcurrent
FPcurrent
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
o reset when CPU reset pin is asserted
o undefined instruction when CPU tries to execute an undefined op-code
o software interrupt when CPU executes the SWI instruction
o prefetch abort when CPU tries to execute an instruction pre-fetched from an
illegal addr
o data abort when data transfer instruction tries to read or write at an illegal
address
o IRQ when CPU's external interrupt request pin is asserted
o FIQ when CPU's external fast interrupt request pin is asserted
ARM Processor Modes (of interest toARM Processor Modes (of interest to
us)us)
• User: the “normal” program execution mode.
• IRQ: used for general-purpose interrupt handling.
• Supervisor: a protected mode for the operating system.
o (there are also Abort, FIQ and Undef modes)
The ARM Register Set
• Registers R0-R15 + CPSR (Current Program Status Register)
o R13: Stack Pointer (by convention)
o R14: Link Register (hardwired)
o 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
o floating point overflow
o MMU fault (e.g., page fault)
o trap (SWI)
• Interrupt usually refers to an external I/O event such as
o I/O device request
o 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)
o SWI_WriteC(SWI 0) Write a byte to the debug channel
o SWI_Write0(SWI 2) Write the null-terminated string to debug
channel
o SWI_ReadC(SWI 4) Read a byte from the debug channel
o SWI_Exit(SWI 0x11) Halt emulation - this is how a program exits
o SWI_EnterOS(SWI 0x16) Put the processor in supervisor mode
o SWI_Clock(SWI 0x61) Return the number of centi-seconds
o SWI_Time(SWI 0x63) Return the number of secs since Jan. 1, 1970
• Read more in Chapter 17 of the JumpStart Reference Manual
o 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 Handler
2
““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)
3 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
SWISWI Handler Uses the “Comment” FieldHandler Uses the “Comment” Field
On SWI, the processor
(1) copies CPSR to SPSR_SVC
(2) set the CPSR mode bits to supervisor mode
(3) sets the CPSR IRQ to disable
(4) stores the value (PC + 4) into LR_SVC
(5) forces PC 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)
LDR r0,[lr,#­4]
BIC r0,r0,#0xff000000
R0 holds SWI number
MOVS pc, lr
SWI Handler
(S_Handler)
24-bit “comment” field (ignored by processor)1 1 1 1cond
FullFull SWISWI HandlerHandler
S_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)
o What is an SWI?
o What happens on an SWI?
o Vectoring SWIs
o What happens on SWI completion?
o What do SWIs do?
o A Full SWI Handler
o 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-class

Weitere ähnliche Inhalte

Was ist angesagt?

Tools for Practical Attacks on Analog-to-Digital Conversion
Tools for Practical Attacks on Analog-to-Digital ConversionTools for Practical Attacks on Analog-to-Digital Conversion
Tools for Practical Attacks on Analog-to-Digital ConversionAlexander Bolshev
 
ARM exceptions and interrupt controls
ARM exceptions and interrupt controlsARM exceptions and interrupt controls
ARM exceptions and interrupt controlsMahima Shastri
 
[DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC
[DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC [DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC
[DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC DefconRussia
 
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery Board
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery BoardProgramming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery Board
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery BoardGaurav Verma
 
Micro c lab2(led patterns)
Micro c lab2(led patterns)Micro c lab2(led patterns)
Micro c lab2(led patterns)Mashood
 
Mastering Microcontroller : TIMERS, PWM, CAN, RTC,LOW POWER
Mastering Microcontroller : TIMERS, PWM, CAN, RTC,LOW POWERMastering Microcontroller : TIMERS, PWM, CAN, RTC,LOW POWER
Mastering Microcontroller : TIMERS, PWM, CAN, RTC,LOW POWERFastBit Embedded Brain Academy
 
Introduction to Vortex86DX2 Motion-Control Evaluation Board
Introduction to Vortex86DX2 Motion-Control Evaluation BoardIntroduction to Vortex86DX2 Motion-Control Evaluation Board
Introduction to Vortex86DX2 Motion-Control Evaluation Boardroboard
 
FRDM-KL46Z_Hands-On_Presentation_v02
FRDM-KL46Z_Hands-On_Presentation_v02FRDM-KL46Z_Hands-On_Presentation_v02
FRDM-KL46Z_Hands-On_Presentation_v02Libor GECNUK
 
2 introduction to arm architecture
2 introduction to arm architecture2 introduction to arm architecture
2 introduction to arm architecturesatish1jisatishji
 
Exception handling in Pipelining in COA
Exception handling in Pipelining in COAException handling in Pipelining in COA
Exception handling in Pipelining in COARishavChandel1
 
LinuxCNC 入門簡介
LinuxCNC 入門簡介LinuxCNC 入門簡介
LinuxCNC 入門簡介roboard
 
Best-embedded-corporate-training-in-mumbai
Best-embedded-corporate-training-in-mumbaiBest-embedded-corporate-training-in-mumbai
Best-embedded-corporate-training-in-mumbaiUnmesh Baile
 
Arm modes
Arm modesArm modes
Arm modesabhi165
 
PIC Introduction and explained in detailed
PIC Introduction and explained in detailedPIC Introduction and explained in detailed
PIC Introduction and explained in detailedAnkita Tiwari
 
Using Ready-for-PIC and SDR Libraries
Using Ready-for-PIC and SDR LibrariesUsing Ready-for-PIC and SDR Libraries
Using Ready-for-PIC and SDR LibrariesCorrado Santoro
 

Was ist angesagt? (20)

Tools for Practical Attacks on Analog-to-Digital Conversion
Tools for Practical Attacks on Analog-to-Digital ConversionTools for Practical Attacks on Analog-to-Digital Conversion
Tools for Practical Attacks on Analog-to-Digital Conversion
 
ARM exceptions and interrupt controls
ARM exceptions and interrupt controlsARM exceptions and interrupt controls
ARM exceptions and interrupt controls
 
Arm
ArmArm
Arm
 
[DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC
[DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC [DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC
[DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC
 
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery Board
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery BoardProgramming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery Board
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery Board
 
Micro c lab2(led patterns)
Micro c lab2(led patterns)Micro c lab2(led patterns)
Micro c lab2(led patterns)
 
Mastering Microcontroller : TIMERS, PWM, CAN, RTC,LOW POWER
Mastering Microcontroller : TIMERS, PWM, CAN, RTC,LOW POWERMastering Microcontroller : TIMERS, PWM, CAN, RTC,LOW POWER
Mastering Microcontroller : TIMERS, PWM, CAN, RTC,LOW POWER
 
Soc
SocSoc
Soc
 
Introduction to Vortex86DX2 Motion-Control Evaluation Board
Introduction to Vortex86DX2 Motion-Control Evaluation BoardIntroduction to Vortex86DX2 Motion-Control Evaluation Board
Introduction to Vortex86DX2 Motion-Control Evaluation Board
 
Arm
ArmArm
Arm
 
FRDM-KL46Z_Hands-On_Presentation_v02
FRDM-KL46Z_Hands-On_Presentation_v02FRDM-KL46Z_Hands-On_Presentation_v02
FRDM-KL46Z_Hands-On_Presentation_v02
 
2 introduction to arm architecture
2 introduction to arm architecture2 introduction to arm architecture
2 introduction to arm architecture
 
Class8
Class8Class8
Class8
 
Exception handling in Pipelining in COA
Exception handling in Pipelining in COAException handling in Pipelining in COA
Exception handling in Pipelining in COA
 
STM32 Microcontroller Clocks and RCC block
STM32 Microcontroller Clocks and RCC blockSTM32 Microcontroller Clocks and RCC block
STM32 Microcontroller Clocks and RCC block
 
LinuxCNC 入門簡介
LinuxCNC 入門簡介LinuxCNC 入門簡介
LinuxCNC 入門簡介
 
Best-embedded-corporate-training-in-mumbai
Best-embedded-corporate-training-in-mumbaiBest-embedded-corporate-training-in-mumbai
Best-embedded-corporate-training-in-mumbai
 
Arm modes
Arm modesArm modes
Arm modes
 
PIC Introduction and explained in detailed
PIC Introduction and explained in detailedPIC Introduction and explained in detailed
PIC Introduction and explained in detailed
 
Using Ready-for-PIC and SDR Libraries
Using Ready-for-PIC and SDR LibrariesUsing Ready-for-PIC and SDR Libraries
Using Ready-for-PIC and SDR Libraries
 

Ähnlich wie Embedded system - introduction to arm7

Ähnlich wie Embedded system - introduction to arm7 (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
 
Arm architecture
Arm architectureArm architecture
Arm architecture
 
ARMInst.ppt
ARMInst.pptARMInst.ppt
ARMInst.ppt
 
ARMInst.ppt
ARMInst.pptARMInst.ppt
ARMInst.ppt
 
Instruction Set Architecture
Instruction Set ArchitectureInstruction Set Architecture
Instruction Set Architecture
 
Arm architecture
Arm architectureArm architecture
Arm architecture
 
Arm architecture overview
Arm architecture overviewArm architecture overview
Arm architecture overview
 
Qemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System EmulationQemu JIT Code Generator and System Emulation
Qemu JIT Code Generator and System Emulation
 
Processor types
Processor typesProcessor types
Processor types
 
Assembly programming
Assembly programmingAssembly programming
Assembly programming
 
Arm teaching material
Arm teaching materialArm teaching material
Arm teaching material
 
Arm teaching material
Arm teaching materialArm teaching material
Arm teaching material
 
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
 
AllBits presentation - Lower Level SW Security
AllBits presentation - Lower Level SW SecurityAllBits presentation - Lower Level SW Security
AllBits presentation - Lower Level SW Security
 
AAME ARM Techcon2013 002v02 Advanced Features
AAME ARM Techcon2013 002v02 Advanced FeaturesAAME ARM Techcon2013 002v02 Advanced Features
AAME ARM Techcon2013 002v02 Advanced Features
 
Linux interrupts
Linux interruptsLinux interrupts
Linux interrupts
 
ARM - Advance RISC Machine
ARM - Advance RISC MachineARM - Advance RISC Machine
ARM - Advance RISC Machine
 
My seminar new 28
My seminar new 28My seminar new 28
My seminar new 28
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1DianaGray10
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Adtran
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
The Kubernetes Gateway API and its role in Cloud Native API Management
The Kubernetes Gateway API and its role in Cloud Native API ManagementThe Kubernetes Gateway API and its role in Cloud Native API Management
The Kubernetes Gateway API and its role in Cloud Native API ManagementNuwan Dias
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemAsko Soukka
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?IES VE
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioChristian Posta
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Brian Pichman
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IES VE
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024SkyPlanner
 

Kürzlich hochgeladen (20)

Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
The Kubernetes Gateway API and its role in Cloud Native API Management
The Kubernetes Gateway API and its role in Cloud Native API ManagementThe Kubernetes Gateway API and its role in Cloud Native API Management
The Kubernetes Gateway API and its role in Cloud Native API Management
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
 
How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?How Accurate are Carbon Emissions Projections?
How Accurate are Carbon Emissions Projections?
 
Comparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and IstioComparing Sidecar-less Service Mesh from Cilium and Istio
Comparing Sidecar-less Service Mesh from Cilium and Istio
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )
 
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
IESVE Software for Florida Code Compliance Using ASHRAE 90.1-2019
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024Salesforce Miami User Group Event - 1st Quarter 2024
Salesforce Miami User Group Event - 1st Quarter 2024
 

Embedded system - introduction to arm7

  • 2. ARM Exception Handling andARM Exception Handling and Software Interrupts (SWI)Software Interrupts (SWI) Designed 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 o Exceptions vs. interrupts • Software Interrupts o What is an SWI? o What happens on an SWI? o Vectoring SWIs o What happens on SWI completion? o What do SWIs do? o A Complete SWI Handler o A C_SWI_Handler (written in C) • Loading the Software Interrupt Vector Table
  • 7. The Frame PointerThe Frame Pointer • fp points to top of the stack area for the current function o Or zero if not being used • By using the frame pointer and storing it at the same offset for every function call, it creates a singly-linked list of activation records o The fp register points to the stack backtrace structure for the currently executing function. o The saved fp value is (zero or) a pointer to a stack backtrace structure created by the function which called the current function. o The saved fp value in this structure is a pointer to the stack backtrace structure for the function that called the function that called the current function; and so on back until the first function. (saved) pc (saved) lr (saved) sb SPbefore address 0x90 0x8c 0x88 0x84 0x80 0x7c 0x78 0x74 0x70 0x6c 0x68 0x64 0x60 0x5c 0x58 0x54 0x50 (saved) ip (saved) fp v7 v6 v5 v4 v3 v2 v1 a4 a3 a2 a1 SPcurrent FPcurrent
  • 8. Creating the “backtrace”Creating the “backtrace” structurestructure MOV ip, sp STMFD sp!,{a1­a4,v1­ v5,sb,fp,ip,lr,pc} SUB fp, ip, #4 … … LDMFD fp, {fp,sp,sb,pc} (saved) pc (saved) lr (saved) sb SPbefore address 0x90 0x8c 0x88 0x84 0x80 0x7c 0x78 0x74 0x70 0x6c 0x68 0x64 0x60 0x5c 0x58 0x54 0x50 (saved) ip (saved) fp v7 v6 v5 v4 v3 v2 v1 a4 a3 a2 a1 SPcurrent FPcurrent
  • 9. 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 o reset when CPU reset pin is asserted o undefined instruction when CPU tries to execute an undefined op-code o software interrupt when CPU executes the SWI instruction o prefetch abort when CPU tries to execute an instruction pre-fetched from an illegal addr o data abort when data transfer instruction tries to read or write at an illegal address o IRQ when CPU's external interrupt request pin is asserted o FIQ when CPU's external fast interrupt request pin is asserted
  • 10. ARM Processor Modes (of interest toARM Processor Modes (of interest to us)us) • User: the “normal” program execution mode. • IRQ: used for general-purpose interrupt handling. • Supervisor: a protected mode for the operating system. o (there are also Abort, FIQ and Undef modes) The ARM Register Set • Registers R0-R15 + CPSR (Current Program Status Register) o R13: Stack Pointer (by convention) o R14: Link Register (hardwired) o R15: Program Counter where bits 0:1 are ignored (hardwired)
  • 11. TerminologyTerminology • The terms exception and interrupt are often confused • Exception usually refers to an internal CPU event such as o floating point overflow o MMU fault (e.g., page fault) o trap (SWI) • Interrupt usually refers to an external I/O event such as o I/O device request o reset • In the ARM architecture manuals, the two terms are mixed together
  • 12. 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) o SWI_WriteC(SWI 0) Write a byte to the debug channel o SWI_Write0(SWI 2) Write the null-terminated string to debug channel o SWI_ReadC(SWI 4) Read a byte from the debug channel o SWI_Exit(SWI 0x11) Halt emulation - this is how a program exits o SWI_EnterOS(SWI 0x16) Put the processor in supervisor mode o SWI_Clock(SWI 0x61) Return the number of centi-seconds o SWI_Time(SWI 0x63) Return the number of secs since Jan. 1, 1970 • Read more in Chapter 17 of the JumpStart Reference Manual o See Recommended Readings
  • 13. 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
  • 14. 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 Handler 2
  • 15. ““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?
  • 16. 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) 3 MOVS pc, lr SWI Handler (S_Handler)
  • 17. 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)
  • 18. 24-bit “comment” field (ignored by processor)1 1 1 1 SWISWI Instruction FormatInstruction Format • Example: SWI 0x18 cond 023242731 28 SWI number
  • 19. SWISWI Handler Uses the “Comment” FieldHandler Uses the “Comment” Field On SWI, the processor (1) copies CPSR to SPSR_SVC (2) set the CPSR mode bits to supervisor mode (3) sets the CPSR IRQ to disable (4) stores the value (PC + 4) into LR_SVC (5) forces PC 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) LDR r0,[lr,#­4] BIC r0,r0,#0xff000000 R0 holds SWI number MOVS pc, lr SWI Handler (S_Handler) 24-bit “comment” field (ignored by processor)1 1 1 1cond
  • 20. FullFull SWISWI HandlerHandler S_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)
  • 21. 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)
  • 22. 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;
  • 23. 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
  • 24. Summary of LectureSummary of Lecture • Software Interrupts (SWIs) o What is an SWI? o What happens on an SWI? o Vectoring SWIs o What happens on SWI completion? o What do SWIs do? o A Full SWI Handler o A C_SWI_Handler (written in C) • Loading Software Interrrupt Vectors
  • 25. Looking AheadLooking Ahead • Program Monitor, Loading and Initialization
  • 26. ThankThank You !!!You !!! For More Information click below link: Follow Us on: http://vibranttechnologies.co.in/embedded-system-class