Whilst MRC
is a generic co-processor inter-op instruction, cp15
is the control processor - which all modern ARM CPUs have and this has been used by ARM was a means of extending the instruction set for on-chip units such as the cache, MMU, performance monitoring and lots else besides.
Taking your instruction a bit at a time:
mrc p15, 0, %0, c9, c13, 0" : : "r" (counter)
According to the ARM Cortex A7 MPCore Reference the instruction format is:
MRC{cond} P15, <Opcode_1>, <Rd>, <CRn>, <CRm>, <Opcode_2>
And on Page 4-11 this is described as a transfer of a CPU register to the performance monitor count register (I guess count=0
and this is a reset of the performance counter).
As for the syntax of inline assembler. refer to this for a x86 overview - which is probably similar to ARM.
The : : "r" (counter)
means that the instruction has:
- No output in a register that needs to end up in a local variable
- Takes input from variable
counter
, and the register this is in should be used as %0
.
- There are no side effects the compiler ought to be aware of (clobbers)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…