The document discusses using ARM SWI (Software Interrupt) functions to handle interrupts in an embedded system. It describes a sample program that installs an interrupt handler for SWI 0x08 and then calls the SWI functions 0 through 3. The main.c file contains functions to install the interrupt handler and call the SWI functions from main.
1 of 4
More Related Content
Arm Swi (1)
1. ARM SWI Stanley.Ho
ADS SVC ʽYҪ(1)ahandle.s(2)chandle.c(3)main.c(4)svc.h
ҪǽBʹ SVC(SWI)Ĺ܁ܛwД
main.c б
ʽf:
Install_Handler() : ׃ԭ vector SWI 0x08 ă,׃҂Ҫ Branch routine
main() : Install_Handler() SWI(0),SWI(1),SWI(2),SWI(3)
#include
#include svc.h
unsigned *svc_vec = (unsigned *)0x08;
extern void SVC_Handler(void);
unsigned Install_Handler( unsigned routine, unsigned *vector ){
unsigned vec, old_vec;
vec = (routine - (unsigned)vector - 8) >> 2; //routinevectorďֵ
/*
Branch instructions contain a signed 2s complement 24 bit offset. This is shifted left
two bits, sign extended to 32 bits, and added to the PC. The instruction can therefore
specify a branch of +