fidl_fuchsia_driver_host__common/
fidl_fuchsia_driver_host__common.rs

1// WARNING: This file is machine generated by fidlgen.
2
3#![warn(clippy::all)]
4#![allow(unused_parens, unused_mut, unused_imports, nonstandard_style)]
5
6use bitflags::bitflags;
7use fidl::encoding::{MessageBufFor, ProxyChannelBox, ResourceDialect};
8use futures::future::{self, MaybeDone, TryFutureExt};
9use zx_status;
10
11/// Information about the driver host's threads. Used for debugging.
12#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
13pub struct DispatcherInfo {
14    pub driver: String,
15    pub name: String,
16    pub options: u32,
17    pub scheduler_role: String,
18}
19
20impl fidl::Persistable for DispatcherInfo {}
21
22/// Information about the driver host. Used for debugging.
23#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
24pub struct ProcessInfo {
25    pub job_koid: u64,
26    pub process_koid: u64,
27    pub main_thread_koid: u64,
28    pub threads: Vec<ThreadInfo>,
29    pub dispatchers: Vec<DispatcherInfo>,
30}
31
32impl fidl::Persistable for ProcessInfo {}
33
34/// Information about the driver host's threads. Used for debugging.
35#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
36pub struct ThreadInfo {
37    pub koid: u64,
38    pub name: String,
39    pub scheduler_role: String,
40}
41
42impl fidl::Persistable for ThreadInfo {}
43
44pub mod driver_ordinals {
45    pub const STOP: u64 = 0x4039e87556689b5f;
46}
47
48pub mod driver_host_ordinals {
49    pub const START: u64 = 0x1848852bd195bde5;
50    pub const START_LOADED_DRIVER: u64 = 0x51957548318c9368;
51    pub const GET_PROCESS_INFO: u64 = 0x1b2d1b727a614973;
52    pub const INSTALL_LOADER: u64 = 0x7022edafc5fcf5a3;
53    pub const TRIGGER_STACK_TRACE: u64 = 0x3bb449b803e49353;
54    pub const FIND_DRIVER_CRASH_INFO_BY_THREAD_KOID: u64 = 0x18b3b336b45a7916;
55}
56
57mod internal {
58    use super::*;
59
60    impl fidl::encoding::ValueTypeMarker for DispatcherInfo {
61        type Borrowed<'a> = &'a Self;
62        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
63            value
64        }
65    }
66
67    unsafe impl fidl::encoding::TypeMarker for DispatcherInfo {
68        type Owned = Self;
69
70        #[inline(always)]
71        fn inline_align(_context: fidl::encoding::Context) -> usize {
72            8
73        }
74
75        #[inline(always)]
76        fn inline_size(_context: fidl::encoding::Context) -> usize {
77            56
78        }
79    }
80
81    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DispatcherInfo, D>
82        for &DispatcherInfo
83    {
84        #[inline]
85        unsafe fn encode(
86            self,
87            encoder: &mut fidl::encoding::Encoder<'_, D>,
88            offset: usize,
89            _depth: fidl::encoding::Depth,
90        ) -> fidl::Result<()> {
91            encoder.debug_check_bounds::<DispatcherInfo>(offset);
92            // Delegate to tuple encoding.
93            fidl::encoding::Encode::<DispatcherInfo, D>::encode(
94                (
95                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
96                        &self.driver,
97                    ),
98                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
99                        &self.name,
100                    ),
101                    <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
102                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
103                        &self.scheduler_role,
104                    ),
105                ),
106                encoder,
107                offset,
108                _depth,
109            )
110        }
111    }
112    unsafe impl<
113        D: fidl::encoding::ResourceDialect,
114        T0: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
115        T1: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
116        T2: fidl::encoding::Encode<u32, D>,
117        T3: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
118    > fidl::encoding::Encode<DispatcherInfo, D> for (T0, T1, T2, T3)
119    {
120        #[inline]
121        unsafe fn encode(
122            self,
123            encoder: &mut fidl::encoding::Encoder<'_, D>,
124            offset: usize,
125            depth: fidl::encoding::Depth,
126        ) -> fidl::Result<()> {
127            encoder.debug_check_bounds::<DispatcherInfo>(offset);
128            // Zero out padding regions. There's no need to apply masks
129            // because the unmasked parts will be overwritten by fields.
130            unsafe {
131                let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
132                (ptr as *mut u64).write_unaligned(0);
133            }
134            // Write the fields.
135            self.0.encode(encoder, offset + 0, depth)?;
136            self.1.encode(encoder, offset + 16, depth)?;
137            self.2.encode(encoder, offset + 32, depth)?;
138            self.3.encode(encoder, offset + 40, depth)?;
139            Ok(())
140        }
141    }
142
143    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DispatcherInfo {
144        #[inline(always)]
145        fn new_empty() -> Self {
146            Self {
147                driver: fidl::new_empty!(fidl::encoding::UnboundedString, D),
148                name: fidl::new_empty!(fidl::encoding::UnboundedString, D),
149                options: fidl::new_empty!(u32, D),
150                scheduler_role: fidl::new_empty!(fidl::encoding::UnboundedString, D),
151            }
152        }
153
154        #[inline]
155        unsafe fn decode(
156            &mut self,
157            decoder: &mut fidl::encoding::Decoder<'_, D>,
158            offset: usize,
159            _depth: fidl::encoding::Depth,
160        ) -> fidl::Result<()> {
161            decoder.debug_check_bounds::<Self>(offset);
162            // Verify that padding bytes are zero.
163            let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
164            let padval = unsafe { (ptr as *const u64).read_unaligned() };
165            let mask = 0xffffffff00000000u64;
166            let maskedval = padval & mask;
167            if maskedval != 0 {
168                return Err(fidl::Error::NonZeroPadding {
169                    padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
170                });
171            }
172            fidl::decode!(
173                fidl::encoding::UnboundedString,
174                D,
175                &mut self.driver,
176                decoder,
177                offset + 0,
178                _depth
179            )?;
180            fidl::decode!(
181                fidl::encoding::UnboundedString,
182                D,
183                &mut self.name,
184                decoder,
185                offset + 16,
186                _depth
187            )?;
188            fidl::decode!(u32, D, &mut self.options, decoder, offset + 32, _depth)?;
189            fidl::decode!(
190                fidl::encoding::UnboundedString,
191                D,
192                &mut self.scheduler_role,
193                decoder,
194                offset + 40,
195                _depth
196            )?;
197            Ok(())
198        }
199    }
200
201    impl fidl::encoding::ValueTypeMarker for ProcessInfo {
202        type Borrowed<'a> = &'a Self;
203        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
204            value
205        }
206    }
207
208    unsafe impl fidl::encoding::TypeMarker for ProcessInfo {
209        type Owned = Self;
210
211        #[inline(always)]
212        fn inline_align(_context: fidl::encoding::Context) -> usize {
213            8
214        }
215
216        #[inline(always)]
217        fn inline_size(_context: fidl::encoding::Context) -> usize {
218            56
219        }
220    }
221
222    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ProcessInfo, D>
223        for &ProcessInfo
224    {
225        #[inline]
226        unsafe fn encode(
227            self,
228            encoder: &mut fidl::encoding::Encoder<'_, D>,
229            offset: usize,
230            _depth: fidl::encoding::Depth,
231        ) -> fidl::Result<()> {
232            encoder.debug_check_bounds::<ProcessInfo>(offset);
233            // Delegate to tuple encoding.
234            fidl::encoding::Encode::<ProcessInfo, D>::encode(
235                (
236                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.job_koid),
237                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.process_koid),
238                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.main_thread_koid),
239                    <fidl::encoding::UnboundedVector<ThreadInfo> as fidl::encoding::ValueTypeMarker>::borrow(&self.threads),
240                    <fidl::encoding::UnboundedVector<DispatcherInfo> as fidl::encoding::ValueTypeMarker>::borrow(&self.dispatchers),
241                ),
242                encoder, offset, _depth
243            )
244        }
245    }
246    unsafe impl<
247        D: fidl::encoding::ResourceDialect,
248        T0: fidl::encoding::Encode<u64, D>,
249        T1: fidl::encoding::Encode<u64, D>,
250        T2: fidl::encoding::Encode<u64, D>,
251        T3: fidl::encoding::Encode<fidl::encoding::UnboundedVector<ThreadInfo>, D>,
252        T4: fidl::encoding::Encode<fidl::encoding::UnboundedVector<DispatcherInfo>, D>,
253    > fidl::encoding::Encode<ProcessInfo, D> for (T0, T1, T2, T3, T4)
254    {
255        #[inline]
256        unsafe fn encode(
257            self,
258            encoder: &mut fidl::encoding::Encoder<'_, D>,
259            offset: usize,
260            depth: fidl::encoding::Depth,
261        ) -> fidl::Result<()> {
262            encoder.debug_check_bounds::<ProcessInfo>(offset);
263            // Zero out padding regions. There's no need to apply masks
264            // because the unmasked parts will be overwritten by fields.
265            // Write the fields.
266            self.0.encode(encoder, offset + 0, depth)?;
267            self.1.encode(encoder, offset + 8, depth)?;
268            self.2.encode(encoder, offset + 16, depth)?;
269            self.3.encode(encoder, offset + 24, depth)?;
270            self.4.encode(encoder, offset + 40, depth)?;
271            Ok(())
272        }
273    }
274
275    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ProcessInfo {
276        #[inline(always)]
277        fn new_empty() -> Self {
278            Self {
279                job_koid: fidl::new_empty!(u64, D),
280                process_koid: fidl::new_empty!(u64, D),
281                main_thread_koid: fidl::new_empty!(u64, D),
282                threads: fidl::new_empty!(fidl::encoding::UnboundedVector<ThreadInfo>, D),
283                dispatchers: fidl::new_empty!(fidl::encoding::UnboundedVector<DispatcherInfo>, D),
284            }
285        }
286
287        #[inline]
288        unsafe fn decode(
289            &mut self,
290            decoder: &mut fidl::encoding::Decoder<'_, D>,
291            offset: usize,
292            _depth: fidl::encoding::Depth,
293        ) -> fidl::Result<()> {
294            decoder.debug_check_bounds::<Self>(offset);
295            // Verify that padding bytes are zero.
296            fidl::decode!(u64, D, &mut self.job_koid, decoder, offset + 0, _depth)?;
297            fidl::decode!(u64, D, &mut self.process_koid, decoder, offset + 8, _depth)?;
298            fidl::decode!(u64, D, &mut self.main_thread_koid, decoder, offset + 16, _depth)?;
299            fidl::decode!(
300                fidl::encoding::UnboundedVector<ThreadInfo>,
301                D,
302                &mut self.threads,
303                decoder,
304                offset + 24,
305                _depth
306            )?;
307            fidl::decode!(
308                fidl::encoding::UnboundedVector<DispatcherInfo>,
309                D,
310                &mut self.dispatchers,
311                decoder,
312                offset + 40,
313                _depth
314            )?;
315            Ok(())
316        }
317    }
318
319    impl fidl::encoding::ValueTypeMarker for ThreadInfo {
320        type Borrowed<'a> = &'a Self;
321        fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
322            value
323        }
324    }
325
326    unsafe impl fidl::encoding::TypeMarker for ThreadInfo {
327        type Owned = Self;
328
329        #[inline(always)]
330        fn inline_align(_context: fidl::encoding::Context) -> usize {
331            8
332        }
333
334        #[inline(always)]
335        fn inline_size(_context: fidl::encoding::Context) -> usize {
336            40
337        }
338    }
339
340    unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ThreadInfo, D>
341        for &ThreadInfo
342    {
343        #[inline]
344        unsafe fn encode(
345            self,
346            encoder: &mut fidl::encoding::Encoder<'_, D>,
347            offset: usize,
348            _depth: fidl::encoding::Depth,
349        ) -> fidl::Result<()> {
350            encoder.debug_check_bounds::<ThreadInfo>(offset);
351            // Delegate to tuple encoding.
352            fidl::encoding::Encode::<ThreadInfo, D>::encode(
353                (
354                    <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.koid),
355                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
356                        &self.name,
357                    ),
358                    <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
359                        &self.scheduler_role,
360                    ),
361                ),
362                encoder,
363                offset,
364                _depth,
365            )
366        }
367    }
368    unsafe impl<
369        D: fidl::encoding::ResourceDialect,
370        T0: fidl::encoding::Encode<u64, D>,
371        T1: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
372        T2: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
373    > fidl::encoding::Encode<ThreadInfo, D> for (T0, T1, T2)
374    {
375        #[inline]
376        unsafe fn encode(
377            self,
378            encoder: &mut fidl::encoding::Encoder<'_, D>,
379            offset: usize,
380            depth: fidl::encoding::Depth,
381        ) -> fidl::Result<()> {
382            encoder.debug_check_bounds::<ThreadInfo>(offset);
383            // Zero out padding regions. There's no need to apply masks
384            // because the unmasked parts will be overwritten by fields.
385            // Write the fields.
386            self.0.encode(encoder, offset + 0, depth)?;
387            self.1.encode(encoder, offset + 8, depth)?;
388            self.2.encode(encoder, offset + 24, depth)?;
389            Ok(())
390        }
391    }
392
393    impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ThreadInfo {
394        #[inline(always)]
395        fn new_empty() -> Self {
396            Self {
397                koid: fidl::new_empty!(u64, D),
398                name: fidl::new_empty!(fidl::encoding::UnboundedString, D),
399                scheduler_role: fidl::new_empty!(fidl::encoding::UnboundedString, D),
400            }
401        }
402
403        #[inline]
404        unsafe fn decode(
405            &mut self,
406            decoder: &mut fidl::encoding::Decoder<'_, D>,
407            offset: usize,
408            _depth: fidl::encoding::Depth,
409        ) -> fidl::Result<()> {
410            decoder.debug_check_bounds::<Self>(offset);
411            // Verify that padding bytes are zero.
412            fidl::decode!(u64, D, &mut self.koid, decoder, offset + 0, _depth)?;
413            fidl::decode!(
414                fidl::encoding::UnboundedString,
415                D,
416                &mut self.name,
417                decoder,
418                offset + 8,
419                _depth
420            )?;
421            fidl::decode!(
422                fidl::encoding::UnboundedString,
423                D,
424                &mut self.scheduler_role,
425                decoder,
426                offset + 24,
427                _depth
428            )?;
429            Ok(())
430        }
431    }
432}