ARM 中斷向量表

以前,我一直很疑惑這個“ARM異常、中斷以及他們的向量表”是怎麼回事,他們到底是怎麼實現的,沒有想到今天偶然看到(ARM System Developer's Guide: Designing and Optimizing System Software的ARM異常、中斷以及他們的向量表的章節,豁然開朗。——ARM嵌入式系統開發:軟件設計與優化的英文原版——我個人感覺這是國內翻譯ARM書籍最好的一本之一,比杜XX的ARM體系結構與編程好千倍。 本書雖然說軟件設計與優化,但是講的硬件也很多,比如MMU和cache等,講的精彩紛呈:我剛纔想寫關於MMU和cache的博客,發現太龐大,看來這段時間要重新看看這本書才能寫。
下載地址:http://download.csdn.net/source/904273


————————下面來看看

2.4 Exceptions, Interrupts, and the Vector Table

When an exception or interrupt occurs, the processor sets the pc to a specific 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 specific routines designed to handle a
particular exception or interrupt.

——當異常或者中斷髮生的時候,處理器設置PC爲一個特殊的內存地址。這個地址叫做中斷向量表。中斷向量表入口是中斷、異常的分支入口((*^__^*) 嘻嘻……,這個翻譯的好爛,不過大家知道就可以了)。

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.

——內存映射地址0x00000000 是爲中斷向量表保留的。在某些處理器中斷向量表地址爲0xffff0000。某些操作系統如linux可以利用這個特徵(其實wince就是採用0xffff0000作爲中斷向量表的地址,但是令人奇怪的是優龍的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 specific routine:

——當異常或者中斷髮生的時候,處理器掛起正常執行的程序並開始加載中斷向量表,每個中斷入口包含一個指向 specific routine(這個不知道怎麼翻譯)的分支指令。

■ Reset vector is the location of the first instruction executed by the processor when power
is applied. This instruction branches to the initialization code.

——復位向量是打開電源被處理器執行的第一條指令,這條指令branches to初始化代碼
■ Undefined 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.

——軟件中斷向量........軟件中斷指令常用在操作系統條用。
■ 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.

——預取終止向量發生處理器試圖取一個指令地址,且沒有正確訪問許可的時候,實際終止發生在解碼階段
■ 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.

——數據終止向量類似預取終止,但是他發生在指令試圖訪問數據,且內存沒有正確訪問許可。
■ Interrupt request vector is used by external hardware to interrupt the normal execution
flow of the processor. It can only be raised if IRQs are not masked in the cpsr.

——中斷申請向量被用在外部硬件中斷正常執行的程序,它只能在IRQs 沒有被cpsr屏蔽的情況下。
總結:這個中斷向量的查找是由硬件實現的,硬件指定PC跳到0xffff0000/0x00000000(具體看編譯器),以前我總是從軟件角度去學習,大錯特錯。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章