]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/powerpc/dl-procinfo.h
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / sysdeps / powerpc / dl-procinfo.h
CommitLineData
857a1627 1/* Processor capability information handling macros. PowerPC version.
f7a9f785 2 Copyright (C) 2005-2016 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
59ba27a6 17 <http://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
94ec7e00
CES
25/* There are 28 bits used, but they are bits 4..31. */
26#define _DL_HWCAP_FIRST 4
89cd9569
RA
27
28/* The total number of available bits (including those prior to
29 _DL_HWCAP_FIRST). Some of these bits might not be used. */
30#define _DL_HWCAP_COUNT 64
31
32/* Features started at bit 31 and decremented as new features were added. */
33#define _DL_HWCAP_LAST 31
34
35/* AT_HWCAP2 features started at bit 31 and decremented as new features were
36 added. HWCAP2 feature bits start at bit 0. */
37#define _DL_HWCAP2_LAST 31
857a1627
RM
38
39/* These bits influence library search. */
594d423a
UD
40#define HWCAP_IMPORTANT (PPC_FEATURE_HAS_ALTIVEC \
41 + PPC_FEATURE_HAS_DFP)
857a1627 42
b1f19b8e 43#define _DL_PLATFORMS_COUNT 15
4cd3633d 44
fac0c5f2 45#define _DL_FIRST_PLATFORM 32
4cd3633d 46/* Mask to filter out platforms. */
fac0c5f2
RA
47#define _DL_HWCAP_PLATFORM (((1ULL << _DL_PLATFORMS_COUNT) - 1) \
48 << _DL_FIRST_PLATFORM)
857a1627 49
594d423a
UD
50/* Platform bits (relative to _DL_FIRST_PLATFORM). */
51#define PPC_PLATFORM_POWER4 0
52#define PPC_PLATFORM_PPC970 1
53#define PPC_PLATFORM_POWER5 2
54#define PPC_PLATFORM_POWER5_PLUS 3
55#define PPC_PLATFORM_POWER6 4
56#define PPC_PLATFORM_CELL_BE 5
57#define PPC_PLATFORM_POWER6X 6
1642331d 58#define PPC_PLATFORM_POWER7 7
d0b9e94f 59#define PPC_PLATFORM_PPCA2 8
fac0c5f2
RA
60#define PPC_PLATFORM_PPC405 9
61#define PPC_PLATFORM_PPC440 10
62#define PPC_PLATFORM_PPC464 11
63#define PPC_PLATFORM_PPC476 12
2f063a6e 64#define PPC_PLATFORM_POWER8 13
b1f19b8e 65#define PPC_PLATFORM_POWER9 14
594d423a 66
857a1627
RM
67static inline const char *
68__attribute__ ((unused))
69_dl_hwcap_string (int idx)
70{
71 return GLRO(dl_powerpc_cap_flags)[idx - _DL_HWCAP_FIRST];
4cd3633d
UD
72}
73
74static inline const char *
75__attribute__ ((unused))
76_dl_platform_string (int idx)
77{
78 return GLRO(dl_powerpc_platforms)[idx - _DL_FIRST_PLATFORM];
79}
857a1627
RM
80
81static inline int
82__attribute__ ((unused))
83_dl_string_hwcap (const char *str)
84{
85 for (int i = _DL_HWCAP_FIRST; i < _DL_HWCAP_COUNT; ++i)
86 if (strcmp (str, _dl_hwcap_string (i)) == 0)
87 return i;
88 return -1;
4cd3633d
UD
89}
90
91static inline int
92__attribute__ ((unused, always_inline))
93_dl_string_platform (const char *str)
94{
95 if (str == NULL)
96 return -1;
97
594d423a 98 if (strncmp (str, GLRO(dl_powerpc_platforms)[PPC_PLATFORM_POWER4], 5) == 0)
4cd3633d
UD
99 {
100 int ret;
101 str += 5;
102 switch (*str)
103 {
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 }
594d423a
UD
138 else if (strncmp (str, GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC970],
139 3) == 0)
4cd3633d 140 {
594d423a
UD
141 if (strcmp (str + 3, GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC970]
142 + 3) == 0)
143 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC970;
144 else if (strcmp (str + 3,
145 GLRO(dl_powerpc_platforms)[PPC_PLATFORM_CELL_BE] + 3)
146 == 0)
147 return _DL_FIRST_PLATFORM + PPC_PLATFORM_CELL_BE;
d0b9e94f
MB
148 else if (strcmp (str + 3,
149 GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPCA2] + 3)
150 == 0)
151 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPCA2;
fac0c5f2
RA
152 else if (strcmp (str + 3,
153 GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC405] + 3)
154 == 0)
155 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC405;
156 else if (strcmp (str + 3,
157 GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC440] + 3)
158 == 0)
159 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC440;
160 else if (strcmp (str + 3,
161 GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC464] + 3)
162 == 0)
163 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC464;
164 else if (strcmp (str + 3,
165 GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC476] + 3)
166 == 0)
167 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC476;
4cd3633d
UD
168 }
169
170 return -1;
171}
857a1627 172
a3848485 173#if IS_IN (rtld)
857a1627
RM
174static inline int
175__attribute__ ((unused))
1ae8bfe0 176_dl_procinfo (unsigned int type, unsigned long int word)
857a1627 177{
89cd9569
RA
178 switch(type)
179 {
180 case AT_HWCAP:
181 _dl_printf ("AT_HWCAP: ");
182
183 for (int i = _DL_HWCAP_FIRST; i <= _DL_HWCAP_LAST; ++i)
184 if (word & (1 << i))
185 _dl_printf (" %s", _dl_hwcap_string (i));
186 break;
187 case AT_HWCAP2:
188 {
189 unsigned int offset = _DL_HWCAP_LAST + 1;
190
191 _dl_printf ("AT_HWCAP2: ");
192
193 /* We have to go through them all because the kernel added the
194 AT_HWCAP2 features starting with the high bits. */
195 for (int i = 0; i <= _DL_HWCAP2_LAST; ++i)
196 if (word & (1 << i))
197 _dl_printf (" %s", _dl_hwcap_string (offset + i));
198 break;
199 }
200 default:
201 /* This should not happen. */
202 return -1;
203 }
204 _dl_printf ("\n");
857a1627
RM
205 return 0;
206}
207#endif
208
209#endif /* dl-procinfo.h */