diff options
author | Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> | 2020-04-27 16:32:13 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-05-11 13:43:59 +0000 |
commit | 6db9f9f58a095ee9a70c8edb6563aaf7027cb278 (patch) | |
tree | 283b384f5bb40f1a16ebf1ee3a7304f71601b499 /devices/src/acpi.rs | |
parent | e1f8d9187d3f16e31d0c1304030ad412cf43b2bf (diff) | |
download | crosvm-6db9f9f58a095ee9a70c8edb6563aaf7027cb278.tar crosvm-6db9f9f58a095ee9a70c8edb6563aaf7027cb278.tar.gz crosvm-6db9f9f58a095ee9a70c8edb6563aaf7027cb278.tar.bz2 crosvm-6db9f9f58a095ee9a70c8edb6563aaf7027cb278.tar.lz crosvm-6db9f9f58a095ee9a70c8edb6563aaf7027cb278.tar.xz crosvm-6db9f9f58a095ee9a70c8edb6563aaf7027cb278.tar.zst crosvm-6db9f9f58a095ee9a70c8edb6563aaf7027cb278.zip |
acpi: refactor the ACPI PM device
Add the AML support to generate the S1 table instead of hard coding. Also use the IO allocater to allocate the IO resouce for ACPI PM. BUG=None TEST=boot crosvm by command "crosvm run -s crosvm.sock -m 4096 --cpus 4 --rwdisk rootfs.img -p "root=/dev/vda rootfstype=ext4" vmlinux". Check the S1 capability by "#echo standby > /sys/power/state" from guest side. Linux guest is suspended. And resume linux guest by "#crosvm resume crosvm.sock" from host side. Change-Id: I75b484c44db05f98d49557ba694a1531b57871c1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2119571 Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com>
Diffstat (limited to 'devices/src/acpi.rs')
-rw-r--r-- | devices/src/acpi.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/devices/src/acpi.rs b/devices/src/acpi.rs index 990a782..1cfab35 100644 --- a/devices/src/acpi.rs +++ b/devices/src/acpi.rs @@ -3,6 +3,7 @@ // found in the LICENSE file. use crate::{BusDevice, BusResumeDevice}; +use acpi_tables::{aml, aml::Aml}; use sys_util::{error, warn, EventFd}; /// ACPI PM resource for handling OS suspend/resume request @@ -29,8 +30,7 @@ impl ACPIPMResource { } } -/// the ACPI PM register's base and length. -pub const ACPIPM_RESOURCE_BASE: u64 = 0x600; +/// the ACPI PM register length. pub const ACPIPM_RESOURCE_LEN: u8 = 8; pub const ACPIPM_RESOURCE_EVENTBLK_LEN: u8 = 4; pub const ACPIPM_RESOURCE_CONTROLBLK_LEN: u8 = 2; @@ -127,3 +127,14 @@ impl BusResumeDevice for ACPIPMResource { self.sleep_status = val | BITMASK_SLEEPCNT_WAKE_STATUS; } } + +impl Aml for ACPIPMResource { + fn to_aml_bytes(&self, bytes: &mut Vec<u8>) { + // S1 + aml::Name::new( + "_S1_".into(), + &aml::Package::new(vec![&aml::ONE, &aml::ONE, &aml::ZERO, &aml::ZERO]), + ) + .to_aml_bytes(bytes); + } +} |