繁体   English   中英

ARM Cortex-A7中的系统控制寄存器

[英]System Control Registers in ARM Cortex-A7

MCRMRC指令以不同的CRMOPT2执行,那么什么CRN寄存器的状态是什么? 例如,如果运行:

asm volatile("mcr p15, 0, %0, c9, c13, 0" : : "r"(val))

要么

asm volatile("mcr p15, 0, %0, c9, c13, 2" : : "r"(val))

那么,哪个寄存器的值将被更改为c9c13 最后一个选项(0或2)的作用是什么? 这里

MCR和MRC指令是通用协处理器指令。 这些指令的作用取决于所使用的特定硬件,具有的协处理器以及操作码和协处理器寄存器操作数( opcode1opcode2CRnCRm )的值。 协处理器寄存器操作数不一定是指实际的协处理器寄存器,因此实际上是附加的操作码操作数。

为了找出MCR / MRC指令的作用,您需要在特定于硬件的文档中查找该代码将在其上运行的特定CPU。 因此,对于您的示例,我们需要查看Cortex-A7的协处理器15文档 ,它是系统控制“协处理器”。 此页面列出了可以使用这些指令按CRnopcode1CRmopcode2顺序访问的系统控制寄存器。

在您的两个示例中, CRn均为c9,在文档中查找该链接会导致我们看到一个页面,其中大部分描述了与性能监控相关的寄存器 在您的第一个示例中, opcode1为0, CRm为13, opcode2为0,此页面告诉我们指令已写入PMCR或性能监视器控制寄存器。 在第二个示例中, opcode1为0, CRm为13, opcode2为2,这意味着它访问PMNCNTENCLR或计数使能清除寄存器。

您最好不要以为op1,op2,crn和crm会形成某个寄存器地址。 后一条指令将协处理器15的寄存器0,c9,c13、2(PMXEVCNTR,性能监视器事件计数寄存器)设置为C编译器决定用于变量“ val”的寄存器中包含的值。

对于除性能计数器寄存器以外的其他寄存器:B3.17.1通过协处理器寄存器编号汇总CP15寄存器图B3-26总结了针对VMSAv7实现的CP15寄存器按主要协处理器寄存器编号的分组。

                 CRn      opc1         CRm           opc2
                  c0      {0-2}        {c0-c7}       {0-7}      ¶    ID registers
                  c1      {0, 4}      {c0, c1}       {0-7}           System control registers
                  c2      {0, 4}      {c0, c1}       {0-2}               Memory protection and
                  c3        0            c0            0                 control registers
                  c5      {0, 4}       {c0,c1}       {0,1}               Memory system
                  c6      {0, 4}         c0        {0, 2, 4}             fault registers
                  c7      {0, 4}      Various      Various      ¶    Cache maintenance, address translations, miscellaneous
                  c8      {0, 4}      Various      Various           TLB maintenance operations
                  c9      {0-7}       Various        {0-7}      ¶    Reserved for performance monitors and maintenance operations
                 c10      {0-7}       Various        {0-7}      ¶    Memory mapping registers and TLB operations
                 c11      {0-7}     {c0-c8,c15}      {0-7}      ¶    Reserved for DMA operations for TCM access
                 c12      {0, 4}       {c0,c1}       {0,1}      ¶    Security Extensions registers, if implemented
                 c13      {0, 4}         c0          {0-4}      ¶    Process, context, and thread ID registers
                 c14      {0-7}       {c0-c15}       {0-7}      ¶    Generic Timer registers, if implemented
                 c15      {0-7}       {c0-c15}       {0-7}      ¶    IMPLEMENTATION DEFINED registers

                       Read-only              Read/Write             Write-only      ¶     Access depends on the implementation

               Figure B3-26 CP15 register grouping by primary coprocessor register, CRn, VMSA implementation

关于调试寄存器,有一个描述:C6.4.1使用CP14访问调试寄存器访问CP14接口中可见的寄存器通常使用以下协处理器指令:•MRC用于读取访问。 •MCR用于写访问。

              In addition, the following coprocessors instructions are defined for specific registers accesses:

              MRRC            Read access to the Debug ROM Address Register, DBGDRAR, and the Debug Self Address Offset
                              Register, DBGDSAR, in an implementation that includes the Large Physical Address Extension.

              STC             Read access to the Host to Target Data Transfer Register, DBGDTRRXint.

              LDC             Write access to the Target to Host Data Transfer Register, DBGDTRTXint.


              Form of MRC and MCR instructions
              The form of the MRC and MCR instructions used for accessing debug registers through the CP14 interface is:

                      MRC p14, 0, <Rt>, <CRn>, <CRm>, <opc2>          ; Read
                      MCR p14, 0, <Rt>, <CRn>, <CRm>, <opc2>          ; Write

              Where <Rt> refers to any of the ARM core registers R0-R14. Use of R13 is UNPREDICTABLE in Thumb and
              ThumbEE states, and is deprecated in ARM state. <CRn>, <CRm>, and <opc2> are mapped from the debug register
              number as shown in Figure C6-1

              The use of the MRC APSR_nzcv form of the MRC instruction is permitted for reads of the DBGDSCRint only. Use with
              other registers is UNPREDICTABLE. See CP14 interface 32-bit access instructions, required in all versions of the
              Debug architecture on page C6-2124 for more information.

              For accesses to the debug registers, <CRn> <= 0b0111 and therefore bit[10] of the value in the figure is 0.

                                                                                       10 9     8    7   6   5    4   3     2    1   0
                                                                                Value 0              Register number[9:0]



                                                                           Arguments      CRn[3:0]       opc2[2:0]        CRm[3:0]


                                 Figure C6-1 Mapping from debug register number to CP14 instruction arguments

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM