mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-21 20:15:21 +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:
parent
c853ed3fdc
commit
2bb153de2b
@ -25,6 +25,8 @@ pub use self::fwdebug::FwDebugDevice;
|
||||
pub use self::i8042::I8042Device;
|
||||
pub use self::serial::Serial;
|
||||
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
pub use self::gpio_pl061::Error as GPIODeviceError;
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
pub use self::gpio_pl061::GPIO;
|
||||
#[cfg(target_arch = "aarch64")]
|
||||
|
@ -403,6 +403,10 @@ pub enum DeviceManagerError {
|
||||
/// Failed to do power button notification
|
||||
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
|
||||
SetDirectIo,
|
||||
|
||||
@ -3521,6 +3525,7 @@ impl DeviceManager {
|
||||
}
|
||||
|
||||
#[cfg(feature = "acpi")]
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub fn notify_power_button(&self) -> DeviceManagerResult<()> {
|
||||
self.ged_notification_device
|
||||
.as_ref()
|
||||
@ -3530,6 +3535,17 @@ impl DeviceManager {
|
||||
.notify(AcpiNotificationFlags::POWER_BUTTON_CHANGED)
|
||||
.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")]
|
||||
|
@ -2038,6 +2038,7 @@ impl Vm {
|
||||
.map_err(Error::ActivateVirtioDevices)
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
pub fn power_button(&self) -> Result<()> {
|
||||
#[cfg(feature = "acpi")]
|
||||
return self
|
||||
@ -2049,6 +2050,15 @@ impl Vm {
|
||||
#[cfg(not(feature = "acpi"))]
|
||||
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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user