| // Copyright 2019 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| library zx; |
| |
| const MAX_POWER_LEVELS usize64 = 256; |
| const MAX_POWER_LEVEL_TRANSITIONS usize64 = 65536; // MAX_POWER_LEVELS^2 |
| type ProcessorPowerDomain = struct { |
| // mask of Cpus that belong to this power domain. |
| mask array<uint64, 8>; |
| // Defines an `id` used for transition requests. |
| domain_id uint32; |
| // Padding bytes. |
| padding1 array<uint8, 4>; |
| }; |
| |
| type ProcessorPowerLevelOptions = flexible bits : uint64 { |
| PROCESSOR_POWER_LEVEL_OPTIONS_DOMAIN_INDEPENDENT = 1; |
| }; |
| |
| type ProcessorPowerControl = flexible enum : uint64 { |
| PROCESSOR_POWER_CONTROL_CPU_DRIVER = 0; |
| PROCESSOR_POWER_CONTROL_ARM_PSCI = 1; |
| PROCESSOR_POWER_CONTROL_ARM_WFI = 2; |
| PROCESSOR_POWER_CONTROL_RISCV_SBI = 3; |
| PROCESSOR_POWER_CONTROL_RISCV_WFI = 4; |
| }; |
| |
| type ProcessorPowerLevel = struct { |
| options ProcessorPowerLevelOptions; |
| processing_rate uint64; |
| power_coefficient_nw uint64; |
| control_interface ProcessorPowerControl; |
| control_argument uint64; |
| diagnostic_name string_array<MAX_NAME_LEN>; |
| reserved array<uint8, 32>; |
| }; |
| |
| type ProcessorPowerLevelTransition = struct { |
| latency Duration; |
| energy_nj uint64; |
| from uint8; |
| to uint8; |
| reserved array<uint8, 6>; |
| }; |
| |
| type ProcessorPowerState = struct { |
| domain_id uint32; |
| option uint32; |
| control_interface ProcessorPowerControl; |
| control_argument uint64; |
| }; |
| |
| type SystemPowerctlArg = struct { |
| // TODO(scottmg): More unnamed unions. |
| //union { |
| // struct { |
| // uint8_t target_s_state; // Value between 1 and 5 indicating which S-state |
| // uint8_t sleep_type_a; // Value from ACPI VM (SLP_TYPa) |
| // uint8_t sleep_type_b; // Value from ACPI VM (SLP_TYPb) |
| // } acpi_transition_s_state; |
| // struct { |
| // uint32_t power_limit; // PL1 value in milliwatts |
| // uint32_t time_window; // PL1 time window in microseconds |
| // uint8_t clamp; // PL1 clamping enable |
| // uint8_t enable; // PL1 enable |
| // } x86_power_limit; |
| //}; |
| }; |
| |
| /// Options which can be passed to `zx_system_suspend_enter` syscalls via the |
| /// `options` parameter. |
| type SystemSuspendOption = flexible bits : uint64 { |
| /// `ZX_SYSTEM_SUSPEND_OPTION_DISCARD` is an option which may be passed to |
| /// `zx_system_suspend_enter` which will cause the syscall to discard any wake |
| /// sources report entries for wake sources which have been both triggered and |
| /// acknowledged, and are only waiting to be reported. This operation takes |
| /// place before any attempt to suspend is made, and before any report is |
| /// generated. |
| DISCARD = 0x1; |
| |
| /// `ZX_SYSTEM_SUSPEND_OPTION_REPORT_ONLY` is an option which may be passed to |
| /// `zx_system_suspend_enter` which will cause the syscall to skip any attempts to |
| /// suspend. Instead, it will only generate a report as it unwinds. |
| REPORT_ONLY = 0x2; |
| }; |
| |
| /// Flags which can be reported via the `flags` member of the |
| /// `zx_wake_support_entry_t` structure. |
| type SystemWakeReportEntryFlag = flexible bits : uint32 { |
| /// A `zx_wake_source_report_entry_t` flag indicating that the entry's wake |
| /// source was still in the signaled (not-yet-acknowledged) state at the |
| /// time of report generation. |
| SIGNALED = 0x01; |
| |
| /// A `zx_wake_source_report_entry_t` flag indicating that this entry has |
| /// been reported before, but is being reported again because the wake |
| /// source is still in the signaled state, and has not been acknowledged |
| /// since being previously reported. |
| PREVIOUSLY_REPORTED = 0x02; |
| }; |
| |
| /// A structure returned from calls to `zx_system_suspend_enter` containing |
| /// details about an individual wake source which may have been involved in |
| /// coming out of suspend. |
| type WakeSourceReportEntry = struct { |
| /// The KOID uniquely identifying the kernel wake-source object being |
| /// reported. |
| koid Koid; |
| |
| /// The name of the object to assist in debugging. This field is for |
| /// debugging only, it is not durable and should not be used in production |
| /// logic. |
| name string_array<MAX_NAME_LEN>; |
| |
| /// The time (on the boot timeline) at which this wake source first became |
| /// signaled. |
| initial_signal_time InstantBoot; |
| |
| /// The time (on the boot timeline) at which this wake source most recently |
| /// became signaled. Will be equal to the initial_signal_time if the wake |
| /// source has only been signaled once. |
| last_signal_time InstantBoot; |
| |
| /// The time (on the boot timeline) at which this wake source most recently |
| /// became acknowledged, if ever. If not, this will be ZX_TIME_INFINITE. |
| last_ack_time InstantBoot; |
| |
| /// The total number of times that this wakes source has been signaled |
| /// before being reported. |
| signal_count uint32; |
| |
| /// Any valid combination of the `ZX_SYSTEM_WAKE_REPORT_ENTRY_FLAG`s. |
| flags SystemWakeReportEntryFlag; |
| }; |
| |
| type WakeSourceReportHeader = struct { |
| /// The timestamp of when the wake report was generated. |
| report_time InstantBoot; |
| |
| /// The timestamp of when the suspend operation was committed to and |
| /// started, or ZX_TIME_INFINITE if no attempt to suspend was made. |
| suspend_start_time InstantBoot; |
| |
| /// The total number of wake sources present in the system at the time of |
| /// report generation. |
| total_wake_sources uint32; |
| |
| /// The total number of report entries which were waiting to be reported at |
| /// the start of report generation, but were skipped due to insufficient |
| /// space in the user's buffer. |
| unreported_wake_report_entries uint32; |
| }; |
| |
| type StringView = struct { |
| c_str experimental_pointer<uchar>; |
| length usize64; |
| }; |
| |
| type CpuPerfLimitType = flexible enum : uint32 { |
| /// Represents a limit on the processing rate of the CPU. Values for min and |
| /// max are interpreted to be in the range [0, MAX_RATE], where MAX_RATE is |
| /// the value of the processing_rate field of the fastest power level in the |
| /// same power domain. Values above MAX_RATE are clamped to MAX_RATE. |
| RATE = 0; |
| |
| /// Represents a limit on the effective power of the CPU. Values for min and |
| /// max are in units of nanowatts. |
| POWER = 1; |
| }; |
| |
| type CpuPerfLimit = struct { |
| // Target CPU. |
| logical_cpu_number uint32; |
| |
| // Type of limit specified by min and max. |
| limit_type CpuPerfLimitType; |
| |
| // The minimum limit to apply to the target CPU. |
| min uint64; |
| |
| // The maximum limit to apply to the target CPU. |
| max uint64; |
| }; |
| |
| @transport("Syscall") |
| closed protocol System { |
| /// ## Summary |
| /// |
| /// TODO(https://fxbug.dev/42108078) |
| /// |
| /// ## Declaration |
| /// |
| /// ```c |
| /// #include <zircon/syscalls.h> |
| /// |
| /// uint32_t zx_system_get_dcache_line_size(void); |
| /// ``` |
| /// |
| /// ## Description |
| /// |
| /// TODO(https://fxbug.dev/42108078) |
| /// |
| /// ## Rights |
| /// |
| /// TODO(https://fxbug.dev/42107318) |
| /// |
| /// ## Return value |
| /// |
| /// TODO(https://fxbug.dev/42108078) |
| /// |
| /// ## Errors |
| /// |
| /// TODO(https://fxbug.dev/42108078) |
| /// |
| /// ## See also |
| /// |
| /// TODO(https://fxbug.dev/42108078) |
| @const |
| @vdsocall |
| strict GetDcacheLineSize() -> (@wrapped_return struct { |
| size uint32; |
| }); |
| |
| /// ## Summary |
| /// |
| /// Get number of logical processors on the system. |
| /// |
| /// ## Declaration |
| /// |
| /// ```c |
| /// #include <zircon/syscalls.h> |
| /// |
| /// uint32_t zx_system_get_num_cpus(void); |
| /// ``` |
| /// |
| /// ## Description |
| /// |
| /// `zx_system_get_num_cpus()` returns the number of CPUs (logical processors) |
| /// that exist on the system currently running. This number cannot change |
| /// during a run of the system, only at boot time. |
| /// |
| /// ## Rights |
| /// |
| /// TODO(https://fxbug.dev/42107318) |
| /// |
| /// ## Return value |
| /// |
| /// `zx_system_get_num_cpus()` returns the number of CPUs. |
| /// |
| /// ## Errors |
| /// |
| /// `zx_system_get_num_cpus()` cannot fail. |
| /// |
| /// ## Notes |
| /// |
| /// ## See also |
| /// |
| /// - [`zx_system_get_physmem()`] |
| /// |
| /// [`zx_system_get_physmem()`]: system_get_physmem.md |
| @const |
| @vdsocall |
| strict GetNumCpus() -> (@wrapped_return struct { |
| count uint32; |
| }); |
| |
| /// ## Summary |
| /// |
| /// Get version string for system. |
| /// |
| /// ## Declaration |
| /// |
| /// ```c |
| /// #include <zircon/syscalls.h> |
| /// |
| /// zx_string_view_t zx_system_get_version_string(void); |
| /// ``` |
| /// |
| /// ## Description |
| /// |
| /// `zx_system_get_version_string()` returns a string identifying the version of |
| /// the Zircon system currently running. |
| /// |
| /// The returned object is a simple pair of C string pointer and length. The |
| /// string is guaranteed to be NUL-terminated and to be valid UTF-8. The length |
| /// does not include the NUL terminator. In C++ the return value can be coerced |
| /// implicitly to `std::string_view`, `std::u8string_view`, or other types with |
| /// equivalent two-argument constructor signatures. |
| /// |
| /// The string constant may be of any length. It is in read-only memory provided |
| /// by the [vDSO](/docs/concepts/kernel/vdso.md). Thus it is always accessible at |
| /// the same address for the life of the process and its contents never change. |
| /// |
| /// The first four characters identify the version scheme. An example of the string |
| /// returned is "git-8a07d52603404521038d8866b297f99de36f9162". |
| /// |
| /// ## Rights |
| /// |
| /// TODO(https://fxbug.dev/42107318) |
| /// |
| /// ## Return value |
| /// |
| /// `zx_system_get_version_string()` returns a `zx_string_view_t` object. |
| /// |
| /// ## Errors |
| /// |
| /// `zx_system_get_version_string()` cannot fail. |
| /// |
| /// ## Notes |
| /// |
| /// ## See also |
| /// |
| @const |
| @vdsocall |
| strict GetVersionString() -> (StringView); |
| |
| /// ## Summary |
| /// |
| /// Get the page size for the system. |
| /// |
| /// ## Declaration |
| /// |
| /// ```c |
| /// #include <zircon/syscalls.h> |
| /// |
| /// uint32_t zx_system_get_page_size(void); |
| /// ``` |
| /// |
| /// ## Description |
| /// |
| /// `zx_system_get_page_size()` returns the base memory page size of the system in |
| /// bytes. This number cannot change during a run of the system, only at boot time, |
| /// and is guaranteed to be an exact power of 2. |
| /// |
| /// The page size represents the allocation and alignment granularity of VMOs in |
| /// `zx_vmo_create()` and the smallest unit that can be mapped via `zx_vmar_map()`. |
| /// |
| /// For every architecture there are well defined minimum and maximum values, |
| /// `ZX_MIN_PAGE_SIZE` and `ZX_MAX_PAGE_SIZE`, that this will return. |
| /// |
| /// | Architecture | `ZX_MIN_PAGE_SIZE` | `ZX_MAX_PAGE_SIZE` | |
| /// | ------------ | ------------------ | ------------------ | |
| /// | ARM | 4KiB | 64KiB | |
| /// | X86-64 | 4KiB | 2MiB | |
| /// |
| /// ## Rights |
| /// |
| /// TODO(https://fxbug.dev/42107318) |
| /// |
| /// ## Return value |
| /// |
| /// `zx_system_get_page_size()` returns the page size in bytes. |
| /// |
| /// ## Errors |
| /// |
| /// `zx_system_get_page_size()` cannot fail. |
| /// |
| /// ## Notes |
| /// |
| /// ## See also |
| /// |
| /// - [`zx_vmar_map()`] |
| /// - [`zx_vmo_create()`] |
| /// |
| /// [`zx_vmar_map()`]: vmar_map.md |
| /// [`zx_vmo_create()`]: vmo_create.md |
| @const |
| @vdsocall |
| strict GetPageSize() -> (@wrapped_return struct { |
| size uint32; |
| }); |
| |
| /// ## Summary |
| /// |
| /// Get amount of physical memory on the system. |
| /// |
| /// ## Declaration |
| /// |
| /// ```c |
| /// #include <zircon/syscalls.h> |
| /// |
| /// uint64_t zx_system_get_physmem(void); |
| /// ``` |
| /// |
| /// ## Description |
| /// |
| /// `zx_system_get_physmem()` returns the total size of physical memory on |
| /// the machine, in bytes. |
| /// |
| /// ## Rights |
| /// |
| /// TODO(https://fxbug.dev/42107318) |
| /// |
| /// ## Return value |
| /// |
| /// `zx_system_get_physmem()` returns a number in bytes. |
| /// |
| /// ## Errors |
| /// |
| /// `zx_system_get_physmem()` cannot fail. |
| /// |
| /// ## Notes |
| /// |
| /// Currently the total size of physical memory cannot change during a run of |
| /// the system, only at boot time. This might change in the future. |
| /// |
| /// ## See also |
| /// |
| /// - [`zx_system_get_num_cpus()`] |
| /// |
| /// [`zx_system_get_num_cpus()`]: system_get_num_cpus.md |
| @vdsocall |
| strict GetPhysmem() -> (@wrapped_return struct { |
| physmem uint64; |
| }); |
| |
| // TODO(scottmg): "features" has a features attribute. I'm not sure if/how it's used. |
| /// ## Summary |
| /// |
| /// Get supported hardware capabilities. |
| /// |
| /// ## Declaration |
| /// |
| /// ```c |
| /// #include <zircon/syscalls.h> |
| /// |
| /// zx_status_t zx_system_get_features(uint32_t kind, uint32_t* features); |
| /// ``` |
| /// |
| /// ## Description |
| /// |
| /// `zx_system_get_features()` populates *features* with a bit mask of |
| /// hardware-specific features. *kind* indicates the specific type of features |
| /// to retrieve, e.g. `ZX_FEATURE_KIND_CPU`. The supported kinds and the meaning |
| /// of individual feature bits is hardware-dependent. `ZX_FEATURE_KIND_VM` is not |
| /// hardware-dependent and returns a bitset currently the only meaningful bit |
| /// is `ZX_VM_FEATURE_CAN_MAP_XOM` which is 1 if the system can map pages with |
| /// execute only permission. |
| /// |
| /// ## Rights |
| /// |
| /// TODO(https://fxbug.dev/42107318) |
| /// |
| /// ## Return value |
| /// |
| /// `zx_system_get_features()` returns `ZX_OK` on success. |
| /// |
| /// ## Errors |
| /// |
| /// `ZX_ERR_NOT_SUPPORTED` The requested feature kind is not available on this |
| /// platform. |
| /// |
| /// ## Notes |
| /// Refer to [Install Fuchsia on a device](/docs/development/hardware/README.md) |
| /// for supported processor architectures. |
| /// |
| /// Refer to [zircon/features.h](/zircon/system/public/zircon/features.h) for kinds |
| /// of features and individual feature bits. |
| /// |
| /// ## See also |
| /// |
| /// - [`zx_system_get_num_cpus()`] |
| /// - [`zx_system_get_physmem()`] |
| /// |
| /// [`zx_system_get_num_cpus()`]: system_get_num_cpus.md |
| /// [`zx_system_get_physmem()`]: system_get_physmem.md |
| @vdsocall |
| strict GetFeatures(struct { |
| kind uint32; |
| }) -> (struct { |
| features uint32; |
| }) error Status; |
| |
| /// ## Summary |
| /// |
| /// Retrieve a handle to a system event. |
| /// |
| /// ## Declaration |
| /// |
| /// ```c |
| /// #include <zircon/syscalls.h> |
| /// |
| /// zx_status_t zx_system_get_event(zx_handle_t root_job, |
| /// uint32_t kind, |
| /// zx_handle_t* event); |
| /// ``` |
| /// |
| /// ## Description |
| /// |
| /// *root_job* must be a handle to the root job of the system. |
| /// |
| /// *kind* must be one of the following: |
| /// |
| /// - `ZX_SYSTEM_EVENT_OUT_OF_MEMORY` - An *event* will be returned that will |
| /// assert ZX_EVENT_SIGNALED when the system is in an out-of-memory situation. |
| /// A process that is waiting on this event must quickly perform any important |
| /// shutdown work. It is unspecified how much memory is available at the time this |
| /// event is signaled, and unspecified how long the waiting process has to act |
| /// before the kernel starts terminating processes or starting a full system reboot. |
| /// |
| /// - `ZX_SYSTEM_EVENT_IMMINENT_OUT_OF_MEMORY` - An *event* will be returned that |
| /// will assert ZX_EVENT_SIGNALED when the system is nearing an out-of-memory |
| /// situation. This event is signaled a little earlier than the |
| /// ZX_SYSTEM_EVENT_OUT_OF_MEMORY event. The intent of this event is to allow the |
| /// waiter to gather diagnostics related to the impending |
| /// ZX_SYSTEM_EVENT_OUT_OF_MEMORY event, since it might be too late to do so |
| /// reliably when ZX_SYSTEM_EVENT_OUT_OF_MEMORY is signaled. |
| /// |
| /// - `ZX_SYSTEM_EVENT_MEMORY_PRESSURE_CRITICAL` - An *event* will be returned |
| /// that will assert ZX_EVENT_SIGNALED when available memory on the system is |
| /// critically low. The memory pressure level in this case is less severe than in |
| /// the case of ZX_SYSTEM_EVENT_OUT_OF_MEMORY. The exact amount of memory available |
| /// at the time the event is signaled is unspecified. |
| /// |
| /// - `ZX_SYSTEM_EVENT_MEMORY_PRESSURE_WARNING` - An *event* will be returned |
| /// that will assert ZX_EVENT_SIGNALED when available memory on the system is |
| /// approaching the critically low range. The memory pressure level in this case is |
| /// less severe than in the case of ZX_SYSTEM_EVENT_MEMORY_PRESSURE_CRITICAL. The |
| /// exact amount of memory available at the time the event is signaled is |
| /// unspecified. |
| /// |
| /// - `ZX_SYSTEM_EVENT_MEMORY_PRESSURE_NORMAL` - An *event* will be returned that |
| /// will assert ZX_EVENT_SIGNALED when available memory on the system is |
| /// healthy. The exact amount of memory available at the time the event is signaled |
| /// is unspecified. |
| /// |
| /// The kernel will assert ZX_EVENT_SIGNALED on these five events in the following |
| /// order of increasing severity: ZX_SYSTEM_EVENT_MEMORY_PRESSURE_NORMAL, |
| /// ZX_SYSTEM_EVENT_MEMORY_PRESSURE_WARNING, |
| /// ZX_SYSTEM_EVENT_MEMORY_PRESSURE_CRITICAL, ZX_SYSTEM_EVENT_IMMINENT_OUT_OF_MEMORY, |
| /// and ZX_SYSTEM_EVENT_OUT_OF_MEMORY. Exactly one of these events will assert |
| /// ZX_EVENT_SIGNALED at a given time. |
| /// |
| /// Both ZX_SYSTEM_EVENT_OUT_OF_MEMORY and ZX_SYSTEM_EVENT_MEMORY_PRESSURE_\* |
| /// retrieve events corresponding to system memory pressure levels, but there is a |
| /// key difference in the way these events are intended to be used. A process |
| /// waiting on the any of the ZX_SYSTEM_EVENT_MEMORY_PRESSURE_\* events must |
| /// undertake actions that free up memory and attempt to relieve the memory |
| /// pressure on the system. On the other hand, a process waiting on the |
| /// ZX_SYSTEM_EVENT_OUT_OF_MEMORY event must perform necessary actions in |
| /// preparation for a clean shutdown - at this point it is too late to attempt |
| /// recovery to a healthy memory pressure level. |
| /// |
| /// The ZX_SYSTEM_EVENT_IMMINENT_OUT_OF_MEMORY event can be seen as a companion event |
| /// for ZX_SYSTEM_EVENT_OUT_OF_MEMORY, which does not trigger memory reclamation |
| /// itself, but instead is used to capture memory diagnostics what will help debug |
| /// the closely following ZX_SYSTEM_EVENT_OUT_OF_MEMORY event (if there is one). |
| /// |
| /// ## Rights |
| /// |
| /// None. |
| /// |
| /// ## Return value |
| /// |
| /// `zx_system_get_event()` returns ZX_OK on success, and *event* will be a valid |
| /// handle, or an error code from below on failure. |
| /// |
| /// ## Errors |
| /// |
| /// `ZX_ERR_ACCESS_DENIED` The calling process' policy was invalid, the handle |
| /// *root_job* did not have ZX_RIGHT_MANAGE_PROCESS rights for *kind* |
| /// ZX_SYSTEM_EVENT_OUT_OF_MEMORY, *root_job* was not the |
| /// root job of the system. |
| /// |
| /// `ZX_ERR_INVALID_ARGS` *kind* was not one of the supported values specified |
| /// above. |
| strict GetEvent(resource struct { |
| root_job Handle:JOB; |
| kind uint32; |
| }) -> (resource struct { |
| event Handle:EVENT; |
| }) error Status; |
| |
| /// ## Summary |
| /// |
| /// Retrieve an event that becomes signaled if the memory stall level |
| /// exceeds a given threshold over a time window. |
| /// |
| /// ## Declaration |
| /// |
| /// ```c |
| /// #include <zircon/syscalls-next.h> |
| /// |
| /// zx_status_t zx_system_watch_memory_stall(zx_handle_t resource, |
| /// zx_system_memory_stall_type_t kind, |
| /// zx_duration_mono_t threshold, |
| /// zx_duration_mono_t window, |
| /// zx_handle_t* event); |
| /// ``` |
| /// |
| /// ## Description |
| /// |
| /// *resource* must be a handle to the stall resource. |
| /// |
| /// *kind* must be one of the following (see the `ZX_INFO_MEMORY_STALL` |
| /// in [`zx_object_get_info()`]): |
| /// |
| /// - `ZX_SYSTEM_MEMORY_STALL_SOME` |
| /// - `ZX_SYSTEM_MEMORY_STALL_FULL` |
| /// |
| /// *threshold* is minimum stall time that will trigger the signal. |
| /// |
| /// *window* is the duration of the observation window. |
| /// |
| /// It must hold that 0 < *threshold* <= *window* <= 10 seconds. |
| /// |
| /// The kernel will set (`ZX_EVENT_SIGNALED`) on the returned event if the |
| /// watched stall timer grew by at least *threshold* during the last |
| /// *window*, and clear it once it is no longer the case. |
| /// |
| /// ## Rights |
| /// |
| /// Caller job policy must allow `ZX_POL_NEW_EVENT`. |
| /// |
| /// ## Return value |
| /// |
| /// `zx_system_watch_memory_stall()` returns ZX_OK on success, and *event* |
| /// will be a valid handle, or an error code from below on failure. |
| /// |
| /// ## Errors |
| /// |
| /// `ZX_ERR_BAD_HANDLE` *resource* is not a valid handle. |
| /// |
| /// `ZX_ERR_WRONG_TYPE` *resource* is not resource kind |
| /// `ZX_RSRC_KIND_SYSTEM`. |
| /// |
| /// `ZX_ERR_OUT_OF_RANGE` *resource* is not in the range |
| /// [`ZX_RSRC_SYSTEM_STALL_BASE`, `ZX_RSRC_SYSTEM_STALL_BASE`+1). |
| /// |
| /// `ZX_ERR_INVALID_ARGS` *kind* is not one of the above values. |
| /// |
| /// `ZX_ERR_INVALID_ARGS` *threshold* or *window* are not in the allowed |
| /// range. |
| /// |
| /// `ZX_ERR_NO_MEMORY` Failure due to lack of memory. |
| /// There is no good way for userspace to handle this (unlikely) error. |
| /// In a future build this error will no longer occur. |
| /// |
| /// ## Notes |
| /// |
| /// Even the API defines *threshold* and *window* as the duration type (that |
| /// is, in nanoseconds), the kernel may not use the full precision of the |
| /// requested values. |
| /// |
| /// ## See also |
| /// |
| /// - `ZX_INFO_MEMORY_STALL` topic in [`zx_object_get_info()`] |
| /// |
| /// [`zx_object_get_info()`]: object_get_info.md |
| strict WatchMemoryStall(resource struct { |
| resource Handle:RESOURCE; |
| kind uint32; |
| threshold Duration; |
| window Duration; |
| }) -> (resource struct { |
| event Handle:EVENT; |
| }) error Status; |
| |
| /// ## Summary |
| /// |
| /// Set CPU performance parameters. |
| /// |
| /// ## Declaration |
| /// |
| /// ```c |
| /// #include <zircon/syscalls.h> |
| /// |
| /// zx_status_t zx_system_set_performance_info(zx_handle_t resource, |
| /// uint32_t topic, |
| /// const void* info, |
| /// size_t count); |
| /// ``` |
| /// |
| /// ## Description |
| /// |
| /// `zx_system_set_performance_info()` sets CPU performance parameters maintained by the kernel. The |
| /// *topic* parameter indicates what specific parameters are affected. |
| /// |
| /// *count* indicates the number of items to set. Topics may impose requirements on this value. |
| /// |
| /// *info* is a pointer to a buffer of sufficient size to accommodate *count* entries of the type |
| /// specified by *topic*. |
| /// |
| /// [TOC] |
| /// |
| /// ## TOPICS |
| /// |
| /// ### ZX_CPU_PERF_SCALE |
| /// |
| /// *count*: Must be non-zero and less than or equal to the number of logical CPUs in the system. |
| /// |
| /// *info* type: `zx_cpu_performance_scale_t[count]` |
| /// |
| /// An array of `zx_cpu_performance_scale_t` with entries specifying the performance scales (scalar |
| /// values representing relative operating points) of the respective logical CPUs in the system. Only |
| /// the CPUs specified in the array are updated, other CPUs are not affected. |
| /// |
| /// Logical CPU numbers must be stored in increasing order in the array. The scale values are unsigned |
| /// fixed point Q32.32 format. The scale values should indicate the relative performance of the CPUs, |
| /// with 1.0 corresponding to the highest operating point of the fastest CPU in the system. |
| /// |
| /// See [RFC 0123](/docs/contribute/governance/rfcs/0123_cpu_performance_info.md) |
| /// for further details on values and update protocols. |
| /// |
| /// ### ZX_CPU_PERF_LIMIT |
| /// |
| /// *count*: Must be non-zero and less than or equal to the number of logical CPUs in the system. |
| /// |
| /// *info* type: `zx_cpu_perf_limit_t[count]` |
| /// |
| /// An array of `zx_cpu_perf_limit_t` with entries specifying performance or power limits. These |
| /// values will be used by the scheduler to constrain the performance or power consumption of |
| /// each affected processor. |
| /// |
| /// ## Rights |
| /// |
| /// *resource* must have resource kind `ZX_RSRC_KIND_SYSTEM`. |
| /// |
| /// ## Return value |
| /// |
| /// `zx_system_set_performance_info()` returns `ZX_OK` on success. In the event of a failure, a |
| /// negative error value is returned. |
| /// |
| /// ## Errors |
| /// |
| /// `ZX_ERR_BAD_HANDLE` *resource* is not a valid handle. |
| /// |
| /// `ZX_ERR_WRONG_TYPE` *resource* is not resource kind `ZX_RSRC_KIND_SYSTEM`. |
| /// |
| /// `ZX_ERR_OUT_OF_RANGE` *resource* is not in the range [`ZX_RSRC_SYSTEM_CPU_BASE`, `ZX_RSRC_SYSTEM_CPU_BASE`+1). |
| /// |
| /// `ZX_ERR_INVALID_ARGS` *topic* or *info* have invalid values or *info* has out-of-order entries. |
| /// |
| /// `ZX_ERR_OUT_OF_RANGE` *count* or *info* entry values do not meet the requirements of the topic. |
| /// |
| /// `ZX_ERR_NO_MEMORY` Failure due to lack of memory. There is no good way for userspace to handle this (unlikely) error. In a future build this error will no longer occur. |
| /// |
| /// ## See also |
| /// |
| /// - [RFC 0123: CPU performance info syscalls](/docs/contribute/governance/rfcs/0123_cpu_performance_info.md) |
| /// |
| /// - [`zx_system_get_performance_info()`] |
| /// |
| /// [`zx_system_get_performance_info()`]: system_get_performance_info.md |
| strict SetPerformanceInfo(resource struct { |
| resource Handle:RESOURCE; |
| topic uint32; |
| // TODO(joshuaseaton): vector<byte> |
| @voidptr |
| info experimental_pointer<byte>; |
| count usize64; |
| }) -> () error Status; |
| |
| |
| /// ## Summary |
| /// |
| /// Updates the current processor power level state as observed by the kernel. |
| /// Note: Process must use next-vdso. |
| /// |
| /// |
| /// ## Declaration |
| /// |
| /// ```c |
| /// #include <zircon/syscalls-next.h> |
| /// |
| /// zx_status_t zx_system_set_processor_power_state(zx_handle_t port, |
| /// const zx_processor_power_state_t* power_state); |
| /// ``` |
| /// |
| /// ## Description |
| /// |
| /// `port` must be of type `ZX_OBJ_TYPE_PORT` and must be the same port where the power domain |
| /// transition requests are queued. The `port` is the capability for updating a specific |
| /// power domain. |
| /// |
| /// `power_state` is the power state of the domain provided in `power_state.target_id`. |
| /// |
| /// ## Rights |
| /// `port` must have `ZX_RIGHT_IO`. |
| /// |
| /// ## Errors |
| /// |
| /// `ZX_ERR_ACCESS_DENIED` if `port` is not the one registered with the power domain. |
| /// |
| /// `ZX_ERR_WRONG_TYPE` if `port` is not of type `ZX_OBJ_TYPE_PORT`. |
| /// |
| /// `ZX_ERR_INVALID_ARGS` if `power_state` transition is not present in the registered energy model. |
| /// |
| @next |
| strict SetProcessorPowerState(resource struct { |
| port Handle:PORT; |
| power_state ProcessorPowerState; |
| }) -> () error Status; |
| |
| /// ## Summary |
| /// |
| /// Get CPU performance parameters. |
| /// |
| /// ## Declaration |
| /// |
| /// ```c |
| /// #include <zircon/syscalls.h> |
| /// |
| /// zx_status_t zx_system_get_performance_info(zx_handle_t resource, |
| /// uint32_t topic, |
| /// size_t count, |
| /// void* info, |
| /// size_t* output_count); |
| /// ``` |
| /// |
| /// ## Description |
| /// |
| /// `zx_system_get_performance_info()` requests CPU performance parameters maintained by the kernel. The |
| /// *topic* parameter indicates what specific information is desired. |
| /// |
| /// *count* indicates the number of items to query. Topics may impose requirements on this value. |
| /// |
| /// *info* is a pointer to a buffer of sufficient size to accommodate *count* entries of the type |
| /// specified by *topic*. The values stored in this array are undefined if the syscall returns an error. |
| /// |
| /// *output_count* is updated with the number of info entries populated by the kernel on success. The |
| /// value stored in this memory location is undefined if the syscall returns an error. |
| /// |
| /// [TOC] |
| /// |
| /// ## TOPICS |
| /// |
| /// ### ZX_CPU_PERF_SCALE |
| /// |
| /// *count*: Must be equal to the number of logical CPUs in the system. |
| /// |
| /// *info* type: `zx_cpu_performance_scale_t[count]` |
| /// |
| /// Returns an array of `zx_cpu_performance_scale_t` with entries indicating the current performance |
| /// scales (scalar values representing relative operating points) of each logical CPU in the system. The |
| /// values reflect the most recent call to `zx_system_set_performance_info`, even if the values have not |
| /// yet taken effect. |
| /// |
| /// See [RFC 0123](/docs/contribute/governance/rfcs/0123_cpu_performance_info.md) |
| /// for further details on values and update protocols. |
| /// |
| /// ### ZX_CPU_DEFAULT_PERF_SCALE |
| /// |
| /// *count*: Must be equal to the number of logical CPUs in the system. |
| /// |
| /// *info* type: `zx_cpu_performance_scale_t[count]` |
| /// |
| /// Returns an array of `zx_cpu_performance_scale_t` with entries indicating the default performance |
| /// scales used during boot of each logical CPU in the system. |
| /// |
| /// See [RFC 0123](/docs/contribute/governance/rfcs/0123_cpu_performance_info.md) |
| /// for further details. |
| /// |
| /// ## Rights |
| /// |
| /// *resource* must have resource kind `ZX_RSRC_KIND_SYSTEM`. |
| /// |
| /// ## Return value |
| /// |
| /// `zx_system_get_performance_info()` returns `ZX_OK` on success. In the event of a failure, a |
| /// negative error value is returned. |
| /// |
| /// ## Errors |
| /// |
| /// `ZX_ERR_BAD_HANDLE` *resource* is not a valid handle. |
| /// |
| /// `ZX_ERR_WRONG_TYPE` *resource* is not resource kind `ZX_RSRC_KIND_SYSTEM`. |
| /// |
| /// `ZX_ERR_ACCESS_DENIED` *resource* is not in the range [`ZX_RSRC_SYSTEM_CPU_BASE`, `ZX_RSRC_SYSTEM_CPU_BASE`+1). |
| /// |
| /// `ZX_ERR_INVALID_ARGS` *topic*, *info*, or *output_count* have invalid values. |
| /// |
| /// `ZX_ERR_OUT_OF_RANGE` *count* does not meet the requirements of the topic. |
| /// |
| /// `ZX_ERR_NO_MEMORY` Failure due to lack of memory. There is no good way for userspace to handle this (unlikely) error. In a future build this error will no longer occur. |
| /// |
| /// ## See also |
| /// |
| /// - [RFC 0123: CPU performance info syscalls](/docs/contribute/governance/rfcs/0123_cpu_performance_info.md) |
| /// |
| /// - [`zx_system_set_performance_info()`] |
| /// |
| /// [`zx_system_set_performance_info()`]: system_set_performance_info.md |
| strict GetPerformanceInfo(resource struct { |
| resource Handle:RESOURCE; |
| topic uint32; |
| count usize64; |
| }) -> (resource struct { |
| // TODO(joshuaseaton): vector<byte> |
| @voidptr |
| info experimental_pointer<byte>; |
| output_count usize64; |
| }) error Status; |
| |
| /// ## Summary |
| /// |
| /// Soft reboot the system with a new kernel and bootimage. |
| /// |
| /// ## Declaration |
| /// |
| /// ```c |
| /// #include <zircon/syscalls.h> |
| /// |
| /// zx_status_t zx_system_mexec(zx_handle_t resource, |
| /// zx_handle_t kernel_vmo, |
| /// zx_handle_t bootimage_vmo); |
| /// ``` |
| /// |
| /// ## Description |
| /// |
| /// `zx_system_mexec()` accepts two vmo handles: *kernel_vmo* should contain a |
| /// kernel image and *bootimage_vmo* should contain an initrd whose address shall |
| /// be passed to the new kernel as a kernel argument. |
| /// |
| /// To supplant the running kernel, a *resource* of `ZX_RSRC_KIND_SYSTEM` with base |
| /// `ZX_RSRC_SYSTEM_MEXEC_BASE` must be supplied. |
| /// |
| /// Upon success, `zx_system_mexec()` shall supplant the currently running kernel |
| /// image with the kernel image contained within *kernel_vmo*, load the ramdisk |
| /// contained within *bootimage_vmo* to a location in physical memory and branch |
| /// directly into the new kernel while providing the address of the loaded initrd |
| /// to the new kernel. |
| /// |
| /// To use the `zx_system_mexec()` function, you must specify |
| /// `kernel.enable-debugging-syscalls=true` on the kernel command line. Otherwise, |
| /// the function returns `ZX_ERR_NOT_SUPPORTED`. |
| /// |
| /// ## Rights |
| /// |
| /// *resource* must have resource kind `ZX_RSRC_KIND_SYSTEM` with base |
| /// `ZX_RSRC_SYSTEM_MEXEC_BASE`. |
| /// |
| /// *kernel_vmo* must be of type `ZX_OBJ_TYPE_VMO` and have `ZX_RIGHT_READ`. |
| /// |
| /// *bootimage_vmo* must be of type `ZX_OBJ_TYPE_VMO` and have `ZX_RIGHT_READ`. |
| /// |
| /// ## Return value |
| /// |
| /// `zx_system_mexec()` shall not return upon success. |
| /// |
| /// `ZX_ERR_NOT_SUPPORTED` `kernel.enable-debugging-syscalls` is not set to `true` |
| /// on the kernel command line. |
| /// |
| /// ## See also |
| /// |
| /// - [`zx_system_mexec_payload_get()`] |
| /// |
| /// [`zx_system_mexec_payload_get()`]: system_mexec_payload_get.md |
| strict Mexec(resource struct { |
| resource Handle:RESOURCE; |
| kernel_vmo Handle:VMO; |
| bootimage_vmo Handle:VMO; |
| }) -> () error Status; |
| |
| /// ## Summary |
| /// |
| /// Return a ZBI containing ZBI entries necessary to boot this system. |
| /// |
| /// ## Declaration |
| /// |
| /// ```c |
| /// #include <zircon/syscalls.h> |
| /// |
| /// zx_status_t zx_system_mexec_payload_get(zx_handle_t resource, |
| /// void* buffer, |
| /// size_t buffer_size); |
| /// ``` |
| /// |
| /// ## Description |
| /// |
| /// `zx_system_mexec_payload_get()` accepts a resource handle and a |
| /// pointer/length corresponding to an output buffer. The head of the buffer is |
| /// overwritten with non-bootable ZBI containing a sequence of entries that should |
| /// be appended to a ZBI before passing that image to [`zx_system_mexec()`]; the |
| /// tail of the buffer is left untouched. |
| /// |
| /// *resource* must be of type `ZX_RSRC_KIND_SYSTEM` with base |
| /// `ZX_RSRC_SYSTEM_MEXEC_BASE`. |
| /// |
| /// *buffer* and *buffer_size* must point to a buffer that is no longer than 16KiB. |
| /// |
| /// To use the `zx_system_mexec_payload_get()` function, you must specify |
| /// `kernel.enable-debugging-syscalls=true` on the kernel command line. Otherwise, |
| /// the function returns `ZX_ERR_NOT_SUPPORTED`. |
| /// |
| /// ## Rights |
| /// |
| /// *resource* must have resource kind `ZX_RSRC_KIND_SYSTEM` with base |
| /// `ZX_RSRC_SYSTEM_MEXEC_BASE`. |
| /// |
| /// ## Return value |
| /// |
| /// `zx_system_mexec_payload_get()` returns `ZX_OK` on success. |
| /// |
| /// `ZX_ERR_NOT_SUPPORTED` `kernel.enable-debugging-syscalls` is not set to `true` |
| /// on the kernel command line. |
| /// |
| /// `ZX_ERR_BUFFER_TOO_SMALL` If the provided buffer is too small for the ZBI. |
| /// In this case, the caller is expected to make the syscall again with a larger |
| /// buffer. |
| /// |
| /// ## See also |
| /// |
| /// - [`zx_system_mexec()`] |
| /// |
| /// [`zx_system_mexec()`]: system_mexec.md |
| strict MexecPayloadGet(resource struct { |
| resource Handle:RESOURCE; |
| }) -> (struct { |
| @voidptr |
| buffer vector<byte>:MAX; |
| }) error Status; |
| |
| /// ## Summary |
| /// |
| /// TODO(https://fxbug.dev/42108078) |
| /// |
| /// ## Declaration |
| /// |
| /// ```c |
| /// #include <zircon/syscalls.h> |
| /// |
| /// zx_status_t zx_system_powerctl(zx_handle_t resource, |
| /// uint32_t cmd, |
| /// const zx_system_powerctl_arg_t* arg); |
| /// ``` |
| /// |
| /// ## Description |
| /// |
| /// `zx_system_powerctl` changes the power state of the system based on the value of |
| /// *cmd*. Zircon may not be able to put the system in a given power state, |
| /// depending on its level of support for the architecture being used. |
| /// |
| /// *arg* is an optional pointer to a struct which provides further information |
| /// about the command to be executed. |
| /// |
| /// ## COMMANDS |
| /// |
| /// ### ZX_SYSTEM_POWERCTL_ENABLE_ALL_CPUS |
| /// |
| /// Sets all processor cores as active. |
| /// |
| /// *arg* type: `n/a` |
| /// |
| /// ### ZX_SYSTEM_POWERCTL_DISABLE_ALL_CPUS_BUT_PRIMARY |
| /// |
| /// Set only the primary CPU as active. |
| /// |
| /// *arg* type: `n/a` |
| /// |
| /// ### ZX_SYSTEM_POWERCTL_ACPI_TRANSITION_S_STATE |
| /// |
| /// Only defined for x86-64, but is no longer supported. |
| /// |
| /// Returns `ZX_ERR_NOT_SUPPORTED`. |
| /// |
| /// ### ZX_SYSTEM_POWERCTL_X86_SET_PKG_PL1 |
| /// |
| /// Only defined for x86-64. |
| /// |
| /// Set CPU to power level 1. |
| /// |
| /// *arg* type: `zx_system_powerctl_arg_t` with only the `x86_power_limit` union |
| /// element considered valid. |
| /// |
| /// ```c |
| /// struct { |
| /// uint32_t power_limit; // PL1 value in milliwatts |
| /// uint32_t time_window; // PL1 time window in microseconds |
| /// uint8_t clamp; // PL1 clamping enable |
| /// uint8_t enable; // PL1 enable |
| /// uint8_t padding2[2]; |
| /// } x86_power_limit; |
| /// ``` |
| /// |
| /// ### ZX_SYSTEM_POWERCTL_REBOOT |
| /// |
| /// Restart the system, control should go through any relevant firmware and |
| /// bootloaders. |
| /// |
| /// *arg* type: `n/a` |
| /// |
| /// ### ZX_SYSTEM_POWERCTL_REBOOT_BOOTLOADER |
| /// |
| /// Restart the system, but stop in the bootloader instead of loading the operating |
| /// system. |
| /// |
| /// *arg* type: `n/a` |
| /// |
| /// ### ZX_SYSTEM_POWERCTL_REBOOT_RECOVERY |
| /// |
| /// Restart the system, but load the recovery operating system instead of the |
| /// primary OS. |
| /// |
| /// *arg* type: `n/a` |
| /// |
| /// ### ZX_SYSTEM_POWERCTL_SHUTDOWN |
| /// |
| /// Turn the system off. |
| /// |
| /// *arg* type: `n/a` |
| /// |
| /// ### ZX_SYSTEM_POWERCTL_ACK_KERNEL_INITIATED_REBOOT |
| /// |
| /// Used by userspace when it is ready for a reboot in response to a previous signal |
| /// from the kernel that the kernel wanted to reboot the system. |
| /// |
| /// *arg* type: `n/a` |
| /// |
| /// Returns `ZX_ERR_BAD_STATE` if the kernel has not previously signaled a desire |
| /// to reboot. |
| /// |
| /// ## Rights |
| /// |
| /// *resource* must have resource kind `ZX_RSRC_KIND_SYSTEM` with base `ZX_RSRC_SYSTEM_POWER_BASE`. |
| /// |
| /// ## Return value |
| /// |
| /// `ZX_OK` |
| /// |
| /// ## Errors |
| /// |
| /// Returns `ZX_ERR_INVALID_ARGS` when an unrecognized `cmd` value is supplied. |
| /// |
| /// ## See also |
| /// |
| /// TODO(https://fxbug.dev/42108078) |
| strict Powerctl(resource struct { |
| resource Handle:RESOURCE; |
| cmd uint32; |
| arg SystemPowerctlArg; |
| }) -> () error Status; |
| |
| /// # Summary |
| /// |
| /// TODO(https://fxbug.dev/42182545): Document exact behavior and interface as it iterates. |
| /// |
| /// ## Declaration |
| /// |
| /// ```c |
| /// #include <zircon/syscalls-next.h> |
| /// |
| /// zx_status_t zx_system_suspend_enter(zx_handle_t resource, |
| /// zx_instant_boot_t resume_deadline, |
| /// uint64_t options, |
| /// zx_wake_source_report_header_t* out_header, |
| /// zx_wake_source_report_entry_t* out_entries, |
| /// uint32_t num_entries, |
| /// uint32_t* actual_entries); |
| /// ``` |
| /// |
| /// ## Description |
| /// |
| /// `zx_system_suspend_enter` suspends task execution on all online processors until the |
| /// absolute time given by *resume_deadline*. Task execution is resumed on all online processors |
| /// and the call to `zx_system_suspend_enter` returns when the resume deadline expires. Offline |
| /// processor states are not affected. |
| /// |
| /// ### Wake Source Reports |
| /// |
| /// #### Requesting reports. |
| /// |
| /// In order to better understand the specific reasons why the system eventually left the |
| /// suspended state, the user may request a "wake source report". A wake source report consists |
| /// of two pieces, a header and a vector of wake source report entries. To request a report, |
| /// users must pass (at least) a pointer to a `zx_wake_source_report_header_t`. However |
| /// practically speaking, in order to be useful, they should also pass a buffer for receiving |
| /// report entries as well. In addition to a pointer to an array of |
| /// `zx_wake_source_report_entry_t`s, users must specify the length of the array using the |
| /// `num_entries` field, and also pass a pointer to a uint32_t (`actual_entries`) which will be |
| /// used to communicate the actual number of entries in the user's buffer that the kernel wrote |
| /// to. |
| /// |
| /// #### The life-cycle of a report entry. |
| /// |
| /// After a wake source in the system first becomes signaled, it will be reported to users the |
| /// next time `zx_system_suspend_enter` is called and a report is requested (and there is |
| /// sufficient space in the user provided entry buffer). Subsequent calls to |
| /// `zx_system_suspend_enter` will continue to report this same entry, but with the |
| /// `ZX_SYSTEM_WAKE_REPORT_ENTRY_FLAG_PREVIOUSLY_REPORTED` flag set, until the wake source |
| /// finally becomes acknowledged. Once signaled, wake sources will always be reported to users |
| /// at least once, even if they are acknowledged and re-signaled multiple times. Fields in the |
| /// entry structure will inform the user of: |
| /// |
| /// * The time at which the wake source was first signaled. |
| /// * The time at which the wake source was most recently signaled. |
| /// * The time at which the wake source was most recently acknowledged (if any). |
| /// * The number of times the wake source became signaled since the last report. |
| /// |
| /// The wake source will continue to be present in requested reports until it has finally been |
| /// both reported, and acknowledged. |
| /// |
| /// #### Requesting a report without suspending. |
| /// |
| /// Users who wish to obtain a wake source report, but do not actually wish to enter suspend, |
| /// may pass the `ZX_SYSTEM_SUSPEND_OPTION_REPORT_ONLY` flag in the options for the syscall. |
| /// The call will behave as it normally does, however it will make no attempt to suspend. |
| /// Instead, it will simply unwind from that point, generating a report on the way out. |
| /// |
| /// #### Discarding acknowledged events. |
| /// |
| /// Users who are not interested in receiving wake report entries for sources which |
| /// had been signaled, but already acknowledged before the call to |
| /// `zx_system_suspend_enter`, may pass the `ZX_SYSTEM_SUSPEND_OPTION_DISCARD` bit in |
| /// the options field when calling `zx_system_suspend_enter`. At the start of the |
| /// suspend operation, any wake report entry for a wake source which has not been |
| /// reported, but is currently not signaled (i.e. acknowledged) will be discarded as |
| /// if it had already been reported. |
| /// |
| /// #### Reporting the Deadline Wake Source. |
| /// |
| /// When a call to `zx_system_suspend_enter` is made with a `resume_deadline` in the |
| /// future, and the system enters suspend only to be woken by the deadline timer, |
| /// this will be reported to the user in the form of a special wake report entry. |
| /// This entry's `koid` field will contain the value `ZX_KOID_KERNEL`. This wake |
| /// source is automatically acknowledged by the kernel; no special user-mode actions |
| /// need to be taken to manage the deadline wake source. |
| /// |
| /// #### Destruction of wake sources. |
| /// |
| /// When a wake source created by user-mode is destroyed, it is implicitly |
| /// acknowledged so that it cannot prevent the system from entering suspend. |
| /// Additionally, if there is a wake report entry waiting to be reported for the |
| /// destroyed wake source, it will immediately be removed from the set of wake |
| /// report entries waiting to be reported. |
| /// |
| /// ## Return value |
| /// |
| /// `ZX_OK` when *resume_deadline* expires and the system resumes. |
| /// |
| /// ## Errors |
| /// |
| /// `ZX_ERR_BAD_HANDLE` *resource* is not a valid handle. |
| /// |
| /// `ZX_ERR_WRONG_TYPE` *resource* is not resource kind `ZX_RSRC_KIND_SYSTEM`. |
| /// |
| /// `ZX_ERR_OUT_OF_RANGE` *resource* is not in the range [`ZX_RSRC_SYSTEM_CPU_BASE`, |
| /// `ZX_RSRC_SYSTEM_CPU_BASE`+1). |
| /// |
| ///options uint64; |
| @next |
| strict SuspendEnter(resource struct { |
| resource Handle:RESOURCE; |
| resume_deadline InstantBoot; |
| options SystemSuspendOption; |
| @out |
| header WakeSourceReportHeader; |
| @out |
| @size32 |
| entries vector<WakeSourceReportEntry>:MAX; |
| }) -> (struct { |
| actual_entries uint32; |
| }) error Status; |
| |
| /// ## Summary |
| /// |
| /// Informs the kernel of the processor power levels within a given power |
| /// domain for energy-aware scheduling. |
| /// |
| /// ## Declaration |
| /// |
| /// ```c |
| /// #include <zircon/syscalls-next.h> |
| /// |
| /// zx_status_t zx_system_set_processor_power_domain( |
| /// zx_handle_t resource, |
| /// uint64_t options, |
| /// const zx_power_domain_t* power_domain, |
| /// zx_handle_t port, |
| /// const zx_processor_power_level_t* power_levels, |
| /// size_t num_power_levels, |
| /// const zx_processor_power_level_transition_t* transitions, |
| /// size_t num_transitions); |
| /// ``` |
| /// |
| /// ## Description |
| /// |
| /// Enables energy-aware scheduling for a given processor power domain. |
| /// |
| /// Power levels are implicitly enumerated as the indices of `power_levels`. |
| /// |
| /// There are no ordering restrictions on `transformations` and the power |
| /// levels they encode correspond to those defined by `power_levels`. An |
| /// absent transformation between levels is assumed to indicate that there |
| /// is no energy cost borne by perfoming it. |
| /// |
| /// The provided `power_domain_id` provides a unique identifier for requesting |
| /// operations on all CPUs that are part of `cpus` mask. Any power level |
| /// transition handler must understand the association. |
| /// |
| /// This syscall shall have "set or update" semantics, such that any new data |
| /// replaces exisitng one. This applies for `power_domain_id` and `cpus`. |
| /// |
| /// Provided `port` will be used for queueing power level transition requests. |
| /// |
| /// ## Rights |
| /// |
| /// `resource` must be of `ZX_RSRC_KIND_SYSTEM` kind and |
| /// `ZX_RSRC_SYSTEM_CPU_BASE` base. |
| /// |
| /// ## Return value |
| /// |
| /// `ZX_OK` is returned if and only if the processor power level domain |
| /// was successfully registered. |
| /// |
| /// ## Errors |
| /// |
| /// `ZX_ERR_ACCESS_DENIED` if `resource` is not a valid handle. |
| /// |
| /// `ZX_ERR_WRONG_TYPE` if `resource` is not a valid resource handle of |
| /// SYSTEM kind and CPU base. |
| /// |
| /// `ZX_ERR_OUT_OF_RANGE` if `num_power_levels` exceeds |
| /// `ZX_MAX_POWER_LEVELS` or `num_transitions` exceeds |
| /// `ZX_MAX_POWER_LEVEL_TRANSITIONS`. |
| /// |
| @next |
| strict SetProcessorPowerDomain(resource struct { |
| resource Handle:RESOURCE; |
| options uint64; |
| domain ProcessorPowerDomain; |
| port Handle:PORT; |
| power_levels vector<ProcessorPowerLevel>:MAX_POWER_LEVELS; |
| transitions vector<ProcessorPowerLevelTransition>:MAX_POWER_LEVEL_TRANSITIONS; |
| }) -> () error Status; |
| }; |