S3C2410中斷詳解
bResetHandler
本文引用地址:http://2s4d.com/article/201611/316988.htmbHandlerUndef;handler for Undefined mode
bHandlerSWI;handler for SWI interrupt
bHandlerPabort;handler for PAbort
bHandlerDabort;handler for DAbort
b.;reserved
bHandlerIRQ;handler for IRQ interrupt
bHandlerFIQ;handler for FIQ interrupt
跳轉(zhuǎn)的標(biāo)號是一系列的宏
LTORG
HandlerFIQ HANDLER HandleFIQ
HandlerIRQ HANDLER HandleIRQ
HandlerUndef HANDLER HandleUndef
HandlerSWI HANDLER HandleSWI
HandlerDabort HANDLER HandleDabort
HandlerPabort HANDLER HandlePabort
該宏在文件的最前面實(shí)現(xiàn),做了一些跳轉(zhuǎn)前的處理。如下:
MACRO
$HandlerLabel HANDLER $HandleLabel
$HandlerLabel
subsp,sp,#4 ;decrement sp(to store jump address)
stmfdsp!,{r0} ;PUSH the work register to stack(lr doest push because it return to original address)
ldr r0,=$HandleLabel;load the address of HandleXXX to r0
ldr r0,[r0] ;load the contents(service routine start address) of HandleXXX
str r0,[sp,#4] ;store the contents(ISR) of HandleXXX to stack
ldmfd sp!,{r0,pc} ;POP the work register and pc(jump to ISR)
MEND
以HandleIRQ跳轉(zhuǎn)為例說明中斷的二級跳轉(zhuǎn)流程,以上的宏代碼說明IRQ跳轉(zhuǎn)到了標(biāo)號HandleIRQ處,該標(biāo)號如下定義:(是一系列的中斷以及二級中斷入口地址)
AREA RamData, DA
^ _ISR_STARTADDRESS ;(該值自己定義,是存放中斷向量表的地址)
HandleReset # 4
HandleUndef # 4
HandleSWI # 4
HandlePabort # 4
HandleDabort # 4
HandleReserved # 4
HandleIRQ # 4
HandleFIQ # 4
;Dont use the label IntVectorTable,
;The value of IntVectorTable is different with the address you think it may be.
;IntVectorTable(二級IRQ中斷向量表)
HandleEINT0 # 4
HandleEINT1 # 4
HandleEINT2 # 4
HandleEINT3 # 4
HandleEINT4_7# 4
HandleEINT8_23# 4
HandleRSV6# 4
HandleBATFLT # 4
HandleTICK # 4
HandleWDT# 4
HandleTIMER0 # 4
HandleTIMER1 # 4
HandleTIMER2 # 4
HandleTIMER3 # 4
HandleTIMER4 # 4
HandleUART2 # 4
HandleLCD # 4
HandleDMA0# 4
HandleDMA1# 4
HandleDMA2# 4
HandleDMA3# 4
HandleMMC# 4
HandleSPI0# 4
HandleUART1# 4
HandleRSV24# 4
HandleUSBD# 4
HandleUSBH# 4
HandleIIC # 4
HandleUART0 # 4
HandleSPI1 # 4
HandleRTC # 4
HandleADC # 4
而HandleIRQ由以下代碼賦值,可以看出跳轉(zhuǎn)到了IsrIRQ:
drr0,=HandleIRQ ;This routine is needed
ldrr1,=IsrIRQ ;if there isnt subs pc,lr,#4 at 0x18, 0x1c放置中斷跳轉(zhuǎn)
strr1,[r0]
IsrIRQ ;真正的IRQ中斷的入口
subsp,sp,#4 ;reserved for PC留出一個(gè)位置保存中斷入口地址
stmfdsp!,{r8-r9}
ldrr9,=INTOFFSET
ldrr9,[r9] ;讀入中斷偏移碼
ldrr8,=HandleEINT0 ;二級跳轉(zhuǎn)表的首地址
addr8,r8,r9,lsl #2 ;R8=R8+R9X4得到相應(yīng)的中斷入口地址
ldrr8,[r8]
strr8,[sp,#8] ;中斷入口地址送進(jìn)SP(第一個(gè)代碼留出的4字節(jié)空間)
ldmfdsp!,{r8-r9,pc}
到此為止,中斷已經(jīng)順利的進(jìn)入了中斷向量表,用C語言編寫服務(wù)程序已變的非常簡單。如EINT0中斷的ISR
void Eint0(void)
{ }
pISR_EINT0=(U32)Eint0; //用中斷入口指向函數(shù)指針即可。
評論