3 * PowerPC hardware feature detection
6 * Alex Rønne Petersen (alexrp@xamarin.com)
7 * Elijah Taylor (elijahtaylor@google.com)
8 * Miguel de Icaza (miguel@xamarin.com)
9 * Neale Ferguson (Neale.Ferguson@SoftwareAG-usa.com)
10 * Paolo Molaro (lupus@xamarin.com)
11 * Rodrigo Kumpera (kumpera@gmail.com)
12 * Sebastien Pouliot (sebastien@xamarin.com)
13 * Zoltan Varga (vargaz@xamarin.com)
15 * Copyright 2003 Ximian, Inc.
16 * Copyright 2003-2011 Novell, Inc
17 * Copyright 2006 Broadcom
18 * Copyright 2007-2008 Andreas Faerber
19 * Copyright 2011-2013 Xamarin Inc
20 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
23 #include "mono/utils/mono-hwcap.h"
25 #if defined(__linux__) && defined(HAVE_SYS_AUXV_H)
29 #include <sys/systemcfg.h>
33 mono_hwcap_arch_init (void)
35 #if defined(__linux__) && defined(HAVE_SYS_AUXV_H)
37 unsigned long platform
;
39 if ((hwcap
= getauxval(AT_HWCAP
))) {
40 /* PPC_FEATURE_ICACHE_SNOOP */
41 if (hwcap
& 0x00002000)
42 mono_hwcap_ppc_has_icache_snoop
= TRUE
;
44 /* PPC_FEATURE_POWER4, PPC_FEATURE_POWER5, PPC_FEATURE_POWER5_PLUS,
45 PPC_FEATURE_CELL_BE, PPC_FEATURE_PA6T, PPC_FEATURE_ARCH_2_05 */
46 if (hwcap
& (0x00080000 | 0x00040000 | 0x00020000 | 0x00010000 | 0x00000800 | 0x00001000))
47 mono_hwcap_ppc_is_isa_2x
= TRUE
;
50 if (hwcap
& 0x40000000)
51 mono_hwcap_ppc_is_isa_64
= TRUE
;
53 /* PPC_FEATURE_POWER6_EXT */
54 if (hwcap
& 0x00000200)
55 mono_hwcap_ppc_has_move_fpr_gpr
= TRUE
;
58 if ((platform
= getauxval(AT_PLATFORM
))) {
59 const char *str
= (const char *) platform
;
61 if (!strcmp (str
, "ppc970") || (!strncmp (str
, "power", 5) && str
[5] >= '4' && str
[5] <= '7'))
62 mono_hwcap_ppc_has_multiple_ls_units
= TRUE
;
66 mono_hwcap_ppc_is_isa_64
= TRUE
;
67 if (__power_4_andup())
68 mono_hwcap_ppc_is_isa_2x
= TRUE
;
69 if (__power_5_andup())
70 mono_hwcap_ppc_has_icache_snoop
= TRUE
;
72 if (__power_4() || __power_5() || __power_6() || __power_7())
73 mono_hwcap_ppc_has_multiple_ls_units
= TRUE
;
75 * I dont see a way to get extended POWER6 and the PV_6_1
76 * def seems to be trigged on the POWER6 here despite not
77 * having these extended instructions, so POWER7 it is
80 * WARNING: reports that this doesn't actually work, try
81 * to re-enable after more investigation
84 if (__power_7_andup())
85 mono_hwcap_ppc_has_move_fpr_gpr = TRUE;