13.ARM協處理器的知識


13.ARM協處理器的知識

在處理器中有協處理器來輔助處理器完成部分功能的,主要是協助作用。

協處理器:

協處理器用於執行特定的處理任務,如:數學協處理器可以控制數字處理,以減輕處理器的負擔。ARM可支持多達16個協處理器,其中CP15是最重要的一個。

 

在ARM9、ARM11、cortexa8等核中,CP15的功能都是一樣的。

在ARM11核的文檔看到圖1-1:

The section gives an overall view of the system control coprocessor. For detail of the registers

in the system control coprocessor, see System control processor registers on page 3-13.

The purpose of the system control coprocessor, CP15, is to control and provide status

information for the functions implemented in the ARM1176JZF-S processor. The main

functions of the system control coprocessor are:

• overall system control and configuration

• cache configuration and management

Tightly-Coupled Memory (TCM) configuration and management

Memory Management Unit (MMU) configuration and management

• DMA control

• system performance monitoring.

The system control coprocessor does not exist in a distinct physical block of logic.

圖1-1

從上面知道:

系統控制協處理器的功能是:

  1. 系統整體控制和配置
  2. 緩存配置和管理
  3. 緊耦合的內存(CTM)的配置和管理
  4. 內存管理單元(MMU)的配置和管理。
  5. DMA控制
  6. 系統性能控制。

確切的說,ARM11核中有16組協處理器,不是16個,每一組里面有很多寄存器,下面來看ARM11核的c0組里的Main ID寄存器。

System control processor registers

This section gives details of all the registers in the system control coprocessor. The section

presents a summary of the registers and detailed descriptions in register order of CRn,

Opcode_1, CRm, Opcode_2.

You can access CP15 registers with MRC and MCR instructions:

MCR{cond} P15,<Opcode_1>,<Rd>,<CRn>,<CRm>,<Opcode_2>

MRC{cond} P15,<Opcode_1>,<Rd>,<CRn>,<CRm>,<Opcode_2>

Register allocation

Table 3-2 on page 3-14 lists the allocation and reset values of the registers of the system control

coprocessor where:

• CRn is the register number within CP15

• Op1 is the Opcode_1 value for the register

• CRm is the operational register

• Op2 is the Opcode_2 value for the register.

• Type applies to the Secure, S, or the Non-secure, NS, world and is:

— B, registers banked in Secure and Non-secure worlds. If the registers are not banked

then they are common to both worlds or only accessible in one world.

— NA, no access

RO, read-only access

— RO, read-only access in privileged modes only

R/W, read/write access

— R/W, read/write access in privileged modes only

WO, write-only access

— WO, write-only access in privileged modes only

— X, access depends on another register or external signal.

Main ID寄存器的參數:

從上面c0組的Main ID寄存器,有32位,這32位被分成了5個地址段。例如[15:4]地址段是表明這是ARM11的處理器。此處的值是0xB76

 

前面的知識看到了,控制CP15協處理器,主要是設置對應的寄存器來實現控制的。接着就是來介紹如何訪問協處理器的寄存器的,並且實現設置。

主要是通過兩個命令來實現的mcr和mrc:r表示register普通寄存器,c表示coprocessor協處理器。

mcr命令中m表示move,c表示coprocessor,r表示register。所以mcr的意思就是把普通寄存器register的內容移到協處理器c里面。

mcr命令中m表示move,c表示coprocessor,r表示register。所以mrc的意思就是把協處理器c里面的內容移到普通寄存器register里面。

 

指令的格式:

You can access CP15 registers with MRC and MCR instructions:

MCR{cond} P15,<Opcode_1>,<Rd>,<CRn>,<CRm>,<Opcode_2>

MRC{cond} P15,<Opcode_1>,<Rd>,<CRn>,<CRm>,<Opcode_2>

上面是CP15的訪問格式,CP14-CP0同理。

各個參數的值,上面的表格已經給出了:

 

上圖看到在c0組的Main ID寄存器,在設置mrc,把Main ID寄存器的內容讀到r1寄存器:

從上圖知道:

  1. CRn=c0:c0組的
  2. Op1=0
  3. CRm=c0
  4. Op2=0
  5. Rd=r1:就是要把Main ID讀到r0寄存器。

這樣就設置好了。接下來實驗訪問Main ID:

讀取Main ID指令:

MRC P15,0,r1,c0,c0,0

運行結果:

讀出來的值是0x410fb766,這跟我們的核手冊的說明里的值是一致的,下圖。說明讀取成功:

上圖中[31:24]=0x41,[23:20]=0x0,[19:16]=0xF,[15:4]=0xB76,最后四位[3:0]是修訂位,是在0x0到0x7之間,這里是6,也是對的。所以讀出正確。

 

上面就是對CP15里的Main ID的讀取操作。

 

接下來是往Control寄存器里寫數據:

往c1組的Control寄存器寫入r1寄存器的值:

MCR P15,0,r1,c1,c0,0

上面運行了,就把r1的值寫進去了。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM