1#![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#[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#[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#[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 FIND_DRIVER_CRASH_INFO_BY_THREAD_KOID: u64 = 0x18b3b336b45a7916;
54}
55
56mod internal {
57 use super::*;
58
59 impl fidl::encoding::ValueTypeMarker for DispatcherInfo {
60 type Borrowed<'a> = &'a Self;
61 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
62 value
63 }
64 }
65
66 unsafe impl fidl::encoding::TypeMarker for DispatcherInfo {
67 type Owned = Self;
68
69 #[inline(always)]
70 fn inline_align(_context: fidl::encoding::Context) -> usize {
71 8
72 }
73
74 #[inline(always)]
75 fn inline_size(_context: fidl::encoding::Context) -> usize {
76 56
77 }
78 }
79
80 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<DispatcherInfo, D>
81 for &DispatcherInfo
82 {
83 #[inline]
84 unsafe fn encode(
85 self,
86 encoder: &mut fidl::encoding::Encoder<'_, D>,
87 offset: usize,
88 _depth: fidl::encoding::Depth,
89 ) -> fidl::Result<()> {
90 encoder.debug_check_bounds::<DispatcherInfo>(offset);
91 fidl::encoding::Encode::<DispatcherInfo, D>::encode(
93 (
94 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
95 &self.driver,
96 ),
97 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
98 &self.name,
99 ),
100 <u32 as fidl::encoding::ValueTypeMarker>::borrow(&self.options),
101 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
102 &self.scheduler_role,
103 ),
104 ),
105 encoder,
106 offset,
107 _depth,
108 )
109 }
110 }
111 unsafe impl<
112 D: fidl::encoding::ResourceDialect,
113 T0: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
114 T1: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
115 T2: fidl::encoding::Encode<u32, D>,
116 T3: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
117 > fidl::encoding::Encode<DispatcherInfo, D> for (T0, T1, T2, T3)
118 {
119 #[inline]
120 unsafe fn encode(
121 self,
122 encoder: &mut fidl::encoding::Encoder<'_, D>,
123 offset: usize,
124 depth: fidl::encoding::Depth,
125 ) -> fidl::Result<()> {
126 encoder.debug_check_bounds::<DispatcherInfo>(offset);
127 unsafe {
130 let ptr = encoder.buf.as_mut_ptr().add(offset).offset(32);
131 (ptr as *mut u64).write_unaligned(0);
132 }
133 self.0.encode(encoder, offset + 0, depth)?;
135 self.1.encode(encoder, offset + 16, depth)?;
136 self.2.encode(encoder, offset + 32, depth)?;
137 self.3.encode(encoder, offset + 40, depth)?;
138 Ok(())
139 }
140 }
141
142 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for DispatcherInfo {
143 #[inline(always)]
144 fn new_empty() -> Self {
145 Self {
146 driver: fidl::new_empty!(fidl::encoding::UnboundedString, D),
147 name: fidl::new_empty!(fidl::encoding::UnboundedString, D),
148 options: fidl::new_empty!(u32, D),
149 scheduler_role: fidl::new_empty!(fidl::encoding::UnboundedString, D),
150 }
151 }
152
153 #[inline]
154 unsafe fn decode(
155 &mut self,
156 decoder: &mut fidl::encoding::Decoder<'_, D>,
157 offset: usize,
158 _depth: fidl::encoding::Depth,
159 ) -> fidl::Result<()> {
160 decoder.debug_check_bounds::<Self>(offset);
161 let ptr = unsafe { decoder.buf.as_ptr().add(offset).offset(32) };
163 let padval = unsafe { (ptr as *const u64).read_unaligned() };
164 let mask = 0xffffffff00000000u64;
165 let maskedval = padval & mask;
166 if maskedval != 0 {
167 return Err(fidl::Error::NonZeroPadding {
168 padding_start: offset + 32 + ((mask as u64).trailing_zeros() / 8) as usize,
169 });
170 }
171 fidl::decode!(
172 fidl::encoding::UnboundedString,
173 D,
174 &mut self.driver,
175 decoder,
176 offset + 0,
177 _depth
178 )?;
179 fidl::decode!(
180 fidl::encoding::UnboundedString,
181 D,
182 &mut self.name,
183 decoder,
184 offset + 16,
185 _depth
186 )?;
187 fidl::decode!(u32, D, &mut self.options, decoder, offset + 32, _depth)?;
188 fidl::decode!(
189 fidl::encoding::UnboundedString,
190 D,
191 &mut self.scheduler_role,
192 decoder,
193 offset + 40,
194 _depth
195 )?;
196 Ok(())
197 }
198 }
199
200 impl fidl::encoding::ValueTypeMarker for ProcessInfo {
201 type Borrowed<'a> = &'a Self;
202 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
203 value
204 }
205 }
206
207 unsafe impl fidl::encoding::TypeMarker for ProcessInfo {
208 type Owned = Self;
209
210 #[inline(always)]
211 fn inline_align(_context: fidl::encoding::Context) -> usize {
212 8
213 }
214
215 #[inline(always)]
216 fn inline_size(_context: fidl::encoding::Context) -> usize {
217 56
218 }
219 }
220
221 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ProcessInfo, D>
222 for &ProcessInfo
223 {
224 #[inline]
225 unsafe fn encode(
226 self,
227 encoder: &mut fidl::encoding::Encoder<'_, D>,
228 offset: usize,
229 _depth: fidl::encoding::Depth,
230 ) -> fidl::Result<()> {
231 encoder.debug_check_bounds::<ProcessInfo>(offset);
232 fidl::encoding::Encode::<ProcessInfo, D>::encode(
234 (
235 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.job_koid),
236 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.process_koid),
237 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.main_thread_koid),
238 <fidl::encoding::UnboundedVector<ThreadInfo> as fidl::encoding::ValueTypeMarker>::borrow(&self.threads),
239 <fidl::encoding::UnboundedVector<DispatcherInfo> as fidl::encoding::ValueTypeMarker>::borrow(&self.dispatchers),
240 ),
241 encoder, offset, _depth
242 )
243 }
244 }
245 unsafe impl<
246 D: fidl::encoding::ResourceDialect,
247 T0: fidl::encoding::Encode<u64, D>,
248 T1: fidl::encoding::Encode<u64, D>,
249 T2: fidl::encoding::Encode<u64, D>,
250 T3: fidl::encoding::Encode<fidl::encoding::UnboundedVector<ThreadInfo>, D>,
251 T4: fidl::encoding::Encode<fidl::encoding::UnboundedVector<DispatcherInfo>, D>,
252 > fidl::encoding::Encode<ProcessInfo, D> for (T0, T1, T2, T3, T4)
253 {
254 #[inline]
255 unsafe fn encode(
256 self,
257 encoder: &mut fidl::encoding::Encoder<'_, D>,
258 offset: usize,
259 depth: fidl::encoding::Depth,
260 ) -> fidl::Result<()> {
261 encoder.debug_check_bounds::<ProcessInfo>(offset);
262 self.0.encode(encoder, offset + 0, depth)?;
266 self.1.encode(encoder, offset + 8, depth)?;
267 self.2.encode(encoder, offset + 16, depth)?;
268 self.3.encode(encoder, offset + 24, depth)?;
269 self.4.encode(encoder, offset + 40, depth)?;
270 Ok(())
271 }
272 }
273
274 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ProcessInfo {
275 #[inline(always)]
276 fn new_empty() -> Self {
277 Self {
278 job_koid: fidl::new_empty!(u64, D),
279 process_koid: fidl::new_empty!(u64, D),
280 main_thread_koid: fidl::new_empty!(u64, D),
281 threads: fidl::new_empty!(fidl::encoding::UnboundedVector<ThreadInfo>, D),
282 dispatchers: fidl::new_empty!(fidl::encoding::UnboundedVector<DispatcherInfo>, D),
283 }
284 }
285
286 #[inline]
287 unsafe fn decode(
288 &mut self,
289 decoder: &mut fidl::encoding::Decoder<'_, D>,
290 offset: usize,
291 _depth: fidl::encoding::Depth,
292 ) -> fidl::Result<()> {
293 decoder.debug_check_bounds::<Self>(offset);
294 fidl::decode!(u64, D, &mut self.job_koid, decoder, offset + 0, _depth)?;
296 fidl::decode!(u64, D, &mut self.process_koid, decoder, offset + 8, _depth)?;
297 fidl::decode!(u64, D, &mut self.main_thread_koid, decoder, offset + 16, _depth)?;
298 fidl::decode!(
299 fidl::encoding::UnboundedVector<ThreadInfo>,
300 D,
301 &mut self.threads,
302 decoder,
303 offset + 24,
304 _depth
305 )?;
306 fidl::decode!(
307 fidl::encoding::UnboundedVector<DispatcherInfo>,
308 D,
309 &mut self.dispatchers,
310 decoder,
311 offset + 40,
312 _depth
313 )?;
314 Ok(())
315 }
316 }
317
318 impl fidl::encoding::ValueTypeMarker for ThreadInfo {
319 type Borrowed<'a> = &'a Self;
320 fn borrow(value: &<Self as fidl::encoding::TypeMarker>::Owned) -> Self::Borrowed<'_> {
321 value
322 }
323 }
324
325 unsafe impl fidl::encoding::TypeMarker for ThreadInfo {
326 type Owned = Self;
327
328 #[inline(always)]
329 fn inline_align(_context: fidl::encoding::Context) -> usize {
330 8
331 }
332
333 #[inline(always)]
334 fn inline_size(_context: fidl::encoding::Context) -> usize {
335 40
336 }
337 }
338
339 unsafe impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Encode<ThreadInfo, D>
340 for &ThreadInfo
341 {
342 #[inline]
343 unsafe fn encode(
344 self,
345 encoder: &mut fidl::encoding::Encoder<'_, D>,
346 offset: usize,
347 _depth: fidl::encoding::Depth,
348 ) -> fidl::Result<()> {
349 encoder.debug_check_bounds::<ThreadInfo>(offset);
350 fidl::encoding::Encode::<ThreadInfo, D>::encode(
352 (
353 <u64 as fidl::encoding::ValueTypeMarker>::borrow(&self.koid),
354 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
355 &self.name,
356 ),
357 <fidl::encoding::UnboundedString as fidl::encoding::ValueTypeMarker>::borrow(
358 &self.scheduler_role,
359 ),
360 ),
361 encoder,
362 offset,
363 _depth,
364 )
365 }
366 }
367 unsafe impl<
368 D: fidl::encoding::ResourceDialect,
369 T0: fidl::encoding::Encode<u64, D>,
370 T1: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
371 T2: fidl::encoding::Encode<fidl::encoding::UnboundedString, D>,
372 > fidl::encoding::Encode<ThreadInfo, D> for (T0, T1, T2)
373 {
374 #[inline]
375 unsafe fn encode(
376 self,
377 encoder: &mut fidl::encoding::Encoder<'_, D>,
378 offset: usize,
379 depth: fidl::encoding::Depth,
380 ) -> fidl::Result<()> {
381 encoder.debug_check_bounds::<ThreadInfo>(offset);
382 self.0.encode(encoder, offset + 0, depth)?;
386 self.1.encode(encoder, offset + 8, depth)?;
387 self.2.encode(encoder, offset + 24, depth)?;
388 Ok(())
389 }
390 }
391
392 impl<D: fidl::encoding::ResourceDialect> fidl::encoding::Decode<Self, D> for ThreadInfo {
393 #[inline(always)]
394 fn new_empty() -> Self {
395 Self {
396 koid: fidl::new_empty!(u64, D),
397 name: fidl::new_empty!(fidl::encoding::UnboundedString, D),
398 scheduler_role: fidl::new_empty!(fidl::encoding::UnboundedString, D),
399 }
400 }
401
402 #[inline]
403 unsafe fn decode(
404 &mut self,
405 decoder: &mut fidl::encoding::Decoder<'_, D>,
406 offset: usize,
407 _depth: fidl::encoding::Depth,
408 ) -> fidl::Result<()> {
409 decoder.debug_check_bounds::<Self>(offset);
410 fidl::decode!(u64, D, &mut self.koid, decoder, offset + 0, _depth)?;
412 fidl::decode!(
413 fidl::encoding::UnboundedString,
414 D,
415 &mut self.name,
416 decoder,
417 offset + 8,
418 _depth
419 )?;
420 fidl::decode!(
421 fidl::encoding::UnboundedString,
422 D,
423 &mut self.scheduler_role,
424 decoder,
425 offset + 24,
426 _depth
427 )?;
428 Ok(())
429 }
430 }
431}