diff options
author | Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> | 2020-02-12 21:58:47 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-02-19 10:38:04 +0000 |
commit | 546f01cb96b0b2c688257371608c64db78b5d31a (patch) | |
tree | a47c679e7cfff5977b99af7b7444c05f30ebaccb /devices/src/acpi.rs | |
parent | 80a8d52fac83f5f6cd0187ebcbab6e1e5bd8586f (diff) | |
download | crosvm-546f01cb96b0b2c688257371608c64db78b5d31a.tar crosvm-546f01cb96b0b2c688257371608c64db78b5d31a.tar.gz crosvm-546f01cb96b0b2c688257371608c64db78b5d31a.tar.bz2 crosvm-546f01cb96b0b2c688257371608c64db78b5d31a.tar.lz crosvm-546f01cb96b0b2c688257371608c64db78b5d31a.tar.xz crosvm-546f01cb96b0b2c688257371608c64db78b5d31a.tar.zst crosvm-546f01cb96b0b2c688257371608c64db78b5d31a.zip |
acpipm: implement suspend and resume mechanism
For suspend request from VM, will write suspend event and notify crosvm main process to pause VCPUs. For resume request, it is not from VM itself but by the resume command through crosvm socket. Resume request will notify the PM device to fill its wakeup registers with wakeup event so that when VCPUs start to run, VM can know there is wakeup from outside. BUG=chromium:1018674 TEST=cargo test -p devices Change-Id: I4724ffee10150065a62bf520076c16cbc70b7749 Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2035169 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Diffstat (limited to 'devices/src/acpi.rs')
-rw-r--r-- | devices/src/acpi.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/devices/src/acpi.rs b/devices/src/acpi.rs index 983e635..6d36353 100644 --- a/devices/src/acpi.rs +++ b/devices/src/acpi.rs @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -use crate::BusDevice; +use crate::{BusDevice, BusResumeDevice}; use sys_util::{error, warn, EventFd}; /// ACPI PM resource for handling OS suspend/resume request @@ -41,6 +41,8 @@ const SLEEP_CONTROL: u16 = 6; const SLEEP_STATUS: u16 = 7; const BITMASK_PM1CNT_SLEEP_ENABLE: u16 = 0x2000; const BITMASK_SLEEPCNT_SLEEP_ENABLE: u8 = 0x20; +const BITMASK_PM1CNT_WAKE_STATUS: u16 = 0x8000; +const BITMASK_SLEEPCNT_WAKE_STATUS: u8 = 0x80; impl BusDevice for ACPIPMResource { fn debug_label(&self) -> String { @@ -113,3 +115,13 @@ impl BusDevice for ACPIPMResource { }; } } + +impl BusResumeDevice for ACPIPMResource { + fn resume_imminent(&mut self) { + let val = self.pm1_status; + self.pm1_status = val | BITMASK_PM1CNT_WAKE_STATUS; + + let val = self.sleep_status; + self.sleep_status = val | BITMASK_SLEEPCNT_WAKE_STATUS; + } +} |