mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-25 13:23:08 +00:00
60b8901b3e
This commit introduces ACPI0003 emulated device, which can be enabled by passing "--ac-adapter" argument. Emulating ac adapter allows to replicate ac adapter state on the guest side. The host kernel already propagates ac adapter status to user-space by generating acpi events: acpi_bus_generate_netlink_event so crosvm upon receiving "ac_adapter" class acpi event, stores the corresponding data (ac status) into ac register. Next the previously allocated GPE is triggered to inform the guest about status change. Guest upon handling GPE, thanks to generated aml code: Device (ACDC) { Name (_HID, "ACPI0003" /* Power Source Device */) // _HID: Hardware ID OperationRegion (VREG, SystemMemory, 0x0000000220E00010, 0x10) Field (VREG, DWordAcc, Lock, Preserve) { ACEX, 32 } Method (_PSR, 0, NotSerialized) // _PSR: Power Source { Return (ACEX) /* \ACDC.ACEX */ } Method (_STA, 0, NotSerialized) // _STA: Status { Return (0x0F) } } Scope (_GPE) { Method (_E00, 0, NotSerialized) // _Exx: Edge-Triggered GPE, xx=0x00-0xFF { Notify (ACDC, 0x80) // Status Change } } triggers Notify on AC adapter and therefore replicates the host ac_adapter state (accessing ACEX pointed by opregion results with trap to crosvm, which returns previously stored ac status). BUG=b:244205651 TEST=Plug/Unplug AC adapter and inside guest run: 1) acpi_listener and confirm that proper acpi events are replicated 2) observe: `cat /sys/class/power_supply/ACDC/online` Change-Id: I9b1045cfcae1c4de48a0ad50f63148cfe9ff226b Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4186657 Auto-Submit: Grzegorz Jaszczyk <jaszczyk@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Grzegorz Jaszczyk <jaszczyk@google.com> |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |