1 /* Processor capability information handling macros. PowerPC version.
2 Copyright (C) 2005-2016 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 /* There are 28 bits used, but they are bits 4..31. */
26 #define _DL_HWCAP_FIRST 4
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
32 /* Features started at bit 31 and decremented as new features were added. */
33 #define _DL_HWCAP_LAST 31
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
39 /* These bits influence library search. */
40 #define HWCAP_IMPORTANT (PPC_FEATURE_HAS_ALTIVEC \
41 + PPC_FEATURE_HAS_DFP)
43 #define _DL_PLATFORMS_COUNT 15
45 #define _DL_FIRST_PLATFORM 32
46 /* Mask to filter out platforms. */
47 #define _DL_HWCAP_PLATFORM (((1ULL << _DL_PLATFORMS_COUNT) - 1) \
48 << _DL_FIRST_PLATFORM)
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
58 #define PPC_PLATFORM_POWER7 7
59 #define PPC_PLATFORM_PPCA2 8
60 #define PPC_PLATFORM_PPC405 9
61 #define PPC_PLATFORM_PPC440 10
62 #define PPC_PLATFORM_PPC464 11
63 #define PPC_PLATFORM_PPC476 12
64 #define PPC_PLATFORM_POWER8 13
65 #define PPC_PLATFORM_POWER9 14
67 static inline const char *
68 __attribute__ ((unused
))
69 _dl_hwcap_string (int idx
)
71 return GLRO(dl_powerpc_cap_flags
)[idx
- _DL_HWCAP_FIRST
];
74 static inline const char *
75 __attribute__ ((unused
))
76 _dl_platform_string (int idx
)
78 return GLRO(dl_powerpc_platforms
)[idx
- _DL_FIRST_PLATFORM
];
82 __attribute__ ((unused
))
83 _dl_string_hwcap (const char *str
)
85 for (int i
= _DL_HWCAP_FIRST
; i
< _DL_HWCAP_COUNT
; ++i
)
86 if (strcmp (str
, _dl_hwcap_string (i
)) == 0)
92 __attribute__ ((unused
, always_inline
))
93 _dl_string_platform (const char *str
)
98 if (strncmp (str
, GLRO(dl_powerpc_platforms
)[PPC_PLATFORM_POWER4
], 5) == 0)
105 ret
= _DL_FIRST_PLATFORM
+ PPC_PLATFORM_POWER4
;
108 ret
= _DL_FIRST_PLATFORM
+ PPC_PLATFORM_POWER5
;
111 ret
= _DL_FIRST_PLATFORM
+ PPC_PLATFORM_POWER5_PLUS
;
116 ret
= _DL_FIRST_PLATFORM
+ PPC_PLATFORM_POWER6
;
119 ret
= _DL_FIRST_PLATFORM
+ PPC_PLATFORM_POWER6X
;
124 ret
= _DL_FIRST_PLATFORM
+ PPC_PLATFORM_POWER7
;
127 ret
= _DL_FIRST_PLATFORM
+ PPC_PLATFORM_POWER8
;
130 ret
= _DL_FIRST_PLATFORM
+ PPC_PLATFORM_POWER9
;
138 else if (strncmp (str
, GLRO(dl_powerpc_platforms
)[PPC_PLATFORM_PPC970
],
141 if (strcmp (str
+ 3, GLRO(dl_powerpc_platforms
)[PPC_PLATFORM_PPC970
]
143 return _DL_FIRST_PLATFORM
+ PPC_PLATFORM_PPC970
;
144 else if (strcmp (str
+ 3,
145 GLRO(dl_powerpc_platforms
)[PPC_PLATFORM_CELL_BE
] + 3)
147 return _DL_FIRST_PLATFORM
+ PPC_PLATFORM_CELL_BE
;
148 else if (strcmp (str
+ 3,
149 GLRO(dl_powerpc_platforms
)[PPC_PLATFORM_PPCA2
] + 3)
151 return _DL_FIRST_PLATFORM
+ PPC_PLATFORM_PPCA2
;
152 else if (strcmp (str
+ 3,
153 GLRO(dl_powerpc_platforms
)[PPC_PLATFORM_PPC405
] + 3)
155 return _DL_FIRST_PLATFORM
+ PPC_PLATFORM_PPC405
;
156 else if (strcmp (str
+ 3,
157 GLRO(dl_powerpc_platforms
)[PPC_PLATFORM_PPC440
] + 3)
159 return _DL_FIRST_PLATFORM
+ PPC_PLATFORM_PPC440
;
160 else if (strcmp (str
+ 3,
161 GLRO(dl_powerpc_platforms
)[PPC_PLATFORM_PPC464
] + 3)
163 return _DL_FIRST_PLATFORM
+ PPC_PLATFORM_PPC464
;
164 else if (strcmp (str
+ 3,
165 GLRO(dl_powerpc_platforms
)[PPC_PLATFORM_PPC476
] + 3)
167 return _DL_FIRST_PLATFORM
+ PPC_PLATFORM_PPC476
;
175 __attribute__ ((unused
))
176 _dl_procinfo (unsigned int type
, unsigned long int word
)
181 _dl_printf ("AT_HWCAP: ");
183 for (int i
= _DL_HWCAP_FIRST
; i
<= _DL_HWCAP_LAST
; ++i
)
185 _dl_printf (" %s", _dl_hwcap_string (i
));
189 unsigned int offset
= _DL_HWCAP_LAST
+ 1;
191 _dl_printf ("AT_HWCAP2: ");
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
)
197 _dl_printf (" %s", _dl_hwcap_string (offset
+ i
));
201 /* This should not happen. */
209 #endif /* dl-procinfo.h */