1 /* powerpc HWCAP/HWCAP2 and AT_PLATFORM data pre-processing.
2 Copyright (C) 2015-2021 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
20 #include <shlib-compat.h>
21 #include <dl-procinfo.h>
23 uint64_t __tcb_hwcap
__attribute__ ((visibility ("hidden")));
24 uint32_t __tcb_platform
__attribute__ ((visibility ("hidden")));
26 /* This function parses the HWCAP/HWCAP2 fields, adding the previous supported
27 ISA bits, as well as converting the AT_PLATFORM string to a number. This
28 data is stored in two global variables that can be used later by the
29 powerpc-specific code to store it into the TCB. */
31 __tcb_parse_hwcap_and_convert_at_platform (void)
36 /* Read AT_PLATFORM string from auxv and convert it to a number. */
37 __tcb_platform
= _dl_string_platform (GLRO (dl_platform
));
39 /* Read HWCAP and HWCAP2 from auxv. */
41 h2
= GLRO (dl_hwcap2
);
43 /* hwcap contains only the latest supported ISA, the code checks which is
44 and fills the previous supported ones. */
46 if (h2
& PPC_FEATURE2_ARCH_2_07
)
47 h1
|= PPC_FEATURE_ARCH_2_06
48 | PPC_FEATURE_ARCH_2_05
49 | PPC_FEATURE_POWER5_PLUS
52 else if (h1
& PPC_FEATURE_ARCH_2_06
)
53 h1
|= PPC_FEATURE_ARCH_2_05
54 | PPC_FEATURE_POWER5_PLUS
57 else if (h1
& PPC_FEATURE_ARCH_2_05
)
58 h1
|= PPC_FEATURE_POWER5_PLUS
61 else if (h1
& PPC_FEATURE_POWER5_PLUS
)
62 h1
|= PPC_FEATURE_POWER5
64 else if (h1
& PPC_FEATURE_POWER5
)
65 h1
|= PPC_FEATURE_POWER4
;
67 /* Consolidate both HWCAP and HWCAP2 into a single doubleword so that
68 we can read both in a single load later. */
70 __tcb_hwcap
= (h1
<< 32) | __tcb_hwcap
;
74 versioned_symbol (ld
, __tcb_parse_hwcap_and_convert_at_platform
, \
75 __parse_hwcap_and_convert_at_platform
, GLIBC_2_23
);
78 /* Export __parse_hwcap_and_convert_at_platform in libc.a. This is used by
79 GCC to make sure that the HWCAP/Platform bits are stored in the TCB when
80 using __builtin_cpu_is()/__builtin_cpu_supports() in the static case. */
82 weak_alias (__tcb_parse_hwcap_and_convert_at_platform
, \
83 __parse_hwcap_and_convert_at_platform
);