mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Implement the power button method for AArch64
This commit implements the power button method for AArch64 using the PL061 GPIO controller. Signed-off-by: Henry Wang <Henry.Wang@arm.com>
This commit is contained in:
@@ -25,6 +25,8 @@ pub use self::fwdebug::FwDebugDevice;
|
|||||||
pub use self::i8042::I8042Device;
|
pub use self::i8042::I8042Device;
|
||||||
pub use self::serial::Serial;
|
pub use self::serial::Serial;
|
||||||
|
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
pub use self::gpio_pl061::Error as GPIODeviceError;
|
||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
pub use self::gpio_pl061::GPIO;
|
pub use self::gpio_pl061::GPIO;
|
||||||
#[cfg(target_arch = "aarch64")]
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
|||||||
@@ -403,6 +403,10 @@ pub enum DeviceManagerError {
|
|||||||
/// Failed to do power button notification
|
/// Failed to do power button notification
|
||||||
PowerButtonNotification(io::Error),
|
PowerButtonNotification(io::Error),
|
||||||
|
|
||||||
|
/// Failed to do AArch64 GPIO power button notification
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
AArch64PowerButtonNotification(devices::legacy::GPIODeviceError),
|
||||||
|
|
||||||
/// Failed to set O_DIRECT flag to file descriptor
|
/// Failed to set O_DIRECT flag to file descriptor
|
||||||
SetDirectIo,
|
SetDirectIo,
|
||||||
|
|
||||||
@@ -3521,6 +3525,7 @@ impl DeviceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "acpi")]
|
#[cfg(feature = "acpi")]
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
pub fn notify_power_button(&self) -> DeviceManagerResult<()> {
|
pub fn notify_power_button(&self) -> DeviceManagerResult<()> {
|
||||||
self.ged_notification_device
|
self.ged_notification_device
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@@ -3530,6 +3535,17 @@ impl DeviceManager {
|
|||||||
.notify(AcpiNotificationFlags::POWER_BUTTON_CHANGED)
|
.notify(AcpiNotificationFlags::POWER_BUTTON_CHANGED)
|
||||||
.map_err(DeviceManagerError::PowerButtonNotification)
|
.map_err(DeviceManagerError::PowerButtonNotification)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
pub fn notify_power_button(&self) -> DeviceManagerResult<()> {
|
||||||
|
self.gpio_device
|
||||||
|
.as_ref()
|
||||||
|
.unwrap()
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.trigger_key(3)
|
||||||
|
.map_err(DeviceManagerError::AArch64PowerButtonNotification)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "acpi")]
|
#[cfg(feature = "acpi")]
|
||||||
|
|||||||
@@ -2038,6 +2038,7 @@ impl Vm {
|
|||||||
.map_err(Error::ActivateVirtioDevices)
|
.map_err(Error::ActivateVirtioDevices)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
pub fn power_button(&self) -> Result<()> {
|
pub fn power_button(&self) -> Result<()> {
|
||||||
#[cfg(feature = "acpi")]
|
#[cfg(feature = "acpi")]
|
||||||
return self
|
return self
|
||||||
@@ -2049,6 +2050,15 @@ impl Vm {
|
|||||||
#[cfg(not(feature = "acpi"))]
|
#[cfg(not(feature = "acpi"))]
|
||||||
Err(Error::PowerButtonNotSupported)
|
Err(Error::PowerButtonNotSupported)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
pub fn power_button(&self) -> Result<()> {
|
||||||
|
self.device_manager
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.notify_power_button()
|
||||||
|
.map_err(Error::PowerButton)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Pausable for Vm {
|
impl Pausable for Vm {
|
||||||
|
|||||||
Reference in New Issue
Block a user