From: Joerg Roedel <[email protected]>

Add a new accelerator operation to request the highest supported plane
number of a given machine instance.

Signed-off-by: Joerg Roedel <[email protected]>
---
 accel/accel-system.c      | 13 +++++++++++++
 include/accel/accel-ops.h |  3 +++
 include/qemu/accel.h      |  7 +++++++
 3 files changed, 23 insertions(+)

diff --git a/accel/accel-system.c b/accel/accel-system.c
index 150af05bf5bf..968473b8692a 100644
--- a/accel/accel-system.c
+++ b/accel/accel-system.c
@@ -75,6 +75,19 @@ void accel_pre_resume(MachineState *ms, bool step_pending)
     }
 }
 
+uint8_t accel_nr_planes(MachineState *ms)
+{
+    AccelState *accel = ms->accelerator;
+    AccelClass *acc = ACCEL_GET_CLASS(accel);
+    uint8_t nr_planes = 1;
+
+    if (acc->nr_planes != NULL) {
+        nr_planes = acc->nr_planes(accel, ms);
+    }
+
+    return nr_planes;
+}
+
 /* initialize the arch-independent accel operation interfaces */
 void accel_init_ops_interfaces(AccelClass *ac)
 {
diff --git a/include/accel/accel-ops.h b/include/accel/accel-ops.h
index f46492e3fe15..1d5decb9359b 100644
--- a/include/accel/accel-ops.h
+++ b/include/accel/accel-ops.h
@@ -36,6 +36,9 @@ struct AccelClass {
     bool (*has_memory)(AccelState *accel, AddressSpace *as,
                        hwaddr start_addr, hwaddr size);
 
+    /* planes related hooks */
+    uint8_t (*nr_planes)(AccelState *as, MachineState *ms);
+
     /* gdbstub related hooks */
     int (*gdbstub_supported_sstep_flags)(AccelState *as);
 
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index d3638c7bfda7..2ecf33e1fa21 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -81,4 +81,11 @@ void accel_cpu_common_unrealize(CPUState *cpu);
  */
 int accel_supported_gdbstub_sstep_flags(void);
 
+/**
+ * accel_nr_planes:
+ *
+ * Returns the number of the highest support plane of a given MachineState.
+ */
+uint8_t accel_nr_planes(MachineState *ms);
+
 #endif /* QEMU_ACCEL_H */
-- 
2.53.0


Reply via email to