xref: /aosp_15_r20/external/cpu_features/include/cpuinfo_s390x.h (revision eca53ba6d2e951e174b64682eaf56a36b8204c89)
1 // Copyright 2022 IBM
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef CPU_FEATURES_INCLUDE_CPUINFO_S390X_H_
16 #define CPU_FEATURES_INCLUDE_CPUINFO_S390X_H_
17 
18 #include "cpu_features_cache_info.h"
19 #include "cpu_features_macros.h"
20 
21 CPU_FEATURES_START_CPP_NAMESPACE
22 
23 typedef struct {
24   int esan3: 1;     // instructions named N3, "backported" to esa-mode
25   int zarch: 1;     // z/Architecture mode active
26   int stfle: 1;     // store-facility-list-extended
27   int msa: 1;       // message-security assist
28   int ldisp: 1;     // long-displacement
29   int eimm: 1;      // extended-immediate
30   int dfp: 1;       // decimal floating point & perform floating point operation
31   int edat: 1;      // huge page support
32   int etf3eh: 1;    // extended-translation facility 3 enhancement
33   int highgprs: 1;  // 64-bit register support for 31-bit processes
34   int te: 1;        // transactional execution
35   int vx: 1;        // vector extension facility
36   int vxd: 1;       // vector-packed-decimal facility
37   int vxe: 1;       // vector-enhancement facility 1
38   int gs: 1;        // guarded-storage facility
39   int vxe2: 1;      // vector-enhancements facility 2
40   int vxp: 1;       // vector-packed-decimal-enhancement facility
41   int sort: 1;      // enhanced-sort facility
42   int dflt: 1;      // deflate-conversion facility
43   int vxp2: 1;      // vector-packed-decimal-enhancement facility 2
44   int nnpa: 1;      // neural network processing assist facility
45   int pcimio: 1;    // PCI mio facility
46   int sie: 1;       // virtualization support
47 
48   // Make sure to update S390XFeaturesEnum below if you add a field here.
49 } S390XFeatures;
50 
51 typedef struct {
52   S390XFeatures features;
53 } S390XInfo;
54 
55 S390XInfo GetS390XInfo(void);
56 
57 typedef struct {
58   char platform[64];       // 0 terminated string
59 } S390XPlatformTypeStrings;
60 
61 typedef struct {
62   int num_processors;      // -1 if N/A
63   S390XPlatformTypeStrings type;
64 } S390XPlatformStrings;
65 
66 S390XPlatformStrings GetS390XPlatformStrings(void);
67 
68 ////////////////////////////////////////////////////////////////////////////////
69 // Introspection functions
70 
71 typedef enum {
72   S390_ESAN3,
73   S390_ZARCH,
74   S390_STFLE,
75   S390_MSA,
76   S390_LDISP,
77   S390_EIMM,
78   S390_DFP,
79   S390_EDAT,
80   S390_ETF3EH,
81   S390_HIGHGPRS,
82   S390_TE,
83   S390_VX,
84   S390_VXD,
85   S390_VXE,
86   S390_GS,
87   S390_VXE2,
88   S390_VXP,
89   S390_SORT,
90   S390_DFLT,
91   S390_VXP2,
92   S390_NNPA,
93   S390_PCIMIO,
94   S390_SIE,
95   S390X_LAST_,
96 } S390XFeaturesEnum;
97 
98 int GetS390XFeaturesEnumValue(const S390XFeatures* features, S390XFeaturesEnum value);
99 
100 const char* GetS390XFeaturesEnumName(S390XFeaturesEnum);
101 
102 CPU_FEATURES_END_CPP_NAMESPACE
103 
104 #if !defined(CPU_FEATURES_ARCH_S390X)
105 #error "Including cpuinfo_s390x.h from a non-s390x target."
106 #endif
107 
108 #endif  // CPU_FEATURES_INCLUDE_CPUINFO_S390X_H_
109