1#![expect(non_camel_case_types)]
8
9use zx_types::*;
10
11#[doc = " Dispatcher interface for performing asynchronous operations.\n There may be multiple implementations of this interface."]
12pub type async_dispatcher_t = async_dispatcher;
13#[doc = " Holds context for a bell trap and its handler.\n\n After successfully posting setting the trap, the client is responsible for retaining\n the structure in memory (and unmodified) until the guest has been destroyed or the\n dispatcher shuts down. There is no way to cancel a trap which has been set."]
14pub type async_guest_bell_trap_t = async_guest_bell_trap;
15#[doc = " Holds context for an asynchronous wait operation and its handler.\n\n After successfully beginning the wait, the client is responsible for retaining\n the structure in memory (and unmodified) until the wait's handler runs, the wait\n is successfully canceled, or the dispatcher shuts down. Thereafter, the wait\n may be started begun or destroyed."]
16pub type async_wait_t = async_wait;
17#[doc = " Holds context for a task and its handler.\n\n After successfully posting the task, the client is responsible for retaining\n the structure in memory (and unmodified) until the task's handler runs, the task\n is successfully canceled, or the dispatcher shuts down. Thereafter, the task\n may be posted again or destroyed."]
18pub type async_task_t = async_task;
19#[doc = " Holds content for a packet receiver and its handler.\n\n After successfully queuing packets to the receiver, the client is responsible\n for retaining the structure in memory (and unmodified) until all packets have\n been received by the handler or the dispatcher shuts down. There is no way\n to cancel a packet which has been queued.\n\n Multiple packets may be delivered to the same receiver concurrently."]
20pub type async_receiver_t = async_receiver;
21#[doc = " Similar to async_wait, but holds state for an interrupt."]
22pub type async_irq_t = async_irq;
23#[doc = " Holds content for a paged request packet receiver and its handler.\n\n The client is responsible for retaining the structure in memory\n (and unmodified) until all packets have been received by the handler or the\n dispatcher shuts down."]
24pub type async_paged_vmo_t = async_paged_vmo;
25#[doc = " A dispatcher-specific sequence identifier, which identifies a set of actions\n with a total ordering of execution: each subsequent action will always\n observe side-effects from previous actions, if the thread(s) performing those\n actions have the same sequence identifier.\n\n For example, a dispatcher backed by a thread pool may choose to implement\n sequences by acquiring a sequence-specific lock before running any actions\n from that sequence, ensuring mutual exclusion within each sequence."]
26pub type async_sequence_id_t = async_sequence_id;
27#[doc = " Private state owned by the asynchronous dispatcher.\n This allows the dispatcher to associate a small amount of state with pending\n asynchronous operations without having to allocate additional heap storage of\n its own.\n\n Clients must initialize the contents of this structure to zero using\n |ASYNC_STATE_INIT| or with calloc, memset, or a similar means."]
28#[repr(C)]
29#[derive(Debug, Default, Copy, Clone)]
30pub struct async_state_t {
31 pub reserved: [usize; 2usize],
32}
33#[allow(clippy::unnecessary_operation, clippy::identity_op)]
34const _: () = {
35 ["Size of async_state_t"][::core::mem::size_of::<async_state_t>() - 16usize];
36 ["Alignment of async_state_t"][::core::mem::align_of::<async_state_t>() - 8usize];
37 ["Offset of field: async_state_t::reserved"]
38 [::core::mem::offset_of!(async_state_t, reserved) - 0usize];
39};
40#[doc = " Asynchronous dispatcher interface.\n\n Clients should not call into this interface directly: use the wrapper functions\n declared in other header files, such as |async_begin_wait()| in <lib/async/wait.h>.\n See the documentation of those functions for details about each method's purpose\n and behavior.\n\n This interface consists of several groups of methods:\n\n - Timing: |now|\n - Waiting for signals: |begin_wait|, |cancel_wait|\n - Posting tasks: |post_task|, |cancel_task|\n - Queuing packets: |queue_packet|\n - Virtual machine operations: |set_guest_bell_trap|\n\n To preserve binary compatibility, each successive version of this interface\n is guaranteed to be backwards-compatible with clients of earlier versions.\n New methods must only be added by extending the structure at the end and\n declaring a new version number. Do not reorder the declarations or modify\n existing versions.\n\n Implementations of this interface must provide valid (non-null) function pointers\n for every method declared in the interface version they support. Unsupported\n methods must return |ZX_ERR_NOT_SUPPORTED| and have no other side-effects.\n Furthermore, if an implementation supports one method of a group, such as |begin_wait|,\n then it must also support the other methods of the group, such as |cancel_wait|.\n\n Many clients assume that the dispatcher interface is fully implemented and may\n fail to work with dispatchers that do not support the methods they need.\n Therefore general-purpose dispatcher implementations are encouraged to support\n the whole interface to ensure broad compatibility."]
41pub type async_ops_version_t = u32;
42pub const ASYNC_OPS_V1: async_ops_version_t = 1;
43pub const ASYNC_OPS_V2: async_ops_version_t = 2;
44pub const ASYNC_OPS_V3: async_ops_version_t = 3;
45pub const ASYNC_OPS_V4: async_ops_version_t = 4;
46#[repr(C)]
47#[derive(Debug, Default, Copy, Clone)]
48pub struct async_ops {
49 #[doc = " The interface version number, e.g. |ASYNC_OPS_V1|."]
50 pub version: async_ops_version_t,
51 #[doc = " Reserved for future expansion, set to zero."]
52 pub reserved: u32,
53 pub v1: async_ops_v1,
54 pub v2: async_ops_v2,
55 pub v3: async_ops_v3,
56 pub v4: async_ops_v4,
57}
58#[doc = " Operations supported by |ASYNC_OPS_V1|."]
59#[repr(C)]
60#[derive(Debug, Default, Copy, Clone)]
61pub struct async_ops_v1 {
62 #[doc = " See |async_now()| for details."]
63 pub now: ::core::option::Option<
64 unsafe extern "C" fn(dispatcher: *mut async_dispatcher_t) -> zx_time_t,
65 >,
66 #[doc = " See |async_begin_wait()| for details."]
67 pub begin_wait: ::core::option::Option<
68 unsafe extern "C" fn(
69 dispatcher: *mut async_dispatcher_t,
70 wait: *mut async_wait_t,
71 ) -> zx_status_t,
72 >,
73 #[doc = " See |async_cancel_wait()| for details."]
74 pub cancel_wait: ::core::option::Option<
75 unsafe extern "C" fn(
76 dispatcher: *mut async_dispatcher_t,
77 wait: *mut async_wait_t,
78 ) -> zx_status_t,
79 >,
80 #[doc = " See |async_post_task()| for details."]
81 pub post_task: ::core::option::Option<
82 unsafe extern "C" fn(
83 dispatcher: *mut async_dispatcher_t,
84 task: *mut async_task_t,
85 ) -> zx_status_t,
86 >,
87 #[doc = " See |async_cancel_task()| for details."]
88 pub cancel_task: ::core::option::Option<
89 unsafe extern "C" fn(
90 dispatcher: *mut async_dispatcher_t,
91 task: *mut async_task_t,
92 ) -> zx_status_t,
93 >,
94 #[doc = " See |async_queue_packet()| for details."]
95 pub queue_packet: ::core::option::Option<
96 unsafe extern "C" fn(
97 dispatcher: *mut async_dispatcher_t,
98 receiver: *mut async_receiver_t,
99 data: *const zx_packet_user_t,
100 ) -> zx_status_t,
101 >,
102 #[doc = " See |async_set_guest_bell_trap()| for details."]
103 pub set_guest_bell_trap: ::core::option::Option<
104 unsafe extern "C" fn(
105 dispatcher: *mut async_dispatcher_t,
106 trap: *mut async_guest_bell_trap_t,
107 guest: zx_handle_t,
108 addr: zx_vaddr_t,
109 length: usize,
110 ) -> zx_status_t,
111 >,
112}
113#[allow(clippy::unnecessary_operation, clippy::identity_op)]
114const _: () = {
115 ["Size of async_ops_v1"][::core::mem::size_of::<async_ops_v1>() - 56usize];
116 ["Alignment of async_ops_v1"][::core::mem::align_of::<async_ops_v1>() - 8usize];
117 ["Offset of field: async_ops_v1::now"][::core::mem::offset_of!(async_ops_v1, now) - 0usize];
118 ["Offset of field: async_ops_v1::begin_wait"]
119 [::core::mem::offset_of!(async_ops_v1, begin_wait) - 8usize];
120 ["Offset of field: async_ops_v1::cancel_wait"]
121 [::core::mem::offset_of!(async_ops_v1, cancel_wait) - 16usize];
122 ["Offset of field: async_ops_v1::post_task"]
123 [::core::mem::offset_of!(async_ops_v1, post_task) - 24usize];
124 ["Offset of field: async_ops_v1::cancel_task"]
125 [::core::mem::offset_of!(async_ops_v1, cancel_task) - 32usize];
126 ["Offset of field: async_ops_v1::queue_packet"]
127 [::core::mem::offset_of!(async_ops_v1, queue_packet) - 40usize];
128 ["Offset of field: async_ops_v1::set_guest_bell_trap"]
129 [::core::mem::offset_of!(async_ops_v1, set_guest_bell_trap) - 48usize];
130};
131#[repr(C)]
132#[derive(Debug, Default, Copy, Clone)]
133pub struct async_ops_v2 {
134 pub bind_irq: ::core::option::Option<
135 unsafe extern "C" fn(
136 dispatcher: *mut async_dispatcher_t,
137 irq: *mut async_irq_t,
138 ) -> zx_status_t,
139 >,
140 pub unbind_irq: ::core::option::Option<
141 unsafe extern "C" fn(
142 dispatcher: *mut async_dispatcher_t,
143 irq: *mut async_irq_t,
144 ) -> zx_status_t,
145 >,
146 pub create_paged_vmo: ::core::option::Option<
147 unsafe extern "C" fn(
148 dispatcher: *mut async_dispatcher_t,
149 paged_vmo: *mut async_paged_vmo_t,
150 options: u32,
151 pager: zx_handle_t,
152 vmo_size: u64,
153 vmo_out: *mut zx_handle_t,
154 ) -> zx_status_t,
155 >,
156 pub detach_paged_vmo: ::core::option::Option<
157 unsafe extern "C" fn(
158 dispatcher: *mut async_dispatcher_t,
159 paged_vmo: *mut async_paged_vmo_t,
160 ) -> zx_status_t,
161 >,
162}
163#[allow(clippy::unnecessary_operation, clippy::identity_op)]
164const _: () = {
165 ["Size of async_ops_v2"][::core::mem::size_of::<async_ops_v2>() - 32usize];
166 ["Alignment of async_ops_v2"][::core::mem::align_of::<async_ops_v2>() - 8usize];
167 ["Offset of field: async_ops_v2::bind_irq"]
168 [::core::mem::offset_of!(async_ops_v2, bind_irq) - 0usize];
169 ["Offset of field: async_ops_v2::unbind_irq"]
170 [::core::mem::offset_of!(async_ops_v2, unbind_irq) - 8usize];
171 ["Offset of field: async_ops_v2::create_paged_vmo"]
172 [::core::mem::offset_of!(async_ops_v2, create_paged_vmo) - 16usize];
173 ["Offset of field: async_ops_v2::detach_paged_vmo"]
174 [::core::mem::offset_of!(async_ops_v2, detach_paged_vmo) - 24usize];
175};
176#[repr(C)]
177#[derive(Debug, Default, Copy, Clone)]
178pub struct async_ops_v3 {
179 #[doc = " See |async_get_sequence_id()| for details."]
180 pub get_sequence_id: ::core::option::Option<
181 unsafe extern "C" fn(
182 dispatcher: *mut async_dispatcher_t,
183 out_sequence_id: *mut async_sequence_id_t,
184 out_error: *mut *const ::core::ffi::c_char,
185 ) -> zx_status_t,
186 >,
187 #[doc = " See |async_check_sequence_id()| for details."]
188 pub check_sequence_id: ::core::option::Option<
189 unsafe extern "C" fn(
190 dispatcher: *mut async_dispatcher_t,
191 sequence_id: async_sequence_id_t,
192 out_error: *mut *const ::core::ffi::c_char,
193 ) -> zx_status_t,
194 >,
195}
196#[allow(clippy::unnecessary_operation, clippy::identity_op)]
197const _: () = {
198 ["Size of async_ops_v3"][::core::mem::size_of::<async_ops_v3>() - 16usize];
199 ["Alignment of async_ops_v3"][::core::mem::align_of::<async_ops_v3>() - 8usize];
200 ["Offset of field: async_ops_v3::get_sequence_id"]
201 [::core::mem::offset_of!(async_ops_v3, get_sequence_id) - 0usize];
202 ["Offset of field: async_ops_v3::check_sequence_id"]
203 [::core::mem::offset_of!(async_ops_v3, check_sequence_id) - 8usize];
204};
205#[repr(C)]
206#[derive(Debug, Default, Copy, Clone)]
207pub struct async_ops_v4 {
208 #[doc = " See |async_acquire_shared_ref| for details."]
209 pub acquire_shared_ref: ::core::option::Option<
210 unsafe extern "C" fn(dispatcher: *mut async_dispatcher_t) -> zx_status_t,
211 >,
212 #[doc = " See |async_release_shared_ref| for details."]
213 pub release_shared_ref: ::core::option::Option<
214 unsafe extern "C" fn(dispatcher: *mut async_dispatcher_t) -> zx_status_t,
215 >,
216}
217#[allow(clippy::unnecessary_operation, clippy::identity_op)]
218const _: () = {
219 ["Size of async_ops_v4"][::core::mem::size_of::<async_ops_v4>() - 16usize];
220 ["Alignment of async_ops_v4"][::core::mem::align_of::<async_ops_v4>() - 8usize];
221 ["Offset of field: async_ops_v4::acquire_shared_ref"]
222 [::core::mem::offset_of!(async_ops_v4, acquire_shared_ref) - 0usize];
223 ["Offset of field: async_ops_v4::release_shared_ref"]
224 [::core::mem::offset_of!(async_ops_v4, release_shared_ref) - 8usize];
225};
226#[allow(clippy::unnecessary_operation, clippy::identity_op)]
227const _: () = {
228 ["Size of async_ops"][::core::mem::size_of::<async_ops>() - 128usize];
229 ["Alignment of async_ops"][::core::mem::align_of::<async_ops>() - 8usize];
230 ["Offset of field: async_ops::version"][::core::mem::offset_of!(async_ops, version) - 0usize];
231 ["Offset of field: async_ops::reserved"][::core::mem::offset_of!(async_ops, reserved) - 4usize];
232 ["Offset of field: async_ops::v1"][::core::mem::offset_of!(async_ops, v1) - 8usize];
233 ["Offset of field: async_ops::v2"][::core::mem::offset_of!(async_ops, v2) - 64usize];
234 ["Offset of field: async_ops::v3"][::core::mem::offset_of!(async_ops, v3) - 96usize];
235 ["Offset of field: async_ops::v4"][::core::mem::offset_of!(async_ops, v4) - 112usize];
236};
237pub type async_ops_t = async_ops;
238#[repr(C)]
239#[derive(Debug, Copy, Clone)]
240pub struct async_dispatcher {
241 pub ops: *const async_ops_t,
242}
243#[allow(clippy::unnecessary_operation, clippy::identity_op)]
244const _: () = {
245 ["Size of async_dispatcher"][::core::mem::size_of::<async_dispatcher>() - 8usize];
246 ["Alignment of async_dispatcher"][::core::mem::align_of::<async_dispatcher>() - 8usize];
247 ["Offset of field: async_dispatcher::ops"]
248 [::core::mem::offset_of!(async_dispatcher, ops) - 0usize];
249};
250impl Default for async_dispatcher {
251 fn default() -> Self {
252 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
253 unsafe {
254 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
255 s.assume_init()
256 }
257 }
258}
259unsafe extern "C" {
260 #[doc = " If supported, acquires a shared dispatcher reference for this dispatcher.\n\n If successful, the internal reference count of the dispatcher object will be incremented so that\n it will not be deallocated for any other reason than the outstanding refcount reaching zero. If\n it fails there will be no guarantees about the lifetime of the dispatcher object.\n\n Note that this will not prevent the dispatcher from shutting down. Calls to dispatcher methods\n after shutting down will behave as if the dispatcher is still shutting down.\n\n The client MUST call |async_release_shared_ref| on the returned pointer when it is no\n longer in use if this call succeeds. Not doing so will result in memory leaks.\n\n Returns |ZX_OK| if a shared dispatcher object's reference count has been incremented and its\n memory won't be released before you have called a corresponding |async_release_shared_ref|.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."]
261 pub fn async_acquire_shared_ref(dispatcher: *mut async_dispatcher_t) -> zx_status_t;
262}
263unsafe extern "C" {
264 #[doc = " Releases a shared dispatcher reference for this dispatcher.\n\n The caller must call this to release a shared dispatcher object acquired by\n |async_acquire_shared_ref|. In general, this should always return ZX_OK if the\n api is used correctly.\n\n Returns |ZX_OK| if the dispatcher has been successfully released.\n Returns |ZX_ERR_NOT_SUPPORTED| if you have tried to call this on a dispatcher that\n does not support having shared references."]
265 pub fn async_release_shared_ref(dispatcher: *mut async_dispatcher_t) -> zx_status_t;
266}
267#[doc = " Handles interrupt.\n\n The |status| is |ZX_OK| if the IRQ was signalled.\n The |status| is |ZX_ERR_CANCELED| if the dispatcher was shut down before\n the task's handler ran or the task was canceled."]
268pub type async_irq_handler_t = ::core::option::Option<
269 unsafe extern "C" fn(
270 dispatcher: *mut async_dispatcher_t,
271 irq: *mut async_irq_t,
272 status: zx_status_t,
273 signal: *const zx_packet_interrupt_t,
274 ),
275>;
276#[doc = " Similar to async_wait, but holds state for an interrupt."]
277#[repr(C)]
278pub struct async_irq {
279 #[doc = " Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|."]
280 pub state: async_state_t,
281 #[doc = " The wait's handler function."]
282 pub handler: async_irq_handler_t,
283 #[doc = " The object to wait for signals on."]
284 pub object: zx_handle_t,
285}
286#[allow(clippy::unnecessary_operation, clippy::identity_op)]
287const _: () = {
288 ["Size of async_irq"][::core::mem::size_of::<async_irq>() - 32usize];
289 ["Alignment of async_irq"][::core::mem::align_of::<async_irq>() - 8usize];
290 ["Offset of field: async_irq::state"][::core::mem::offset_of!(async_irq, state) - 0usize];
291 ["Offset of field: async_irq::handler"][::core::mem::offset_of!(async_irq, handler) - 16usize];
292 ["Offset of field: async_irq::object"][::core::mem::offset_of!(async_irq, object) - 24usize];
293};
294impl Default for async_irq {
295 fn default() -> Self {
296 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
297 unsafe {
298 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
299 s.assume_init()
300 }
301 }
302}
303impl ::core::fmt::Debug for async_irq {
304 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
305 write!(f, "async_irq {{ state: {:?}, handler: {:?} }}", self.state, self.handler)
306 }
307}
308unsafe extern "C" {
309 #[doc = " Begins asynchronously waiting on an IRQ specified in |irq|.\n Invokes the handler when the wait completes.\n The irq's handler will be invoked once for each interrupt packet received,\n until the irq object is unbound with |async_unbind_irq| or the dispatcher is\n shut down.\n When the dispatcher is shutting down (being destroyed), if the irq has not\n been unbound, the handlers of all remaining irqs will be invoked with a\n status of |ZX_ERR_CANCELED|.\n\n Returns |ZX_OK| if the wait was successfully begun.\n Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."]
310 pub fn async_bind_irq(
311 dispatcher: *mut async_dispatcher_t,
312 irq: *mut async_irq_t,
313 ) -> zx_status_t;
314}
315unsafe extern "C" {
316 #[doc = " Unbinds the IRQ associated with |irq|.\n\n If successful, the IRQ will be unbound from the async loop and no further\n handler callbacks will be called.\n\n Returns |ZX_OK| if the IRQ has been successfully unbound.\n Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."]
317 pub fn async_unbind_irq(
318 dispatcher: *mut async_dispatcher_t,
319 irq: *mut async_irq_t,
320 ) -> zx_status_t;
321}
322#[doc = " Handles port packets containing page requests.\n\n The |status| is |ZX_OK| if the packet was successfully delivered and |request|\n contains the information from the packet, otherwise |request| is null.\n The |status| is |ZX_ERR_CANCELED| if the dispatcher was shut down."]
323pub type async_paged_vmo_handler_t = ::core::option::Option<
324 unsafe extern "C" fn(
325 dispatcher: *mut async_dispatcher_t,
326 paged_vmo: *mut async_paged_vmo_t,
327 status: zx_status_t,
328 request: *const zx_packet_page_request_t,
329 ),
330>;
331#[doc = " Holds content for a paged request packet receiver and its handler.\n\n The client is responsible for retaining the structure in memory\n (and unmodified) until all packets have been received by the handler or the\n dispatcher shuts down."]
332#[repr(C)]
333pub struct async_paged_vmo {
334 #[doc = " Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|."]
335 pub state: async_state_t,
336 #[doc = " The handler to invoke when a packet is received."]
337 pub handler: async_paged_vmo_handler_t,
338 #[doc = " The associated pager when creating the VMO."]
339 pub pager: zx_handle_t,
340 #[doc = " The VMO for this request."]
341 pub vmo: zx_handle_t,
342}
343#[allow(clippy::unnecessary_operation, clippy::identity_op)]
344const _: () = {
345 ["Size of async_paged_vmo"][::core::mem::size_of::<async_paged_vmo>() - 32usize];
346 ["Alignment of async_paged_vmo"][::core::mem::align_of::<async_paged_vmo>() - 8usize];
347 ["Offset of field: async_paged_vmo::state"]
348 [::core::mem::offset_of!(async_paged_vmo, state) - 0usize];
349 ["Offset of field: async_paged_vmo::handler"]
350 [::core::mem::offset_of!(async_paged_vmo, handler) - 16usize];
351 ["Offset of field: async_paged_vmo::pager"]
352 [::core::mem::offset_of!(async_paged_vmo, pager) - 24usize];
353 ["Offset of field: async_paged_vmo::vmo"]
354 [::core::mem::offset_of!(async_paged_vmo, vmo) - 28usize];
355};
356impl Default for async_paged_vmo {
357 fn default() -> Self {
358 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
359 unsafe {
360 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
361 s.assume_init()
362 }
363 }
364}
365impl ::core::fmt::Debug for async_paged_vmo {
366 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
367 write!(f, "async_paged_vmo {{ state: {:?}, handler: {:?} }}", self.state, self.handler)
368 }
369}
370unsafe extern "C" {
371 #[doc = " Create a pager owned VMO.\n\n Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n Other error values are possible. See the documentation for\n |zx_pager_create_vmo()|."]
372 pub fn async_create_paged_vmo(
373 dispatcher: *mut async_dispatcher_t,
374 paged_vmo: *mut async_paged_vmo_t,
375 options: u32,
376 pager: zx_handle_t,
377 vmo_size: u64,
378 vmo_out: *mut zx_handle_t,
379 ) -> zx_status_t;
380}
381unsafe extern "C" {
382 #[doc = " Detach ownership of VMO from pager.\n\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n Returns |ZX_ERR_BAD_HANDLE| if pager or vmo is not a valid handle.\n Returns |ZX_ERR_WRONG_TYPE| if pager is not a pager handle or vmo is not a vmo handle.\n Returns |ZX_ERR_INVALID_ARGS| if vmo is not a vmo created from pager.\n Other error values are possible. See the documentation for\n |zx_detach_paged_vmo()|."]
383 pub fn async_detach_paged_vmo(
384 dispatcher: *mut async_dispatcher_t,
385 paged_vmo: *mut async_paged_vmo_t,
386 ) -> zx_status_t;
387}
388#[doc = " Handles receipt of packets containing user supplied data.\n\n The |status| is |ZX_OK| if the packet was successfully delivered and |data|\n contains the information from the packet, otherwise |data| is null."]
389pub type async_receiver_handler_t = ::core::option::Option<
390 unsafe extern "C" fn(
391 dispatcher: *mut async_dispatcher_t,
392 receiver: *mut async_receiver_t,
393 status: zx_status_t,
394 data: *const zx_packet_user_t,
395 ),
396>;
397#[doc = " Holds content for a packet receiver and its handler.\n\n After successfully queuing packets to the receiver, the client is responsible\n for retaining the structure in memory (and unmodified) until all packets have\n been received by the handler or the dispatcher shuts down. There is no way\n to cancel a packet which has been queued.\n\n Multiple packets may be delivered to the same receiver concurrently."]
398#[repr(C)]
399#[derive(Debug, Default, Copy, Clone)]
400pub struct async_receiver {
401 #[doc = " Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|."]
402 pub state: async_state_t,
403 #[doc = " The handler to invoke when a packet is received."]
404 pub handler: async_receiver_handler_t,
405}
406#[allow(clippy::unnecessary_operation, clippy::identity_op)]
407const _: () = {
408 ["Size of async_receiver"][::core::mem::size_of::<async_receiver>() - 24usize];
409 ["Alignment of async_receiver"][::core::mem::align_of::<async_receiver>() - 8usize];
410 ["Offset of field: async_receiver::state"]
411 [::core::mem::offset_of!(async_receiver, state) - 0usize];
412 ["Offset of field: async_receiver::handler"]
413 [::core::mem::offset_of!(async_receiver, handler) - 16usize];
414};
415unsafe extern "C" {
416 #[doc = " Enqueues a packet of data for delivery to a receiver.\n\n The |data| will be copied into the packet. May be NULL to create a\n zero-initialized packet payload.\n\n Returns |ZX_OK| if the packet was successfully enqueued.\n Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."]
417 pub fn async_queue_packet(
418 dispatcher: *mut async_dispatcher_t,
419 receiver: *mut async_receiver_t,
420 data: *const zx_packet_user_t,
421 ) -> zx_status_t;
422}
423#[doc = " A dispatcher-specific sequence identifier, which identifies a set of actions\n with a total ordering of execution: each subsequent action will always\n observe side-effects from previous actions, if the thread(s) performing those\n actions have the same sequence identifier.\n\n For example, a dispatcher backed by a thread pool may choose to implement\n sequences by acquiring a sequence-specific lock before running any actions\n from that sequence, ensuring mutual exclusion within each sequence."]
424#[repr(C)]
425#[derive(Debug, Default, Copy, Clone)]
426pub struct async_sequence_id {
427 pub value: u64,
428}
429#[allow(clippy::unnecessary_operation, clippy::identity_op)]
430const _: () = {
431 ["Size of async_sequence_id"][::core::mem::size_of::<async_sequence_id>() - 8usize];
432 ["Alignment of async_sequence_id"][::core::mem::align_of::<async_sequence_id>() - 8usize];
433 ["Offset of field: async_sequence_id::value"]
434 [::core::mem::offset_of!(async_sequence_id, value) - 0usize];
435};
436unsafe extern "C" {
437 #[doc = " Gets the dispatcher-specific sequence identifier of the currently executing\n task.\n\n If the execution context of the calling thread is associated with a sequence,\n the dispatcher should populate the sequence identifier representing the\n current sequence. Otherwise, it should return an error code detailed below.\n\n Returns |ZX_OK| if the sequence identifier was successfully obtained.\n Returns |ZX_ERR_INVALID_ARGS| if the dispatcher supports sequences, but the\n calling thread is not executing a task managed by the dispatcher.\n Returns |ZX_ERR_WRONG_TYPE| if the calling thread is executing a task\n managed by the dispatcher, but that task is not part of a sequence.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n |out_error| will not be mutated when the return value is |ZX_OK|. Otherwise,\n it will be set to a NULL-terminated detailed explanation of the error, which\n may suggest corrective actions that are specific to that asynchronous\n runtime. If set, the error string will have static storage duration (for\n example, an implementation may return string literals).\n\n This operation is thread-safe."]
438 pub fn async_get_sequence_id(
439 dispatcher: *mut async_dispatcher_t,
440 out_sequence_id: *mut async_sequence_id_t,
441 out_error: *mut *const ::core::ffi::c_char,
442 ) -> zx_status_t;
443}
444unsafe extern "C" {
445 #[doc = " Checks that the the dispatcher-specific sequence identifier of the currently\n executing task is equal to |sequence_id|.\n\n If the sequence identifier of the calling thread cannot be successfully\n obtained, it should return an error code detailed below:\n\n - Returns |ZX_ERR_INVALID_ARGS| if the dispatcher supports sequences, but the\n calling thread is not executing a task managed by the dispatcher.\n - Returns |ZX_ERR_WRONG_TYPE| if the calling thread is executing a task\n managed by the dispatcher, but that task is not part of a sequence.\n - Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n Otherwise, the dispatcher should check that the sequence identifier\n representing the current sequence equals to |sequence_id|:\n\n - Returns |ZX_OK| if the sequence identifiers are equal.\n - Returns |ZX_ERR_OUT_OF_RANGE| if the sequence identifiers are not equal.\n\n |out_error| will not be mutated when the return value is |ZX_OK|. Otherwise,\n it will be set to a NULL-terminated detailed explanation of the error, which\n may suggest corrective actions that are specific to that asynchronous\n runtime. If set, the error string will have static storage duration (for\n example, an implementation may return string literals).\n\n This operation is thread-safe."]
446 pub fn async_check_sequence_id(
447 dispatcher: *mut async_dispatcher_t,
448 sequence_id: async_sequence_id_t,
449 out_error: *mut *const ::core::ffi::c_char,
450 ) -> zx_status_t;
451}
452#[doc = " Handles execution of a posted task.\n\n The |status| is |ZX_OK| if the task's deadline elapsed and the task should run.\n The |status| is |ZX_ERR_CANCELED| if the dispatcher was shut down before\n the task's handler ran."]
453pub type async_task_handler_t = ::core::option::Option<
454 unsafe extern "C" fn(
455 dispatcher: *mut async_dispatcher_t,
456 task: *mut async_task_t,
457 status: zx_status_t,
458 ),
459>;
460#[doc = " Holds context for a task and its handler.\n\n After successfully posting the task, the client is responsible for retaining\n the structure in memory (and unmodified) until the task's handler runs, the task\n is successfully canceled, or the dispatcher shuts down. Thereafter, the task\n may be posted again or destroyed."]
461#[repr(C)]
462pub struct async_task {
463 #[doc = " Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|."]
464 pub state: async_state_t,
465 #[doc = " The task's handler function."]
466 pub handler: async_task_handler_t,
467 #[doc = " The task's deadline must be expressed in the time base used by the asynchronous\n dispatcher (usually |ZX_CLOCK_MONOTONIC| except in unit tests).\n See |async_now()| for details."]
468 pub deadline: zx_time_t,
469}
470#[allow(clippy::unnecessary_operation, clippy::identity_op)]
471const _: () = {
472 ["Size of async_task"][::core::mem::size_of::<async_task>() - 32usize];
473 ["Alignment of async_task"][::core::mem::align_of::<async_task>() - 8usize];
474 ["Offset of field: async_task::state"][::core::mem::offset_of!(async_task, state) - 0usize];
475 ["Offset of field: async_task::handler"]
476 [::core::mem::offset_of!(async_task, handler) - 16usize];
477 ["Offset of field: async_task::deadline"]
478 [::core::mem::offset_of!(async_task, deadline) - 24usize];
479};
480impl Default for async_task {
481 fn default() -> Self {
482 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
483 unsafe {
484 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
485 s.assume_init()
486 }
487 }
488}
489impl ::core::fmt::Debug for async_task {
490 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
491 write!(f, "async_task {{ state: {:?}, handler: {:?} }}", self.state, self.handler)
492 }
493}
494unsafe extern "C" {
495 #[doc = " Posts a task to run on or after its deadline following all posted\n tasks with lesser or equal deadlines.\n\n The task's handler will be invoked exactly once unless the task is canceled.\n When the dispatcher is shutting down (being destroyed), the handlers of\n all remaining tasks will be invoked with a status of |ZX_ERR_CANCELED|.\n\n Dispatcher implementations must treat |ZX_TIME_INFINITE_PAST| as a sentinel\n value meaning \"no deadline\". Tasks with expired deadlines must always be\n processed before tasks without deadlines (those posted with\n |ZX_TIME_INFINITE_PAST|).\n\n Note: If there are always tasks with expired deadlines, tasks without\n deadlines may be starved.\n\n Returns |ZX_OK| if the task was successfully posted.\n Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."]
496 pub fn async_post_task(
497 dispatcher: *mut async_dispatcher_t,
498 task: *mut async_task_t,
499 ) -> zx_status_t;
500}
501unsafe extern "C" {
502 #[doc = " Cancels the task associated with |task|.\n\n If successful, the task's handler will not run.\n\n Returns |ZX_OK| if the task was pending and it has been successfully\n canceled; its handler will not run again and can be released immediately.\n Returns |ZX_ERR_NOT_FOUND| if there was no pending task either because it\n already ran, had not been posted, or has been dequeued and is pending\n execution (perhaps on another thread).\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."]
503 pub fn async_cancel_task(
504 dispatcher: *mut async_dispatcher_t,
505 task: *mut async_task_t,
506 ) -> zx_status_t;
507}
508unsafe extern "C" {
509 #[doc = " Returns the current time in the dispatcher's timebase.\n For most loops, this is generally obtained from |ZX_CLOCK_MONOTONIC|\n but certain loops may use a different tiembase, notably for testing."]
510 pub fn async_now(dispatcher: *mut async_dispatcher_t) -> zx_time_t;
511}
512#[doc = " Handles an asynchronous trap access.\n\n The |status| is |ZX_OK| if the bell was received and |bell| contains the\n information from the packet, otherwise |bell| is null."]
513pub type async_guest_bell_trap_handler_t = ::core::option::Option<
514 unsafe extern "C" fn(
515 dispatcher: *mut async_dispatcher_t,
516 trap: *mut async_guest_bell_trap_t,
517 status: zx_status_t,
518 bell: *const zx_packet_guest_bell_t,
519 ),
520>;
521#[doc = " Holds context for a bell trap and its handler.\n\n After successfully posting setting the trap, the client is responsible for retaining\n the structure in memory (and unmodified) until the guest has been destroyed or the\n dispatcher shuts down. There is no way to cancel a trap which has been set."]
522#[repr(C)]
523#[derive(Debug, Default, Copy, Clone)]
524pub struct async_guest_bell_trap {
525 #[doc = " Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|."]
526 pub state: async_state_t,
527 #[doc = " The handler to invoke to handle the trap access."]
528 pub handler: async_guest_bell_trap_handler_t,
529}
530#[allow(clippy::unnecessary_operation, clippy::identity_op)]
531const _: () = {
532 ["Size of async_guest_bell_trap"][::core::mem::size_of::<async_guest_bell_trap>() - 24usize];
533 ["Alignment of async_guest_bell_trap"]
534 [::core::mem::align_of::<async_guest_bell_trap>() - 8usize];
535 ["Offset of field: async_guest_bell_trap::state"]
536 [::core::mem::offset_of!(async_guest_bell_trap, state) - 0usize];
537 ["Offset of field: async_guest_bell_trap::handler"]
538 [::core::mem::offset_of!(async_guest_bell_trap, handler) - 16usize];
539};
540unsafe extern "C" {
541 #[doc = " Sets a bell trap in the guest to be handled asynchronously via a handler.\n\n |guest| is the handle of the guest the trap will be set on.\n |addr| is the base address for the trap in the guest's physical address space.\n |length| is the size of the trap in the guest's physical address space.\n\n Returns |ZX_OK| if the trap was successfully set.\n Returns |ZX_ERR_ACCESS_DENIED| if the guest does not have |ZX_RIGHT_WRITE|.\n Returns |ZX_ERR_ALREADY_EXISTS| if a bell trap with the same |addr| exists.\n Returns |ZX_ERR_INVALID_ARGS| if |addr| or |length| are invalid.\n Returns |ZX_ERR_OUT_OF_RANGE| if |addr| or |length| are out of range of the\n address space.\n Returns |ZX_ERR_WRONG_TYPE| if |guest| is not a handle to a guest.\n Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."]
542 pub fn async_set_guest_bell_trap(
543 dispatcher: *mut async_dispatcher_t,
544 trap: *mut async_guest_bell_trap_t,
545 guest: zx_handle_t,
546 addr: zx_vaddr_t,
547 length: usize,
548 ) -> zx_status_t;
549}
550#[doc = " Handles completion of asynchronous wait operations.\n\n The |status| is |ZX_OK| if the wait was satisfied and |signal| is non-null.\n The |status| is |ZX_ERR_CANCELED| if the dispatcher was shut down before\n the task's handler ran or the task was canceled."]
551pub type async_wait_handler_t = ::core::option::Option<
552 unsafe extern "C" fn(
553 dispatcher: *mut async_dispatcher_t,
554 wait: *mut async_wait_t,
555 status: zx_status_t,
556 signal: *const zx_packet_signal_t,
557 ),
558>;
559#[doc = " Holds context for an asynchronous wait operation and its handler.\n\n After successfully beginning the wait, the client is responsible for retaining\n the structure in memory (and unmodified) until the wait's handler runs, the wait\n is successfully canceled, or the dispatcher shuts down. Thereafter, the wait\n may be started begun or destroyed."]
560#[repr(C)]
561pub struct async_wait {
562 #[doc = " Private state owned by the dispatcher, initialize to zero with |ASYNC_STATE_INIT|."]
563 pub state: async_state_t,
564 #[doc = " The wait's handler function."]
565 pub handler: async_wait_handler_t,
566 #[doc = " The object to wait for signals on."]
567 pub object: zx_handle_t,
568 #[doc = " The set of signals to wait for."]
569 pub trigger: zx_signals_t,
570 #[doc = " Wait options, see zx_object_wait_async()."]
571 pub options: u32,
572}
573#[allow(clippy::unnecessary_operation, clippy::identity_op)]
574const _: () = {
575 ["Size of async_wait"][::core::mem::size_of::<async_wait>() - 40usize];
576 ["Alignment of async_wait"][::core::mem::align_of::<async_wait>() - 8usize];
577 ["Offset of field: async_wait::state"][::core::mem::offset_of!(async_wait, state) - 0usize];
578 ["Offset of field: async_wait::handler"]
579 [::core::mem::offset_of!(async_wait, handler) - 16usize];
580 ["Offset of field: async_wait::object"][::core::mem::offset_of!(async_wait, object) - 24usize];
581 ["Offset of field: async_wait::trigger"]
582 [::core::mem::offset_of!(async_wait, trigger) - 28usize];
583 ["Offset of field: async_wait::options"]
584 [::core::mem::offset_of!(async_wait, options) - 32usize];
585};
586impl Default for async_wait {
587 fn default() -> Self {
588 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
589 unsafe {
590 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
591 s.assume_init()
592 }
593 }
594}
595impl ::core::fmt::Debug for async_wait {
596 fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
597 write!(f, "async_wait {{ state: {:?}, handler: {:?} }}", self.state, self.handler)
598 }
599}
600unsafe extern "C" {
601 #[doc = " Begins asynchronously waiting for an object to receive one or more signals\n specified in |wait|. Invokes the handler when the wait completes.\n\n The wait's handler will be invoked exactly once unless the wait is canceled.\n When the dispatcher is shutting down (being destroyed), the handlers of\n all remaining waits will be invoked with a status of |ZX_ERR_CANCELED|.\n\n Returns |ZX_OK| if the wait was successfully begun.\n Returns |ZX_ERR_ACCESS_DENIED| if the object does not have |ZX_RIGHT_WAIT|.\n Returns |ZX_ERR_BAD_STATE| if the dispatcher is shutting down.\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."]
602 pub fn async_begin_wait(
603 dispatcher: *mut async_dispatcher_t,
604 wait: *mut async_wait_t,
605 ) -> zx_status_t;
606}
607unsafe extern "C" {
608 #[doc = " Cancels the wait associated with |wait|.\n\n If successful, the wait's handler will not run.\n\n Returns |ZX_OK| if the wait was pending and it has been successfully\n canceled; its handler will not run again and can be released immediately.\n Returns |ZX_ERR_NOT_FOUND| if there was no pending wait either because it\n already completed, had not been started, or its completion packet has been\n dequeued from the port and is pending delivery to its handler (perhaps on\n another thread).\n Returns |ZX_ERR_NOT_SUPPORTED| if not supported by the dispatcher.\n\n This operation is thread-safe."]
609 pub fn async_cancel_wait(
610 dispatcher: *mut async_dispatcher_t,
611 wait: *mut async_wait_t,
612 ) -> zx_status_t;
613}