1 /* s390 version of processor capability information handling macros.
2    Copyright (C) 2006-2022 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, see
17    <https://www.gnu.org/licenses/>.  */
18 
19 #ifndef _DL_PROCINFO_H
20 #define _DL_PROCINFO_H	1
21 #include <ldsodefs.h>
22 
23 #define _DL_HWCAP_COUNT 23
24 
25 #define _DL_PLATFORMS_COUNT	11
26 
27 /* The kernel provides up to 32 capability bits with elf_hwcap.  */
28 #define _DL_FIRST_PLATFORM	32
29 /* Mask to filter out platforms.  */
30 #define _DL_HWCAP_PLATFORM	(((1ULL << _DL_PLATFORMS_COUNT) - 1) \
31 				 << _DL_FIRST_PLATFORM)
32 
33 /* Hardware capability bit numbers are derived directly from the
34    facility indications as stored by the "store facility list" (STFL)
35    instruction.
36    highgprs is an alien in that list.  It describes a *kernel*
37    capability.  */
38 
39 enum
40 {
41   HWCAP_S390_ESAN3 = 1 << 0,
42   HWCAP_S390_ZARCH = 1 << 1,
43   HWCAP_S390_STFLE = 1 << 2,
44   HWCAP_S390_MSA = 1 << 3,
45   HWCAP_S390_LDISP = 1 << 4,
46   HWCAP_S390_EIMM = 1 << 5,
47   HWCAP_S390_DFP = 1 << 6,
48   HWCAP_S390_HPAGE = 1 << 7,
49   HWCAP_S390_ETF3EH = 1 << 8,
50   HWCAP_S390_HIGH_GPRS = 1 << 9,
51   HWCAP_S390_TE = 1 << 10,
52   HWCAP_S390_VX = 1 << 11,
53   HWCAP_S390_VXRS = HWCAP_S390_VX,
54   HWCAP_S390_VXD = 1 << 12,
55   HWCAP_S390_VXRS_BCD = HWCAP_S390_VXD,
56   HWCAP_S390_VXE = 1 << 13,
57   HWCAP_S390_VXRS_EXT = HWCAP_S390_VXE,
58   HWCAP_S390_GS = 1 << 14,
59   HWCAP_S390_VXRS_EXT2 = 1 << 15,
60   HWCAP_S390_VXRS_PDE = 1 << 16,
61   HWCAP_S390_SORT = 1 << 17,
62   HWCAP_S390_DFLT = 1 << 18,
63   HWCAP_S390_VXRS_PDE2 = 1 << 19,
64   HWCAP_S390_NNPA = 1 << 20,
65   HWCAP_S390_PCI_MIO = 1 << 21,
66   HWCAP_S390_SIE = 1 << 22,
67 };
68 
69 #define HWCAP_IMPORTANT (HWCAP_S390_ZARCH | HWCAP_S390_LDISP \
70 			 | HWCAP_S390_EIMM | HWCAP_S390_DFP  \
71 			 | HWCAP_S390_VX | HWCAP_S390_VXE    \
72 			 | HWCAP_S390_VXRS_EXT2)
73 
74 /* We cannot provide a general printing function.  */
75 #define _dl_procinfo(type, word) -1
76 
77 static inline const char *
78 __attribute__ ((unused))
_dl_hwcap_string(int idx)79 _dl_hwcap_string (int idx)
80 {
81   return GLRO(dl_s390_cap_flags)[idx];
82 };
83 
84 static inline int
85 __attribute__ ((unused, always_inline))
_dl_string_hwcap(const char * str)86 _dl_string_hwcap (const char *str)
87 {
88   int i;
89 
90   for (i = 0; i < _DL_HWCAP_COUNT; i++)
91     {
92       if (strcmp (str, GLRO(dl_s390_cap_flags)[i]) == 0)
93 	return i;
94     }
95   return -1;
96 };
97 
98 static inline int
99 __attribute__ ((unused, always_inline))
_dl_string_platform(const char * str)100 _dl_string_platform (const char *str)
101 {
102   int i;
103 
104   if (str != NULL)
105     for (i = 0; i < _DL_PLATFORMS_COUNT; ++i)
106       {
107 	if (strcmp (str, GLRO(dl_s390_platforms)[i]) == 0)
108 	  return _DL_FIRST_PLATFORM + i;
109       }
110   return -1;
111 };
112 
113 #endif /* dl-procinfo.h */
114