1#![forbid(unsafe_code)]
7
8pub mod i8042 {
9 use mesh::MeshPayload;
12 use vm_resource::Resource;
13 use vm_resource::ResourceId;
14 use vm_resource::kind::ChipsetDeviceHandleKind;
15 use vm_resource::kind::KeyboardInputHandleKind;
16
17 #[derive(MeshPayload)]
19 pub struct I8042DeviceHandle {
20 pub keyboard_input: Resource<KeyboardInputHandleKind>,
22 }
23
24 impl ResourceId<ChipsetDeviceHandleKind> for I8042DeviceHandle {
25 const ID: &'static str = "i8042";
26 }
27}
28
29pub mod battery {
30 #[cfg(feature = "arbitrary")]
33 use arbitrary::Arbitrary;
34 use inspect::Inspect;
35 use mesh::MeshPayload;
36 use vm_resource::ResourceId;
37 use vm_resource::kind::ChipsetDeviceHandleKind;
38 #[derive(MeshPayload)]
40 pub struct BatteryDeviceHandleX64 {
41 pub battery_status_recv: mesh::Receiver<HostBatteryUpdate>,
43 }
44
45 impl ResourceId<ChipsetDeviceHandleKind> for BatteryDeviceHandleX64 {
46 const ID: &'static str = "batteryX64";
47 }
48
49 #[derive(MeshPayload)]
51 pub struct BatteryDeviceHandleAArch64 {
52 pub battery_status_recv: mesh::Receiver<HostBatteryUpdate>,
54 }
55
56 impl ResourceId<ChipsetDeviceHandleKind> for BatteryDeviceHandleAArch64 {
57 const ID: &'static str = "batteryAArch64";
58 }
59
60 #[derive(Debug, Clone, Copy, Inspect, PartialEq, Eq, MeshPayload, Default)]
62 #[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
63 pub struct HostBatteryUpdate {
64 pub battery_present: bool,
66 pub charging: bool,
68 pub discharging: bool,
70 pub rate: u32,
72 pub remaining_capacity: u32,
74 pub max_capacity: u32,
76 pub ac_online: bool,
78 }
79
80 impl HostBatteryUpdate {
81 pub fn default_present() -> Self {
83 Self {
84 battery_present: true,
85 charging: true,
86 discharging: false,
87 rate: 1,
88 remaining_capacity: 950,
89 max_capacity: 1000,
90 ac_online: true,
91 }
92 }
93 }
94}