fidl_data_zx/
system.rs

1// Copyright 2022 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// DO NOT EDIT.
6// Generated from FIDL library `zx` by zither, a Fuchsia platform tool.
7
8#![allow(unused_imports)]
9
10use bitflags::bitflags;
11use zerocopy::{FromBytes, IntoBytes};
12
13use crate::zx_common::*;
14
15pub const MAX_POWER_LEVELS: usize = 256;
16
17pub const MAX_POWER_LEVEL_TRANSITIONS: usize = 65536;
18
19#[repr(C)]
20#[derive(Clone, Copy, Debug, Eq, FromBytes, IntoBytes, PartialEq)]
21pub struct ProcessorPowerDomain {
22    pub mask: [u64; 8],
23    pub domain_id: u32,
24    pub padding1: [u8; 4],
25}
26
27#[repr(C)]
28#[derive(IntoBytes, FromBytes, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
29pub struct ProcessorPowerLevelOptions(u64);
30
31bitflags::bitflags! {
32    impl ProcessorPowerLevelOptions : u64 {
33        const PROCESSOR_POWER_LEVEL_OPTIONS_DOMAIN_INDEPENDENT = 1 << 0;
34  }
35}
36
37#[repr(u64)]
38#[derive(Clone, Copy, Debug, Eq, IntoBytes, PartialEq)]
39pub enum ProcessorPowerControl {
40    ProcessorPowerControlCpuDriver = 0,
41    ProcessorPowerControlArmPsci = 1,
42    ProcessorPowerControlArmWfi = 2,
43    ProcessorPowerControlRiscvSbi = 3,
44    ProcessorPowerControlRiscvWfi = 4,
45}
46
47impl ProcessorPowerControl {
48    pub fn from_raw(raw: u64) -> Option<Self> {
49        match raw {
50            0 => Some(Self::ProcessorPowerControlCpuDriver),
51
52            1 => Some(Self::ProcessorPowerControlArmPsci),
53
54            2 => Some(Self::ProcessorPowerControlArmWfi),
55
56            3 => Some(Self::ProcessorPowerControlRiscvSbi),
57
58            4 => Some(Self::ProcessorPowerControlRiscvWfi),
59
60            _ => None,
61        }
62    }
63}
64
65#[repr(C)]
66#[derive(Clone, Copy, Debug, Eq, IntoBytes, PartialEq)]
67pub struct ProcessorPowerLevel {
68    pub options: ProcessorPowerLevelOptions,
69    pub processing_rate: u64,
70    pub power_coefficient_nw: u64,
71    pub control_interface: ProcessorPowerControl,
72    pub control_argument: u64,
73    pub diagnostic_name: [u8; 32],
74    pub reserved: [u8; 32],
75}
76
77#[repr(C)]
78#[derive(Clone, Copy, Debug, Eq, FromBytes, IntoBytes, PartialEq)]
79pub struct ProcessorPowerLevelTransition {
80    pub latency: Duration,
81    pub energy_nj: u64,
82    pub from: u8,
83    pub to: u8,
84    pub reserved: [u8; 6],
85}
86
87#[repr(C)]
88#[derive(Clone, Copy, Debug, Eq, IntoBytes, PartialEq)]
89pub struct ProcessorPowerState {
90    pub domain_id: u32,
91    pub option: u32,
92    pub control_interface: ProcessorPowerControl,
93    pub control_argument: u64,
94}
95
96#[repr(C)]
97#[derive(Clone, Copy, Debug, Eq, FromBytes, IntoBytes, PartialEq)]
98pub struct SystemPowerctlArg {}
99
100/// Options which can be passed to `zx_system_suspend_enter` syscalls via the
101/// `options` parameter.
102#[repr(C)]
103#[derive(IntoBytes, FromBytes, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
104pub struct SystemSuspendOption(u64);
105
106bitflags::bitflags! {
107    impl SystemSuspendOption : u64 {
108
109        /// `ZX_SYSTEM_SUSPEND_OPTION_DISCARD` is an option which may be passed to
110        /// `zx_system_suspend_enter` which will cause the syscall to discard any wake
111        /// sources report entries for wake sources which have been both triggered and
112        /// acknowledged, and are only waiting to be reported.  This operation takes
113        /// place before any attempt to suspend is made, and before any report is
114        /// generated.
115        const DISCARD = 1 << 0;
116
117        /// `ZX_SYSTEM_SUSPEND_OPTION_REPORT_ONLY` is an option which may be passed to
118        /// `zx_system_suspend_enter` which will cause the syscall to skip any attempts to
119        /// suspend.  Instead, it will only generate a report as it unwinds.
120        const REPORT_ONLY = 1 << 1;
121  }
122}
123
124/// Flags which can be reported via the `flags` member of the
125/// `zx_wake_support_entry_t` structure.
126#[repr(C)]
127#[derive(IntoBytes, FromBytes, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
128pub struct SystemWakeReportEntryFlag(u32);
129
130bitflags::bitflags! {
131    impl SystemWakeReportEntryFlag : u32 {
132
133        /// A `zx_wake_source_report_entry_t` flag indicating that the entry's wake
134        /// source was still in the signaled (not-yet-acknowledged) state at the
135        /// time of report generation.
136        const SIGNALED = 1 << 0;
137
138        /// A `zx_wake_source_report_entry_t` flag indicating that this entry has
139        /// been reported before, but is being reported again because the wake
140        /// source is still in the signaled state, and has not been acknowledged
141        /// since being previously reported.
142        const PREVIOUSLY_REPORTED = 1 << 1;
143  }
144}
145
146/// A structure returned from calls to `zx_system_suspend_enter` containing
147/// details about an individual wake source which may have been involved in
148/// coming out of suspend.
149#[repr(C)]
150#[derive(Clone, Copy, Debug, Eq, FromBytes, IntoBytes, PartialEq)]
151pub struct WakeSourceReportEntry {
152    /// The KOID uniquely identifying the kernel wake-source object being
153    /// reported.
154    pub koid: Koid,
155
156    /// The name of the object to assist in debugging.  This field is for
157    /// debugging only, it is not durable and should not be used in production
158    /// logic.
159    pub name: [u8; 32],
160
161    /// The time (on the boot timeline) at which this wake source first became
162    /// signaled.
163    pub initial_signal_time: InstantBoot,
164
165    /// The time (on the boot timeline) at which this wake source most recently
166    /// became signaled.  Will be equal to the initial_signal_time if the wake
167    /// source has only been signaled once.
168    pub last_signal_time: InstantBoot,
169
170    /// The time (on the boot timeline) at which this wake source most recently
171    /// became acknowledged, if ever.  If not, this will be ZX_TIME_INFINITE.
172    pub last_ack_time: InstantBoot,
173
174    /// The total number of times that this wakes source has been signaled
175    /// before being reported.
176    pub signal_count: u32,
177
178    /// Any valid combination of the `ZX_SYSTEM_WAKE_REPORT_ENTRY_FLAG`s.
179    pub flags: SystemWakeReportEntryFlag,
180}
181
182#[repr(C)]
183#[derive(Clone, Copy, Debug, Eq, FromBytes, IntoBytes, PartialEq)]
184pub struct WakeSourceReportHeader {
185    /// The timestamp of when the wake report was generated.
186    pub report_time: InstantBoot,
187
188    /// The timestamp of when the suspend operation was committed to and
189    /// started, or ZX_TIME_INFINITE if no attempt to suspend was made.
190    pub suspend_start_time: InstantBoot,
191
192    /// The total number of wake sources present in the system at the time of
193    /// report generation.
194    pub total_wake_sources: u32,
195
196    /// The total number of report entries which were waiting to be reported at
197    /// the start of report generation, but were skipped due to insufficient
198    /// space in the user's buffer.
199    pub unreported_wake_report_entries: u32,
200}
201
202#[repr(C)]
203#[derive(Clone, Copy, Debug, Eq, PartialEq)]
204pub struct StringView {
205    pub c_str: *const u8,
206    pub length: usize,
207}
208
209#[repr(u32)]
210#[derive(Clone, Copy, Debug, Eq, IntoBytes, PartialEq)]
211pub enum CpuPerfLimitType {
212    /// Represents a limit on the processing rate of the CPU. Values for min and
213    /// max are interpreted to be in the range [0, MAX_RATE], where MAX_RATE is
214    /// the value of the processing_rate field of the fastest power level in the
215    /// same power domain. Values above MAX_RATE are clamped to MAX_RATE.
216    Rate = 0,
217
218    /// Represents a limit on the effective power of the CPU. Values for min and
219    /// max are in units of nanowatts.
220    Power = 1,
221}
222
223impl CpuPerfLimitType {
224    pub fn from_raw(raw: u32) -> Option<Self> {
225        match raw {
226            0 => Some(Self::Rate),
227
228            1 => Some(Self::Power),
229
230            _ => None,
231        }
232    }
233}
234
235#[repr(C)]
236#[derive(Clone, Copy, Debug, Eq, IntoBytes, PartialEq)]
237pub struct CpuPerfLimit {
238    pub logical_cpu_number: u32,
239    pub limit_type: CpuPerfLimitType,
240    pub min: u64,
241    pub max: u64,
242}