微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > S3C2440启动代码 中断分析

S3C2440启动代码 中断分析

时间:11-22 来源:互联网 点击:

1.建立中断向量表

b ResetHandler;hereis the first instrument 0x00这是第一条执行的指令

b HandlerUndef ;handler for Undefined mode

b HandlerSWI ;handler for SWI interrupt

b HandlerPabort ;handler for PAbort

b HandlerDabort ;handler for DAbort

b . ;reserved

b HandlerIRQ ;handler for IRQ interrupt

b HandlerFIQ ;handler for FIQ interrupt

2. 设置缺省中断处理函数

;将普通中断判断程序的入口地址给HandleIRQ

ldr r0,=HandleIRQ ;This routine is needed

ldr r1,=IsrIRQ ;ifthere isnt subs pc,lr,#4 at 0x18, 0x1c

str r1,[r0]

3.IRQ的中断服务程序

IsrIRQ

sub sp,sp,#4;reserved for PC

stmfd sp!,{r8-r9}

ldr r9,=INTOFFSET ;地址为0x4a000014的空间存着中断的偏移

ldr r9,[r9]

ldr r8,=HandleEINT0

add r8,r8,r9,lsl#2

ldr r8,[r8]

str r8,[sp,#8]

ldmfd sp!,{r8-r9,pc}

;外部中断号判断,通过中断服务程序入口地址存储器的地址偏移确定

;PC=[HandleEINT0+[INTOFFSET]]

4.中断处理

HandlerFIQ HANDLER HandleFIQ

HandlerIRQ HANDLER HandleIRQ

HandlerUndef HANDLER HandleUndef

HandlerSWI HANDLER HandleSWI

HandlerDabort HANDLER HandleDabort

HandlerPabort HANDLER HandlePabort

5.将$HandleLabel地址空间中的数据给PC

MACRO

$HandlerLabel HANDLER $HandleLabel

$HandlerLabel

sub sp,sp,#4 ;decrementsp(to store jump address) sp=sp-4

stmfd sp!,{r0} ;PUSH the work register to stack(lr doest push because it return to originaladdress) r0进栈

ldr r0,=$HandleLabel;load the address ofHandleXXX to r0

ldr r0,[r0] ;load the contents(service routine start address) of HandleXXX

str r0,[sp,#4] ;store the contents(ISR) of HandleXXX tostack r0进栈,将ro中的数据写入sp+4为地址的存储器中

ldmfd sp!,{r0,pc} ;POP the work register and pc(jump to ISR) 恢复r0的值,同时也将$HandleLabel地址空间中的数据给PC

MEND

;将$HandleLabel地址空间中的数据给PC,中断服务程序的入口

6 中断向量表

ALIGN

AREARamData, DATA, READWRITE

^ _ISR_STARTADDRESS ; _ISR_STARTADDRESS=0x33FF_FF00

;表定位在 RAM 高端,基地址为 _ISR_STARTADDRESS

;^是MAP的同义词,#是FIELD的同义词

HandleReset # 4

HandleUndef # 4

HandleSWI # 4

HandlePabort # 4

HandleDabort # 4

HandleReserved # 4

HandleIRQ # 4

HandleFIQ # 4

HandleEINT0 #4

HandleEINT1 #4

HandleEINT2 #4

HandleEINT3 #4

HandleEINT4_7 # 4

HandleEINT8_23 # 4

HandleCAM #4 ; Added for 2440.

HandleBATFLT # 4

HandleTICK #4

HandleWDT #4

HandleTIMER0 #4

HandleTIMER1 #4

HandleTIMER2 #4

HandleTIMER3 #4

HandleTIMER4 # 4

HandleUART2 # 4

;@0x33FF_FF60

HandleLCD #4

HandleDMA0 #4

HandleDMA1 #4

HandleDMA2 #4

HandleDMA3 #4

HandleMMC #4

HandleSPI0 #4

HandleUART1 #4

HandleNFCON #4 ; Added for 2440.

HandleUSBD #4

HandleUSBH #4

HandleIIC #4

HandleUART0 #4

HandleSPI1 #4

HandleRTC #4

HandleADC # 4

7映射(定义一个指针的指针)

/ Exception vector

#define pISR_RESET (*(unsigned *)(_ISR_STARTADDRESS+0x0))

#define pISR_UNDEF (*(unsigned *)(_ISR_STARTADDRESS+0x4))

#define pISR_SWI (*(unsigned *)(_ISR_STARTADDRESS+0x8))

#define pISR_PABORT (*(unsigned *)(_ISR_STARTADDRESS+0xc))

#define pISR_DABORT (*(unsigned *)(_ISR_STARTADDRESS+0x10))

#define pISR_RESERVED (*(unsigned *)(_ISR_STARTADDRESS+0x14))

#define pISR_IRQ (*(unsigned *)(_ISR_STARTADDRESS+0x18))

#define pISR_FIQ (*(unsigned *)(_ISR_STARTADDRESS+0x1c))

// Interrupt vector

#define pISR_EINT0 (*(unsigned *)(_ISR_STARTADDRESS+0x20))

#define pISR_EINT1 (*(unsigned *)(_ISR_STARTADDRESS+0x24))

#define pISR_EINT2 (*(unsigned *)(_ISR_STARTADDRESS+0x28))

#define pISR_EINT3 (*(unsigned *)(_ISR_STARTADDRESS+0x2c))

#define pISR_EINT4_7 (*(unsigned *)(_ISR_STARTADDRESS+0x30))

#define pISR_EINT8_23 (*(unsigned *)(_ISR_STARTADDRESS+0x34))

#define pISR_CAM (*(unsigned *)(_ISR_STARTADDRESS+0x38)) // Added for 2440.

#define pISR_BAT_FLT (*(unsigned *)(_ISR_STARTADDRESS+0x3c))

#define pISR_TICK (*(unsigned *)(_ISR_STARTADDRESS+0x40))

#define pISR_WDT_AC97 (*(unsigned*)(_ISR_START

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top