]>
Commit | Line | Data |
---|---|---|
0ecb606c JJ |
1 | /* Processor capability information handling macros. PowerPC version. |
2 | Copyright (C) 2005, 2006 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 | |
16 | License along with the GNU C Library; if not, write to the Free | |
17 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
18 | 02111-1307 USA. */ | |
19 | ||
20 | #ifndef _DL_PROCINFO_H | |
21 | #define _DL_PROCINFO_H 1 | |
22 | ||
23 | #include <ldsodefs.h> | |
24 | #include <sysdep.h> /* This defines the PPC_FEATURE_* macros. */ | |
25 | ||
26 | /* There are 20 bits used, but they are bits 12..31. */ | |
27 | #define _DL_HWCAP_FIRST 9 | |
28 | #define _DL_HWCAP_COUNT 32 | |
29 | ||
30 | /* These bits influence library search. */ | |
31 | #define HWCAP_IMPORTANT (PPC_FEATURE_HAS_ALTIVEC \ | |
32 | + PPC_FEATURE_HAS_DFP) | |
33 | ||
34 | #define _DL_PLATFORMS_COUNT 7 | |
35 | ||
36 | #define _DL_FIRST_PLATFORM 32 | |
37 | /* Mask to filter out platforms. */ | |
38 | #define _DL_HWCAP_PLATFORM (((1ULL << _DL_PLATFORMS_COUNT) - 1) \ | |
39 | << _DL_FIRST_PLATFORM) | |
40 | ||
41 | /* Platform bits (relative to _DL_FIRST_PLATFORM). */ | |
42 | #define PPC_PLATFORM_POWER4 0 | |
43 | #define PPC_PLATFORM_PPC970 1 | |
44 | #define PPC_PLATFORM_POWER5 2 | |
45 | #define PPC_PLATFORM_POWER5_PLUS 3 | |
46 | #define PPC_PLATFORM_POWER6 4 | |
47 | #define PPC_PLATFORM_CELL_BE 5 | |
48 | #define PPC_PLATFORM_POWER6X 6 | |
49 | ||
50 | static inline const char * | |
51 | __attribute__ ((unused)) | |
52 | _dl_hwcap_string (int idx) | |
53 | { | |
54 | return GLRO(dl_powerpc_cap_flags)[idx - _DL_HWCAP_FIRST]; | |
55 | } | |
56 | ||
57 | static inline const char * | |
58 | __attribute__ ((unused)) | |
59 | _dl_platform_string (int idx) | |
60 | { | |
61 | return GLRO(dl_powerpc_platforms)[idx - _DL_FIRST_PLATFORM]; | |
62 | } | |
63 | ||
64 | static inline int | |
65 | __attribute__ ((unused)) | |
66 | _dl_string_hwcap (const char *str) | |
67 | { | |
68 | for (int i = _DL_HWCAP_FIRST; i < _DL_HWCAP_COUNT; ++i) | |
69 | if (strcmp (str, _dl_hwcap_string (i)) == 0) | |
70 | return i; | |
71 | return -1; | |
72 | } | |
73 | ||
74 | static inline int | |
75 | __attribute__ ((unused, always_inline)) | |
76 | _dl_string_platform (const char *str) | |
77 | { | |
78 | if (str == NULL) | |
79 | return -1; | |
80 | ||
81 | if (strncmp (str, GLRO(dl_powerpc_platforms)[PPC_PLATFORM_POWER4], 5) == 0) | |
82 | { | |
83 | int ret; | |
84 | str += 5; | |
85 | switch (*str) | |
86 | { | |
87 | case '4': | |
88 | ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER4; | |
89 | break; | |
90 | case '5': | |
91 | ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER5; | |
92 | if (str[1] == '+') | |
93 | { | |
94 | ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER5_PLUS; | |
95 | ++str; | |
96 | } | |
97 | break; | |
98 | case '6': | |
99 | ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER6; | |
100 | if (str[1] == 'x') | |
101 | { | |
102 | ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER6X; | |
103 | ++str; | |
104 | } | |
105 | break; | |
106 | default: | |
107 | return -1; | |
108 | } | |
109 | if (str[1] == '\0') | |
110 | return ret; | |
111 | } | |
112 | else if (strncmp (str, GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC970], | |
113 | 3) == 0) | |
114 | { | |
115 | if (strcmp (str + 3, GLRO(dl_powerpc_platforms)[PPC_PLATFORM_PPC970] | |
116 | + 3) == 0) | |
117 | return _DL_FIRST_PLATFORM + PPC_PLATFORM_PPC970; | |
118 | else if (strcmp (str + 3, | |
119 | GLRO(dl_powerpc_platforms)[PPC_PLATFORM_CELL_BE] + 3) | |
120 | == 0) | |
121 | return _DL_FIRST_PLATFORM + PPC_PLATFORM_CELL_BE; | |
122 | } | |
123 | ||
124 | return -1; | |
125 | } | |
126 | ||
127 | #ifdef IS_IN_rtld | |
128 | static inline int | |
129 | __attribute__ ((unused)) | |
130 | _dl_procinfo (int word) | |
131 | { | |
132 | _dl_printf ("AT_HWCAP: "); | |
133 | ||
134 | for (int i = _DL_HWCAP_FIRST; i < _DL_HWCAP_COUNT; ++i) | |
135 | if (word & (1 << i)) | |
136 | _dl_printf (" %s", _dl_hwcap_string (i)); | |
137 | ||
138 | _dl_printf ("\n"); | |
139 | ||
140 | return 0; | |
141 | } | |
142 | #endif | |
143 | ||
144 | #endif /* dl-procinfo.h */ |