Here is the kernel module source code which works OK on Raspberry Pi 3, armv7 architecture:
void
enable_ccr(
*info) {
asm
volatile
(
"MCR p15, 0, %0, c9, c14, 0"
::
"r"
(1));
"MCR p15, 0, %0, c9, c12, 0\t\n"
"MCR p15, 0, %0, c9, c12, 1\t\n"
(0x80000000));
}
I have now switched my Raspberry Pi to 64-bit Linux Ubuntu OS, so the architecture is aarch64.
When I try to compile the source, I get error:
Error: unknown mnemonic `mcr' -- `mcr p15,0,x0,c9,c14,0'
How do I fix this?
OK, seems like the instructions are different:
https://developer.arm.com/documentation/ddi0500/j/Performance-Monitor-Unit/AArch64-PMU-register-descriptions/Performance-Monitors-Control-Register?lang=en
To access the PMCR_EL0:
MRS <Xt>, PMCR_EL0 ; Read PMCR_EL0 into Xt MSR PMCR_EL0, <Xt> ; Write Xt to PMCR_EL0
To access the PMCR in AArch32 Execution state, read or write the CP15 registers with:
MRC p15, 0, <Rt>, c9, c12, 0; Read Performance Monitor Control Register MCR p15, 0, <Rt>, c9, c12, 0; Write Performance Monitor Control Register
Does anyone know how to exactly rewrite my 3 lines of code?
Hi ,
In AArch64, the system registers are accessed using the MSR (and MRS) instructions.
The AArch32 registers PMUSERENR, PMCR and PMCNTENSET your 32b code is accessing need to be replaced by the AArch64 registers PMUSERENR_EL0, PMCR_EN0 and PMCNTENSET_EL0.
Best regards,
Vincent.