Debug
ARM DDI 0363G
Copyright © 2006-2011 ARM Limited. All rights reserved.
12-73
ID073015
Non-Confidential
Example 12-27 Reading a coprocessor register
uint32 ReadCPReg(int CPnum, int opc1, int CRn, int CRm, int opc2)
{
// Step 1. Save R0.
saved_r0 := ReadRegister(0);
// Step 2. Execute instruction MCR p15, 0, R0, c0, c1, 0 through the DBGITR.
ExecuteARMInstruction(0xEE (CPnum<<8) + (opc1<<21) + (CRn<<16) + CRm
+ (opc2<<5));
// Step 3. Read the value of R0 that now contains the CP register.
CP15c1 := ReadRegister(0);
// Step 4. Restore the value of R0.
WriteRegister(0, saved_r0);
return CP15c1;
}