5

In armv7 / 32bit mode I can read the cpuid using

   uint32_t arm_cpuid;
   __asm__("mrc p15, 0, %0, c0, c0, 0" : "=r"(arm_cpuid));

This gives 0x410FD034 for RPi3 and 0x410FD083 for RPi4.

What is the equivalent for that in aarch64 / armv8 syntax?

Note: I'm trying to detect if I'm running on a RPi3, RPi4 or some other arm board. This is before parsing the device tree so that isn't an alternate option.

1 Answers1

5

On aarch64 the cpuid can be read using

__asm__("mrs %0, MIDR_EL1" : "=r"(arm_cpuid));