hw/arm/xlnx-versal: Use qdev_prop_set_array()
[qemu/ar7.git] / util / cpuinfo-ppc.c
blob1ea3db0ac8209b30a7a746a521dcebbfabac8b49
1 /*
2 * SPDX-License-Identifier: GPL-2.0-or-later
3 * Host specific cpu identification for ppc.
4 */
6 #include "qemu/osdep.h"
7 #include "host/cpuinfo.h"
9 #ifdef CONFIG_GETAUXVAL
10 # include <sys/auxv.h>
11 #else
12 # include <asm/cputable.h>
13 # include "elf.h"
14 #endif
16 unsigned cpuinfo;
18 /* Called both as constructor and (possibly) via other constructors. */
19 unsigned __attribute__((constructor)) cpuinfo_init(void)
21 unsigned info = cpuinfo;
22 unsigned long hwcap, hwcap2;
24 if (info) {
25 return info;
28 hwcap = qemu_getauxval(AT_HWCAP);
29 hwcap2 = qemu_getauxval(AT_HWCAP2);
30 info = CPUINFO_ALWAYS;
32 /* Version numbers are monotonic, and so imply all lower versions. */
33 if (hwcap2 & PPC_FEATURE2_ARCH_3_1) {
34 info |= CPUINFO_V3_1 | CPUINFO_V3_0 | CPUINFO_V2_07 | CPUINFO_V2_06;
35 } else if (hwcap2 & PPC_FEATURE2_ARCH_3_00) {
36 info |= CPUINFO_V3_0 | CPUINFO_V2_07 | CPUINFO_V2_06;
37 } else if (hwcap2 & PPC_FEATURE2_ARCH_2_07) {
38 info |= CPUINFO_V2_07 | CPUINFO_V2_06;
39 } else if (hwcap & PPC_FEATURE_ARCH_2_06) {
40 info |= CPUINFO_V2_06;
43 if (hwcap2 & PPC_FEATURE2_HAS_ISEL) {
44 info |= CPUINFO_ISEL;
46 if (hwcap & PPC_FEATURE_HAS_ALTIVEC) {
47 info |= CPUINFO_ALTIVEC;
48 /* We only care about the portion of VSX that overlaps Altivec. */
49 if (hwcap & PPC_FEATURE_HAS_VSX) {
50 info |= CPUINFO_VSX;
52 * We use VSX especially for little-endian, but we should
53 * always have both anyway, since VSX came with Power7
54 * and crypto came with Power8.
56 if (hwcap2 & PPC_FEATURE2_HAS_VEC_CRYPTO) {
57 info |= CPUINFO_CRYPTO;
62 cpuinfo = info;
63 return info;