[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 14/15] target-s390x: Introduce facility test rout
From: |
Michael Mueller |
Subject: |
[Qemu-devel] [PATCH v4 14/15] target-s390x: Introduce facility test routine |
Date: |
Mon, 30 Mar 2015 16:28:27 +0200 |
The patch introduces routine s390_facility_test() which allows to
verify a specific facility bit is set.
Signed-off-by: Michael Mueller <address@hidden>
---
target-s390x/cpu-models.c | 29 +++++++++++++++++++++++++++++
target-s390x/cpu-models.h | 1 +
2 files changed, 30 insertions(+)
diff --git a/target-s390x/cpu-models.c b/target-s390x/cpu-models.c
index aba44dd..a9f7372 100644
--- a/target-s390x/cpu-models.c
+++ b/target-s390x/cpu-models.c
@@ -736,3 +736,32 @@ bool s390_cpu_models_used(void)
{
return cpu_models_used;
}
+
+static inline int test_facility(uint64_t *fac_list, uint16_t nr)
+{
+ uint16_t word = nr / BITS_PER_LONG;
+ uint16_t be_bit = (BITS_PER_LONG - 1) - (nr % BITS_PER_LONG);
+
+ return (nr < FAC_LIST_CPU_S390_SIZE_UINT1) ?
+ (fac_list[word] >> be_bit) & __UINT64_C(1) : 0;
+}
+
+/**
+ * s390_test_facility:
+ * @nr: facility bit number to test
+ * @cc: cpu class to test
+ *
+ * The functions tests if the cpu facility identified by bit @nr is available
+ * to the cpu class @cc.
+ *
+ * Returns: a boolean value.
+ *
+ * Since: 2.4
+ */
+bool s390_test_facility(S390CPUClass *cc, uint16_t nr)
+{
+ if (!cc) {
+ return false;
+ }
+ return test_facility(cc->fac_list[ACCEL_CURRENT], nr) ? true : false;
+}
diff --git a/target-s390x/cpu-models.h b/target-s390x/cpu-models.h
index 4734c58..eb0476f 100644
--- a/target-s390x/cpu-models.h
+++ b/target-s390x/cpu-models.h
@@ -120,6 +120,7 @@ uint64_t *s390_fac_list_mask_by_machine(const char *name);
uint64_t *s390_current_fac_list_mask(void);
void s390_cpu_model_init(S390CPUClass *cc);
bool s390_cpu_models_used(void);
+bool s390_test_facility(S390CPUClass *cc, uint16_t nr);
extern uint64_t qemu_s390_fac_list_mask[];
--
1.8.3.1
- Re: [Qemu-devel] [PATCH v4 11/15] target-s390x: New QMP command query-cpu-model, (continued)
- [Qemu-devel] [PATCH v4 06/15] target-s390x: Add cpu model alias definition routines, Michael Mueller, 2015/03/30
- [Qemu-devel] [PATCH v4 09/15] target-s390x: Add cpu class initialization routines, Michael Mueller, 2015/03/30
- [Qemu-devel] [PATCH v4 03/15] target-s390x: Generate facility defines per cpu model, Michael Mueller, 2015/03/30
- [Qemu-devel] [PATCH v4 08/15] target-s390x: Add KVM VM attribute interface for cpu models, Michael Mueller, 2015/03/30
- [Qemu-devel] [PATCH v4 10/15] target-s390x: Prepare accelerator during cpu object realization, Michael Mueller, 2015/03/30
- [Qemu-devel] [PATCH v4 14/15] target-s390x: Introduce facility test routine,
Michael Mueller <=
- [Qemu-devel] [PATCH v4 15/15] target-s390x: Enable cpu model usage, Michael Mueller, 2015/03/30
- [Qemu-devel] [PATCH v4 12/15] Add optional parameters to QMP command query-cpu-definitions, Michael Mueller, 2015/03/30
- [Qemu-devel] [PATCH v4 02/15] target-s390x: Introduce cpu facilities, Michael Mueller, 2015/03/30
- [Qemu-devel] [PATCH v4 13/15] target-s390x: Extend QMP command query-cpu-definitions, Michael Mueller, 2015/03/30