]>
Commit | Line | Data |
---|---|---|
857a1627 | 1 | /* Processor capability information handling macros. PowerPC version. |
2b778ceb | 2 | Copyright (C) 2005-2021 Free Software Foundation, Inc. |
857a1627 RM |
3 | This file is part of the GNU C Library. |
4 | ||
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. | |
9 | ||
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. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
fac0c5f2 | 16 | License along with the GNU C Library. If not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
857a1627 RM |
18 | |
19 | #ifndef _DL_PROCINFO_H | |
fac0c5f2 | 20 | #define _DL_PROCINFO_H 1 |
857a1627 RM |
21 | |
22 | #include <ldsodefs.h> | |
89cd9569 | 23 | #include <sysdep.h> /* This defines the PPC_FEATURE[2]_* macros. */ |
857a1627 | 24 | |
89cd9569 RA |
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 | |
28 | ||
29 | /* Features started at bit 31 and decremented as new features were added. */ | |
30 | #define _DL_HWCAP_LAST 31 | |
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 | |
857a1627 RM |
35 | |
36 | /* These bits influence library search. */ | |
594d423a UD |
37 | #define HWCAP_IMPORTANT (PPC_FEATURE_HAS_ALTIVEC \ |
38 | + PPC_FEATURE_HAS_DFP) | |
857a1627 | 39 | |
d2ba3677 | 40 | #define _DL_PLATFORMS_COUNT 16 |
4cd3633d | 41 | |
fac0c5f2 | 42 | #define _DL_FIRST_PLATFORM 32 |
4cd3633d | 43 | /* Mask to filter out platforms. */ |
fac0c5f2 RA |
44 | #define _DL_HWCAP_PLATFORM (((1ULL << _DL_PLATFORMS_COUNT) - 1) \ |
45 | << _DL_FIRST_PLATFORM) | |
857a1627 | 46 | |
594d423a UD |
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 | |
1642331d | 55 | #define PPC_PLATFORM_POWER7 7 |
d0b9e94f | 56 | #define PPC_PLATFORM_PPCA2 8 |
fac0c5f2 RA |
57 | #define PPC_PLATFORM_PPC405 9 |
58 | #define PPC_PLATFORM_PPC440 10 | |
59 | #define PPC_PLATFORM_PPC464 11 | |
60 | #define PPC_PLATFORM_PPC476 12 | |
2f063a6e | 61 | #define PPC_PLATFORM_POWER8 13 |
b1f19b8e | 62 | #define PPC_PLATFORM_POWER9 14 |
d2ba3677 | 63 | #define PPC_PLATFORM_POWER10 15 |
594d423a | 64 | |
857a1627 RM |
65 | static inline const char * |
66 | __attribute__ ((unused)) | |
67 | _dl_hwcap_string (int idx) | |
68 | { | |
911569d0 | 69 | return GLRO(dl_powerpc_cap_flags)[idx]; |
4cd3633d UD |
70 | } |
71 | ||
857a1627 RM |
72 | static inline int |
73 | __attribute__ ((unused)) | |
74 | _dl_string_hwcap (const char *str) | |
75 | { | |
911569d0 | 76 | for (int i = 0; i < _DL_HWCAP_COUNT; ++i) |
857a1627 RM |
77 | if (strcmp (str, _dl_hwcap_string (i)) == 0) |
78 | return i; | |
79 | return -1; | |
4cd3633d UD |
80 | } |
81 | ||
82 | static inline int | |
83 | __attribute__ ((unused, always_inline)) | |
84 | _dl_string_platform (const char *str) | |
85 | { | |
86 | if (str == NULL) | |
87 | return -1; | |
88 | ||
5f4f13b4 | 89 | if (strncmp (str, "power", 5) == 0) |
4cd3633d UD |
90 | { |
91 | int ret; | |
92 | str += 5; | |
93 | switch (*str) | |
94 | { | |
d2ba3677 TMQMF |
95 | case '1': |
96 | if (str[1] == '0') | |
97 | { | |
98 | ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER10; | |
f6add169 | 99 | str++; |
d2ba3677 TMQMF |
100 | } |
101 | else | |
102 | return -1; | |
103 | break; | |
4cd3633d | 104 | case '4': |
594d423a | 105 | ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER4; |
4cd3633d UD |
106 | break; |
107 | case '5': | |
594d423a | 108 | ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER5; |
4cd3633d | 109 | if (str[1] == '+') |
594d423a UD |
110 | { |
111 | ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER5_PLUS; | |
112 | ++str; | |
113 | } | |
4cd3633d UD |
114 | break; |
115 | case '6': | |
594d423a UD |
116 | ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER6; |
117 | if (str[1] == 'x') | |
118 | { | |
119 | ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER6X; | |
120 | ++str; | |
121 | } | |
4cd3633d | 122 | break; |
1642331d UD |
123 | case '7': |
124 | ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER7; | |
125 | break; | |
2f063a6e RA |
126 | case '8': |
127 | ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER8; | |
128 | break; | |
b1f19b8e CES |
129 | case '9': |
130 | ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER9; | |
131 | break; | |
4cd3633d UD |
132 | default: |
133 | return -1; | |
134 | } | |
135 | if (str[1] == '\0') | |
fac0c5f2 | 136 | return ret; |
4cd3633d | 137 | } |
5f4f13b4 | 138 | else if (strncmp (str, "ppc", 3) == 0) |
4cd3633d | 139 | { |
5f4f13b4 | 140 | if (strcmp (str + 3, "970") == 0) |
594d423a | 141 | return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC970; |
5f4f13b4 | 142 | else if (strcmp (str + 3, "-cell-be") == 0) |
594d423a | 143 | return _DL_FIRST_PLATFORM + PPC_PLATFORM_CELL_BE; |
5f4f13b4 | 144 | else if (strcmp (str + 3, "a2") == 0) |
d0b9e94f | 145 | return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPCA2; |
5f4f13b4 | 146 | else if (strcmp (str + 3, "405") == 0) |
fac0c5f2 | 147 | return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC405; |
5f4f13b4 | 148 | else if (strcmp (str + 3, "440") == 0) |
fac0c5f2 | 149 | return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC440; |
5f4f13b4 | 150 | else if (strcmp (str + 3, "464") == 0) |
fac0c5f2 | 151 | return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC464; |
5f4f13b4 | 152 | else if (strcmp (str + 3, "476") == 0) |
fac0c5f2 | 153 | return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC476; |
4cd3633d UD |
154 | } |
155 | ||
156 | return -1; | |
157 | } | |
857a1627 | 158 | |
a3848485 | 159 | #if IS_IN (rtld) |
1616d034 TMQMF |
160 | static inline void |
161 | cache_geometry (const char * name, unsigned long int geometry) | |
162 | { | |
163 | unsigned long int assocty, line; | |
164 | ||
165 | _dl_printf ("%s", name); | |
166 | ||
167 | line = geometry & 0xffff; | |
168 | assocty = (geometry >> 16) & 0xffff; | |
169 | ||
170 | if (line == 0) | |
171 | _dl_printf ("Unknown line size, "); | |
172 | else | |
173 | _dl_printf ("%luB line size, ", line); | |
174 | ||
175 | switch (assocty) | |
176 | { | |
177 | case 0: | |
178 | _dl_printf ("Unknown associativity"); | |
179 | break; | |
180 | case 1: | |
181 | _dl_printf ("Directly mapped"); | |
182 | break; | |
183 | case 0xffff: | |
184 | _dl_printf ("Fully associative"); | |
185 | break; | |
186 | default: | |
187 | _dl_printf ("%lu-way set associative", assocty); | |
188 | } | |
189 | } | |
190 | ||
857a1627 RM |
191 | static inline int |
192 | __attribute__ ((unused)) | |
1ae8bfe0 | 193 | _dl_procinfo (unsigned int type, unsigned long int word) |
857a1627 | 194 | { |
89cd9569 RA |
195 | switch(type) |
196 | { | |
197 | case AT_HWCAP: | |
1616d034 | 198 | _dl_printf ("AT_HWCAP: "); |
89cd9569 | 199 | |
911569d0 | 200 | for (int i = 0; i <= _DL_HWCAP_LAST; ++i) |
89cd9569 RA |
201 | if (word & (1 << i)) |
202 | _dl_printf (" %s", _dl_hwcap_string (i)); | |
203 | break; | |
204 | case AT_HWCAP2: | |
205 | { | |
206 | unsigned int offset = _DL_HWCAP_LAST + 1; | |
207 | ||
1616d034 | 208 | _dl_printf ("AT_HWCAP2: "); |
89cd9569 RA |
209 | |
210 | /* We have to go through them all because the kernel added the | |
211 | AT_HWCAP2 features starting with the high bits. */ | |
212 | for (int i = 0; i <= _DL_HWCAP2_LAST; ++i) | |
213 | if (word & (1 << i)) | |
214 | _dl_printf (" %s", _dl_hwcap_string (offset + i)); | |
215 | break; | |
216 | } | |
1616d034 TMQMF |
217 | case AT_L1I_CACHEGEOMETRY: |
218 | { | |
219 | cache_geometry ("AT_L1I_CACHEGEOMETRY: ", word); | |
220 | break; | |
221 | } | |
222 | case AT_L1D_CACHEGEOMETRY: | |
223 | { | |
224 | cache_geometry ("AT_L1D_CACHEGEOMETRY: ", word); | |
225 | break; | |
226 | } | |
227 | case AT_L2_CACHEGEOMETRY: | |
228 | { | |
229 | cache_geometry ("AT_L2_CACHEGEOMETRY: ", word); | |
230 | break; | |
231 | } | |
232 | case AT_L3_CACHEGEOMETRY: | |
233 | { | |
234 | cache_geometry ("AT_L3_CACHEGEOMETRY: ", word); | |
235 | break; | |
236 | } | |
89cd9569 | 237 | default: |
7c651308 | 238 | /* Fallback to generic output mechanism. */ |
89cd9569 RA |
239 | return -1; |
240 | } | |
241 | _dl_printf ("\n"); | |
857a1627 RM |
242 | return 0; |
243 | } | |
244 | #endif | |
245 | ||
246 | #endif /* dl-procinfo.h */ |