]>
Commit | Line | Data |
---|---|---|
78241744 MM |
1 | /* |
2 | * CPU features/facilities helper structs and utility functions for s390 | |
3 | * | |
4 | * Copyright 2016 IBM Corp. | |
5 | * | |
6 | * Author(s): Michael Mueller <[email protected]> | |
7 | * David Hildenbrand <[email protected]> | |
8 | * | |
9 | * This work is licensed under the terms of the GNU GPL, version 2 or (at | |
10 | * your option) any later version. See the COPYING file in the top-level | |
11 | * directory. | |
12 | */ | |
13 | ||
14 | #ifndef TARGET_S390X_CPU_FEATURES_H | |
15 | #define TARGET_S390X_CPU_FEATURES_H | |
16 | ||
17 | #include "qemu/bitmap.h" | |
18 | #include "cpu_features_def.h" | |
19 | ||
20 | /* CPU features are announced via different ways */ | |
21 | typedef enum { | |
22 | S390_FEAT_TYPE_STFL, | |
23 | S390_FEAT_TYPE_SCLP_CONF_CHAR, | |
24 | S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT, | |
25 | S390_FEAT_TYPE_SCLP_CPU, | |
26 | S390_FEAT_TYPE_MISC, | |
27 | S390_FEAT_TYPE_PLO, | |
28 | S390_FEAT_TYPE_PTFF, | |
29 | S390_FEAT_TYPE_KMAC, | |
30 | S390_FEAT_TYPE_KMC, | |
31 | S390_FEAT_TYPE_KM, | |
32 | S390_FEAT_TYPE_KIMD, | |
33 | S390_FEAT_TYPE_KLMD, | |
34 | S390_FEAT_TYPE_PCKMO, | |
35 | S390_FEAT_TYPE_KMCTR, | |
36 | S390_FEAT_TYPE_KMF, | |
37 | S390_FEAT_TYPE_KMO, | |
38 | S390_FEAT_TYPE_PCC, | |
39 | S390_FEAT_TYPE_PPNO, | |
6da5c593 | 40 | S390_FEAT_TYPE_KMA, |
78241744 MM |
41 | } S390FeatType; |
42 | ||
43 | /* Definition of a CPU feature */ | |
44 | typedef struct { | |
45 | const char *name; /* name exposed to the user */ | |
46 | const char *desc; /* description exposed to the user */ | |
47 | S390FeatType type; /* feature type (way of indication)*/ | |
48 | int bit; /* bit within the feature type area (fixed) */ | |
49 | } S390FeatDef; | |
50 | ||
51 | /* use ordinary bitmap operations to work with features */ | |
52 | typedef unsigned long S390FeatBitmap[BITS_TO_LONGS(S390_FEAT_MAX)]; | |
53 | ||
54 | /* 64bit based bitmap used to init S390FeatBitmap from generated data */ | |
55 | typedef uint64_t S390FeatInit[S390_FEAT_MAX / 64 + 1]; | |
56 | ||
57 | const S390FeatDef *s390_feat_def(S390Feat feat); | |
58 | S390Feat s390_feat_by_type_and_bit(S390FeatType type, int bit); | |
59 | void s390_init_feat_bitmap(const S390FeatInit init, S390FeatBitmap bitmap); | |
60 | void s390_fill_feat_block(const S390FeatBitmap features, S390FeatType type, | |
61 | uint8_t *data); | |
62 | void s390_add_from_feat_block(S390FeatBitmap features, S390FeatType type, | |
63 | uint8_t *data); | |
64 | void s390_feat_bitmap_to_ascii(const S390FeatBitmap features, void *opaque, | |
65 | void (*fn)(const char *name, void *opaque)); | |
66 | ||
8b3d6cb1 DH |
67 | /* static groups that will never change */ |
68 | typedef enum { | |
69 | S390_FEAT_GROUP_PLO, | |
70 | S390_FEAT_GROUP_TOD_CLOCK_STEERING, | |
71 | S390_FEAT_GROUP_GEN13_PTFF_ENH, | |
72 | S390_FEAT_GROUP_MSA, | |
73 | S390_FEAT_GROUP_MSA_EXT_1, | |
74 | S390_FEAT_GROUP_MSA_EXT_2, | |
75 | S390_FEAT_GROUP_MSA_EXT_3, | |
76 | S390_FEAT_GROUP_MSA_EXT_4, | |
77 | S390_FEAT_GROUP_MSA_EXT_5, | |
6da5c593 JH |
78 | S390_FEAT_GROUP_MSA_EXT_6, |
79 | S390_FEAT_GROUP_MSA_EXT_7, | |
80 | S390_FEAT_GROUP_MSA_EXT_8, | |
06a97eda | 81 | S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF, |
8b3d6cb1 DH |
82 | S390_FEAT_GROUP_MAX, |
83 | } S390FeatGroup; | |
84 | ||
85 | /* Definition of a CPU feature group */ | |
86 | typedef struct { | |
87 | const char *name; /* name exposed to the user */ | |
88 | const char *desc; /* description exposed to the user */ | |
89 | S390FeatBitmap feat; /* features contained in the group */ | |
90 | S390FeatInit init; /* used to init feat from generated data */ | |
91 | } S390FeatGroupDef; | |
92 | ||
93 | const S390FeatGroupDef *s390_feat_group_def(S390FeatGroup group); | |
94 | ||
78241744 | 95 | #define BE_BIT_NR(BIT) (BIT ^ (BITS_PER_LONG - 1)) |
78241744 | 96 | |
3d1cfc3c DH |
97 | static inline void set_be_bit(unsigned int bit_nr, uint8_t *array) |
98 | { | |
99 | array[bit_nr / 8] |= 0x80 >> (bit_nr % 8); | |
100 | } | |
101 | static inline bool test_be_bit(unsigned int bit_nr, const uint8_t *array) | |
102 | { | |
103 | return array[bit_nr / 8] & (0x80 >> (bit_nr % 8)); | |
104 | } | |
78241744 | 105 | #endif /* TARGET_S390X_CPU_FEATURES_H */ |