]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/powerpc/dl-procinfo.h
Replace FSF snail mail address by URL.
[thirdparty/glibc.git] / sysdeps / powerpc / dl-procinfo.h
CommitLineData
a72cc2b2
LM
1/* Processor capability information handling macros. PowerPC version.
2 Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc.
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
ab84e3ff
PE
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
a72cc2b2
LM
18
19#ifndef _DL_PROCINFO_H
20#define _DL_PROCINFO_H 1
21
22#include <ldsodefs.h>
23#include <sysdep.h> /* This defines the PPC_FEATURE_* macros. */
24
25/* There are 25 bits used, but they are bits 7..31. */
26#define _DL_HWCAP_FIRST 7
27#define _DL_HWCAP_COUNT 32
28
29/* These bits influence library search. */
30#define HWCAP_IMPORTANT (PPC_FEATURE_HAS_ALTIVEC \
31 + PPC_FEATURE_HAS_DFP)
32
33#define _DL_PLATFORMS_COUNT 12
34
35#define _DL_FIRST_PLATFORM 32
36/* Mask to filter out platforms. */
37#define _DL_HWCAP_PLATFORM (((1ULL << _DL_PLATFORMS_COUNT) - 1) \
38 << _DL_FIRST_PLATFORM)
39
40/* Platform bits (relative to _DL_FIRST_PLATFORM). */
41#define PPC_PLATFORM_POWER4 0
42#define PPC_PLATFORM_PPC970 1
43#define PPC_PLATFORM_POWER5 2
44#define PPC_PLATFORM_POWER5_PLUS 3
45#define PPC_PLATFORM_POWER6 4
46#define PPC_PLATFORM_CELL_BE 5
47#define PPC_PLATFORM_POWER6X 6
48#define PPC_PLATFORM_POWER7 7
49#define PPC_PLATFORM_PPC405 8
50#define PPC_PLATFORM_PPC440 9
51#define PPC_PLATFORM_PPC464 10
52#define PPC_PLATFORM_PPC476 11
53
54static inline const char *
55__attribute__ ((unused))
56_dl_hwcap_string (int idx)
57{
58 return GLRO(dl_powerpc_cap_flags)[idx - _DL_HWCAP_FIRST];
59}
60
61static inline const char *
62__attribute__ ((unused))
63_dl_platform_string (int idx)
64{
65 return GLRO(dl_powerpc_platforms)[idx - _DL_FIRST_PLATFORM];
66}
67
68static inline int
69__attribute__ ((unused))
70_dl_string_hwcap (const char *str)
71{
72 for (int i = _DL_HWCAP_FIRST; i < _DL_HWCAP_COUNT; ++i)
73 if (strcmp (str, _dl_hwcap_string (i)) == 0)
74 return i;
75 return -1;
76}
77
78static inline int
79__attribute__ ((unused, always_inline))
80_dl_string_platform (const char *str)
81{
82 if (str == NULL)
83 return -1;
84
85 if (strncmp (str, GLRO(dl_powerpc_platforms)[PPC_PLATFORM_POWER4], 5) == 0)
86 {
87 int ret;
88 str += 5;
89 switch (*str)
90 {
91 case '4':
92 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER4;
93 break;
94 case '5':
95 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER5;
96 if (str[1] == '+')
97 {
98 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER5_PLUS;
99 ++str;
100 }
101 break;
102 case '6':
103 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER6;
104 if (str[1] == 'x')
105 {
106 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER6X;
107 ++str;
108 }
109 break;
110 case '7':
111 ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER7;
112 break;
113 default:
114 return -1;
115 }
116 if (str[1] == '\0')
117 return ret;
118 }
119 else if (strncmp (str, GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC970],
120 3) == 0)
121 {
122 if (strcmp (str + 3, GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC970]
123 + 3) == 0)
124 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC970;
125 else if (strcmp (str + 3,
126 GLRO(dl_powerpc_platforms)[PPC_PLATFORM_CELL_BE] + 3)
127 == 0)
128 return _DL_FIRST_PLATFORM + PPC_PLATFORM_CELL_BE;
129 else if (strcmp (str + 3,
130 GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC405] + 3)
131 == 0)
132 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC405;
133 else if (strcmp (str + 3,
134 GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC440] + 3)
135 == 0)
136 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC440;
137 else if (strcmp (str + 3,
138 GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC464] + 3)
139 == 0)
140 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC464;
141 else if (strcmp (str + 3,
142 GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC476] + 3)
143 == 0)
144 return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC476;
145 }
146
147 return -1;
148}
149
150#ifdef IS_IN_rtld
151static inline int
152__attribute__ ((unused))
153_dl_procinfo (int word)
154{
155 _dl_printf ("AT_HWCAP: ");
156
157 for (int i = _DL_HWCAP_FIRST; i < _DL_HWCAP_COUNT; ++i)
158 if (word & (1 << i))
159 _dl_printf (" %s", _dl_hwcap_string (i));
160
161 _dl_printf ("\n");
162
163 return 0;
164}
165#endif
166
167#endif /* dl-procinfo.h */