如何理解ARM異常、中斷和向量表
以前,我一直很疑惑這個“ARM異常、中斷以及他們的向量表”是怎么回事,他們到底是怎么實現(xiàn)的,沒有想到今天偶然看到(ARM System Developer's Guide: Designing and OpTImizing System Software的ARM異常、中斷以及他們的向量表的章節(jié),豁然開朗。——ARM嵌入式系統(tǒng)開發(fā):軟件設(shè)計與優(yōu)化的英文原版——我個人感覺這是國內(nèi)翻譯ARM書籍最好的一本之一,比杜XX的ARM體系結(jié)構(gòu)與編程好千倍。 本書雖然說軟件設(shè)計與優(yōu)化,但是講的硬件也很多,比如MMU和cache等,講的精彩紛呈:我剛才想寫關(guān)于MMU和cache的博客,發(fā)現(xiàn)太龐大,看來這段時間要重新看看這本書才能寫。
下載地址:
)
————————下面來看看
2.4 ExcepTIons, Interrupts, and the Vector Table
When an excepTIon or interrupt occurs, the processor sets the pc to a speci?c memory
address. The address is within a special address range called the vector table. The entries
in the vector table are instrucTIons that branch to speci?c routines designed to handle a
particular exception or interrupt.
——當異常或者中斷發(fā)生的時候,處理器設(shè)置PC為一個特殊的內(nèi)存地址。這個地址叫做中斷向量表。中斷向量表入口是中斷、異常的分支入口((*^__^*) 嘻嘻……,這個翻譯的好爛,不過大家知道就可以了)。
The memory map address 0x00000000 is reserved for the vector table, a set of 32-bit
words. On some processors the vector table can be optionally located at a higher address
in memory (starting at the offset 0xffff0000). Operating systems such as Linux and
Microsoft’s embedded products can take advantage of this feature.
——內(nèi)存映射地址0x00000000 是為中斷向量表保留的。在某些處理器中斷向量表地址為0xffff0000。某些操作系統(tǒng)如linux可以利用這個特征(其實wince就是采用0xffff0000作為中斷向量表的地址,但是令人奇怪的是優(yōu)龍的ADS bootloader的中斷向量表地址是0x00000000 ,估計這是編譯器決定了)。
When an exception or interrupt occurs, the processor suspends normal execution and
starts loading instructions fromthe exception vector table (see Table 2.6). Each vector table
entry contains a form of branch instruction pointing to the start of a speci?c routine:
——當異?;蛘咧袛喟l(fā)生的時候,處理器掛起正常執(zhí)行的程序并開始加載中斷向量表,每個中斷入口包含一個指向 speci?c routine(這個不知道怎么翻譯)的分支指令。
■ Reset vector is the location of the ?rst instruction executed by the processor when power
is applied. This instruction branches to the initialization code.
——復(fù)位向量是打開電源被處理器執(zhí)行的第一條指令,這條指令branches to初始化代碼
■ Unde?ned instruction vector is used when the processor cannot decode an instruction.
——未定義指令向量,被用在處理器無法解碼指令的時候
■ Software interrupt vector is called when you execute a SWI instruction. The SWI
instruction is frequently used as themechanismto invoke an operating systemroutine.
——軟件中斷向量........軟件中斷指令常用在操作系統(tǒng)條用。
■ Prefetch abort vector occurs when the processor attempts to fetch an instruction froman
address without the correct access permissions. The actual abort occurs in the decode
stage.
——預(yù)取終止向量發(fā)生處理器試圖取一個指令地址,且沒有正確訪問許可的時候,實際終止發(fā)生在解碼階段
■ Data abort vector is similar to a prefetch abort but is raised when an instruction attempts
to access data memory without the correct access permissions.
——數(shù)據(jù)終止向量類似預(yù)取終止,但是他發(fā)生在指令試圖訪問數(shù)據(jù),且內(nèi)存沒有正確訪問許可。
■ Interrupt request vector is used by external hardware to interrupt the normal execution
?ow of the processor. It can only be raised if IRQs are not masked in the cpsr.
——中斷申請向量被用在外部硬件中斷正常執(zhí)行的程序,它只能在IRQs 沒有被cpsr屏蔽的情況下。
====================================================================================