This is a follow-up question for this answer.
I'm trying to read the content of ID_AA64MMFR1_EL1
register into the 64-bit variable using inline assembly:
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
int main(void)
{
uint64_t foo;
__asm volatile("mov %0, ID_AA64MMFR1_EL1" : "=r"(foo) ::);
printf("%"PRIx64"\n", foo);
}
Note: I need to read ID_AA64MMFR1_EL1
in order to know the value of AFP
field.
However, assembler rejects this code:
$ gcc t1b.c
/tmp/ccTDGH7d.s: Assembler messages:
/tmp/ccTDGH7d.s:22: Error: undefined symbol ID_AA64MMFR1_EL1 used as an immediate value
A simple question: how to do it correctly?
If your program is running at EL0
, you should rather use the HWCAP_CPUID API available in hwcaps - more details in this article, ARM64 CPU Feature Registers. See here for a working example code.