+#elif __aarch64__
+ int fd;
+ unformat_input_t input;
+ u32 implementer, primary_part_number, variant, revision;
+
+ fd = open ("/proc/cpuinfo", 0);
+ if (fd < 0)
+ return format (s, "unknown");
+
+ unformat_init_clib_file (&input, fd);
+ while (unformat_check_input (&input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (&input, "CPU implementer%_: 0x%x", &implementer))
+ ;
+ else if (unformat (&input, "CPU part%_: 0x%x", &primary_part_number))
+ ;
+ else if (unformat (&input, "CPU variant%_: 0x%x", &variant))
+ ;
+ else if (unformat (&input, "CPU revision%_: %u", &revision))
+ ;
+ else
+ unformat_skip_line (&input);
+ }
+ unformat_free (&input);
+ close (fd);
+
+#define _(i,p,a,c,_format) if ((implementer == i) && (primary_part_number == p)){ \
+ if (_format)\
+ return format(s, "%s (%s PASS %c%u)", a, c, 'A'+variant, revision);\
+ else {\
+ if (implementer == 0x43)\
+ variant++; \
+ return format (s, "%s (%s PASS %u.%u)", a, c, variant, revision);}}
+
+ foreach_aarch64_cpu_uarch
+#undef _
+ return format (s, "unknown (implementer 0x%02x part 0x%03x PASS %u.%u)",
+ implementer, primary_part_number, variant, revision);
+