1 /* Processor capability information handling macros. PowerPC version.
2 Copyright (C) 2005-2018 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 <http://www.gnu.org/licenses/>. */
19 #ifndef _DL_PROCINFO_H
20 #define _DL_PROCINFO_H 1
23 #include <sysdep.h> /* This defines the PPC_FEATURE[2]_* macros. */
25 /* The total number of available bits (including those prior to
26 _DL_HWCAP_FIRST). Some of these bits might not be used. */
27 #define _DL_HWCAP_COUNT 64
29 /* Features started at bit 31 and decremented as new features were added. */
30 #define _DL_HWCAP_LAST 31
32 /* AT_HWCAP2 features started at bit 31 and decremented as new features were
33 added. HWCAP2 feature bits start at bit 0. */
34 #define _DL_HWCAP2_LAST 31
36 /* These bits influence library search. */
37 #define HWCAP_IMPORTANT (PPC_FEATURE_HAS_ALTIVEC \
38 + PPC_FEATURE_HAS_DFP)
40 #define _DL_PLATFORMS_COUNT 15
42 #define _DL_FIRST_PLATFORM 32
43 /* Mask to filter out platforms. */
44 #define _DL_HWCAP_PLATFORM (((1ULL << _DL_PLATFORMS_COUNT) - 1) \
45 << _DL_FIRST_PLATFORM)
47 /* Platform bits (relative to _DL_FIRST_PLATFORM). */
48 #define PPC_PLATFORM_POWER4 0
49 #define PPC_PLATFORM_PPC970 1
50 #define PPC_PLATFORM_POWER5 2
51 #define PPC_PLATFORM_POWER5_PLUS 3
52 #define PPC_PLATFORM_POWER6 4
53 #define PPC_PLATFORM_CELL_BE 5
54 #define PPC_PLATFORM_POWER6X 6
55 #define PPC_PLATFORM_POWER7 7
56 #define PPC_PLATFORM_PPCA2 8
57 #define PPC_PLATFORM_PPC405 9
58 #define PPC_PLATFORM_PPC440 10
59 #define PPC_PLATFORM_PPC464 11
60 #define PPC_PLATFORM_PPC476 12
61 #define PPC_PLATFORM_POWER8 13
62 #define PPC_PLATFORM_POWER9 14
64 static inline const char *
65 __attribute__ ((unused
))
66 _dl_hwcap_string (int idx
)
68 return GLRO(dl_powerpc_cap_flags
)[idx
];
72 __attribute__ ((unused
))
73 _dl_string_hwcap (const char *str
)
75 for (int i
= 0; i
< _DL_HWCAP_COUNT
; ++i
)
76 if (strcmp (str
, _dl_hwcap_string (i
)) == 0)
82 __attribute__ ((unused
, always_inline
))
83 _dl_string_platform (const char *str
)
88 if (strncmp (str
, "power", 5) == 0)
95 ret
= _DL_FIRST_PLATFORM
+ PPC_PLATFORM_POWER4
;
98 ret
= _DL_FIRST_PLATFORM
+ PPC_PLATFORM_POWER5
;
101 ret
= _DL_FIRST_PLATFORM
+ PPC_PLATFORM_POWER5_PLUS
;
106 ret
= _DL_FIRST_PLATFORM
+ PPC_PLATFORM_POWER6
;
109 ret
= _DL_FIRST_PLATFORM
+ PPC_PLATFORM_POWER6X
;
114 ret
= _DL_FIRST_PLATFORM
+ PPC_PLATFORM_POWER7
;
117 ret
= _DL_FIRST_PLATFORM
+ PPC_PLATFORM_POWER8
;
120 ret
= _DL_FIRST_PLATFORM
+ PPC_PLATFORM_POWER9
;
128 else if (strncmp (str
, "ppc", 3) == 0)
130 if (strcmp (str
+ 3, "970") == 0)
131 return _DL_FIRST_PLATFORM
+ PPC_PLATFORM_PPC970
;
132 else if (strcmp (str
+ 3, "-cell-be") == 0)
133 return _DL_FIRST_PLATFORM
+ PPC_PLATFORM_CELL_BE
;
134 else if (strcmp (str
+ 3, "a2") == 0)
135 return _DL_FIRST_PLATFORM
+ PPC_PLATFORM_PPCA2
;
136 else if (strcmp (str
+ 3, "405") == 0)
137 return _DL_FIRST_PLATFORM
+ PPC_PLATFORM_PPC405
;
138 else if (strcmp (str
+ 3, "440") == 0)
139 return _DL_FIRST_PLATFORM
+ PPC_PLATFORM_PPC440
;
140 else if (strcmp (str
+ 3, "464") == 0)
141 return _DL_FIRST_PLATFORM
+ PPC_PLATFORM_PPC464
;
142 else if (strcmp (str
+ 3, "476") == 0)
143 return _DL_FIRST_PLATFORM
+ PPC_PLATFORM_PPC476
;
151 __attribute__ ((unused
))
152 _dl_procinfo (unsigned int type
, unsigned long int word
)
157 _dl_printf ("AT_HWCAP: ");
159 for (int i
= 0; i
<= _DL_HWCAP_LAST
; ++i
)
161 _dl_printf (" %s", _dl_hwcap_string (i
));
165 unsigned int offset
= _DL_HWCAP_LAST
+ 1;
167 _dl_printf ("AT_HWCAP2: ");
169 /* We have to go through them all because the kernel added the
170 AT_HWCAP2 features starting with the high bits. */
171 for (int i
= 0; i
<= _DL_HWCAP2_LAST
; ++i
)
173 _dl_printf (" %s", _dl_hwcap_string (offset
+ i
));
177 /* This should not happen. */
185 #endif /* dl-procinfo.h */