xref: /qemu/target/s390x/cpu_features.h (revision 782417446279717aa85320191a519b51f6d5dd31)
178241744SMichael Mueller /*
278241744SMichael Mueller  * CPU features/facilities helper structs and utility functions for s390
378241744SMichael Mueller  *
478241744SMichael Mueller  * Copyright 2016 IBM Corp.
578241744SMichael Mueller  *
678241744SMichael Mueller  * Author(s): Michael Mueller <mimu@linux.vnet.ibm.com>
778241744SMichael Mueller  *            David Hildenbrand <dahi@linux.vnet.ibm.com>
878241744SMichael Mueller  *
978241744SMichael Mueller  * This work is licensed under the terms of the GNU GPL, version 2 or (at
1078241744SMichael Mueller  * your option) any later version. See the COPYING file in the top-level
1178241744SMichael Mueller  * directory.
1278241744SMichael Mueller  */
1378241744SMichael Mueller 
1478241744SMichael Mueller #ifndef TARGET_S390X_CPU_FEATURES_H
1578241744SMichael Mueller #define TARGET_S390X_CPU_FEATURES_H
1678241744SMichael Mueller 
1778241744SMichael Mueller #include "qemu/bitmap.h"
1878241744SMichael Mueller #include "cpu_features_def.h"
1978241744SMichael Mueller 
2078241744SMichael Mueller /* CPU features are announced via different ways */
2178241744SMichael Mueller typedef enum {
2278241744SMichael Mueller     S390_FEAT_TYPE_STFL,
2378241744SMichael Mueller     S390_FEAT_TYPE_SCLP_CONF_CHAR,
2478241744SMichael Mueller     S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT,
2578241744SMichael Mueller     S390_FEAT_TYPE_SCLP_CPU,
2678241744SMichael Mueller     S390_FEAT_TYPE_MISC,
2778241744SMichael Mueller     S390_FEAT_TYPE_PLO,
2878241744SMichael Mueller     S390_FEAT_TYPE_PTFF,
2978241744SMichael Mueller     S390_FEAT_TYPE_KMAC,
3078241744SMichael Mueller     S390_FEAT_TYPE_KMC,
3178241744SMichael Mueller     S390_FEAT_TYPE_KM,
3278241744SMichael Mueller     S390_FEAT_TYPE_KIMD,
3378241744SMichael Mueller     S390_FEAT_TYPE_KLMD,
3478241744SMichael Mueller     S390_FEAT_TYPE_PCKMO,
3578241744SMichael Mueller     S390_FEAT_TYPE_KMCTR,
3678241744SMichael Mueller     S390_FEAT_TYPE_KMF,
3778241744SMichael Mueller     S390_FEAT_TYPE_KMO,
3878241744SMichael Mueller     S390_FEAT_TYPE_PCC,
3978241744SMichael Mueller     S390_FEAT_TYPE_PPNO,
4078241744SMichael Mueller } S390FeatType;
4178241744SMichael Mueller 
4278241744SMichael Mueller /* Definition of a CPU feature */
4378241744SMichael Mueller typedef struct {
4478241744SMichael Mueller     const char *name;       /* name exposed to the user */
4578241744SMichael Mueller     const char *desc;       /* description exposed to the user */
4678241744SMichael Mueller     S390FeatType type;      /* feature type (way of indication)*/
4778241744SMichael Mueller     int bit;                /* bit within the feature type area (fixed) */
4878241744SMichael Mueller } S390FeatDef;
4978241744SMichael Mueller 
5078241744SMichael Mueller /* use ordinary bitmap operations to work with features */
5178241744SMichael Mueller typedef unsigned long S390FeatBitmap[BITS_TO_LONGS(S390_FEAT_MAX)];
5278241744SMichael Mueller 
5378241744SMichael Mueller /* 64bit based bitmap used to init S390FeatBitmap from generated data */
5478241744SMichael Mueller typedef uint64_t S390FeatInit[S390_FEAT_MAX / 64 + 1];
5578241744SMichael Mueller 
5678241744SMichael Mueller const S390FeatDef *s390_feat_def(S390Feat feat);
5778241744SMichael Mueller S390Feat s390_feat_by_type_and_bit(S390FeatType type, int bit);
5878241744SMichael Mueller void s390_init_feat_bitmap(const S390FeatInit init, S390FeatBitmap bitmap);
5978241744SMichael Mueller void s390_fill_feat_block(const S390FeatBitmap features, S390FeatType type,
6078241744SMichael Mueller                           uint8_t *data);
6178241744SMichael Mueller void s390_add_from_feat_block(S390FeatBitmap features, S390FeatType type,
6278241744SMichael Mueller                           uint8_t *data);
6378241744SMichael Mueller void s390_feat_bitmap_to_ascii(const S390FeatBitmap features, void *opaque,
6478241744SMichael Mueller                                void (*fn)(const char *name, void *opaque));
6578241744SMichael Mueller 
6678241744SMichael Mueller #define BE_BIT_NR(BIT) (BIT ^ (BITS_PER_LONG - 1))
6778241744SMichael Mueller #define BE_BIT(BIT) (1ULL < BE_BIT_NR(BIT))
6878241744SMichael Mueller 
6978241744SMichael Mueller #endif /* TARGET_S390X_CPU_FEATURES_H */
70