在ARM芯片资猜中,针对协处理器CP15的介绍十分少,可是CP15又十分重要,例如在运用MMU编写虚拟地址映射表时,最终的一步重要工作便是要将映射表的基地址存储到CP15的寄存器C2中,还有一些操控的TLB,Cache等拜访操控权限等等。。。
在根据ARM的嵌入式运用系统中,存储系统通常是经过系统操控协处理器CP15完结的。CP15包括16个32位的寄存器,其编号为0~15。
拜访CP15寄存器的指令
MCR
MRC
MCR指令和MRC指令只能在处理器形式为系统形式时履行,在用户形式下履行MCR指令和MRC指令将会触发未定义指令的异常中断。
MCR指令
MCR指令将ARM处理器的寄存器中的数据传送到协处理器寄存器中。假如协处理器不能成功地履行该操作,将发生未定义的指令异常中断。
指令语法格局
MCR{}
,< opcode_1>,,,{,}
MCR{} p15,0,,,{,}
其间,为指令履行的条件码。当疏忽时指令为无条件履行。
< opcode_1>为协处理器将履行的操作的操作码。关于CP15协处理器来说,< opcode_1>永远为0b000,当< opcode_1>不为0b000时,该指令操作成果不行预知。
作为源寄存器的ARM寄存器,其值将被传送到协处理器寄存器中。
作为方针寄存器的协处理器寄存器,其编号或许是C0,C1,…,C15。
和两者组合决议对协处理器寄存器进行所需求的操作,假如没有指定,则将为为C0,opcode_2为0,不然或许导致不行预知的成果。
The CRm field and opcode_2 field are used to specify a particular action when addressing registers.The opcode_1, opcode_2 and CRm fields should be zero, except when the values specified are used to select the desired operations, in all instructions which access CP15. Using other values will result in unpredictable behavior. Attempting to read from a non-readable register, or writing to a non-writable register will cause unpredictable results.
运用示例
下面的指令从ARM寄存器R4中中将数据传送到协处理器CP15的寄存器C1中。其间R4为ARM寄存器,寄存源操作数,C1、C0为协处理器寄存器,为方针寄存器,opcode_1为0,opcode_2为0。
MCR
MRC指令
MRC指令将协处理器的寄存器中的数值传送到ARM处理器的寄存器中、假如协处理器不能成功地履行该操作,将发生未定义的指令异常中断。
指令语法格局
MRC{}
,< opcode_1>,,,{,}
MRC{} p15,0,,,{,}
参数用法同MCR指令
CP15中的寄存器介绍
Register(寄存器) |
Read |
Write |
|
C0 |
ID Code (1) |
Unpredictable |
|
C0 |
Catch type(1) |
Unpredictable |
|
C1 |
Control |
Control |
|
C2 |
Translation table base |
Translation table base |
|
C3 |
Domain access control |
Domain access control |
|
C4 |
Unpredictable |
Unpredictable |
|
C5 |
Fault status(2) |
Fault status (2) |
|
C6 |
Fault address |
Fault address |
|
C7 |
Unpredictable |
Cache operations |
|
C8 |
Unpredictable |
TLB operations |
|
C9 |
Cache lockdown(2) |
Cache lockdown (2) |
|
C10 |
TLB lock down(2) |
TLB lock down(2) |
|
C11 |
Unpredictable |
Unpredictable |
|
C12 |
Unpredictable |
Unpredictable |
|
C13 |
Process ID |
Process ID |
|
C14 |
Unpredictable |
Unpredictable |
|
C15 |
Test configuration |
Test configuration |
|
Notes:
1.
2.
寄存器0:ID Code Register
The ID code register is accessed by reading CP15 register 0 with the opcode_2 field set to any value other than 1(the CRm field should be zero when reading). For example:
MRC
ID Code内容如下:
Register bits |
Function |
Value |
[31:24] |
Implementor |
0x41(‘A’,表明Arm公司) |
[23:20] |
Specification revision |
0x1 |
[19:16] |
Architecture version(4T) |
0x2(ARM系统版别4T) |
[15:4] |
Part number |
0x920 |
[3:0] |
Layout revision |
0x0 |
寄存器0:Cache type register
This is a read-only register which contains information about the size and architecture of the caches, allowing operating systems to establish how to perform such operations as cache cleaning and lockdown.
这个只读寄存器包括了高速缓存的巨细和类型。
The cache type register is accessed by reading CP15 register 0 with the opcode_2 field set to 1.for example:
MRC
The format of cache type register (寄存器的数据格局如下)
Register bits |
Function |
Value |
[31:29] |
Reserved |
000 |
[28:25] |
Cache type (缓存类型) |
0110 |
[24] |
Harvard/Unified |
1(defines Harvard cache) |
[23:21] |
Reserved |
000 |
[20:18] |
Data Cache size(数据缓存巨细) |
101(defines 16KB) |
[17:15] |
Data Cache associativity |
110(defines 64 way) |
[14] |
Reserved |
0 |
[13:12] |
Data Cache words per line |
10(defines 8 words per line) |
[11:9] |
Reserved |
000 |
[ 8:6] |
Instruction Cache size(指令缓存巨细) |
101(defines 16KB) |
[5:3] |
Instruction Cache Associativity |
110(defines 64 way) |
[2] |
Reserved |
0 |
[1:0] |
Instruction Cache per line |
10(defines 8 words per line) |