Home | History | Annotate | Line # | Download | only in arch
aarch64.c revision 1.15
      1  1.15  riastrad /*	$NetBSD: aarch64.c,v 1.15 2021/05/17 18:43:18 riastradh 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.15  riastrad __RCSID("$NetBSD: aarch64.c,v 1.15 2021/05/17 18:43:18 riastradh 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.13       ryo 	{ CPU_ID_CORTEXA35R0 & CPU_PARTMASK, "Cortex-A35", "Arm", "v8-A" },
     76  1.13       ryo 	{ CPU_ID_CORTEXA53R0 & CPU_PARTMASK, "Cortex-A53", "Arm", "v8-A" },
     77  1.13       ryo 	{ CPU_ID_CORTEXA57R0 & CPU_PARTMASK, "Cortex-A57", "Arm", "v8-A" },
     78  1.13       ryo 	{ CPU_ID_CORTEXA55R1 & CPU_PARTMASK, "Cortex-A55", "Arm", "v8.2-A+" },
     79  1.13       ryo 	{ CPU_ID_CORTEXA65R0 & CPU_PARTMASK, "Cortex-A65", "Arm", "v8.2-A+" },
     80  1.13       ryo 	{ CPU_ID_CORTEXA72R0 & CPU_PARTMASK, "Cortex-A72", "Arm", "v8-A" },
     81  1.13       ryo 	{ CPU_ID_CORTEXA73R0 & CPU_PARTMASK, "Cortex-A73", "Arm", "v8-A" },
     82  1.13       ryo 	{ CPU_ID_CORTEXA75R2 & CPU_PARTMASK, "Cortex-A75", "Arm", "v8.2-A+" },
     83  1.13       ryo 	{ CPU_ID_CORTEXA76R3 & CPU_PARTMASK, "Cortex-A76", "Arm", "v8.2-A+" },
     84  1.13       ryo 	{ CPU_ID_CORTEXA76AER1 & CPU_PARTMASK, "Cortex-A76AE", "Arm", "v8.2-A+" },
     85  1.13       ryo 	{ CPU_ID_CORTEXA77R0 & CPU_PARTMASK, "Cortex-A77", "Arm", "v8.2-A+" },
     86  1.13       ryo 	{ CPU_ID_NVIDIADENVER2 & CPU_PARTMASK, "Denver2", "NVIDIA", "v8-A" },
     87  1.13       ryo 	{ CPU_ID_EMAG8180 & CPU_PARTMASK, "eMAG", "Ampere", "v8-A" },
     88  1.13       ryo 	{ CPU_ID_NEOVERSEE1R1 & CPU_PARTMASK, "Neoverse E1", "Arm", "v8.2-A+" },
     89  1.13       ryo 	{ CPU_ID_NEOVERSEN1R3 & CPU_PARTMASK, "Neoverse N1", "Arm", "v8.2-A+" },
     90  1.13       ryo 	{ CPU_ID_THUNDERXRX, "ThunderX", "Cavium", "v8-A" },
     91  1.13       ryo 	{ CPU_ID_THUNDERX81XXRX, "ThunderX CN81XX", "Cavium", "v8-A" },
     92  1.13       ryo 	{ CPU_ID_THUNDERX83XXRX, "ThunderX CN83XX", "Cavium", "v8-A" },
     93  1.13       ryo 	{ CPU_ID_THUNDERX2RX, "ThunderX2", "Marvell", "v8.1-A" },
     94   1.1       ryo };
     95   1.1       ryo 
     96   1.1       ryo const struct impltab implids[] = {
     97   1.1       ryo 	{ CPU_ID_ARM_LTD,	"ARM Limited"				},
     98   1.1       ryo 	{ CPU_ID_BROADCOM,	"Broadcom Corporation"			},
     99   1.1       ryo 	{ CPU_ID_CAVIUM,	"Cavium Inc."				},
    100   1.1       ryo 	{ CPU_ID_DEC,		"Digital Equipment Corporation"		},
    101   1.1       ryo 	{ CPU_ID_INFINEON,	"Infineon Technologies AG"		},
    102   1.1       ryo 	{ CPU_ID_MOTOROLA,	"Motorola or Freescale Semiconductor Inc." },
    103   1.1       ryo 	{ CPU_ID_NVIDIA,	"NVIDIA Corporation"			},
    104   1.1       ryo 	{ CPU_ID_APM,		"Applied Micro Circuits Corporation"	},
    105   1.1       ryo 	{ CPU_ID_QUALCOMM,	"Qualcomm Inc."				},
    106   1.1       ryo 	{ CPU_ID_SAMSUNG,	"SAMSUNG"				},
    107   1.1       ryo 	{ CPU_ID_TI,		"Texas Instruments"			},
    108   1.1       ryo 	{ CPU_ID_MARVELL,	"Marvell International Ltd."		},
    109   1.1       ryo 	{ CPU_ID_APPLE,		"Apple Inc."				},
    110   1.1       ryo 	{ CPU_ID_FARADAY,	"Faraday Technology Corporation"	},
    111   1.1       ryo 	{ CPU_ID_INTEL,		"Intel Corporation"			}
    112   1.1       ryo };
    113   1.1       ryo 
    114   1.1       ryo /* ID_AA64PFR0_EL1 - AArch64 Processor Feature Register 0 */
    115   1.1       ryo struct fieldinfo id_aa64pfr0_fieldinfo[] = {
    116   1.1       ryo 	{
    117   1.1       ryo 		.bitpos = 0, .bitwidth = 4, .name = "EL0",
    118   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    119   1.1       ryo 			[0] = "No EL0",
    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 = 4, .bitwidth = 4, .name = "EL1",
    126   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    127   1.1       ryo 			[0] = "No EL1",
    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 = 8, .bitwidth = 4, .name = "EL2",
    134   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    135   1.1       ryo 			[0] = "No EL2",
    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 = 12, .bitwidth = 4, .name = "EL3",
    142   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    143   1.1       ryo 			[0] = "No EL3",
    144   1.1       ryo 			[1] = "AArch64",
    145   1.1       ryo 			[2] = "AArch64/AArch32"
    146   1.1       ryo 		}
    147   1.1       ryo 	},
    148   1.1       ryo 	{
    149   1.1       ryo 		.bitpos = 16, .bitwidth = 4, .name = "FP",
    150   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    151   1.1       ryo 			[0] = "Floating Point",
    152  1.12  jmcneill 			[1] = "Floating Point including half-precision support",
    153   1.1       ryo 			[15] = "No Floating Point"
    154   1.1       ryo 		}
    155   1.1       ryo 	},
    156   1.1       ryo 	{
    157   1.1       ryo 		.bitpos = 20, .bitwidth = 4, .name = "AdvSIMD",
    158   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    159   1.1       ryo 			[0] = "Advanced SIMD",
    160  1.12  jmcneill 			[1] = "Advanced SIMD including half-precision support",
    161   1.1       ryo 			[15] = "No Advanced SIMD"
    162   1.1       ryo 		}
    163   1.1       ryo 	},
    164   1.1       ryo 	{
    165   1.1       ryo 		.bitpos = 24, .bitwidth = 4, .name = "GIC",
    166   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    167  1.14  jmcneill 			[0] = "GIC CPU interface sysregs not implemented",
    168  1.14  jmcneill 			[1] = "GIC CPU interface sysregs v3.0/4.0 supported",
    169  1.14  jmcneill 			[3] = "GIC CPU interface sysregs v4.1 supported"
    170   1.1       ryo 		}
    171   1.1       ryo 	},
    172  1.15  riastrad 	{
    173  1.15  riastrad 		.bitpos = 28, .bitwidth = 4, .name = "RAS",
    174  1.15  riastrad 		.info = (const char *[16]) { /* 16=4bit */
    175  1.15  riastrad 			[0] = "Reliability/Availability/Serviceability not supported",
    176  1.15  riastrad 			[1] = "Reliability/Availability/Serviceability supported",
    177  1.15  riastrad 			[2] = "Reliability/Availability/Serviceability ARMv8.4 supported",
    178  1.15  riastrad 		},
    179  1.15  riastrad 	},
    180  1.15  riastrad 	{
    181  1.15  riastrad 		.bitpos = 32, .bitwidth = 4, .name = "SVE",
    182  1.15  riastrad 		.info = (const char *[16]) { /* 16=4bit */
    183  1.15  riastrad 			[0] = "Scalable Vector Extensions not implemented",
    184  1.15  riastrad 			[1] = "Scalable Vector Extensions implemented",
    185  1.15  riastrad 		},
    186  1.15  riastrad 	},
    187  1.15  riastrad 	{
    188  1.15  riastrad 		.bitpos = 36, .bitwidth = 4, .name = "SEL2",
    189  1.15  riastrad 		.info = (const char *[16]) { /* 16=4bit */
    190  1.15  riastrad 			[0] = "Secure EL2 not implemented",
    191  1.15  riastrad 			[1] = "Secure EL2 implemented",
    192  1.15  riastrad 		},
    193  1.15  riastrad 	},
    194  1.15  riastrad 	{
    195  1.15  riastrad 		.bitpos = 40, .bitwidth = 4, .name = "MPAM",
    196  1.15  riastrad 		.info = (const char *[16]) { /* 16=4bit */
    197  1.15  riastrad 			[0] = "Memory Partitioning and Monitoring not implemented",
    198  1.15  riastrad 			[1] = "Memory Partitioning and Monitoring implemented",
    199  1.15  riastrad 		},
    200  1.15  riastrad 	},
    201  1.15  riastrad 	{
    202  1.15  riastrad 		.bitpos = 44, .bitwidth = 4, .name = "AMU",
    203  1.15  riastrad 		.info = (const char *[16]) { /* 16=4bit */
    204  1.15  riastrad 			[0] = "Activity Monitors Extension not implemented",
    205  1.15  riastrad 			[1] = "Activity Monitors Extension v1 ARMv8.4",
    206  1.15  riastrad 			[2] = "Activity Monitors Extension v1 ARMv8.6",
    207  1.15  riastrad 		},
    208  1.15  riastrad 	},
    209  1.15  riastrad 	{
    210  1.15  riastrad 		.bitpos = 48, .bitwidth = 4, .name = "DIT",
    211  1.15  riastrad 		.info = (const char *[16]) { /* 16=4bit */
    212  1.15  riastrad 			[0] = "No Data-Independent Timing guarantees",
    213  1.15  riastrad 			[1] = "Data-Independent Timing guaranteed by PSTATE.DIT",
    214  1.15  riastrad 		},
    215  1.15  riastrad 	},
    216  1.15  riastrad 	{
    217  1.15  riastrad 		.bitpos = 56, .bitwidth = 4, .name = "CSV2",
    218  1.15  riastrad 		.info = (const char *[16]) { /* 16=4bit */
    219  1.15  riastrad 			[0] = "Branch prediction might be Spectred",
    220  1.15  riastrad 			[1] = "Branch prediction maybe not Spectred",
    221  1.15  riastrad 			[2] = "Branch prediction probably not Spectred",
    222  1.15  riastrad 		},
    223  1.15  riastrad 	},
    224  1.15  riastrad 	{
    225  1.15  riastrad 		.bitpos = 60, .bitwidth = 4, .name = "CSV3",
    226  1.15  riastrad 		.info = (const char *[16]) { /* 16=4bit */
    227  1.15  riastrad 			[0] = "Faults might be Spectred",
    228  1.15  riastrad 			[1] = "Faults maybe not Spectred",
    229  1.15  riastrad 			[2] = "Faults probably not Spectred",
    230  1.15  riastrad 		},
    231  1.15  riastrad 	},
    232   1.1       ryo 	{ .bitwidth = 0 }	/* end of table */
    233   1.1       ryo };
    234   1.1       ryo 
    235   1.8      maxv /* ID_AA64PFR1_EL1 - AArch64 Processor Feature Register 1 */
    236   1.8      maxv struct fieldinfo id_aa64pfr1_fieldinfo[] = {
    237   1.8      maxv 	{
    238   1.8      maxv 		.bitpos = 0, .bitwidth = 4, .name = "BT",
    239   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    240   1.8      maxv 			[0] = "Branch Target Identification not implemented",
    241   1.8      maxv 			[1] = "Branch Target Identification implemented",
    242   1.8      maxv 		}
    243   1.8      maxv 	},
    244   1.8      maxv 	{
    245   1.8      maxv 		.bitpos = 4, .bitwidth = 4, .name = "SSBS",
    246   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    247   1.8      maxv 			[0] = "Speculative Store Bypassing control not implemented",
    248   1.8      maxv 			[1] = "Speculative Store Bypassing control implemented",
    249   1.8      maxv 			[2] = "Speculative Store Bypassing control implemented, plus MSR/MRS"
    250   1.8      maxv 		}
    251   1.8      maxv 	},
    252   1.8      maxv 	{
    253   1.8      maxv 		.bitpos = 8, .bitwidth = 4, .name = "MTE",
    254   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    255   1.8      maxv 			[0] = "Tagged Memory Extension not implemented",
    256   1.8      maxv 			[1] = "Tagged Memory Extension implemented, EL0 only",
    257   1.8      maxv 			[2] = "Tagged Memory Extension implemented"
    258   1.8      maxv 		}
    259   1.8      maxv 	},
    260   1.8      maxv 	{
    261   1.8      maxv 		.bitpos = 12, .bitwidth = 4, .name = "RAS_frac",
    262   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    263   1.8      maxv 			[0] = "Regular RAS",
    264   1.8      maxv 			[1] = "RAS plus registers",
    265   1.8      maxv 		}
    266   1.8      maxv 	},
    267   1.8      maxv 	{ .bitwidth = 0 }	/* end of table */
    268   1.8      maxv };
    269   1.8      maxv 
    270   1.1       ryo /* ID_AA64ISAR0_EL1 - AArch64 Instruction Set Attribute Register 0 */
    271   1.1       ryo struct fieldinfo id_aa64isar0_fieldinfo[] = {
    272   1.1       ryo 	{
    273   1.1       ryo 		.bitpos = 4, .bitwidth = 4, .name = "AES",
    274   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    275   1.1       ryo 			[0] = "No AES",
    276   1.1       ryo 			[1] = "AESE/AESD/AESMC/AESIMC",
    277   1.1       ryo 			[2] = "AESE/AESD/AESMC/AESIMC+PMULL/PMULL2"
    278   1.1       ryo 		}
    279   1.1       ryo 	},
    280   1.1       ryo 	{
    281   1.1       ryo 		.bitpos = 8, .bitwidth = 4, .name = "SHA1",
    282   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    283   1.1       ryo 			[0] = "No SHA1",
    284   1.1       ryo 			[1] = "SHA1C/SHA1P/SHA1M/SHA1H/SHA1SU0/SHA1SU1"
    285   1.1       ryo 		}
    286   1.1       ryo 	},
    287   1.1       ryo 	{
    288   1.1       ryo 		.bitpos = 12, .bitwidth = 4, .name = "SHA2",
    289   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    290   1.1       ryo 			[0] = "No SHA2",
    291   1.1       ryo 			[1] = "SHA256H/SHA256H2/SHA256SU0/SHA256U1"
    292   1.1       ryo 		}
    293   1.1       ryo 	},
    294   1.1       ryo 	{
    295   1.1       ryo 		.bitpos = 16, .bitwidth = 4, .name = "CRC32",
    296   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    297   1.1       ryo 			[0] = "No CRC32",
    298   1.1       ryo 			[1] = "CRC32B/CRC32H/CRC32W/CRC32X"
    299   1.1       ryo 			    "/CRC32CB/CRC32CH/CRC32CW/CRC32CX"
    300   1.1       ryo 		}
    301   1.1       ryo 	},
    302   1.9  riastrad 	{
    303  1.11  riastrad 		.bitpos = 20, .bitwidth = 4, .name = "Atomic",
    304  1.11  riastrad 		.info = (const char *[16]) { /* 16=4bit */
    305  1.11  riastrad 			[0] = "No Atomic",
    306  1.11  riastrad 			[1] = "LDADD/LDCLR/LDEOR/LDSET/LDSMAX/LDSMIN"
    307  1.11  riastrad 			    "/LDUMAX/LDUMIN/CAS/CASP/SWP",
    308  1.11  riastrad 		}
    309  1.11  riastrad 	},
    310  1.11  riastrad 	{
    311  1.11  riastrad 		.bitpos = 28, .bitwidth = 4, .name = "RDM",
    312  1.11  riastrad 		.info = (const char *[16]) { /* 16=4bit */
    313  1.11  riastrad 			[0] = "No RDMA",
    314  1.11  riastrad 			[1] = "SQRDMLAH/SQRDMLSH",
    315  1.11  riastrad 		}
    316  1.11  riastrad 	},
    317  1.11  riastrad 	{
    318  1.11  riastrad 		.bitpos = 32, .bitwidth = 4, .name = "SHA3",
    319  1.11  riastrad 		.info = (const char *[16]) { /* 16=4bit */
    320  1.11  riastrad 			[0] = "No SHA3",
    321  1.11  riastrad 			[1] = "EOR3/RAX1/XAR/BCAX",
    322  1.11  riastrad 		}
    323  1.11  riastrad 	},
    324  1.11  riastrad 	{
    325  1.11  riastrad 		.bitpos = 36, .bitwidth = 4, .name = "SM3",
    326  1.11  riastrad 		.info = (const char *[16]) { /* 16=4bit */
    327  1.11  riastrad 			[0] = "No SM3",
    328  1.11  riastrad 			[1] = "SM3SS1/SM3TT1A/SM3TT1B/SM3TT2A/SM3TT2B"
    329  1.11  riastrad 			    "/SM3PARTW1/SM3PARTW2",
    330  1.11  riastrad 		}
    331  1.11  riastrad 	},
    332  1.11  riastrad 	{
    333  1.11  riastrad 		.bitpos = 40, .bitwidth = 4, .name = "SM4",
    334  1.11  riastrad 		.info = (const char *[16]) { /* 16=4bit */
    335  1.11  riastrad 			[0] = "No SM4",
    336  1.11  riastrad 			[1] = "SM4E/SM4EKEY",
    337  1.11  riastrad 		}
    338  1.11  riastrad 	},
    339  1.11  riastrad 	{
    340  1.11  riastrad 		.bitpos = 44, .bitwidth = 4, .name = "DP",
    341  1.11  riastrad 		.info = (const char *[16]) { /* 16=4bit */
    342  1.11  riastrad 			[0] = "No Dot Product",
    343  1.11  riastrad 			[1] = "UDOT/SDOT",
    344  1.11  riastrad 		}
    345  1.11  riastrad 	},
    346  1.11  riastrad 	{
    347  1.11  riastrad 		.bitpos = 48, .bitwidth = 4, .name = "FHM",
    348  1.11  riastrad 		.info = (const char *[16]) { /* 16=4bit */
    349  1.11  riastrad 			[0] = "No FHM",
    350  1.11  riastrad 			[1] = "FMLAL/FMLSL",
    351  1.11  riastrad 		}
    352  1.11  riastrad 	},
    353  1.11  riastrad 	{
    354  1.11  riastrad 		.bitpos = 52, .bitwidth = 4, .name = "TS",
    355  1.11  riastrad 		.info = (const char *[16]) { /* 16=4bit */
    356  1.11  riastrad 			[0] = "No TS",
    357  1.11  riastrad 			[1] = "CFINV/RMIF/SETF16/SETF8",
    358  1.11  riastrad 			[2] = "CFINV/RMIF/SETF16/SETF8/AXFLAG/XAFLAG",
    359  1.11  riastrad 		}
    360  1.11  riastrad 	},
    361  1.11  riastrad 	{
    362  1.11  riastrad 		.bitpos = 56, .bitwidth = 4, .name = "TLBI",
    363  1.11  riastrad 		.info = (const char *[16]) { /* 16=4bit */
    364  1.11  riastrad 			[0] = "No outer shareable and TLB range maintenance"
    365  1.11  riastrad 			    " instructions",
    366  1.11  riastrad 			[1] = "Outer shareable TLB maintenance instructions",
    367  1.11  riastrad 			[2] = "Outer shareable and TLB range maintenance"
    368  1.11  riastrad 			    " instructions",
    369  1.11  riastrad 		}
    370  1.11  riastrad 	},
    371  1.11  riastrad 	{
    372   1.9  riastrad 		.bitpos = 60, .bitwidth = 4, .name = "RNDR",
    373   1.9  riastrad 		.info = (const char *[16]) { /* 16=4bit */
    374   1.9  riastrad 			[0] = "No RNDR/RNDRRS",
    375   1.9  riastrad 			[1] = "RNDR/RNDRRS",
    376   1.9  riastrad 		},
    377   1.9  riastrad 	},
    378   1.1       ryo 	{ .bitwidth = 0 }	/* end of table */
    379   1.1       ryo };
    380   1.1       ryo 
    381   1.1       ryo /* ID_AA64MMFR0_EL1 - AArch64 Memory Model Feature Register 0 */
    382   1.1       ryo struct fieldinfo id_aa64mmfr0_fieldinfo[] = {
    383   1.1       ryo 	{
    384   1.1       ryo 		.bitpos = 0, .bitwidth = 4, .name = "PARange",
    385   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    386   1.1       ryo 			[0] = "32bits/4GB",
    387   1.1       ryo 			[1] = "36bits/64GB",
    388   1.1       ryo 			[2] = "40bits/1TB",
    389   1.1       ryo 			[3] = "42bits/4TB",
    390   1.1       ryo 			[4] = "44bits/16TB",
    391   1.1       ryo 			[5] = "48bits/256TB"
    392   1.1       ryo 		}
    393   1.1       ryo 	},
    394   1.1       ryo 	{
    395   1.1       ryo 		.bitpos = 4, .bitwidth = 4, .name = "ASIDBit",
    396   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    397   1.1       ryo 			[0] = "8bits",
    398   1.1       ryo 			[2] = "16bits"
    399   1.1       ryo 		}
    400   1.1       ryo 	},
    401   1.1       ryo 	{
    402   1.1       ryo 		.bitpos = 8, .bitwidth = 4, .name = "BigEnd",
    403   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    404   1.1       ryo 			[0] = "No mixed-endian",
    405   1.1       ryo 			[1] = "Mixed-endian"
    406   1.1       ryo 		}
    407   1.1       ryo 	},
    408   1.1       ryo 	{
    409   1.1       ryo 		.bitpos = 12, .bitwidth = 4, .name = "SNSMem",
    410   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    411   1.1       ryo 			[0] = "No distinction B/W Secure and Non-secure Memory",
    412   1.1       ryo 			[1] = "Distinction B/W Secure and Non-secure Memory"
    413   1.1       ryo 		}
    414   1.1       ryo 	},
    415   1.1       ryo 	{
    416   1.1       ryo 		.bitpos = 16, .bitwidth = 4, .name = "BigEndEL0",
    417   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    418   1.1       ryo 			[0] = "No mixed-endian at EL0",
    419   1.1       ryo 			[1] = "Mixed-endian at EL0"
    420   1.1       ryo 		}
    421   1.1       ryo 	},
    422   1.1       ryo 	{
    423   1.1       ryo 		.bitpos = 20, .bitwidth = 4, .name = "TGran16",
    424   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    425   1.1       ryo 			[0] = "No 16KB granule",
    426   1.1       ryo 			[1] = "16KB granule"
    427   1.1       ryo 		}
    428   1.1       ryo 	},
    429   1.1       ryo 	{
    430   1.1       ryo 		.bitpos = 24, .bitwidth = 4, .name = "TGran64",
    431   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    432   1.2       ryo 			[0] = "64KB granule",
    433   1.2       ryo 			[15] = "No 64KB granule"
    434   1.1       ryo 		}
    435   1.1       ryo 	},
    436   1.1       ryo 	{
    437   1.1       ryo 		.bitpos = 28, .bitwidth = 4, .name = "TGran4",
    438   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    439   1.1       ryo 			[0] = "4KB granule",
    440   1.1       ryo 			[15] = "No 4KB granule"
    441   1.1       ryo 		}
    442   1.1       ryo 	},
    443   1.1       ryo 	{ .bitwidth = 0 }	/* end of table */
    444   1.1       ryo };
    445   1.1       ryo 
    446   1.8      maxv /* ID_AA64MMFR1_EL1 - AArch64 Memory Model Feature Register 1 */
    447   1.8      maxv struct fieldinfo id_aa64mmfr1_fieldinfo[] = {
    448   1.8      maxv 	{
    449   1.8      maxv 		.bitpos = 0, .bitwidth = 4, .name = "HAFDBS",
    450   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    451   1.8      maxv 			[0] = "Access and Dirty flags not supported",
    452   1.8      maxv 			[1] = "Access flag supported",
    453   1.8      maxv 			[2] = "Access and Dirty flags supported",
    454   1.8      maxv 		}
    455   1.8      maxv 	},
    456   1.8      maxv 	{
    457   1.8      maxv 		.bitpos = 4, .bitwidth = 4, .name = "VMIDBits",
    458   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    459   1.8      maxv 			[0] = "8bits",
    460   1.8      maxv 			[2] = "16bits"
    461   1.8      maxv 		}
    462   1.8      maxv 	},
    463   1.8      maxv 	{
    464   1.8      maxv 		.bitpos = 8, .bitwidth = 4, .name = "VH",
    465   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    466   1.8      maxv 			[0] = "Virtualization Host Extensions not supported",
    467   1.8      maxv 			[1] = "Virtualization Host Extensions supported",
    468   1.8      maxv 		}
    469   1.8      maxv 	},
    470   1.8      maxv 	{
    471   1.8      maxv 		.bitpos = 12, .bitwidth = 4, .name = "HPDS",
    472   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    473   1.8      maxv 			[0] = "Disabling of hierarchical controls not supported",
    474   1.8      maxv 			[1] = "Disabling of hierarchical controls supported",
    475   1.8      maxv 			[2] = "Disabling of hierarchical controls supported, plus PTD"
    476   1.8      maxv 		}
    477   1.8      maxv 	},
    478   1.8      maxv 	{
    479   1.8      maxv 		.bitpos = 16, .bitwidth = 4, .name = "LO",
    480   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    481   1.8      maxv 			[0] = "LORegions not supported",
    482   1.8      maxv 			[1] = "LORegions supported"
    483   1.8      maxv 		}
    484   1.8      maxv 	},
    485   1.8      maxv 	{
    486   1.8      maxv 		.bitpos = 20, .bitwidth = 4, .name = "PAN",
    487   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    488   1.8      maxv 			[0] = "PAN not supported",
    489   1.8      maxv 			[1] = "PAN supported",
    490   1.8      maxv 			[2] = "PAN supported, and instructions supported"
    491   1.8      maxv 		}
    492   1.8      maxv 	},
    493   1.8      maxv 	{
    494   1.8      maxv 		.bitpos = 24, .bitwidth = 4, .name = "SpecSEI",
    495   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    496   1.8      maxv 			[0] = "SError interrupt not supported",
    497   1.8      maxv 			[1] = "SError interrupt supported"
    498   1.8      maxv 		}
    499   1.8      maxv 	},
    500   1.8      maxv 	{
    501   1.8      maxv 		.bitpos = 28, .bitwidth = 4, .name = "XNX",
    502   1.8      maxv 		.info = (const char *[16]) { /* 16=4bit */
    503   1.8      maxv 			[0] = "Distinction between EL0 and EL1 XN control at stage 2 not supported",
    504   1.8      maxv 			[1] = "Distinction between EL0 and EL1 XN control at stage 2 supported"
    505   1.8      maxv 		}
    506   1.8      maxv 	},
    507   1.8      maxv 	{ .bitwidth = 0 }	/* end of table */
    508   1.8      maxv };
    509   1.8      maxv 
    510   1.5       ryo /* ID_AA64DFR0_EL1 - AArch64 Debug Feature Register 0 */
    511   1.5       ryo struct fieldinfo id_aa64dfr0_fieldinfo[] = {
    512   1.5       ryo 	{
    513   1.5       ryo 		.bitpos = 0, .bitwidth = 4, .name = "DebugVer",
    514   1.5       ryo 		.info = (const char *[16]) { /* 16=4bit */
    515   1.5       ryo 			[6] = "v8-A debug architecture"
    516   1.5       ryo 		}
    517   1.5       ryo 	},
    518   1.5       ryo 	{
    519   1.5       ryo 		.bitpos = 4, .bitwidth = 4, .name = "TraceVer",
    520   1.5       ryo 		.info = (const char *[16]) { /* 16=4bit */
    521   1.5       ryo 			[0] = "Trace supported",
    522   1.5       ryo 			[1] = "Trace not supported"
    523   1.5       ryo 		}
    524   1.5       ryo 	},
    525   1.5       ryo 	{
    526   1.5       ryo 		.bitpos = 8, .bitwidth = 4, .name = "PMUVer",
    527   1.5       ryo 		.info = (const char *[16]) { /* 16=4bit */
    528   1.5       ryo 			[0] = "No Performance monitor",
    529   1.5       ryo 			[1] = "Performance monitor unit v3"
    530   1.5       ryo 		}
    531   1.5       ryo 	},
    532   1.5       ryo 	{ .bitwidth = 0 }	/* end of table */
    533   1.5       ryo };
    534   1.5       ryo 
    535   1.5       ryo 
    536   1.1       ryo /* MVFR0_EL1 - Media and VFP Feature Register 0 */
    537   1.1       ryo struct fieldinfo mvfr0_fieldinfo[] = {
    538   1.1       ryo 	{
    539   1.1       ryo 		.bitpos = 0, .bitwidth = 4, .name = "SIMDreg",
    540   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    541   1.1       ryo 			[0] = "No SIMD",
    542   1.1       ryo 			[1] = "16x64-bit SIMD",
    543   1.1       ryo 			[2] = "32x64-bit SIMD"
    544   1.1       ryo 		}
    545   1.1       ryo 	},
    546   1.1       ryo 	{
    547   1.1       ryo 		.bitpos = 4, .bitwidth = 4, .name = "FPSP",
    548   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    549   1.1       ryo 			[0] = "No VFP support single precision",
    550   1.1       ryo 			[1] = "VFPv2 support single precision",
    551   1.1       ryo 			[2] = "VFPv2/VFPv3/VFPv4 support single precision"
    552   1.1       ryo 		}
    553   1.1       ryo 	},
    554   1.1       ryo 	{
    555   1.1       ryo 		.bitpos = 8, .bitwidth = 4, .name = "FPDP",
    556   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    557   1.1       ryo 			[0] = "No VFP support double precision",
    558   1.1       ryo 			[1] = "VFPv2 support double precision",
    559   1.1       ryo 			[2] = "VFPv2/VFPv3/VFPv4 support double precision"
    560   1.1       ryo 		}
    561   1.1       ryo 	},
    562   1.1       ryo 	{
    563   1.1       ryo 		.bitpos = 12, .bitwidth = 4, .name = "FPTrap",
    564   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    565   1.6     skrll 			[0] = "No floating point exception trapping support",
    566   1.1       ryo 			[1] = "VFPv2/VFPv3/VFPv4 support exception trapping"
    567   1.1       ryo 		}
    568   1.1       ryo 	},
    569   1.1       ryo 	{
    570   1.1       ryo 		.bitpos = 16, .bitwidth = 4, .name = "FPDivide",
    571   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    572   1.1       ryo 			[0] = "VDIV not supported",
    573   1.1       ryo 			[1] = "VDIV supported"
    574   1.1       ryo 		}
    575   1.1       ryo 	},
    576   1.1       ryo 	{
    577   1.1       ryo 		.bitpos = 20, .bitwidth = 4, .name = "FPSqrt",
    578   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    579   1.1       ryo 			[0] = "VSQRT not supported",
    580   1.1       ryo 			[1] = "VSQRT supported"
    581   1.1       ryo 		}
    582   1.1       ryo 	},
    583   1.1       ryo 	{
    584   1.1       ryo 		.bitpos = 24, .bitwidth = 4, .name = "FPShVec",
    585   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    586   1.1       ryo 			[0] = "Short Vectors not supported",
    587   1.1       ryo 			[1] = "Short Vectors supported"
    588   1.1       ryo 		}
    589   1.1       ryo 	},
    590   1.1       ryo 	{
    591   1.1       ryo 		.bitpos = 28, .bitwidth = 4, .name = "FPRound",
    592   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    593   1.1       ryo 			[0] = "Only Round to Nearest mode",
    594   1.1       ryo 			[1] = "All rounding modes"
    595   1.1       ryo 		}
    596   1.1       ryo 	},
    597   1.1       ryo 	{ .bitwidth = 0 }	/* end of table */
    598   1.1       ryo };
    599   1.1       ryo 
    600   1.1       ryo /* MVFR1_EL1 - Media and VFP Feature Register 1 */
    601   1.1       ryo struct fieldinfo mvfr1_fieldinfo[] = {
    602   1.1       ryo 	{
    603   1.1       ryo 		.bitpos = 0, .bitwidth = 4, .name = "FPFtZ",
    604   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    605   1.1       ryo 			[0] = "only the Flush-to-Zero",
    606   1.1       ryo 			[1] = "full Denormalized number arithmetic"
    607   1.1       ryo 		}
    608   1.1       ryo 	},
    609   1.1       ryo 	{
    610   1.1       ryo 		.bitpos = 4, .bitwidth = 4, .name = "FPDNan",
    611   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    612   1.1       ryo 			[0] = "Default NaN",
    613   1.1       ryo 			[1] = "Propagation of NaN"
    614   1.1       ryo 		}
    615   1.1       ryo 	},
    616   1.1       ryo 	{
    617   1.1       ryo 		.bitpos = 8, .bitwidth = 4, .name = "SIMDLS",
    618   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    619   1.1       ryo 			[0] = "No Advanced SIMD Load/Store",
    620   1.1       ryo 			[1] = "Advanced SIMD Load/Store"
    621   1.1       ryo 		}
    622   1.1       ryo 	},
    623   1.1       ryo 	{
    624   1.1       ryo 		.bitpos = 12, .bitwidth = 4, .name = "SIMDInt",
    625   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    626   1.1       ryo 			[0] = "No Advanced SIMD Integer",
    627   1.1       ryo 			[1] = "Advanced SIMD Integer"
    628   1.1       ryo 		}
    629   1.1       ryo 	},
    630   1.1       ryo 	{
    631   1.1       ryo 		.bitpos = 16, .bitwidth = 4, .name = "SIMDSP",
    632   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    633   1.1       ryo 			[0] = "No Advanced SIMD single precision",
    634   1.1       ryo 			[1] = "Advanced SIMD single precision"
    635   1.1       ryo 		}
    636   1.1       ryo 	},
    637   1.1       ryo 	{
    638   1.1       ryo 		.bitpos = 20, .bitwidth = 4, .name = "SIMDHP",
    639   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    640   1.1       ryo 			[0] = "No Advanced SIMD half precision",
    641   1.1       ryo 			[1] = "Advanced SIMD half precision"
    642   1.1       ryo 		}
    643   1.1       ryo 	},
    644   1.1       ryo 	{
    645   1.1       ryo 		.bitpos = 24, .bitwidth = 4, .name = "FPHP",
    646   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    647   1.1       ryo 			[0] = "No half precision conversion",
    648   1.1       ryo 			[1] = "half/single precision conversion",
    649   1.1       ryo 			[2] = "half/single/double precision conversion"
    650   1.1       ryo 		}
    651   1.1       ryo 	},
    652   1.1       ryo 	{
    653   1.1       ryo 		.bitpos = 28, .bitwidth = 4, .name = "SIMDFMAC",
    654   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    655   1.1       ryo 			[0] = "No Fused Multiply-Accumulate",
    656   1.1       ryo 			[1] = "Fused Multiply-Accumulate"
    657   1.1       ryo 		}
    658   1.1       ryo 	},
    659   1.1       ryo 	{ .bitwidth = 0 }	/* end of table */
    660   1.1       ryo };
    661   1.1       ryo 
    662   1.1       ryo /* MVFR2_EL1 - Media and VFP Feature Register 2 */
    663   1.1       ryo struct fieldinfo mvfr2_fieldinfo[] = {
    664   1.1       ryo 	{
    665   1.1       ryo 		.bitpos = 0, .bitwidth = 4, .name = "SIMDMisc",
    666   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    667   1.1       ryo 			[0] = "No miscellaneous features",
    668   1.1       ryo 			[1] = "Conversion to Integer w/Directed Rounding modes",
    669   1.1       ryo 			[2] = "Conversion to Integer w/Directed Rounding modes"
    670   1.1       ryo 			    ", Round to Integral floating point",
    671   1.1       ryo 			[3] = "Conversion to Integer w/Directed Rounding modes"
    672   1.1       ryo 			    ", Round to Integral floating point"
    673   1.1       ryo 			    ", MaxNum and MinNum"
    674   1.1       ryo 		}
    675   1.1       ryo 	},
    676   1.1       ryo 	{
    677   1.1       ryo 		.bitpos = 4, .bitwidth = 4, .name = "FPMisc",
    678   1.1       ryo 		.info = (const char *[16]) { /* 16=4bit */
    679   1.1       ryo 			[0] = "No miscellaneous features",
    680   1.1       ryo 			[1] = "Floating point selection",
    681   1.1       ryo 			[2] = "Floating point selection"
    682   1.1       ryo 			    ", Conversion to Integer w/Directed Rounding modes",
    683   1.1       ryo 			[3] = "Floating point selection"
    684   1.1       ryo 			    ", Conversion to Integer w/Directed Rounding modes"
    685   1.1       ryo 			    ", Round to Integral floating point",
    686   1.1       ryo 			[4] = "Floating point selection"
    687   1.1       ryo 			    ", Conversion to Integer w/Directed Rounding modes"
    688   1.1       ryo 			    ", Round to Integral floating point"
    689   1.1       ryo 			    ", MaxNum and MinNum"
    690   1.1       ryo 		}
    691   1.1       ryo 	},
    692   1.1       ryo 	{ .bitwidth = 0 }	/* end of table */
    693   1.1       ryo };
    694   1.1       ryo 
    695  1.10       ryo /* CLIDR_EL1 - Cache Level ID Register */
    696  1.10       ryo const char * const clidr_cachetype[8] = { /* 8=3bit */
    697  1.10       ryo 	[0] = "None",
    698  1.10       ryo 	[1] = "Instruction cache",
    699  1.10       ryo 	[2] = "Data cache",
    700  1.10       ryo 	[3] = "Instruction and Data cache",
    701  1.10       ryo 	[4] = "Unified cache"
    702  1.10       ryo };
    703  1.10       ryo 
    704  1.10       ryo struct fieldinfo clidr_fieldinfo[] = {
    705  1.10       ryo 	{
    706  1.10       ryo 		.bitpos = 0, .bitwidth = 3, .name = "L1",
    707  1.10       ryo 		.info = clidr_cachetype
    708  1.10       ryo 	},
    709  1.10       ryo 	{
    710  1.10       ryo 		.bitpos = 3, .bitwidth = 3, .name = "L2",
    711  1.10       ryo 		.info = clidr_cachetype
    712  1.10       ryo 	},
    713  1.10       ryo 	{
    714  1.10       ryo 		.bitpos = 6, .bitwidth = 3, .name = "L3",
    715  1.10       ryo 		.info = clidr_cachetype
    716  1.10       ryo 	},
    717  1.10       ryo 	{
    718  1.10       ryo 		.bitpos = 9, .bitwidth = 3, .name = "L4",
    719  1.10       ryo 		.info = clidr_cachetype
    720  1.10       ryo 	},
    721  1.10       ryo 	{
    722  1.10       ryo 		.bitpos = 12, .bitwidth = 3, .name = "L5",
    723  1.10       ryo 		.info = clidr_cachetype
    724  1.10       ryo 	},
    725  1.10       ryo 	{
    726  1.10       ryo 		.bitpos = 15, .bitwidth = 3, .name = "L6",
    727  1.10       ryo 		.info = clidr_cachetype
    728  1.10       ryo 	},
    729  1.10       ryo 	{
    730  1.10       ryo 		.bitpos = 18, .bitwidth = 3, .name = "L7",
    731  1.10       ryo 		.info = clidr_cachetype
    732  1.10       ryo 	},
    733  1.10       ryo 	{
    734  1.10       ryo 		.bitpos = 21, .bitwidth = 3, .name = "LoUU",
    735  1.10       ryo 		.flags = FIELDINFO_FLAGS_DEC
    736  1.10       ryo 	},
    737  1.10       ryo 	{
    738  1.10       ryo 		.bitpos = 24, .bitwidth = 3, .name = "LoC",
    739  1.10       ryo 		.flags = FIELDINFO_FLAGS_DEC
    740  1.10       ryo 	},
    741  1.10       ryo 	{
    742  1.10       ryo 		.bitpos = 27, .bitwidth = 3, .name = "LoUIS",
    743  1.10       ryo 		.flags = FIELDINFO_FLAGS_DEC
    744  1.10       ryo 	},
    745  1.10       ryo 	{
    746  1.10       ryo 		.bitpos = 30, .bitwidth = 3, .name = "ICB",
    747  1.10       ryo 		.flags = FIELDINFO_FLAGS_DEC
    748  1.10       ryo 	},
    749  1.10       ryo 	{ .bitwidth = 0 }	/* end of table */
    750  1.10       ryo };
    751  1.10       ryo 
    752  1.10       ryo struct fieldinfo ctr_fieldinfo[] = {
    753  1.10       ryo 	{
    754  1.10       ryo 		.bitpos = 0, .bitwidth = 4, .name = "IminLine",
    755  1.10       ryo 		.flags = FIELDINFO_FLAGS_DEC | FIELDINFO_FLAGS_4LOG2
    756  1.10       ryo 	},
    757  1.10       ryo 	{
    758  1.10       ryo 		.bitpos = 16, .bitwidth = 4, .name = "DminLine",
    759  1.10       ryo 		.flags = FIELDINFO_FLAGS_DEC | FIELDINFO_FLAGS_4LOG2
    760  1.10       ryo 	},
    761  1.10       ryo 	{
    762  1.10       ryo 		.bitpos = 14, .bitwidth = 2, .name = "L1 Icache policy",
    763  1.10       ryo 		.info = (const char *[4]) { /* 4=2bit */
    764  1.10       ryo 			[0] = "VMID aware PIPT (VPIPT)",
    765  1.10       ryo 			[1] = "ASID-tagged VIVT (AIVIVT)",
    766  1.10       ryo 			[2] = "VIPT",
    767  1.10       ryo 			[3] = "PIPT"
    768  1.10       ryo 		},
    769  1.10       ryo 	},
    770  1.10       ryo 	{
    771  1.10       ryo 		.bitpos = 20, .bitwidth = 4, .name = "ERG",
    772  1.10       ryo 		.flags = FIELDINFO_FLAGS_DEC | FIELDINFO_FLAGS_4LOG2
    773  1.10       ryo 	},
    774  1.10       ryo 	{
    775  1.10       ryo 		.bitpos = 24, .bitwidth = 4, .name = "CWG",
    776  1.10       ryo 		.flags = FIELDINFO_FLAGS_DEC | FIELDINFO_FLAGS_4LOG2
    777  1.10       ryo 	},
    778  1.10       ryo 	{
    779  1.10       ryo 		.bitpos = 28, .bitwidth = 1, .name = "DIC",
    780  1.10       ryo 		.flags = FIELDINFO_FLAGS_DEC
    781  1.10       ryo 	},
    782  1.10       ryo 	{
    783  1.10       ryo 		.bitpos = 29, .bitwidth = 1, .name = "IDC",
    784  1.10       ryo 		.flags = FIELDINFO_FLAGS_DEC
    785  1.10       ryo 	},
    786  1.10       ryo 	{ .bitwidth = 0 }	/* end of table */
    787  1.10       ryo };
    788  1.10       ryo 
    789  1.10       ryo 
    790   1.1       ryo static void
    791   1.1       ryo print_fieldinfo(const char *cpuname, const char *setname,
    792   1.1       ryo     struct fieldinfo *fieldinfo, uint64_t data)
    793   1.1       ryo {
    794   1.1       ryo 	uint64_t v;
    795   1.1       ryo 	const char *info;
    796  1.10       ryo 	int i, flags;
    797   1.1       ryo 
    798   1.1       ryo #define WIDTHMASK(w)	(0xffffffffffffffffULL >> (64 - (w)))
    799   1.1       ryo 
    800   1.1       ryo 	for (i = 0; fieldinfo[i].bitwidth != 0; i++) {
    801   1.1       ryo 		v = (data >> fieldinfo[i].bitpos) &
    802   1.1       ryo 		    WIDTHMASK(fieldinfo[i].bitwidth);
    803   1.1       ryo 
    804  1.10       ryo 		flags = fieldinfo[i].flags;
    805  1.10       ryo 		info = NULL;
    806  1.10       ryo 		if (fieldinfo[i].info != NULL)
    807  1.10       ryo 			info = fieldinfo[i].info[v];
    808  1.10       ryo 
    809  1.10       ryo 		printf("%s: %s: %s: ",
    810  1.10       ryo 		    cpuname, setname, fieldinfo[i].name);
    811  1.10       ryo 
    812  1.10       ryo 		if (info == NULL) {
    813  1.10       ryo 			if (flags & FIELDINFO_FLAGS_4LOG2)
    814  1.10       ryo 				v = 4 * (1 << v);
    815  1.10       ryo 			if (flags & FIELDINFO_FLAGS_DEC)
    816  1.10       ryo 				printf("%"PRIu64"\n", v);
    817  1.10       ryo 			else
    818  1.10       ryo 				printf("0x%"PRIx64"\n", v);
    819  1.10       ryo 		} else {
    820  1.10       ryo 			printf("%s\n", info);
    821  1.10       ryo 		}
    822   1.1       ryo 	}
    823   1.1       ryo }
    824   1.1       ryo 
    825   1.1       ryo /* MIDR_EL1 - Main ID Register */
    826   1.1       ryo static void
    827   1.1       ryo identify_midr(const char *cpuname, uint32_t cpuid)
    828   1.1       ryo {
    829   1.1       ryo 	unsigned int i;
    830   1.1       ryo 	uint32_t implid, cpupart, variant, revision;
    831   1.1       ryo 	const char *implementer = NULL;
    832   1.1       ryo 	static char implbuf[128];
    833   1.1       ryo 
    834   1.1       ryo 	implid = cpuid & CPU_ID_IMPLEMENTOR_MASK;
    835   1.1       ryo 	cpupart = cpuid & CPU_PARTMASK;
    836   1.1       ryo 	variant = __SHIFTOUT(cpuid, CPU_ID_VARIANT_MASK);
    837   1.1       ryo 	revision = __SHIFTOUT(cpuid, CPU_ID_REVISION_MASK);
    838   1.1       ryo 
    839   1.1       ryo 	for (i = 0; i < __arraycount(implids); i++) {
    840   1.1       ryo 		if (implid == implids[i].impl_id) {
    841   1.1       ryo 			implementer = implids[i].impl_name;
    842   1.1       ryo 		}
    843   1.1       ryo 	}
    844   1.1       ryo 	if (implementer == NULL) {
    845   1.1       ryo 		snprintf(implbuf, sizeof(implbuf), "unknown implementer: 0x%02x",
    846   1.1       ryo 		    implid >> 24);
    847   1.1       ryo 		implementer = implbuf;
    848   1.1       ryo 	}
    849   1.1       ryo 
    850   1.1       ryo 	for (i = 0; i < __arraycount(cpuids); i++) {
    851   1.1       ryo 		if (cpupart == cpuids[i].cpu_partnum) {
    852   1.1       ryo 			printf("%s: %s, %s r%dp%d (%s %s core)\n",
    853   1.1       ryo 			    cpuname, implementer,
    854   1.1       ryo 			    cpuids[i].cpu_name, variant, revision,
    855   1.1       ryo 			    cpuids[i].cpu_class,
    856   1.1       ryo 			    cpuids[i].cpu_architecture);
    857   1.1       ryo 			return;
    858   1.1       ryo 		}
    859   1.1       ryo 	}
    860   1.1       ryo 	printf("%s: unknown CPU ID: 0x%08x\n", cpuname, cpuid);
    861   1.1       ryo }
    862   1.1       ryo 
    863   1.1       ryo /* REVIDR_EL1 - Revision ID Register */
    864   1.1       ryo static void
    865   1.1       ryo identify_revidr(const char *cpuname, uint32_t revidr)
    866   1.1       ryo {
    867   1.1       ryo 	printf("%s: revision: 0x%08x\n", cpuname, revidr);
    868   1.1       ryo }
    869   1.1       ryo 
    870   1.1       ryo /* MPIDR_EL1 - Multiprocessor Affinity Register */
    871   1.1       ryo static void
    872   1.1       ryo identify_mpidr(const char *cpuname, uint32_t mpidr)
    873   1.1       ryo {
    874   1.1       ryo 	const char *setname = "multiprocessor affinity";
    875   1.1       ryo 
    876   1.1       ryo 	printf("%s: %s: Affinity-Level: %"PRIu64"-%"PRIu64"-%"PRIu64"-%"PRIu64"\n",
    877   1.1       ryo 	    cpuname, setname,
    878   1.1       ryo 	    __SHIFTOUT(mpidr, MPIDR_AFF3),
    879   1.1       ryo 	    __SHIFTOUT(mpidr, MPIDR_AFF2),
    880   1.1       ryo 	    __SHIFTOUT(mpidr, MPIDR_AFF1),
    881   1.1       ryo 	    __SHIFTOUT(mpidr, MPIDR_AFF0));
    882   1.1       ryo 
    883   1.1       ryo 	if ((mpidr & MPIDR_U) == 0)
    884   1.1       ryo 		printf("%s: %s: Multiprocessor system\n", cpuname, setname);
    885   1.1       ryo 	else
    886   1.1       ryo 		printf("%s: %s: Uniprocessor system\n", cpuname, setname);
    887   1.1       ryo 
    888   1.1       ryo 	if ((mpidr & MPIDR_MT) == 0)
    889   1.1       ryo 		printf("%s: %s: Core Independent\n", cpuname, setname);
    890   1.1       ryo 	else
    891   1.1       ryo 		printf("%s: %s: Multi-Threading\n", cpuname, setname);
    892   1.1       ryo 
    893   1.1       ryo }
    894   1.1       ryo 
    895   1.5       ryo /* AA64DFR0 - Debug feature register 0 */
    896   1.5       ryo static void
    897   1.5       ryo identify_dfr0(const char *cpuname, uint64_t dfr0)
    898   1.5       ryo {
    899   1.5       ryo 	const char *setname = "debug feature 0";
    900   1.5       ryo 
    901   1.5       ryo 	printf("%s: %s: CTX_CMPs: %lu context-aware breakpoints\n",
    902   1.5       ryo 	    cpuname, setname, __SHIFTOUT(dfr0, ID_AA64DFR0_EL1_CTX_CMPS) + 1);
    903   1.5       ryo 	printf("%s: %s: WRPs: %lu watchpoints\n",
    904   1.5       ryo 	    cpuname, setname, __SHIFTOUT(dfr0, ID_AA64DFR0_EL1_WRPS) + 1);
    905   1.5       ryo 	printf("%s: %s: BRPs: %lu breakpoints\n",
    906   1.5       ryo 	    cpuname, setname, __SHIFTOUT(dfr0, ID_AA64DFR0_EL1_BRPS) + 1);
    907   1.5       ryo 	print_fieldinfo(cpuname, setname,
    908   1.5       ryo 	    id_aa64dfr0_fieldinfo, dfr0);
    909   1.5       ryo }
    910   1.5       ryo 
    911   1.1       ryo void
    912   1.1       ryo identifycpu(int fd, const char *cpuname)
    913   1.1       ryo {
    914   1.3       mrg 	char path[128];
    915   1.1       ryo 	size_t len;
    916   1.5       ryo #define SYSCTL_CPU_ID_MAXSIZE	64
    917   1.5       ryo 	uint64_t sysctlbuf[SYSCTL_CPU_ID_MAXSIZE];
    918   1.5       ryo 	struct aarch64_sysctl_cpu_id *id =
    919   1.5       ryo 	    (struct aarch64_sysctl_cpu_id *)sysctlbuf;
    920   1.1       ryo 
    921   1.3       mrg 	snprintf(path, sizeof path, "machdep.%s.cpu_id", cpuname);
    922   1.5       ryo 	len = sizeof(sysctlbuf);
    923  1.10       ryo 	memset(sysctlbuf, 0, len);
    924   1.5       ryo 	if (sysctlbyname(path, id, &len, 0, 0) == -1)
    925   1.3       mrg 		err(1, "couldn't get %s", path);
    926   1.5       ryo 	if (len != sizeof(struct aarch64_sysctl_cpu_id))
    927   1.5       ryo 		fprintf(stderr, "Warning: kernel version bumped?\n");
    928   1.5       ryo 
    929   1.5       ryo 	if (verbose) {
    930   1.5       ryo 		printf("%s: MIDR_EL1: 0x%08"PRIx64"\n",
    931   1.5       ryo 		    cpuname, id->ac_midr);
    932   1.5       ryo 		printf("%s: MPIDR_EL1: 0x%016"PRIx64"\n",
    933   1.5       ryo 		    cpuname, id->ac_mpidr);
    934   1.5       ryo 		printf("%s: ID_AA64DFR0_EL1: 0x%016"PRIx64"\n",
    935   1.5       ryo 		    cpuname, id->ac_aa64dfr0);
    936   1.5       ryo 		printf("%s: ID_AA64DFR1_EL1: 0x%016"PRIx64"\n",
    937   1.5       ryo 		    cpuname, id->ac_aa64dfr1);
    938   1.5       ryo 		printf("%s: ID_AA64ISAR0_EL1: 0x%016"PRIx64"\n",
    939   1.5       ryo 		    cpuname, id->ac_aa64isar0);
    940   1.5       ryo 		printf("%s: ID_AA64ISAR1_EL1: 0x%016"PRIx64"\n",
    941   1.5       ryo 		    cpuname, id->ac_aa64isar1);
    942   1.5       ryo 		printf("%s: ID_AA64MMFR0_EL1: 0x%016"PRIx64"\n",
    943   1.5       ryo 		    cpuname, id->ac_aa64mmfr0);
    944   1.5       ryo 		printf("%s: ID_AA64MMFR1_EL1: 0x%016"PRIx64"\n",
    945   1.5       ryo 		    cpuname, id->ac_aa64mmfr1);
    946   1.5       ryo 		printf("%s: ID_AA64MMFR2_EL1: 0x%016"PRIx64"\n",
    947   1.5       ryo 		    cpuname, id->ac_aa64mmfr2);
    948   1.5       ryo 		printf("%s: ID_AA64PFR0_EL1: 0x%08"PRIx64"\n",
    949   1.5       ryo 		    cpuname, id->ac_aa64pfr0);
    950   1.5       ryo 		printf("%s: ID_AA64PFR1_EL1: 0x%08"PRIx64"\n",
    951   1.5       ryo 		    cpuname, id->ac_aa64pfr1);
    952   1.5       ryo 		printf("%s: ID_AA64ZFR0_EL1: 0x%016"PRIx64"\n",
    953   1.5       ryo 		    cpuname, id->ac_aa64zfr0);
    954   1.5       ryo 		printf("%s: MVFR0_EL1: 0x%08"PRIx32"\n",
    955   1.5       ryo 		    cpuname, id->ac_mvfr0);
    956   1.5       ryo 		printf("%s: MVFR1_EL1: 0x%08"PRIx32"\n",
    957   1.5       ryo 		    cpuname, id->ac_mvfr1);
    958   1.5       ryo 		printf("%s: MVFR2_EL1: 0x%08"PRIx32"\n",
    959   1.5       ryo 		    cpuname, id->ac_mvfr2);
    960  1.10       ryo 		printf("%s: CLIDR_EL1: 0x%016"PRIx64"\n",
    961  1.10       ryo 		    cpuname, id->ac_clidr);
    962  1.10       ryo 		printf("%s: CTR_EL0: 0x%016"PRIx64"\n",
    963  1.10       ryo 		    cpuname, id->ac_ctr);
    964   1.5       ryo 	}
    965   1.3       mrg 
    966   1.5       ryo 	identify_midr(cpuname, id->ac_midr);
    967   1.5       ryo 	identify_revidr(cpuname, id->ac_revidr);
    968   1.5       ryo 	identify_mpidr(cpuname, id->ac_mpidr);
    969   1.3       mrg 	print_fieldinfo(cpuname, "isa features 0",
    970   1.5       ryo 	    id_aa64isar0_fieldinfo, id->ac_aa64isar0);
    971   1.3       mrg 	print_fieldinfo(cpuname, "memory model 0",
    972   1.5       ryo 	    id_aa64mmfr0_fieldinfo, id->ac_aa64mmfr0);
    973   1.8      maxv 	print_fieldinfo(cpuname, "memory model 1",
    974   1.8      maxv 	    id_aa64mmfr1_fieldinfo, id->ac_aa64mmfr1);
    975   1.3       mrg 	print_fieldinfo(cpuname, "processor feature 0",
    976   1.5       ryo 	    id_aa64pfr0_fieldinfo, id->ac_aa64pfr0);
    977   1.8      maxv 	print_fieldinfo(cpuname, "processor feature 1",
    978   1.8      maxv 	    id_aa64pfr1_fieldinfo, id->ac_aa64pfr1);
    979   1.5       ryo 	identify_dfr0(cpuname, id->ac_aa64dfr0);
    980   1.3       mrg 
    981   1.3       mrg 	print_fieldinfo(cpuname, "media and VFP features 0",
    982   1.5       ryo 	    mvfr0_fieldinfo, id->ac_mvfr0);
    983   1.3       mrg 	print_fieldinfo(cpuname, "media and VFP features 1",
    984   1.5       ryo 	    mvfr1_fieldinfo, id->ac_mvfr1);
    985   1.3       mrg 	print_fieldinfo(cpuname, "media and VFP features 2",
    986   1.5       ryo 	    mvfr2_fieldinfo, id->ac_mvfr2);
    987  1.10       ryo 
    988  1.10       ryo 	if (len <= offsetof(struct aarch64_sysctl_cpu_id, ac_clidr))
    989  1.10       ryo 		return;
    990  1.10       ryo 	print_fieldinfo(cpuname, "cache level",
    991  1.10       ryo 	    clidr_fieldinfo, id->ac_clidr);
    992  1.10       ryo 	print_fieldinfo(cpuname, "cache type",
    993  1.10       ryo 	    ctr_fieldinfo, id->ac_ctr);
    994   1.1       ryo }
    995   1.1       ryo 
    996   1.1       ryo bool
    997   1.1       ryo identifycpu_bind(void)
    998   1.1       ryo {
    999   1.3       mrg 	return false;
   1000   1.1       ryo }
   1001   1.1       ryo 
   1002   1.1       ryo int
   1003   1.1       ryo ucodeupdate_check(int fd, struct cpu_ucode *uc)
   1004   1.1       ryo {
   1005   1.1       ryo 	return 0;
   1006   1.1       ryo }
   1007