Home | History | Annotate | Line # | Download | only in arch
aarch64.c revision 1.10
      1  1.10       ryo /*	$NetBSD: aarch64.c,v 1.10 2020/07/01 08:03:10 ryo Exp $	*/
      2   1.1       ryo 
      3   1.1       ryo /*
      4   1.1       ryo  * Copyright (c) 2018 Ryo Shimizu <ryo (at) nerv.org>
      5   1.1       ryo  * All rights reserved.
      6   1.1       ryo  *
      7   1.1       ryo  * Redistribution and use in source and binary forms, with or without
      8   1.1       ryo  * modification, are permitted provided that the following conditions
      9   1.1       ryo  * are met:
     10   1.1       ryo  * 1. Redistributions of source code must retain the above copyright
     11   1.1       ryo  *    notice, this list of conditions and the following disclaimer.
     12   1.1       ryo  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1       ryo  *    notice, this list of conditions and the following disclaimer in the
     14   1.1       ryo  *    documentation and/or other materials provided with the distribution.
     15   1.1       ryo  *
     16   1.1       ryo  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17   1.1       ryo  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     18   1.1       ryo  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     19   1.1       ryo  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
     20   1.1       ryo  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     21   1.1       ryo  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     22   1.1       ryo  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23   1.1       ryo  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     24   1.1       ryo  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     25   1.1       ryo  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     26   1.1       ryo  * POSSIBILITY OF SUCH DAMAGE.
     27   1.1       ryo  */
     28   1.1       ryo 
     29   1.1       ryo #include <sys/cdefs.h>
     30   1.1       ryo 
     31   1.1       ryo #ifndef lint
     32  1.10       ryo __RCSID("$NetBSD: aarch64.c,v 1.10 2020/07/01 08:03:10 ryo Exp $");
     33   1.1       ryo #endif /* no lint */
     34   1.1       ryo 
     35   1.1       ryo #include <sys/types.h>
     36   1.1       ryo #include <sys/cpuio.h>
     37   1.1       ryo #include <sys/sysctl.h>
     38   1.1       ryo #include <stdio.h>
     39   1.1       ryo #include <stdbool.h>
     40   1.1       ryo #include <stdlib.h>
     41   1.1       ryo #include <string.h>
     42   1.1       ryo #include <inttypes.h>
     43   1.1       ryo #include <err.h>
     44   1.1       ryo 
     45   1.1       ryo #include <arm/cputypes.h>
     46   1.1       ryo #include <aarch64/armreg.h>
     47   1.1       ryo 
     48   1.1       ryo #include "../cpuctl.h"
     49   1.1       ryo 
     50   1.1       ryo struct cpuidtab {
     51   1.1       ryo 	uint32_t cpu_partnum;
     52   1.1       ryo 	const char *cpu_name;
     53   1.1       ryo 	const char *cpu_class;
     54   1.1       ryo 	const char *cpu_architecture;
     55   1.1       ryo };
     56   1.1       ryo 
     57   1.1       ryo struct impltab {
     58   1.1       ryo 	uint32_t impl_id;
     59   1.1       ryo 	const char *impl_name;
     60   1.1       ryo };
     61   1.1       ryo 
     62   1.1       ryo struct fieldinfo {
     63  1.10       ryo 	unsigned int flags;
     64  1.10       ryo #define FIELDINFO_FLAGS_DEC	0x0001
     65  1.10       ryo #define FIELDINFO_FLAGS_4LOG2	0x0002
     66  1.10       ryo 	unsigned char bitpos;
     67  1.10       ryo 	unsigned char bitwidth;
     68   1.1       ryo 	const char *name;
     69   1.1       ryo 	const char * const *info;
     70   1.1       ryo };
     71   1.1       ryo 
     72   1.1       ryo 
     73   1.1       ryo #define CPU_PARTMASK	(CPU_ID_IMPLEMENTOR_MASK | CPU_ID_PARTNO_MASK)
     74   1.1       ryo const struct cpuidtab cpuids[] = {
     75   1.1       ryo 	{ CPU_ID_CORTEXA53R0 & CPU_PARTMASK, "Cortex-A53", "Cortex", "V8-A" },
     76   1.1       ryo 	{ CPU_ID_CORTEXA57R0 & CPU_PARTMASK, "Cortex-A57", "Cortex", "V8-A" },
     77   1.1       ryo 	{ CPU_ID_CORTEXA72R0 & CPU_PARTMASK, "Cortex-A72", "Cortex", "V8-A" },
     78   1.1       ryo 	{ CPU_ID_CORTEXA73R0 & CPU_PARTMASK, "Cortex-A73", "Cortex", "V8-A" },
     79   1.1       ryo 	{ CPU_ID_CORTEXA55R1 & CPU_PARTMASK, "Cortex-A55", "Cortex", "V8.2-A" },
     80   1.4       ryo 	{ CPU_ID_CORTEXA75R2 & CPU_PARTMASK, "Cortex-A75", "Cortex", "V8.2-A" },
     81   1.7       mrg 	{ CPU_ID_CORTEXA76R3 & CPU_PARTMASK, "Cortex-A76", "Cortex", "V8.2-A" },
     82   1.4       ryo 	{ CPU_ID_THUNDERXRX, "Cavium ThunderX", "Cavium", "V8-A" },
     83   1.4       ryo 	{ CPU_ID_THUNDERX81XXRX, "Cavium ThunderX CN81XX", "Cavium", "V8-A" },
     84   1.4       ryo 	{ CPU_ID_THUNDERX83XXRX, "Cavium ThunderX CN83XX", "Cavium", "V8-A" },
     85   1.4       ryo 	{ CPU_ID_THUNDERX2RX, "Cavium ThunderX2", "Cavium", "V8.1-A" },
     86   1.1       ryo };
     87   1.1       ryo 
     88   1.1       ryo const struct impltab implids[] = {
     89   1.1       ryo 	{ CPU_ID_ARM_LTD,	"ARM Limited"				},
     90   1.1       ryo 	{ CPU_ID_BROADCOM,	"Broadcom Corporation"			},
     91   1.1       ryo 	{ CPU_ID_CAVIUM,	"Cavium Inc."				},
     92   1.1       ryo 	{ CPU_ID_DEC,		"Digital Equipment Corporation"		},
     93   1.1       ryo 	{ CPU_ID_INFINEON,	"Infineon Technologies AG"		},
     94   1.1       ryo 	{ CPU_ID_MOTOROLA,	"Motorola or Freescale Semiconductor Inc." },
     95   1.1       ryo 	{ CPU_ID_NVIDIA,	"NVIDIA Corporation"			},
     96   1.1       ryo 	{ CPU_ID_APM,		"Applied Micro Circuits Corporation"	},
     97   1.1       ryo 	{ CPU_ID_QUALCOMM,	"Qualcomm Inc."				},
     98   1.1       ryo 	{ CPU_ID_SAMSUNG,	"SAMSUNG"				},
     99   1.1       ryo 	{ CPU_ID_TI,		"Texas Instruments"			},
    100   1.1       ryo 	{ CPU_ID_MARVELL,	"Marvell International Ltd."		},
    101   1.1       ryo 	{ CPU_ID_APPLE,		"Apple Inc."				},
    102   1.1       ryo 	{ CPU_ID_FARADAY,	"Faraday Technology Corporation"	},
    103   1.1       ryo 	{ CPU_ID_INTEL,		"Intel Corporation"			}
    104   1.1       ryo };
    105   1.1       ryo 
    106   1.1       ryo /* ID_AA64PFR0_EL1 - AArch64 Processor Feature Register 0 */
    107   1.1       ryo struct fieldinfo id_aa64pfr0_fieldinfo[] = {
    108   1.1       ryo 	{
    109   1.1       ryo 		.bitpos = 0, .bitwidth = 4, .name = "EL0",
    110   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    111   1.1       ryo 			[0] = "No EL0",
    112   1.1       ryo 			[1] = "AArch64",
    113   1.1       ryo 			[2] = "AArch64/AArch32"
    114   1.1       ryo 		}
    115   1.1       ryo 	},
    116   1.1       ryo 	{
    117   1.1       ryo 		.bitpos = 4, .bitwidth = 4, .name = "EL1",
    118   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    119   1.1       ryo 			[0] = "No EL1",
    120   1.1       ryo 			[1] = "AArch64",
    121   1.1       ryo 			[2] = "AArch64/AArch32"
    122   1.1       ryo 		}
    123   1.1       ryo 	},
    124   1.1       ryo 	{
    125   1.1       ryo 		.bitpos = 8, .bitwidth = 4, .name = "EL2",
    126   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    127   1.1       ryo 			[0] = "No EL2",
    128   1.1       ryo 			[1] = "AArch64",
    129   1.1       ryo 			[2] = "AArch64/AArch32"
    130   1.1       ryo 		}
    131   1.1       ryo 	},
    132   1.1       ryo 	{
    133   1.1       ryo 		.bitpos = 12, .bitwidth = 4, .name = "EL3",
    134   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    135   1.1       ryo 			[0] = "No EL3",
    136   1.1       ryo 			[1] = "AArch64",
    137   1.1       ryo 			[2] = "AArch64/AArch32"
    138   1.1       ryo 		}
    139   1.1       ryo 	},
    140   1.1       ryo 	{
    141   1.1       ryo 		.bitpos = 16, .bitwidth = 4, .name = "FP",
    142   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    143   1.1       ryo 			[0] = "Floating Point",
    144   1.1       ryo 			[15] = "No Floating Point"
    145   1.1       ryo 		}
    146   1.1       ryo 	},
    147   1.1       ryo 	{
    148   1.1       ryo 		.bitpos = 20, .bitwidth = 4, .name = "AdvSIMD",
    149   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    150   1.1       ryo 			[0] = "Advanced SIMD",
    151   1.1       ryo 			[15] = "No Advanced SIMD"
    152   1.1       ryo 		}
    153   1.1       ryo 	},
    154   1.1       ryo 	{
    155   1.1       ryo 		.bitpos = 24, .bitwidth = 4, .name = "GIC",
    156   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    157   1.1       ryo 			[0] = "No GIC",
    158   1.1       ryo 			[1] = "GICv3"
    159   1.1       ryo 		}
    160   1.1       ryo 	},
    161   1.1       ryo 	{ .bitwidth = 0 }	/* end of table */
    162   1.1       ryo };
    163   1.1       ryo 
    164   1.8      maxv /* ID_AA64PFR1_EL1 - AArch64 Processor Feature Register 1 */
    165   1.8      maxv struct fieldinfo id_aa64pfr1_fieldinfo[] = {
    166   1.8      maxv 	{
    167   1.8      maxv 		.bitpos = 0, .bitwidth = 4, .name = "BT",
    168   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    169   1.8      maxv 			[0] = "Branch Target Identification not implemented",
    170   1.8      maxv 			[1] = "Branch Target Identification implemented",
    171   1.8      maxv 		}
    172   1.8      maxv 	},
    173   1.8      maxv 	{
    174   1.8      maxv 		.bitpos = 4, .bitwidth = 4, .name = "SSBS",
    175   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    176   1.8      maxv 			[0] = "Speculative Store Bypassing control not implemented",
    177   1.8      maxv 			[1] = "Speculative Store Bypassing control implemented",
    178   1.8      maxv 			[2] = "Speculative Store Bypassing control implemented, plus MSR/MRS"
    179   1.8      maxv 		}
    180   1.8      maxv 	},
    181   1.8      maxv 	{
    182   1.8      maxv 		.bitpos = 8, .bitwidth = 4, .name = "MTE",
    183   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    184   1.8      maxv 			[0] = "Tagged Memory Extension not implemented",
    185   1.8      maxv 			[1] = "Tagged Memory Extension implemented, EL0 only",
    186   1.8      maxv 			[2] = "Tagged Memory Extension implemented"
    187   1.8      maxv 		}
    188   1.8      maxv 	},
    189   1.8      maxv 	{
    190   1.8      maxv 		.bitpos = 12, .bitwidth = 4, .name = "RAS_frac",
    191   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    192   1.8      maxv 			[0] = "Regular RAS",
    193   1.8      maxv 			[1] = "RAS plus registers",
    194   1.8      maxv 		}
    195   1.8      maxv 	},
    196   1.8      maxv 	{ .bitwidth = 0 }	/* end of table */
    197   1.8      maxv };
    198   1.8      maxv 
    199   1.1       ryo /* ID_AA64ISAR0_EL1 - AArch64 Instruction Set Attribute Register 0 */
    200   1.1       ryo struct fieldinfo id_aa64isar0_fieldinfo[] = {
    201   1.1       ryo 	{
    202   1.1       ryo 		.bitpos = 4, .bitwidth = 4, .name = "AES",
    203   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    204   1.1       ryo 			[0] = "No AES",
    205   1.1       ryo 			[1] = "AESE/AESD/AESMC/AESIMC",
    206   1.1       ryo 			[2] = "AESE/AESD/AESMC/AESIMC+PMULL/PMULL2"
    207   1.1       ryo 		}
    208   1.1       ryo 	},
    209   1.1       ryo 	{
    210   1.1       ryo 		.bitpos = 8, .bitwidth = 4, .name = "SHA1",
    211   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    212   1.1       ryo 			[0] = "No SHA1",
    213   1.1       ryo 			[1] = "SHA1C/SHA1P/SHA1M/SHA1H/SHA1SU0/SHA1SU1"
    214   1.1       ryo 		}
    215   1.1       ryo 	},
    216   1.1       ryo 	{
    217   1.1       ryo 		.bitpos = 12, .bitwidth = 4, .name = "SHA2",
    218   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    219   1.1       ryo 			[0] = "No SHA2",
    220   1.1       ryo 			[1] = "SHA256H/SHA256H2/SHA256SU0/SHA256U1"
    221   1.1       ryo 		}
    222   1.1       ryo 	},
    223   1.1       ryo 	{
    224   1.1       ryo 		.bitpos = 16, .bitwidth = 4, .name = "CRC32",
    225   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    226   1.1       ryo 			[0] = "No CRC32",
    227   1.1       ryo 			[1] = "CRC32B/CRC32H/CRC32W/CRC32X"
    228   1.1       ryo 			    "/CRC32CB/CRC32CH/CRC32CW/CRC32CX"
    229   1.1       ryo 		}
    230   1.1       ryo 	},
    231   1.9  riastrad 	{
    232   1.9  riastrad 		.bitpos = 60, .bitwidth = 4, .name = "RNDR",
    233   1.9  riastrad 		.info = (const char *[16]) { /* 16=4bit */
    234   1.9  riastrad 			[0] = "No RNDR/RNDRRS",
    235   1.9  riastrad 			[1] = "RNDR/RNDRRS",
    236   1.9  riastrad 		},
    237   1.9  riastrad 	},
    238   1.1       ryo 	{ .bitwidth = 0 }	/* end of table */
    239   1.1       ryo };
    240   1.1       ryo 
    241   1.1       ryo /* ID_AA64MMFR0_EL1 - AArch64 Memory Model Feature Register 0 */
    242   1.1       ryo struct fieldinfo id_aa64mmfr0_fieldinfo[] = {
    243   1.1       ryo 	{
    244   1.1       ryo 		.bitpos = 0, .bitwidth = 4, .name = "PARange",
    245   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    246   1.1       ryo 			[0] = "32bits/4GB",
    247   1.1       ryo 			[1] = "36bits/64GB",
    248   1.1       ryo 			[2] = "40bits/1TB",
    249   1.1       ryo 			[3] = "42bits/4TB",
    250   1.1       ryo 			[4] = "44bits/16TB",
    251   1.1       ryo 			[5] = "48bits/256TB"
    252   1.1       ryo 		}
    253   1.1       ryo 	},
    254   1.1       ryo 	{
    255   1.1       ryo 		.bitpos = 4, .bitwidth = 4, .name = "ASIDBit",
    256   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    257   1.1       ryo 			[0] = "8bits",
    258   1.1       ryo 			[2] = "16bits"
    259   1.1       ryo 		}
    260   1.1       ryo 	},
    261   1.1       ryo 	{
    262   1.1       ryo 		.bitpos = 8, .bitwidth = 4, .name = "BigEnd",
    263   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    264   1.1       ryo 			[0] = "No mixed-endian",
    265   1.1       ryo 			[1] = "Mixed-endian"
    266   1.1       ryo 		}
    267   1.1       ryo 	},
    268   1.1       ryo 	{
    269   1.1       ryo 		.bitpos = 12, .bitwidth = 4, .name = "SNSMem",
    270   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    271   1.1       ryo 			[0] = "No distinction B/W Secure and Non-secure Memory",
    272   1.1       ryo 			[1] = "Distinction B/W Secure and Non-secure Memory"
    273   1.1       ryo 		}
    274   1.1       ryo 	},
    275   1.1       ryo 	{
    276   1.1       ryo 		.bitpos = 16, .bitwidth = 4, .name = "BigEndEL0",
    277   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    278   1.1       ryo 			[0] = "No mixed-endian at EL0",
    279   1.1       ryo 			[1] = "Mixed-endian at EL0"
    280   1.1       ryo 		}
    281   1.1       ryo 	},
    282   1.1       ryo 	{
    283   1.1       ryo 		.bitpos = 20, .bitwidth = 4, .name = "TGran16",
    284   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    285   1.1       ryo 			[0] = "No 16KB granule",
    286   1.1       ryo 			[1] = "16KB granule"
    287   1.1       ryo 		}
    288   1.1       ryo 	},
    289   1.1       ryo 	{
    290   1.1       ryo 		.bitpos = 24, .bitwidth = 4, .name = "TGran64",
    291   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    292   1.2       ryo 			[0] = "64KB granule",
    293   1.2       ryo 			[15] = "No 64KB granule"
    294   1.1       ryo 		}
    295   1.1       ryo 	},
    296   1.1       ryo 	{
    297   1.1       ryo 		.bitpos = 28, .bitwidth = 4, .name = "TGran4",
    298   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    299   1.1       ryo 			[0] = "4KB granule",
    300   1.1       ryo 			[15] = "No 4KB granule"
    301   1.1       ryo 		}
    302   1.1       ryo 	},
    303   1.1       ryo 	{ .bitwidth = 0 }	/* end of table */
    304   1.1       ryo };
    305   1.1       ryo 
    306   1.8      maxv /* ID_AA64MMFR1_EL1 - AArch64 Memory Model Feature Register 1 */
    307   1.8      maxv struct fieldinfo id_aa64mmfr1_fieldinfo[] = {
    308   1.8      maxv 	{
    309   1.8      maxv 		.bitpos = 0, .bitwidth = 4, .name = "HAFDBS",
    310   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    311   1.8      maxv 			[0] = "Access and Dirty flags not supported",
    312   1.8      maxv 			[1] = "Access flag supported",
    313   1.8      maxv 			[2] = "Access and Dirty flags supported",
    314   1.8      maxv 		}
    315   1.8      maxv 	},
    316   1.8      maxv 	{
    317   1.8      maxv 		.bitpos = 4, .bitwidth = 4, .name = "VMIDBits",
    318   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    319   1.8      maxv 			[0] = "8bits",
    320   1.8      maxv 			[2] = "16bits"
    321   1.8      maxv 		}
    322   1.8      maxv 	},
    323   1.8      maxv 	{
    324   1.8      maxv 		.bitpos = 8, .bitwidth = 4, .name = "VH",
    325   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    326   1.8      maxv 			[0] = "Virtualization Host Extensions not supported",
    327   1.8      maxv 			[1] = "Virtualization Host Extensions supported",
    328   1.8      maxv 		}
    329   1.8      maxv 	},
    330   1.8      maxv 	{
    331   1.8      maxv 		.bitpos = 12, .bitwidth = 4, .name = "HPDS",
    332   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    333   1.8      maxv 			[0] = "Disabling of hierarchical controls not supported",
    334   1.8      maxv 			[1] = "Disabling of hierarchical controls supported",
    335   1.8      maxv 			[2] = "Disabling of hierarchical controls supported, plus PTD"
    336   1.8      maxv 		}
    337   1.8      maxv 	},
    338   1.8      maxv 	{
    339   1.8      maxv 		.bitpos = 16, .bitwidth = 4, .name = "LO",
    340   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    341   1.8      maxv 			[0] = "LORegions not supported",
    342   1.8      maxv 			[1] = "LORegions supported"
    343   1.8      maxv 		}
    344   1.8      maxv 	},
    345   1.8      maxv 	{
    346   1.8      maxv 		.bitpos = 20, .bitwidth = 4, .name = "PAN",
    347   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    348   1.8      maxv 			[0] = "PAN not supported",
    349   1.8      maxv 			[1] = "PAN supported",
    350   1.8      maxv 			[2] = "PAN supported, and instructions supported"
    351   1.8      maxv 		}
    352   1.8      maxv 	},
    353   1.8      maxv 	{
    354   1.8      maxv 		.bitpos = 24, .bitwidth = 4, .name = "SpecSEI",
    355   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    356   1.8      maxv 			[0] = "SError interrupt not supported",
    357   1.8      maxv 			[1] = "SError interrupt supported"
    358   1.8      maxv 		}
    359   1.8      maxv 	},
    360   1.8      maxv 	{
    361   1.8      maxv 		.bitpos = 28, .bitwidth = 4, .name = "XNX",
    362   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    363   1.8      maxv 			[0] = "Distinction between EL0 and EL1 XN control at stage 2 not supported",
    364   1.8      maxv 			[1] = "Distinction between EL0 and EL1 XN control at stage 2 supported"
    365   1.8      maxv 		}
    366   1.8      maxv 	},
    367   1.8      maxv 	{ .bitwidth = 0 }	/* end of table */
    368   1.8      maxv };
    369   1.8      maxv 
    370   1.5       ryo /* ID_AA64DFR0_EL1 - AArch64 Debug Feature Register 0 */
    371   1.5       ryo struct fieldinfo id_aa64dfr0_fieldinfo[] = {
    372   1.5       ryo 	{
    373   1.5       ryo 		.bitpos = 0, .bitwidth = 4, .name = "DebugVer",
    374   1.5       ryo 		.info = (const char *[16]) { /* 16=4bit */
    375   1.5       ryo 			[6] = "v8-A debug architecture"
    376   1.5       ryo 		}
    377   1.5       ryo 	},
    378   1.5       ryo 	{
    379   1.5       ryo 		.bitpos = 4, .bitwidth = 4, .name = "TraceVer",
    380   1.5       ryo 		.info = (const char *[16]) { /* 16=4bit */
    381   1.5       ryo 			[0] = "Trace supported",
    382   1.5       ryo 			[1] = "Trace not supported"
    383   1.5       ryo 		}
    384   1.5       ryo 	},
    385   1.5       ryo 	{
    386   1.5       ryo 		.bitpos = 8, .bitwidth = 4, .name = "PMUVer",
    387   1.5       ryo 		.info = (const char *[16]) { /* 16=4bit */
    388   1.5       ryo 			[0] = "No Performance monitor",
    389   1.5       ryo 			[1] = "Performance monitor unit v3"
    390   1.5       ryo 		}
    391   1.5       ryo 	},
    392   1.5       ryo 	{ .bitwidth = 0 }	/* end of table */
    393   1.5       ryo };
    394   1.5       ryo 
    395   1.5       ryo 
    396   1.1       ryo /* MVFR0_EL1 - Media and VFP Feature Register 0 */
    397   1.1       ryo struct fieldinfo mvfr0_fieldinfo[] = {
    398   1.1       ryo 	{
    399   1.1       ryo 		.bitpos = 0, .bitwidth = 4, .name = "SIMDreg",
    400   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    401   1.1       ryo 			[0] = "No SIMD",
    402   1.1       ryo 			[1] = "16x64-bit SIMD",
    403   1.1       ryo 			[2] = "32x64-bit SIMD"
    404   1.1       ryo 		}
    405   1.1       ryo 	},
    406   1.1       ryo 	{
    407   1.1       ryo 		.bitpos = 4, .bitwidth = 4, .name = "FPSP",
    408   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    409   1.1       ryo 			[0] = "No VFP support single precision",
    410   1.1       ryo 			[1] = "VFPv2 support single precision",
    411   1.1       ryo 			[2] = "VFPv2/VFPv3/VFPv4 support single precision"
    412   1.1       ryo 		}
    413   1.1       ryo 	},
    414   1.1       ryo 	{
    415   1.1       ryo 		.bitpos = 8, .bitwidth = 4, .name = "FPDP",
    416   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    417   1.1       ryo 			[0] = "No VFP support double precision",
    418   1.1       ryo 			[1] = "VFPv2 support double precision",
    419   1.1       ryo 			[2] = "VFPv2/VFPv3/VFPv4 support double precision"
    420   1.1       ryo 		}
    421   1.1       ryo 	},
    422   1.1       ryo 	{
    423   1.1       ryo 		.bitpos = 12, .bitwidth = 4, .name = "FPTrap",
    424   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    425   1.6     skrll 			[0] = "No floating point exception trapping support",
    426   1.1       ryo 			[1] = "VFPv2/VFPv3/VFPv4 support exception trapping"
    427   1.1       ryo 		}
    428   1.1       ryo 	},
    429   1.1       ryo 	{
    430   1.1       ryo 		.bitpos = 16, .bitwidth = 4, .name = "FPDivide",
    431   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    432   1.1       ryo 			[0] = "VDIV not supported",
    433   1.1       ryo 			[1] = "VDIV supported"
    434   1.1       ryo 		}
    435   1.1       ryo 	},
    436   1.1       ryo 	{
    437   1.1       ryo 		.bitpos = 20, .bitwidth = 4, .name = "FPSqrt",
    438   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    439   1.1       ryo 			[0] = "VSQRT not supported",
    440   1.1       ryo 			[1] = "VSQRT supported"
    441   1.1       ryo 		}
    442   1.1       ryo 	},
    443   1.1       ryo 	{
    444   1.1       ryo 		.bitpos = 24, .bitwidth = 4, .name = "FPShVec",
    445   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    446   1.1       ryo 			[0] = "Short Vectors not supported",
    447   1.1       ryo 			[1] = "Short Vectors supported"
    448   1.1       ryo 		}
    449   1.1       ryo 	},
    450   1.1       ryo 	{
    451   1.1       ryo 		.bitpos = 28, .bitwidth = 4, .name = "FPRound",
    452   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    453   1.1       ryo 			[0] = "Only Round to Nearest mode",
    454   1.1       ryo 			[1] = "All rounding modes"
    455   1.1       ryo 		}
    456   1.1       ryo 	},
    457   1.1       ryo 	{ .bitwidth = 0 }	/* end of table */
    458   1.1       ryo };
    459   1.1       ryo 
    460   1.1       ryo /* MVFR1_EL1 - Media and VFP Feature Register 1 */
    461   1.1       ryo struct fieldinfo mvfr1_fieldinfo[] = {
    462   1.1       ryo 	{
    463   1.1       ryo 		.bitpos = 0, .bitwidth = 4, .name = "FPFtZ",
    464   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    465   1.1       ryo 			[0] = "only the Flush-to-Zero",
    466   1.1       ryo 			[1] = "full Denormalized number arithmetic"
    467   1.1       ryo 		}
    468   1.1       ryo 	},
    469   1.1       ryo 	{
    470   1.1       ryo 		.bitpos = 4, .bitwidth = 4, .name = "FPDNan",
    471   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    472   1.1       ryo 			[0] = "Default NaN",
    473   1.1       ryo 			[1] = "Propagation of NaN"
    474   1.1       ryo 		}
    475   1.1       ryo 	},
    476   1.1       ryo 	{
    477   1.1       ryo 		.bitpos = 8, .bitwidth = 4, .name = "SIMDLS",
    478   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    479   1.1       ryo 			[0] = "No Advanced SIMD Load/Store",
    480   1.1       ryo 			[1] = "Advanced SIMD Load/Store"
    481   1.1       ryo 		}
    482   1.1       ryo 	},
    483   1.1       ryo 	{
    484   1.1       ryo 		.bitpos = 12, .bitwidth = 4, .name = "SIMDInt",
    485   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    486   1.1       ryo 			[0] = "No Advanced SIMD Integer",
    487   1.1       ryo 			[1] = "Advanced SIMD Integer"
    488   1.1       ryo 		}
    489   1.1       ryo 	},
    490   1.1       ryo 	{
    491   1.1       ryo 		.bitpos = 16, .bitwidth = 4, .name = "SIMDSP",
    492   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    493   1.1       ryo 			[0] = "No Advanced SIMD single precision",
    494   1.1       ryo 			[1] = "Advanced SIMD single precision"
    495   1.1       ryo 		}
    496   1.1       ryo 	},
    497   1.1       ryo 	{
    498   1.1       ryo 		.bitpos = 20, .bitwidth = 4, .name = "SIMDHP",
    499   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    500   1.1       ryo 			[0] = "No Advanced SIMD half precision",
    501   1.1       ryo 			[1] = "Advanced SIMD half precision"
    502   1.1       ryo 		}
    503   1.1       ryo 	},
    504   1.1       ryo 	{
    505   1.1       ryo 		.bitpos = 24, .bitwidth = 4, .name = "FPHP",
    506   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    507   1.1       ryo 			[0] = "No half precision conversion",
    508   1.1       ryo 			[1] = "half/single precision conversion",
    509   1.1       ryo 			[2] = "half/single/double precision conversion"
    510   1.1       ryo 		}
    511   1.1       ryo 	},
    512   1.1       ryo 	{
    513   1.1       ryo 		.bitpos = 28, .bitwidth = 4, .name = "SIMDFMAC",
    514   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    515   1.1       ryo 			[0] = "No Fused Multiply-Accumulate",
    516   1.1       ryo 			[1] = "Fused Multiply-Accumulate"
    517   1.1       ryo 		}
    518   1.1       ryo 	},
    519   1.1       ryo 	{ .bitwidth = 0 }	/* end of table */
    520   1.1       ryo };
    521   1.1       ryo 
    522   1.1       ryo /* MVFR2_EL1 - Media and VFP Feature Register 2 */
    523   1.1       ryo struct fieldinfo mvfr2_fieldinfo[] = {
    524   1.1       ryo 	{
    525   1.1       ryo 		.bitpos = 0, .bitwidth = 4, .name = "SIMDMisc",
    526   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    527   1.1       ryo 			[0] = "No miscellaneous features",
    528   1.1       ryo 			[1] = "Conversion to Integer w/Directed Rounding modes",
    529   1.1       ryo 			[2] = "Conversion to Integer w/Directed Rounding modes"
    530   1.1       ryo 			    ", Round to Integral floating point",
    531   1.1       ryo 			[3] = "Conversion to Integer w/Directed Rounding modes"
    532   1.1       ryo 			    ", Round to Integral floating point"
    533   1.1       ryo 			    ", MaxNum and MinNum"
    534   1.1       ryo 		}
    535   1.1       ryo 	},
    536   1.1       ryo 	{
    537   1.1       ryo 		.bitpos = 4, .bitwidth = 4, .name = "FPMisc",
    538   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    539   1.1       ryo 			[0] = "No miscellaneous features",
    540   1.1       ryo 			[1] = "Floating point selection",
    541   1.1       ryo 			[2] = "Floating point selection"
    542   1.1       ryo 			    ", Conversion to Integer w/Directed Rounding modes",
    543   1.1       ryo 			[3] = "Floating point selection"
    544   1.1       ryo 			    ", Conversion to Integer w/Directed Rounding modes"
    545   1.1       ryo 			    ", Round to Integral floating point",
    546   1.1       ryo 			[4] = "Floating point selection"
    547   1.1       ryo 			    ", Conversion to Integer w/Directed Rounding modes"
    548   1.1       ryo 			    ", Round to Integral floating point"
    549   1.1       ryo 			    ", MaxNum and MinNum"
    550   1.1       ryo 		}
    551   1.1       ryo 	},
    552   1.1       ryo 	{ .bitwidth = 0 }	/* end of table */
    553   1.1       ryo };
    554   1.1       ryo 
    555  1.10       ryo /* CLIDR_EL1 - Cache Level ID Register */
    556  1.10       ryo const char * const clidr_cachetype[8] = { /* 8=3bit */
    557  1.10       ryo 	[0] = "None",
    558  1.10       ryo 	[1] = "Instruction cache",
    559  1.10       ryo 	[2] = "Data cache",
    560  1.10       ryo 	[3] = "Instruction and Data cache",
    561  1.10       ryo 	[4] = "Unified cache"
    562  1.10       ryo };
    563  1.10       ryo 
    564  1.10       ryo struct fieldinfo clidr_fieldinfo[] = {
    565  1.10       ryo 	{
    566  1.10       ryo 		.bitpos = 0, .bitwidth = 3, .name = "L1",
    567  1.10       ryo 		.info = clidr_cachetype
    568  1.10       ryo 	},
    569  1.10       ryo 	{
    570  1.10       ryo 		.bitpos = 3, .bitwidth = 3, .name = "L2",
    571  1.10       ryo 		.info = clidr_cachetype
    572  1.10       ryo 	},
    573  1.10       ryo 	{
    574  1.10       ryo 		.bitpos = 6, .bitwidth = 3, .name = "L3",
    575  1.10       ryo 		.info = clidr_cachetype
    576  1.10       ryo 	},
    577  1.10       ryo 	{
    578  1.10       ryo 		.bitpos = 9, .bitwidth = 3, .name = "L4",
    579  1.10       ryo 		.info = clidr_cachetype
    580  1.10       ryo 	},
    581  1.10       ryo 	{
    582  1.10       ryo 		.bitpos = 12, .bitwidth = 3, .name = "L5",
    583  1.10       ryo 		.info = clidr_cachetype
    584  1.10       ryo 	},
    585  1.10       ryo 	{
    586  1.10       ryo 		.bitpos = 15, .bitwidth = 3, .name = "L6",
    587  1.10       ryo 		.info = clidr_cachetype
    588  1.10       ryo 	},
    589  1.10       ryo 	{
    590  1.10       ryo 		.bitpos = 18, .bitwidth = 3, .name = "L7",
    591  1.10       ryo 		.info = clidr_cachetype
    592  1.10       ryo 	},
    593  1.10       ryo 	{
    594  1.10       ryo 		.bitpos = 21, .bitwidth = 3, .name = "LoUU",
    595  1.10       ryo 		.flags = FIELDINFO_FLAGS_DEC
    596  1.10       ryo 	},
    597  1.10       ryo 	{
    598  1.10       ryo 		.bitpos = 24, .bitwidth = 3, .name = "LoC",
    599  1.10       ryo 		.flags = FIELDINFO_FLAGS_DEC
    600  1.10       ryo 	},
    601  1.10       ryo 	{
    602  1.10       ryo 		.bitpos = 27, .bitwidth = 3, .name = "LoUIS",
    603  1.10       ryo 		.flags = FIELDINFO_FLAGS_DEC
    604  1.10       ryo 	},
    605  1.10       ryo 	{
    606  1.10       ryo 		.bitpos = 30, .bitwidth = 3, .name = "ICB",
    607  1.10       ryo 		.flags = FIELDINFO_FLAGS_DEC
    608  1.10       ryo 	},
    609  1.10       ryo 	{ .bitwidth = 0 }	/* end of table */
    610  1.10       ryo };
    611  1.10       ryo 
    612  1.10       ryo struct fieldinfo ctr_fieldinfo[] = {
    613  1.10       ryo 	{
    614  1.10       ryo 		.bitpos = 0, .bitwidth = 4, .name = "IminLine",
    615  1.10       ryo 		.flags = FIELDINFO_FLAGS_DEC | FIELDINFO_FLAGS_4LOG2
    616  1.10       ryo 	},
    617  1.10       ryo 	{
    618  1.10       ryo 		.bitpos = 16, .bitwidth = 4, .name = "DminLine",
    619  1.10       ryo 		.flags = FIELDINFO_FLAGS_DEC | FIELDINFO_FLAGS_4LOG2
    620  1.10       ryo 	},
    621  1.10       ryo 	{
    622  1.10       ryo 		.bitpos = 14, .bitwidth = 2, .name = "L1 Icache policy",
    623  1.10       ryo 		.info = (const char *[4]) { /* 4=2bit */
    624  1.10       ryo 			[0] = "VMID aware PIPT (VPIPT)",
    625  1.10       ryo 			[1] = "ASID-tagged VIVT (AIVIVT)",
    626  1.10       ryo 			[2] = "VIPT",
    627  1.10       ryo 			[3] = "PIPT"
    628  1.10       ryo 		},
    629  1.10       ryo 	},
    630  1.10       ryo 	{
    631  1.10       ryo 		.bitpos = 20, .bitwidth = 4, .name = "ERG",
    632  1.10       ryo 		.flags = FIELDINFO_FLAGS_DEC | FIELDINFO_FLAGS_4LOG2
    633  1.10       ryo 	},
    634  1.10       ryo 	{
    635  1.10       ryo 		.bitpos = 24, .bitwidth = 4, .name = "CWG",
    636  1.10       ryo 		.flags = FIELDINFO_FLAGS_DEC | FIELDINFO_FLAGS_4LOG2
    637  1.10       ryo 	},
    638  1.10       ryo 	{
    639  1.10       ryo 		.bitpos = 28, .bitwidth = 1, .name = "DIC",
    640  1.10       ryo 		.flags = FIELDINFO_FLAGS_DEC
    641  1.10       ryo 	},
    642  1.10       ryo 	{
    643  1.10       ryo 		.bitpos = 29, .bitwidth = 1, .name = "IDC",
    644  1.10       ryo 		.flags = FIELDINFO_FLAGS_DEC
    645  1.10       ryo 	},
    646  1.10       ryo 	{ .bitwidth = 0 }	/* end of table */
    647  1.10       ryo };
    648  1.10       ryo 
    649  1.10       ryo 
    650   1.1       ryo static void
    651   1.1       ryo print_fieldinfo(const char *cpuname, const char *setname,
    652   1.1       ryo     struct fieldinfo *fieldinfo, uint64_t data)
    653   1.1       ryo {
    654   1.1       ryo 	uint64_t v;
    655   1.1       ryo 	const char *info;
    656  1.10       ryo 	int i, flags;
    657   1.1       ryo 
    658   1.1       ryo #define WIDTHMASK(w)	(0xffffffffffffffffULL >> (64 - (w)))
    659   1.1       ryo 
    660   1.1       ryo 	for (i = 0; fieldinfo[i].bitwidth != 0; i++) {
    661   1.1       ryo 		v = (data >> fieldinfo[i].bitpos) &
    662   1.1       ryo 		    WIDTHMASK(fieldinfo[i].bitwidth);
    663   1.1       ryo 
    664  1.10       ryo 		flags = fieldinfo[i].flags;
    665  1.10       ryo 		info = NULL;
    666  1.10       ryo 		if (fieldinfo[i].info != NULL)
    667  1.10       ryo 			info = fieldinfo[i].info[v];
    668  1.10       ryo 
    669  1.10       ryo 		printf("%s: %s: %s: ",
    670  1.10       ryo 		    cpuname, setname, fieldinfo[i].name);
    671  1.10       ryo 
    672  1.10       ryo 		if (info == NULL) {
    673  1.10       ryo 			if (flags & FIELDINFO_FLAGS_4LOG2)
    674  1.10       ryo 				v = 4 * (1 << v);
    675  1.10       ryo 			if (flags & FIELDINFO_FLAGS_DEC)
    676  1.10       ryo 				printf("%"PRIu64"\n", v);
    677  1.10       ryo 			else
    678  1.10       ryo 				printf("0x%"PRIx64"\n", v);
    679  1.10       ryo 		} else {
    680  1.10       ryo 			printf("%s\n", info);
    681  1.10       ryo 		}
    682   1.1       ryo 	}
    683   1.1       ryo }
    684   1.1       ryo 
    685   1.1       ryo /* MIDR_EL1 - Main ID Register */
    686   1.1       ryo static void
    687   1.1       ryo identify_midr(const char *cpuname, uint32_t cpuid)
    688   1.1       ryo {
    689   1.1       ryo 	unsigned int i;
    690   1.1       ryo 	uint32_t implid, cpupart, variant, revision;
    691   1.1       ryo 	const char *implementer = NULL;
    692   1.1       ryo 	static char implbuf[128];
    693   1.1       ryo 
    694   1.1       ryo 	implid = cpuid & CPU_ID_IMPLEMENTOR_MASK;
    695   1.1       ryo 	cpupart = cpuid & CPU_PARTMASK;
    696   1.1       ryo 	variant = __SHIFTOUT(cpuid, CPU_ID_VARIANT_MASK);
    697   1.1       ryo 	revision = __SHIFTOUT(cpuid, CPU_ID_REVISION_MASK);
    698   1.1       ryo 
    699   1.1       ryo 	for (i = 0; i < __arraycount(implids); i++) {
    700   1.1       ryo 		if (implid == implids[i].impl_id) {
    701   1.1       ryo 			implementer = implids[i].impl_name;
    702   1.1       ryo 		}
    703   1.1       ryo 	}
    704   1.1       ryo 	if (implementer == NULL) {
    705   1.1       ryo 		snprintf(implbuf, sizeof(implbuf), "unknown implementer: 0x%02x",
    706   1.1       ryo 		    implid >> 24);
    707   1.1       ryo 		implementer = implbuf;
    708   1.1       ryo 	}
    709   1.1       ryo 
    710   1.1       ryo 	for (i = 0; i < __arraycount(cpuids); i++) {
    711   1.1       ryo 		if (cpupart == cpuids[i].cpu_partnum) {
    712   1.1       ryo 			printf("%s: %s, %s r%dp%d (%s %s core)\n",
    713   1.1       ryo 			    cpuname, implementer,
    714   1.1       ryo 			    cpuids[i].cpu_name, variant, revision,
    715   1.1       ryo 			    cpuids[i].cpu_class,
    716   1.1       ryo 			    cpuids[i].cpu_architecture);
    717   1.1       ryo 			return;
    718   1.1       ryo 		}
    719   1.1       ryo 	}
    720   1.1       ryo 	printf("%s: unknown CPU ID: 0x%08x\n", cpuname, cpuid);
    721   1.1       ryo }
    722   1.1       ryo 
    723   1.1       ryo /* REVIDR_EL1 - Revision ID Register */
    724   1.1       ryo static void
    725   1.1       ryo identify_revidr(const char *cpuname, uint32_t revidr)
    726   1.1       ryo {
    727   1.1       ryo 	printf("%s: revision: 0x%08x\n", cpuname, revidr);
    728   1.1       ryo }
    729   1.1       ryo 
    730   1.1       ryo /* MPIDR_EL1 - Multiprocessor Affinity Register */
    731   1.1       ryo static void
    732   1.1       ryo identify_mpidr(const char *cpuname, uint32_t mpidr)
    733   1.1       ryo {
    734   1.1       ryo 	const char *setname = "multiprocessor affinity";
    735   1.1       ryo 
    736   1.1       ryo 	printf("%s: %s: Affinity-Level: %"PRIu64"-%"PRIu64"-%"PRIu64"-%"PRIu64"\n",
    737   1.1       ryo 	    cpuname, setname,
    738   1.1       ryo 	    __SHIFTOUT(mpidr, MPIDR_AFF3),
    739   1.1       ryo 	    __SHIFTOUT(mpidr, MPIDR_AFF2),
    740   1.1       ryo 	    __SHIFTOUT(mpidr, MPIDR_AFF1),
    741   1.1       ryo 	    __SHIFTOUT(mpidr, MPIDR_AFF0));
    742   1.1       ryo 
    743   1.1       ryo 	if ((mpidr & MPIDR_U) == 0)
    744   1.1       ryo 		printf("%s: %s: Multiprocessor system\n", cpuname, setname);
    745   1.1       ryo 	else
    746   1.1       ryo 		printf("%s: %s: Uniprocessor system\n", cpuname, setname);
    747   1.1       ryo 
    748   1.1       ryo 	if ((mpidr & MPIDR_MT) == 0)
    749   1.1       ryo 		printf("%s: %s: Core Independent\n", cpuname, setname);
    750   1.1       ryo 	else
    751   1.1       ryo 		printf("%s: %s: Multi-Threading\n", cpuname, setname);
    752   1.1       ryo 
    753   1.1       ryo }
    754   1.1       ryo 
    755   1.5       ryo /* AA64DFR0 - Debug feature register 0 */
    756   1.5       ryo static void
    757   1.5       ryo identify_dfr0(const char *cpuname, uint64_t dfr0)
    758   1.5       ryo {
    759   1.5       ryo 	const char *setname = "debug feature 0";
    760   1.5       ryo 
    761   1.5       ryo 	printf("%s: %s: CTX_CMPs: %lu context-aware breakpoints\n",
    762   1.5       ryo 	    cpuname, setname, __SHIFTOUT(dfr0, ID_AA64DFR0_EL1_CTX_CMPS) + 1);
    763   1.5       ryo 	printf("%s: %s: WRPs: %lu watchpoints\n",
    764   1.5       ryo 	    cpuname, setname, __SHIFTOUT(dfr0, ID_AA64DFR0_EL1_WRPS) + 1);
    765   1.5       ryo 	printf("%s: %s: BRPs: %lu breakpoints\n",
    766   1.5       ryo 	    cpuname, setname, __SHIFTOUT(dfr0, ID_AA64DFR0_EL1_BRPS) + 1);
    767   1.5       ryo 	print_fieldinfo(cpuname, setname,
    768   1.5       ryo 	    id_aa64dfr0_fieldinfo, dfr0);
    769   1.5       ryo }
    770   1.5       ryo 
    771   1.1       ryo void
    772   1.1       ryo identifycpu(int fd, const char *cpuname)
    773   1.1       ryo {
    774   1.3       mrg 	char path[128];
    775   1.1       ryo 	size_t len;
    776   1.5       ryo #define SYSCTL_CPU_ID_MAXSIZE	64
    777   1.5       ryo 	uint64_t sysctlbuf[SYSCTL_CPU_ID_MAXSIZE];
    778   1.5       ryo 	struct aarch64_sysctl_cpu_id *id =
    779   1.5       ryo 	    (struct aarch64_sysctl_cpu_id *)sysctlbuf;
    780   1.1       ryo 
    781   1.3       mrg 	snprintf(path, sizeof path, "machdep.%s.cpu_id", cpuname);
    782   1.5       ryo 	len = sizeof(sysctlbuf);
    783  1.10       ryo 	memset(sysctlbuf, 0, len);
    784   1.5       ryo 	if (sysctlbyname(path, id, &len, 0, 0) == -1)
    785   1.3       mrg 		err(1, "couldn't get %s", path);
    786   1.5       ryo 	if (len != sizeof(struct aarch64_sysctl_cpu_id))
    787   1.5       ryo 		fprintf(stderr, "Warning: kernel version bumped?\n");
    788   1.5       ryo 
    789   1.5       ryo 	if (verbose) {
    790   1.5       ryo 		printf("%s: MIDR_EL1: 0x%08"PRIx64"\n",
    791   1.5       ryo 		    cpuname, id->ac_midr);
    792   1.5       ryo 		printf("%s: MPIDR_EL1: 0x%016"PRIx64"\n",
    793   1.5       ryo 		    cpuname, id->ac_mpidr);
    794   1.5       ryo 		printf("%s: ID_AA64DFR0_EL1: 0x%016"PRIx64"\n",
    795   1.5       ryo 		    cpuname, id->ac_aa64dfr0);
    796   1.5       ryo 		printf("%s: ID_AA64DFR1_EL1: 0x%016"PRIx64"\n",
    797   1.5       ryo 		    cpuname, id->ac_aa64dfr1);
    798   1.5       ryo 		printf("%s: ID_AA64ISAR0_EL1: 0x%016"PRIx64"\n",
    799   1.5       ryo 		    cpuname, id->ac_aa64isar0);
    800   1.5       ryo 		printf("%s: ID_AA64ISAR1_EL1: 0x%016"PRIx64"\n",
    801   1.5       ryo 		    cpuname, id->ac_aa64isar1);
    802   1.5       ryo 		printf("%s: ID_AA64MMFR0_EL1: 0x%016"PRIx64"\n",
    803   1.5       ryo 		    cpuname, id->ac_aa64mmfr0);
    804   1.5       ryo 		printf("%s: ID_AA64MMFR1_EL1: 0x%016"PRIx64"\n",
    805   1.5       ryo 		    cpuname, id->ac_aa64mmfr1);
    806   1.5       ryo 		printf("%s: ID_AA64MMFR2_EL1: 0x%016"PRIx64"\n",
    807   1.5       ryo 		    cpuname, id->ac_aa64mmfr2);
    808   1.5       ryo 		printf("%s: ID_AA64PFR0_EL1: 0x%08"PRIx64"\n",
    809   1.5       ryo 		    cpuname, id->ac_aa64pfr0);
    810   1.5       ryo 		printf("%s: ID_AA64PFR1_EL1: 0x%08"PRIx64"\n",
    811   1.5       ryo 		    cpuname, id->ac_aa64pfr1);
    812   1.5       ryo 		printf("%s: ID_AA64ZFR0_EL1: 0x%016"PRIx64"\n",
    813   1.5       ryo 		    cpuname, id->ac_aa64zfr0);
    814   1.5       ryo 		printf("%s: MVFR0_EL1: 0x%08"PRIx32"\n",
    815   1.5       ryo 		    cpuname, id->ac_mvfr0);
    816   1.5       ryo 		printf("%s: MVFR1_EL1: 0x%08"PRIx32"\n",
    817   1.5       ryo 		    cpuname, id->ac_mvfr1);
    818   1.5       ryo 		printf("%s: MVFR2_EL1: 0x%08"PRIx32"\n",
    819   1.5       ryo 		    cpuname, id->ac_mvfr2);
    820  1.10       ryo 		printf("%s: CLIDR_EL1: 0x%016"PRIx64"\n",
    821  1.10       ryo 		    cpuname, id->ac_clidr);
    822  1.10       ryo 		printf("%s: CTR_EL0: 0x%016"PRIx64"\n",
    823  1.10       ryo 		    cpuname, id->ac_ctr);
    824   1.5       ryo 	}
    825   1.3       mrg 
    826   1.5       ryo 	identify_midr(cpuname, id->ac_midr);
    827   1.5       ryo 	identify_revidr(cpuname, id->ac_revidr);
    828   1.5       ryo 	identify_mpidr(cpuname, id->ac_mpidr);
    829   1.3       mrg 	print_fieldinfo(cpuname, "isa features 0",
    830   1.5       ryo 	    id_aa64isar0_fieldinfo, id->ac_aa64isar0);
    831   1.3       mrg 	print_fieldinfo(cpuname, "memory model 0",
    832   1.5       ryo 	    id_aa64mmfr0_fieldinfo, id->ac_aa64mmfr0);
    833   1.8      maxv 	print_fieldinfo(cpuname, "memory model 1",
    834   1.8      maxv 	    id_aa64mmfr1_fieldinfo, id->ac_aa64mmfr1);
    835   1.3       mrg 	print_fieldinfo(cpuname, "processor feature 0",
    836   1.5       ryo 	    id_aa64pfr0_fieldinfo, id->ac_aa64pfr0);
    837   1.8      maxv 	print_fieldinfo(cpuname, "processor feature 1",
    838   1.8      maxv 	    id_aa64pfr1_fieldinfo, id->ac_aa64pfr1);
    839   1.5       ryo 	identify_dfr0(cpuname, id->ac_aa64dfr0);
    840   1.3       mrg 
    841   1.3       mrg 	print_fieldinfo(cpuname, "media and VFP features 0",
    842   1.5       ryo 	    mvfr0_fieldinfo, id->ac_mvfr0);
    843   1.3       mrg 	print_fieldinfo(cpuname, "media and VFP features 1",
    844   1.5       ryo 	    mvfr1_fieldinfo, id->ac_mvfr1);
    845   1.3       mrg 	print_fieldinfo(cpuname, "media and VFP features 2",
    846   1.5       ryo 	    mvfr2_fieldinfo, id->ac_mvfr2);
    847  1.10       ryo 
    848  1.10       ryo 	if (len <= offsetof(struct aarch64_sysctl_cpu_id, ac_clidr))
    849  1.10       ryo 		return;
    850  1.10       ryo 	print_fieldinfo(cpuname, "cache level",
    851  1.10       ryo 	    clidr_fieldinfo, id->ac_clidr);
    852  1.10       ryo 	print_fieldinfo(cpuname, "cache type",
    853  1.10       ryo 	    ctr_fieldinfo, id->ac_ctr);
    854   1.1       ryo }
    855   1.1       ryo 
    856   1.1       ryo bool
    857   1.1       ryo identifycpu_bind(void)
    858   1.1       ryo {
    859   1.3       mrg 	return false;
    860   1.1       ryo }
    861   1.1       ryo 
    862   1.1       ryo int
    863   1.1       ryo ucodeupdate_check(int fd, struct cpu_ucode *uc)
    864   1.1       ryo {
    865   1.1       ryo 	return 0;
    866   1.1       ryo }
    867