1 /* powerpc HWCAP/HWCAP2 and AT_PLATFORM data pre-processing.
2 Copyright (C) 2015-2022 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 tcbhead_t __tcb
__attribute__ ((visibility ("hidden")));
25 /* This function parses the HWCAP/HWCAP2 fields, adding the previous supported
26 ISA bits, as well as converting the AT_PLATFORM string to a number. This
27 data is stored in two global variables that can be used later by the
28 powerpc-specific code to store it into the TCB. */
30 __tcb_parse_hwcap_and_convert_at_platform (void)
35 /* Read AT_PLATFORM string from auxv and convert it to a number. */
36 __tcb
.at_platform
= _dl_string_platform (GLRO (dl_platform
));
38 /* Read HWCAP and HWCAP2 from auxv. */
40 h2
= GLRO (dl_hwcap2
);
42 /* hwcap contains only the latest supported ISA, the code checks which is
43 and fills the previous supported ones. */
45 if (h2
& PPC_FEATURE2_ARCH_2_07
)
46 h1
|= PPC_FEATURE_ARCH_2_06
47 | PPC_FEATURE_ARCH_2_05
48 | PPC_FEATURE_POWER5_PLUS
51 else if (h1
& PPC_FEATURE_ARCH_2_06
)
52 h1
|= PPC_FEATURE_ARCH_2_05
53 | PPC_FEATURE_POWER5_PLUS
56 else if (h1
& PPC_FEATURE_ARCH_2_05
)
57 h1
|= PPC_FEATURE_POWER5_PLUS
60 else if (h1
& PPC_FEATURE_POWER5_PLUS
)
61 h1
|= PPC_FEATURE_POWER5
63 else if (h1
& PPC_FEATURE_POWER5
)
64 h1
|= PPC_FEATURE_POWER4
;
66 /* Consolidate both HWCAP and HWCAP2 into a single doubleword so that
67 we can read both in a single load later. */
68 __tcb
.hwcap
= (h1
<< 32) | (h2
& 0xffffffff);
72 versioned_symbol (ld
, __tcb_parse_hwcap_and_convert_at_platform
, \
73 __parse_hwcap_and_convert_at_platform
, GLIBC_2_23
);
76 /* Export __parse_hwcap_and_convert_at_platform in libc.a. This is used by
77 GCC to make sure that the HWCAP/Platform bits are stored in the TCB when
78 using __builtin_cpu_is()/__builtin_cpu_supports() in the static case. */
80 weak_alias (__tcb_parse_hwcap_and_convert_at_platform
, \
81 __parse_hwcap_and_convert_at_platform
);