feat: add power management VM helpers
Add two helpers returning whether a VM registered to receive specific
power management events.
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
Change-Id: I10000f1c75d7dfaf96c4e27a9c007400f87ab968
diff --git a/inc/hf/vm.h b/inc/hf/vm.h
index bb3a016..b9d69ff 100644
--- a/inc/hf/vm.h
+++ b/inc/hf/vm.h
@@ -29,6 +29,13 @@
#define OTHER_S_INT_ACTION_SIGNALED 1
/**
+ * Power management bifields stating which messages a VM is willing to be
+ * notified about.
+ */
+#define VM_POWER_MANAGEMENT_CPU_OFF_SHIFT (0)
+#define VM_POWER_MANAGEMENT_CPU_ON_SHIFT (3)
+
+/**
* The state of an RX buffer.
*
* EMPTY is the initial state. The follow state transitions are possible:
@@ -346,3 +353,23 @@
bool npi_injected);
bool vm_notifications_is_npi_injected(struct vm_locked vm_locked);
void vm_set_boot_info_gp_reg(struct vm *vm, struct vcpu *vcpu);
+
+/**
+ * Returns true if the VM requested to receive cpu on power management
+ * events.
+ */
+static inline bool vm_power_management_cpu_on_requested(struct vm *vm)
+{
+ return (vm->power_management &
+ (UINT32_C(1) << VM_POWER_MANAGEMENT_CPU_ON_SHIFT)) != 0;
+}
+
+/**
+ * Returns true if the VM requested to receive cpu off power management
+ * events.
+ */
+static inline bool vm_power_management_cpu_off_requested(struct vm *vm)
+{
+ return (vm->power_management &
+ (UINT32_C(1) << VM_POWER_MANAGEMENT_CPU_OFF_SHIFT)) != 0;
+}