1#![doc = "DPLL subsystem.\n"]
2#![allow(clippy::all)]
3#![allow(unused_imports)]
4#![allow(unused_assignments)]
5#![allow(non_snake_case)]
6#![allow(unused_variables)]
7#![allow(irrefutable_let_patterns)]
8#![allow(unreachable_code)]
9#![allow(unreachable_patterns)]
10use crate::builtin::{BuiltinBitfield32, BuiltinNfgenmsg, Nlmsghdr, PushDummy};
11use crate::{
12 consts,
13 traits::{NetlinkRequest, Protocol},
14 utils::*,
15};
16pub const PROTONAME: &str = "dpll";
17pub const PROTONAME_CSTR: &CStr = c"dpll";
18#[doc = "working modes a dpll can support, differentiates if and how dpll selects\none of its inputs to syntonize with it, valid values for DPLL_A_MODE\nattribute\n"]
19#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
20#[derive(Debug, Clone, Copy)]
21pub enum Mode {
22 #[doc = "input can be only selected by sending a request to dpll\n"]
23 Manual = 1,
24 #[doc = "highest prio input pin auto selected by dpll\n"]
25 Automatic = 2,
26}
27impl Mode {
28 pub fn from_value(value: u64) -> Option<Self> {
29 Some(match value {
30 1 => Self::Manual,
31 2 => Self::Automatic,
32 _ => return None,
33 })
34 }
35}
36#[doc = "provides information of dpll device lock status, valid values for\nDPLL_A_LOCK_STATUS attribute\n"]
37#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
38#[derive(Debug, Clone, Copy)]
39pub enum LockStatus {
40 #[doc = "dpll was not yet locked to any valid input (or forced by setting\nDPLL_A_MODE to DPLL_MODE_DETACHED)\n"]
41 Unlocked = 1,
42 #[doc = "dpll is locked to a valid signal, but no holdover available\n"]
43 Locked = 2,
44 #[doc = "dpll is locked and holdover acquired\n"]
45 LockedHoAcq = 3,
46 #[doc = "dpll is in holdover state - lost a valid lock or was forced by\ndisconnecting all the pins (latter possible only when dpll lock-state\nwas already DPLL_LOCK_STATUS_LOCKED_HO_ACQ, if dpll lock-state was not\nDPLL_LOCK_STATUS_LOCKED_HO_ACQ, the dpll\\'s lock-state shall remain\nDPLL_LOCK_STATUS_UNLOCKED)\n"]
47 Holdover = 4,
48}
49impl LockStatus {
50 pub fn from_value(value: u64) -> Option<Self> {
51 Some(match value {
52 1 => Self::Unlocked,
53 2 => Self::Locked,
54 3 => Self::LockedHoAcq,
55 4 => Self::Holdover,
56 _ => return None,
57 })
58 }
59}
60#[doc = "if previous status change was done due to a failure, this provides\ninformation of dpll device lock status error. Valid values for\nDPLL_A_LOCK_STATUS_ERROR attribute\n"]
61#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
62#[derive(Debug, Clone, Copy)]
63pub enum LockStatusError {
64 #[doc = "dpll device lock status was changed without any error\n"]
65 None = 1,
66 #[doc = "dpll device lock status was changed due to undefined error. Driver fills\nthis value up in case it is not able to obtain suitable exact error\ntype.\n"]
67 Undefined = 2,
68 #[doc = "dpll device lock status was changed because of associated media got\ndown. This may happen for example if dpll device was previously locked\non an input pin of type PIN_TYPE_SYNCE_ETH_PORT.\n"]
69 MediaDown = 3,
70 #[doc = "the FFO (Fractional Frequency Offset) between the RX and TX symbol rate\non the media got too high. This may happen for example if dpll device\nwas previously locked on an input pin of type PIN_TYPE_SYNCE_ETH_PORT.\n"]
71 FractionalFrequencyOffsetTooHigh = 4,
72}
73impl LockStatusError {
74 pub fn from_value(value: u64) -> Option<Self> {
75 Some(match value {
76 1 => Self::None,
77 2 => Self::Undefined,
78 3 => Self::MediaDown,
79 4 => Self::FractionalFrequencyOffsetTooHigh,
80 _ => return None,
81 })
82 }
83}
84#[doc = "level of quality of a clock device. This mainly applies when the dpll\nlock-status is DPLL_LOCK_STATUS_HOLDOVER. The current list is defined\naccording to the table 11-7 contained in ITU-T G.8264/Y.1364 document.\nOne may extend this list freely by other ITU-T defined clock qualities,\nor different ones defined by another standardization body (for those,\nplease use different prefix).\n"]
85#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
86#[derive(Debug, Clone, Copy)]
87pub enum ClockQualityLevel {
88 ItuOpt1Prc = 1,
89 ItuOpt1SsuA = 2,
90 ItuOpt1SsuB = 3,
91 ItuOpt1Eec1 = 4,
92 ItuOpt1Prtc = 5,
93 ItuOpt1Eprtc = 6,
94 ItuOpt1Eeec = 7,
95 ItuOpt1Eprc = 8,
96}
97impl ClockQualityLevel {
98 pub fn from_value(value: u64) -> Option<Self> {
99 Some(match value {
100 1 => Self::ItuOpt1Prc,
101 2 => Self::ItuOpt1SsuA,
102 3 => Self::ItuOpt1SsuB,
103 4 => Self::ItuOpt1Eec1,
104 5 => Self::ItuOpt1Prtc,
105 6 => Self::ItuOpt1Eprtc,
106 7 => Self::ItuOpt1Eeec,
107 8 => Self::ItuOpt1Eprc,
108 _ => return None,
109 })
110 }
111}
112#[doc = "temperature divider allowing userspace to calculate the temperature as\nfloat with three digit decimal precision. Value of (DPLL_A_TEMP /\nDPLL_TEMP_DIVIDER) is integer part of temperature value. Value of\n(DPLL_A_TEMP % DPLL_TEMP_DIVIDER) is fractional part of temperature\nvalue.\n"]
113pub const TEMP_DIVIDER: u64 = 1000u64;
114#[doc = "type of dpll, valid values for DPLL_A_TYPE attribute\n"]
115#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
116#[derive(Debug, Clone, Copy)]
117pub enum Type {
118 #[doc = "dpll produces Pulse-Per-Second signal\n"]
119 Pps = 1,
120 #[doc = "dpll drives the Ethernet Equipment Clock\n"]
121 Eec = 2,
122 #[doc = "generic dpll type for devices outside PPS/EEC classes\n"]
123 Generic = 3,
124}
125impl Type {
126 pub fn from_value(value: u64) -> Option<Self> {
127 Some(match value {
128 1 => Self::Pps,
129 2 => Self::Eec,
130 3 => Self::Generic,
131 _ => return None,
132 })
133 }
134}
135#[doc = "defines possible types of a pin, valid values for DPLL_A_PIN_TYPE\nattribute\n"]
136#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
137#[derive(Debug, Clone, Copy)]
138pub enum PinType {
139 #[doc = "aggregates another layer of selectable pins\n"]
140 Mux = 1,
141 #[doc = "external input\n"]
142 Ext = 2,
143 #[doc = "ethernet port PHY\\'s recovered clock\n"]
144 SynceEthPort = 3,
145 #[doc = "device internal oscillator\n"]
146 IntOscillator = 4,
147 #[doc = "GNSS recovered clock\n"]
148 Gnss = 5,
149}
150impl PinType {
151 pub fn from_value(value: u64) -> Option<Self> {
152 Some(match value {
153 1 => Self::Mux,
154 2 => Self::Ext,
155 3 => Self::SynceEthPort,
156 4 => Self::IntOscillator,
157 5 => Self::Gnss,
158 _ => return None,
159 })
160 }
161}
162#[doc = "defines possible direction of a pin, valid values for\nDPLL_A_PIN_DIRECTION attribute\n"]
163#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
164#[derive(Debug, Clone, Copy)]
165pub enum PinDirection {
166 #[doc = "pin used as a input of a signal\n"]
167 Input = 1,
168 #[doc = "pin used to output the signal\n"]
169 Output = 2,
170}
171impl PinDirection {
172 pub fn from_value(value: u64) -> Option<Self> {
173 Some(match value {
174 1 => Self::Input,
175 2 => Self::Output,
176 _ => return None,
177 })
178 }
179}
180pub const PIN_FREQUENCY_1_HZ: u64 = 1u64;
181pub const PIN_FREQUENCY_10_KHZ: u64 = 10000u64;
182pub const PIN_FREQUENCY_77_5_KHZ: u64 = 77500u64;
183pub const PIN_FREQUENCY_10_MHZ: u64 = 10000000u64;
184#[doc = "defines possible states of a pin, valid values for DPLL_A_PIN_STATE\nattribute\n"]
185#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
186#[derive(Debug, Clone, Copy)]
187pub enum PinState {
188 #[doc = "pin connected, active input of phase locked loop\n"]
189 Connected = 1,
190 #[doc = "pin disconnected, not considered as a valid input\n"]
191 Disconnected = 2,
192 #[doc = "pin enabled for automatic input selection\n"]
193 Selectable = 3,
194}
195impl PinState {
196 pub fn from_value(value: u64) -> Option<Self> {
197 Some(match value {
198 1 => Self::Connected,
199 2 => Self::Disconnected,
200 3 => Self::Selectable,
201 _ => return None,
202 })
203 }
204}
205#[doc = "defines possible operational states of a pin with respect to its parent\nDPLL device, valid values for DPLL_A_PIN_OPERSTATE attribute\n"]
206#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
207#[derive(Debug, Clone, Copy)]
208pub enum PinOperstate {
209 #[doc = "pin is qualified and actively used by the DPLL\n"]
210 Active = 1,
211 #[doc = "pin is qualified but not actively used by the DPLL\n"]
212 Standby = 2,
213 #[doc = "pin does not have a valid signal\n"]
214 NoSignal = 3,
215 #[doc = "pin signal failed qualification (e.g. frequency or phase monitor)\n"]
216 QualFailed = 4,
217}
218impl PinOperstate {
219 pub fn from_value(value: u64) -> Option<Self> {
220 Some(match value {
221 1 => Self::Active,
222 2 => Self::Standby,
223 3 => Self::NoSignal,
224 4 => Self::QualFailed,
225 _ => return None,
226 })
227 }
228}
229#[doc = "defines possible capabilities of a pin, valid flags on\nDPLL_A_PIN_CAPABILITIES attribute\n"]
230#[doc = "Flags - defines an integer enumeration, with values for each entry occupying a bit, starting from bit 0, (e.g. 1, 2, 4, 8)"]
231#[derive(Debug, Clone, Copy)]
232pub enum PinCapabilities {
233 #[doc = "pin direction can be changed\n"]
234 DirectionCanChange = 1 << 0,
235 #[doc = "pin priority can be changed\n"]
236 PriorityCanChange = 1 << 1,
237 #[doc = "pin state can be changed\n"]
238 StateCanChange = 1 << 2,
239}
240impl PinCapabilities {
241 pub fn from_value(value: u64) -> Option<Self> {
242 Some(match value {
243 n if n == 1 << 0 => Self::DirectionCanChange,
244 n if n == 1 << 1 => Self::PriorityCanChange,
245 n if n == 1 << 2 => Self::StateCanChange,
246 _ => return None,
247 })
248 }
249}
250#[doc = "phase offset divider allows userspace to calculate a value of measured\nsignal phase difference between a pin and dpll device as a fractional\nvalue with three digit decimal precision. Value of (DPLL_A_PHASE_OFFSET\n/ DPLL_PHASE_OFFSET_DIVIDER) is an integer part of a measured phase\noffset value. Value of (DPLL_A_PHASE_OFFSET % DPLL_PHASE_OFFSET_DIVIDER)\nis a fractional part of a measured phase offset value.\n"]
251pub const PHASE_OFFSET_DIVIDER: u64 = 1000u64;
252#[doc = "pin measured frequency divider allows userspace to calculate a value of\nmeasured input frequency as a fractional value with three digit decimal\nprecision (millihertz). Value of (DPLL_A_PIN_MEASURED_FREQUENCY /\nDPLL_PIN_MEASURED_FREQUENCY_DIVIDER) is an integer part of a measured\nfrequency value. Value of (DPLL_A_PIN_MEASURED_FREQUENCY %\nDPLL_PIN_MEASURED_FREQUENCY_DIVIDER) is a fractional part of a measured\nfrequency value.\n"]
253pub const PIN_MEASURED_FREQUENCY_DIVIDER: u64 = 1000u64;
254#[doc = "Allow control (enable/disable) and status checking over features.\n"]
255#[doc = "Enum - defines an integer enumeration, with values for each entry incrementing by 1, (e.g. 0, 1, 2, 3)"]
256#[derive(Debug, Clone, Copy)]
257pub enum FeatureState {
258 #[doc = "feature shall be disabled\n"]
259 Disable = 0,
260 #[doc = "feature shall be enabled\n"]
261 Enable = 1,
262}
263impl FeatureState {
264 pub fn from_value(value: u64) -> Option<Self> {
265 Some(match value {
266 0 => Self::Disable,
267 1 => Self::Enable,
268 _ => return None,
269 })
270 }
271}
272#[derive(Clone)]
273pub enum Dpll<'a> {
274 Id(u32),
275 ModuleName(&'a CStr),
276 Pad(&'a [u8]),
277 ClockId(u64),
278 #[doc = "Associated type: [`Mode`] (enum)"]
279 Mode(u32),
280 #[doc = "Associated type: [`Mode`] (enum)\nAttribute may repeat multiple times (treat it as array)"]
281 ModeSupported(u32),
282 #[doc = "Associated type: [`LockStatus`] (enum)"]
283 LockStatus(u32),
284 Temp(i32),
285 #[doc = "Associated type: [`Type`] (enum)"]
286 Type(u32),
287 #[doc = "Associated type: [`LockStatusError`] (enum)"]
288 LockStatusError(u32),
289 #[doc = "Level of quality of a clock device. This mainly applies when the dpll\nlock-status is DPLL_LOCK_STATUS_HOLDOVER. This could be put to message\nmultiple times to indicate possible parallel quality levels (e.g. one\nspecified by ITU option 1 and another one specified by option 2).\n\nAssociated type: [`ClockQualityLevel`] (enum)\nAttribute may repeat multiple times (treat it as array)"]
290 ClockQualityLevel(u32),
291 #[doc = "Receive or request state of phase offset monitor feature. If enabled,\ndpll device shall monitor and notify all currently available inputs for\nchanges of their phase offset against the dpll device.\n\nAssociated type: [`FeatureState`] (enum)"]
292 PhaseOffsetMonitor(u32),
293 #[doc = "Averaging factor applied to calculation of reported phase offset.\n"]
294 PhaseOffsetAvgFactor(u32),
295 #[doc = "Current or desired state of the frequency monitor feature. If enabled,\ndpll device shall measure all currently available inputs for their\nactual input frequency.\n\nAssociated type: [`FeatureState`] (enum)"]
296 FrequencyMonitor(u32),
297}
298impl<'a> IterableDpll<'a> {
299 pub fn get_id(&self) -> Result<u32, ErrorContext> {
300 let mut iter = self.clone();
301 iter.pos = 0;
302 for attr in iter {
303 if let Ok(Dpll::Id(val)) = attr {
304 return Ok(val);
305 }
306 }
307 Err(ErrorContext::new_missing(
308 "Dpll",
309 "Id",
310 self.orig_loc,
311 self.buf.as_ptr() as usize,
312 ))
313 }
314 pub fn get_module_name(&self) -> Result<&'a CStr, ErrorContext> {
315 let mut iter = self.clone();
316 iter.pos = 0;
317 for attr in iter {
318 if let Ok(Dpll::ModuleName(val)) = attr {
319 return Ok(val);
320 }
321 }
322 Err(ErrorContext::new_missing(
323 "Dpll",
324 "ModuleName",
325 self.orig_loc,
326 self.buf.as_ptr() as usize,
327 ))
328 }
329 pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
330 let mut iter = self.clone();
331 iter.pos = 0;
332 for attr in iter {
333 if let Ok(Dpll::Pad(val)) = attr {
334 return Ok(val);
335 }
336 }
337 Err(ErrorContext::new_missing(
338 "Dpll",
339 "Pad",
340 self.orig_loc,
341 self.buf.as_ptr() as usize,
342 ))
343 }
344 pub fn get_clock_id(&self) -> Result<u64, ErrorContext> {
345 let mut iter = self.clone();
346 iter.pos = 0;
347 for attr in iter {
348 if let Ok(Dpll::ClockId(val)) = attr {
349 return Ok(val);
350 }
351 }
352 Err(ErrorContext::new_missing(
353 "Dpll",
354 "ClockId",
355 self.orig_loc,
356 self.buf.as_ptr() as usize,
357 ))
358 }
359 #[doc = "Associated type: [`Mode`] (enum)"]
360 pub fn get_mode(&self) -> Result<u32, ErrorContext> {
361 let mut iter = self.clone();
362 iter.pos = 0;
363 for attr in iter {
364 if let Ok(Dpll::Mode(val)) = attr {
365 return Ok(val);
366 }
367 }
368 Err(ErrorContext::new_missing(
369 "Dpll",
370 "Mode",
371 self.orig_loc,
372 self.buf.as_ptr() as usize,
373 ))
374 }
375 #[doc = "Associated type: [`Mode`] (enum)\nAttribute may repeat multiple times (treat it as array)"]
376 pub fn get_mode_supported(&self) -> MultiAttrIterable<Self, Dpll<'a>, u32> {
377 MultiAttrIterable::new(self.clone(), |variant| {
378 if let Dpll::ModeSupported(val) = variant {
379 Some(val)
380 } else {
381 None
382 }
383 })
384 }
385 #[doc = "Associated type: [`LockStatus`] (enum)"]
386 pub fn get_lock_status(&self) -> Result<u32, ErrorContext> {
387 let mut iter = self.clone();
388 iter.pos = 0;
389 for attr in iter {
390 if let Ok(Dpll::LockStatus(val)) = attr {
391 return Ok(val);
392 }
393 }
394 Err(ErrorContext::new_missing(
395 "Dpll",
396 "LockStatus",
397 self.orig_loc,
398 self.buf.as_ptr() as usize,
399 ))
400 }
401 pub fn get_temp(&self) -> Result<i32, ErrorContext> {
402 let mut iter = self.clone();
403 iter.pos = 0;
404 for attr in iter {
405 if let Ok(Dpll::Temp(val)) = attr {
406 return Ok(val);
407 }
408 }
409 Err(ErrorContext::new_missing(
410 "Dpll",
411 "Temp",
412 self.orig_loc,
413 self.buf.as_ptr() as usize,
414 ))
415 }
416 #[doc = "Associated type: [`Type`] (enum)"]
417 pub fn get_type(&self) -> Result<u32, ErrorContext> {
418 let mut iter = self.clone();
419 iter.pos = 0;
420 for attr in iter {
421 if let Ok(Dpll::Type(val)) = attr {
422 return Ok(val);
423 }
424 }
425 Err(ErrorContext::new_missing(
426 "Dpll",
427 "Type",
428 self.orig_loc,
429 self.buf.as_ptr() as usize,
430 ))
431 }
432 #[doc = "Associated type: [`LockStatusError`] (enum)"]
433 pub fn get_lock_status_error(&self) -> Result<u32, ErrorContext> {
434 let mut iter = self.clone();
435 iter.pos = 0;
436 for attr in iter {
437 if let Ok(Dpll::LockStatusError(val)) = attr {
438 return Ok(val);
439 }
440 }
441 Err(ErrorContext::new_missing(
442 "Dpll",
443 "LockStatusError",
444 self.orig_loc,
445 self.buf.as_ptr() as usize,
446 ))
447 }
448 #[doc = "Level of quality of a clock device. This mainly applies when the dpll\nlock-status is DPLL_LOCK_STATUS_HOLDOVER. This could be put to message\nmultiple times to indicate possible parallel quality levels (e.g. one\nspecified by ITU option 1 and another one specified by option 2).\n\nAssociated type: [`ClockQualityLevel`] (enum)\nAttribute may repeat multiple times (treat it as array)"]
449 pub fn get_clock_quality_level(&self) -> MultiAttrIterable<Self, Dpll<'a>, u32> {
450 MultiAttrIterable::new(self.clone(), |variant| {
451 if let Dpll::ClockQualityLevel(val) = variant {
452 Some(val)
453 } else {
454 None
455 }
456 })
457 }
458 #[doc = "Receive or request state of phase offset monitor feature. If enabled,\ndpll device shall monitor and notify all currently available inputs for\nchanges of their phase offset against the dpll device.\n\nAssociated type: [`FeatureState`] (enum)"]
459 pub fn get_phase_offset_monitor(&self) -> Result<u32, ErrorContext> {
460 let mut iter = self.clone();
461 iter.pos = 0;
462 for attr in iter {
463 if let Ok(Dpll::PhaseOffsetMonitor(val)) = attr {
464 return Ok(val);
465 }
466 }
467 Err(ErrorContext::new_missing(
468 "Dpll",
469 "PhaseOffsetMonitor",
470 self.orig_loc,
471 self.buf.as_ptr() as usize,
472 ))
473 }
474 #[doc = "Averaging factor applied to calculation of reported phase offset.\n"]
475 pub fn get_phase_offset_avg_factor(&self) -> Result<u32, ErrorContext> {
476 let mut iter = self.clone();
477 iter.pos = 0;
478 for attr in iter {
479 if let Ok(Dpll::PhaseOffsetAvgFactor(val)) = attr {
480 return Ok(val);
481 }
482 }
483 Err(ErrorContext::new_missing(
484 "Dpll",
485 "PhaseOffsetAvgFactor",
486 self.orig_loc,
487 self.buf.as_ptr() as usize,
488 ))
489 }
490 #[doc = "Current or desired state of the frequency monitor feature. If enabled,\ndpll device shall measure all currently available inputs for their\nactual input frequency.\n\nAssociated type: [`FeatureState`] (enum)"]
491 pub fn get_frequency_monitor(&self) -> Result<u32, ErrorContext> {
492 let mut iter = self.clone();
493 iter.pos = 0;
494 for attr in iter {
495 if let Ok(Dpll::FrequencyMonitor(val)) = attr {
496 return Ok(val);
497 }
498 }
499 Err(ErrorContext::new_missing(
500 "Dpll",
501 "FrequencyMonitor",
502 self.orig_loc,
503 self.buf.as_ptr() as usize,
504 ))
505 }
506}
507impl Dpll<'_> {
508 pub fn new<'a>(buf: &'a [u8]) -> IterableDpll<'a> {
509 IterableDpll::with_loc(buf, buf.as_ptr() as usize)
510 }
511 fn attr_from_type(r#type: u16) -> Option<&'static str> {
512 let res = match r#type {
513 1u16 => "Id",
514 2u16 => "ModuleName",
515 3u16 => "Pad",
516 4u16 => "ClockId",
517 5u16 => "Mode",
518 6u16 => "ModeSupported",
519 7u16 => "LockStatus",
520 8u16 => "Temp",
521 9u16 => "Type",
522 10u16 => "LockStatusError",
523 11u16 => "ClockQualityLevel",
524 12u16 => "PhaseOffsetMonitor",
525 13u16 => "PhaseOffsetAvgFactor",
526 14u16 => "FrequencyMonitor",
527 _ => return None,
528 };
529 Some(res)
530 }
531}
532#[derive(Clone, Copy, Default)]
533pub struct IterableDpll<'a> {
534 buf: &'a [u8],
535 pos: usize,
536 orig_loc: usize,
537}
538impl<'a> IterableDpll<'a> {
539 fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
540 Self {
541 buf,
542 pos: 0,
543 orig_loc,
544 }
545 }
546 pub fn get_buf(&self) -> &'a [u8] {
547 self.buf
548 }
549}
550impl<'a> Iterator for IterableDpll<'a> {
551 type Item = Result<Dpll<'a>, ErrorContext>;
552 fn next(&mut self) -> Option<Self::Item> {
553 let mut pos;
554 let mut r#type;
555 loop {
556 pos = self.pos;
557 r#type = None;
558 if self.buf.len() == self.pos {
559 return None;
560 }
561 let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
562 self.pos = self.buf.len();
563 break;
564 };
565 r#type = Some(header.r#type);
566 let res = match header.r#type {
567 1u16 => Dpll::Id({
568 let res = parse_u32(next);
569 let Some(val) = res else { break };
570 val
571 }),
572 2u16 => Dpll::ModuleName({
573 let res = CStr::from_bytes_with_nul(next).ok();
574 let Some(val) = res else { break };
575 val
576 }),
577 3u16 => Dpll::Pad({
578 let res = Some(next);
579 let Some(val) = res else { break };
580 val
581 }),
582 4u16 => Dpll::ClockId({
583 let res = parse_u64(next);
584 let Some(val) = res else { break };
585 val
586 }),
587 5u16 => Dpll::Mode({
588 let res = parse_u32(next);
589 let Some(val) = res else { break };
590 val
591 }),
592 6u16 => Dpll::ModeSupported({
593 let res = parse_u32(next);
594 let Some(val) = res else { break };
595 val
596 }),
597 7u16 => Dpll::LockStatus({
598 let res = parse_u32(next);
599 let Some(val) = res else { break };
600 val
601 }),
602 8u16 => Dpll::Temp({
603 let res = parse_i32(next);
604 let Some(val) = res else { break };
605 val
606 }),
607 9u16 => Dpll::Type({
608 let res = parse_u32(next);
609 let Some(val) = res else { break };
610 val
611 }),
612 10u16 => Dpll::LockStatusError({
613 let res = parse_u32(next);
614 let Some(val) = res else { break };
615 val
616 }),
617 11u16 => Dpll::ClockQualityLevel({
618 let res = parse_u32(next);
619 let Some(val) = res else { break };
620 val
621 }),
622 12u16 => Dpll::PhaseOffsetMonitor({
623 let res = parse_u32(next);
624 let Some(val) = res else { break };
625 val
626 }),
627 13u16 => Dpll::PhaseOffsetAvgFactor({
628 let res = parse_u32(next);
629 let Some(val) = res else { break };
630 val
631 }),
632 14u16 => Dpll::FrequencyMonitor({
633 let res = parse_u32(next);
634 let Some(val) = res else { break };
635 val
636 }),
637 n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
638 n => continue,
639 };
640 return Some(Ok(res));
641 }
642 Some(Err(ErrorContext::new(
643 "Dpll",
644 r#type.and_then(|t| Dpll::attr_from_type(t)),
645 self.orig_loc,
646 self.buf.as_ptr().wrapping_add(pos) as usize,
647 )))
648 }
649}
650impl<'a> std::fmt::Debug for IterableDpll<'_> {
651 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
652 let mut fmt = f.debug_struct("Dpll");
653 for attr in self.clone() {
654 let attr = match attr {
655 Ok(a) => a,
656 Err(err) => {
657 fmt.finish()?;
658 f.write_str("Err(")?;
659 err.fmt(f)?;
660 return f.write_str(")");
661 }
662 };
663 match attr {
664 Dpll::Id(val) => fmt.field("Id", &val),
665 Dpll::ModuleName(val) => fmt.field("ModuleName", &val),
666 Dpll::Pad(val) => fmt.field("Pad", &val),
667 Dpll::ClockId(val) => fmt.field("ClockId", &val),
668 Dpll::Mode(val) => fmt.field("Mode", &FormatEnum(val.into(), Mode::from_value)),
669 Dpll::ModeSupported(val) => {
670 fmt.field("ModeSupported", &FormatEnum(val.into(), Mode::from_value))
671 }
672 Dpll::LockStatus(val) => fmt.field(
673 "LockStatus",
674 &FormatEnum(val.into(), LockStatus::from_value),
675 ),
676 Dpll::Temp(val) => fmt.field("Temp", &val),
677 Dpll::Type(val) => fmt.field("Type", &FormatEnum(val.into(), Type::from_value)),
678 Dpll::LockStatusError(val) => fmt.field(
679 "LockStatusError",
680 &FormatEnum(val.into(), LockStatusError::from_value),
681 ),
682 Dpll::ClockQualityLevel(val) => fmt.field(
683 "ClockQualityLevel",
684 &FormatEnum(val.into(), ClockQualityLevel::from_value),
685 ),
686 Dpll::PhaseOffsetMonitor(val) => fmt.field(
687 "PhaseOffsetMonitor",
688 &FormatEnum(val.into(), FeatureState::from_value),
689 ),
690 Dpll::PhaseOffsetAvgFactor(val) => fmt.field("PhaseOffsetAvgFactor", &val),
691 Dpll::FrequencyMonitor(val) => fmt.field(
692 "FrequencyMonitor",
693 &FormatEnum(val.into(), FeatureState::from_value),
694 ),
695 };
696 }
697 fmt.finish()
698 }
699}
700impl IterableDpll<'_> {
701 pub fn lookup_attr(
702 &self,
703 offset: usize,
704 missing_type: Option<u16>,
705 ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
706 let mut stack = Vec::new();
707 let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
708 if missing_type.is_some() && cur == offset {
709 stack.push(("Dpll", offset));
710 return (stack, missing_type.and_then(|t| Dpll::attr_from_type(t)));
711 }
712 if cur > offset || cur + self.buf.len() < offset {
713 return (stack, None);
714 }
715 let mut attrs = self.clone();
716 let mut last_off = cur + attrs.pos;
717 while let Some(attr) = attrs.next() {
718 let Ok(attr) = attr else { break };
719 match attr {
720 Dpll::Id(val) => {
721 if last_off == offset {
722 stack.push(("Id", last_off));
723 break;
724 }
725 }
726 Dpll::ModuleName(val) => {
727 if last_off == offset {
728 stack.push(("ModuleName", last_off));
729 break;
730 }
731 }
732 Dpll::Pad(val) => {
733 if last_off == offset {
734 stack.push(("Pad", last_off));
735 break;
736 }
737 }
738 Dpll::ClockId(val) => {
739 if last_off == offset {
740 stack.push(("ClockId", last_off));
741 break;
742 }
743 }
744 Dpll::Mode(val) => {
745 if last_off == offset {
746 stack.push(("Mode", last_off));
747 break;
748 }
749 }
750 Dpll::ModeSupported(val) => {
751 if last_off == offset {
752 stack.push(("ModeSupported", last_off));
753 break;
754 }
755 }
756 Dpll::LockStatus(val) => {
757 if last_off == offset {
758 stack.push(("LockStatus", last_off));
759 break;
760 }
761 }
762 Dpll::Temp(val) => {
763 if last_off == offset {
764 stack.push(("Temp", last_off));
765 break;
766 }
767 }
768 Dpll::Type(val) => {
769 if last_off == offset {
770 stack.push(("Type", last_off));
771 break;
772 }
773 }
774 Dpll::LockStatusError(val) => {
775 if last_off == offset {
776 stack.push(("LockStatusError", last_off));
777 break;
778 }
779 }
780 Dpll::ClockQualityLevel(val) => {
781 if last_off == offset {
782 stack.push(("ClockQualityLevel", last_off));
783 break;
784 }
785 }
786 Dpll::PhaseOffsetMonitor(val) => {
787 if last_off == offset {
788 stack.push(("PhaseOffsetMonitor", last_off));
789 break;
790 }
791 }
792 Dpll::PhaseOffsetAvgFactor(val) => {
793 if last_off == offset {
794 stack.push(("PhaseOffsetAvgFactor", last_off));
795 break;
796 }
797 }
798 Dpll::FrequencyMonitor(val) => {
799 if last_off == offset {
800 stack.push(("FrequencyMonitor", last_off));
801 break;
802 }
803 }
804 _ => {}
805 };
806 last_off = cur + attrs.pos;
807 }
808 if !stack.is_empty() {
809 stack.push(("Dpll", cur));
810 }
811 (stack, None)
812 }
813}
814#[derive(Clone)]
815pub enum Pin<'a> {
816 Id(u32),
817 ParentId(u32),
818 ModuleName(&'a CStr),
819 Pad(&'a [u8]),
820 ClockId(u64),
821 BoardLabel(&'a CStr),
822 PanelLabel(&'a CStr),
823 PackageLabel(&'a CStr),
824 #[doc = "Associated type: [`PinType`] (enum)"]
825 Type(u32),
826 #[doc = "Associated type: [`PinDirection`] (enum)"]
827 Direction(u32),
828 Frequency(u64),
829 #[doc = "Attribute may repeat multiple times (treat it as array)"]
830 FrequencySupported(IterableFrequencyRange<'a>),
831 FrequencyMin(u64),
832 FrequencyMax(u64),
833 Prio(u32),
834 #[doc = "Associated type: [`PinState`] (enum)"]
835 State(u32),
836 #[doc = "Associated type: [`PinCapabilities`] (enum)"]
837 Capabilities(u32),
838 #[doc = "Attribute may repeat multiple times (treat it as array)"]
839 ParentDevice(IterablePinParentDevice<'a>),
840 #[doc = "Attribute may repeat multiple times (treat it as array)"]
841 ParentPin(IterablePinParentPin<'a>),
842 PhaseAdjustMin(i32),
843 PhaseAdjustMax(i32),
844 PhaseAdjust(i32),
845 PhaseOffset(i64),
846 #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPM\n(parts per million). This is a lower-precision version of\nfractional-frequency-offset-ppt.\n"]
847 FractionalFrequencyOffset(i32),
848 #[doc = "Frequency of Embedded SYNC signal. If provided, the pin is configured\nwith a SYNC signal embedded into its base clock frequency.\n"]
849 EsyncFrequency(u64),
850 #[doc = "If provided a pin is capable of embedding a SYNC signal (within given\nrange) into its base frequency signal.\n\nAttribute may repeat multiple times (treat it as array)"]
851 EsyncFrequencySupported(IterableFrequencyRange<'a>),
852 #[doc = "A ratio of high to low state of a SYNC signal pulse embedded into base\nclock frequency. Value is in percents.\n"]
853 EsyncPulse(u32),
854 #[doc = "Capable pin provides list of pins that can be bound to create a\nreference-sync pin pair.\n\nAttribute may repeat multiple times (treat it as array)"]
855 ReferenceSync(IterableReferenceSync<'a>),
856 #[doc = "Granularity of phase adjustment, in picoseconds. The value of phase\nadjustment must be a multiple of this granularity.\n"]
857 PhaseAdjustGran(u32),
858 #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPT\n(parts per trillion, 10\\^-12). This is a higher-precision version of\nfractional-frequency-offset.\n"]
859 FractionalFrequencyOffsetPpt(i32),
860 #[doc = "The measured frequency of the input pin in millihertz (mHz). Value of\n(DPLL_A_PIN_MEASURED_FREQUENCY / DPLL_PIN_MEASURED_FREQUENCY_DIVIDER) is\nan integer part (Hz) of a measured frequency value. Value of\n(DPLL_A_PIN_MEASURED_FREQUENCY % DPLL_PIN_MEASURED_FREQUENCY_DIVIDER) is\na fractional part of a measured frequency value.\n"]
861 MeasuredFrequency(u64),
862 #[doc = "Operational state of the pin with respect to its parent DPLL device.\nUnlike state (which reflects the administrative intent), operstate\nreflects the actual hardware status.\n\nAssociated type: [`PinOperstate`] (enum)"]
863 Operstate(u32),
864}
865impl<'a> IterablePin<'a> {
866 pub fn get_id(&self) -> Result<u32, ErrorContext> {
867 let mut iter = self.clone();
868 iter.pos = 0;
869 for attr in iter {
870 if let Ok(Pin::Id(val)) = attr {
871 return Ok(val);
872 }
873 }
874 Err(ErrorContext::new_missing(
875 "Pin",
876 "Id",
877 self.orig_loc,
878 self.buf.as_ptr() as usize,
879 ))
880 }
881 pub fn get_parent_id(&self) -> Result<u32, ErrorContext> {
882 let mut iter = self.clone();
883 iter.pos = 0;
884 for attr in iter {
885 if let Ok(Pin::ParentId(val)) = attr {
886 return Ok(val);
887 }
888 }
889 Err(ErrorContext::new_missing(
890 "Pin",
891 "ParentId",
892 self.orig_loc,
893 self.buf.as_ptr() as usize,
894 ))
895 }
896 pub fn get_module_name(&self) -> Result<&'a CStr, ErrorContext> {
897 let mut iter = self.clone();
898 iter.pos = 0;
899 for attr in iter {
900 if let Ok(Pin::ModuleName(val)) = attr {
901 return Ok(val);
902 }
903 }
904 Err(ErrorContext::new_missing(
905 "Pin",
906 "ModuleName",
907 self.orig_loc,
908 self.buf.as_ptr() as usize,
909 ))
910 }
911 pub fn get_pad(&self) -> Result<&'a [u8], ErrorContext> {
912 let mut iter = self.clone();
913 iter.pos = 0;
914 for attr in iter {
915 if let Ok(Pin::Pad(val)) = attr {
916 return Ok(val);
917 }
918 }
919 Err(ErrorContext::new_missing(
920 "Pin",
921 "Pad",
922 self.orig_loc,
923 self.buf.as_ptr() as usize,
924 ))
925 }
926 pub fn get_clock_id(&self) -> Result<u64, ErrorContext> {
927 let mut iter = self.clone();
928 iter.pos = 0;
929 for attr in iter {
930 if let Ok(Pin::ClockId(val)) = attr {
931 return Ok(val);
932 }
933 }
934 Err(ErrorContext::new_missing(
935 "Pin",
936 "ClockId",
937 self.orig_loc,
938 self.buf.as_ptr() as usize,
939 ))
940 }
941 pub fn get_board_label(&self) -> Result<&'a CStr, ErrorContext> {
942 let mut iter = self.clone();
943 iter.pos = 0;
944 for attr in iter {
945 if let Ok(Pin::BoardLabel(val)) = attr {
946 return Ok(val);
947 }
948 }
949 Err(ErrorContext::new_missing(
950 "Pin",
951 "BoardLabel",
952 self.orig_loc,
953 self.buf.as_ptr() as usize,
954 ))
955 }
956 pub fn get_panel_label(&self) -> Result<&'a CStr, ErrorContext> {
957 let mut iter = self.clone();
958 iter.pos = 0;
959 for attr in iter {
960 if let Ok(Pin::PanelLabel(val)) = attr {
961 return Ok(val);
962 }
963 }
964 Err(ErrorContext::new_missing(
965 "Pin",
966 "PanelLabel",
967 self.orig_loc,
968 self.buf.as_ptr() as usize,
969 ))
970 }
971 pub fn get_package_label(&self) -> Result<&'a CStr, ErrorContext> {
972 let mut iter = self.clone();
973 iter.pos = 0;
974 for attr in iter {
975 if let Ok(Pin::PackageLabel(val)) = attr {
976 return Ok(val);
977 }
978 }
979 Err(ErrorContext::new_missing(
980 "Pin",
981 "PackageLabel",
982 self.orig_loc,
983 self.buf.as_ptr() as usize,
984 ))
985 }
986 #[doc = "Associated type: [`PinType`] (enum)"]
987 pub fn get_type(&self) -> Result<u32, ErrorContext> {
988 let mut iter = self.clone();
989 iter.pos = 0;
990 for attr in iter {
991 if let Ok(Pin::Type(val)) = attr {
992 return Ok(val);
993 }
994 }
995 Err(ErrorContext::new_missing(
996 "Pin",
997 "Type",
998 self.orig_loc,
999 self.buf.as_ptr() as usize,
1000 ))
1001 }
1002 #[doc = "Associated type: [`PinDirection`] (enum)"]
1003 pub fn get_direction(&self) -> Result<u32, ErrorContext> {
1004 let mut iter = self.clone();
1005 iter.pos = 0;
1006 for attr in iter {
1007 if let Ok(Pin::Direction(val)) = attr {
1008 return Ok(val);
1009 }
1010 }
1011 Err(ErrorContext::new_missing(
1012 "Pin",
1013 "Direction",
1014 self.orig_loc,
1015 self.buf.as_ptr() as usize,
1016 ))
1017 }
1018 pub fn get_frequency(&self) -> Result<u64, ErrorContext> {
1019 let mut iter = self.clone();
1020 iter.pos = 0;
1021 for attr in iter {
1022 if let Ok(Pin::Frequency(val)) = attr {
1023 return Ok(val);
1024 }
1025 }
1026 Err(ErrorContext::new_missing(
1027 "Pin",
1028 "Frequency",
1029 self.orig_loc,
1030 self.buf.as_ptr() as usize,
1031 ))
1032 }
1033 #[doc = "Attribute may repeat multiple times (treat it as array)"]
1034 pub fn get_frequency_supported(
1035 &self,
1036 ) -> MultiAttrIterable<Self, Pin<'a>, IterableFrequencyRange<'a>> {
1037 MultiAttrIterable::new(self.clone(), |variant| {
1038 if let Pin::FrequencySupported(val) = variant {
1039 Some(val)
1040 } else {
1041 None
1042 }
1043 })
1044 }
1045 pub fn get_frequency_min(&self) -> Result<u64, ErrorContext> {
1046 let mut iter = self.clone();
1047 iter.pos = 0;
1048 for attr in iter {
1049 if let Ok(Pin::FrequencyMin(val)) = attr {
1050 return Ok(val);
1051 }
1052 }
1053 Err(ErrorContext::new_missing(
1054 "Pin",
1055 "FrequencyMin",
1056 self.orig_loc,
1057 self.buf.as_ptr() as usize,
1058 ))
1059 }
1060 pub fn get_frequency_max(&self) -> Result<u64, ErrorContext> {
1061 let mut iter = self.clone();
1062 iter.pos = 0;
1063 for attr in iter {
1064 if let Ok(Pin::FrequencyMax(val)) = attr {
1065 return Ok(val);
1066 }
1067 }
1068 Err(ErrorContext::new_missing(
1069 "Pin",
1070 "FrequencyMax",
1071 self.orig_loc,
1072 self.buf.as_ptr() as usize,
1073 ))
1074 }
1075 pub fn get_prio(&self) -> Result<u32, ErrorContext> {
1076 let mut iter = self.clone();
1077 iter.pos = 0;
1078 for attr in iter {
1079 if let Ok(Pin::Prio(val)) = attr {
1080 return Ok(val);
1081 }
1082 }
1083 Err(ErrorContext::new_missing(
1084 "Pin",
1085 "Prio",
1086 self.orig_loc,
1087 self.buf.as_ptr() as usize,
1088 ))
1089 }
1090 #[doc = "Associated type: [`PinState`] (enum)"]
1091 pub fn get_state(&self) -> Result<u32, ErrorContext> {
1092 let mut iter = self.clone();
1093 iter.pos = 0;
1094 for attr in iter {
1095 if let Ok(Pin::State(val)) = attr {
1096 return Ok(val);
1097 }
1098 }
1099 Err(ErrorContext::new_missing(
1100 "Pin",
1101 "State",
1102 self.orig_loc,
1103 self.buf.as_ptr() as usize,
1104 ))
1105 }
1106 #[doc = "Associated type: [`PinCapabilities`] (enum)"]
1107 pub fn get_capabilities(&self) -> Result<u32, ErrorContext> {
1108 let mut iter = self.clone();
1109 iter.pos = 0;
1110 for attr in iter {
1111 if let Ok(Pin::Capabilities(val)) = attr {
1112 return Ok(val);
1113 }
1114 }
1115 Err(ErrorContext::new_missing(
1116 "Pin",
1117 "Capabilities",
1118 self.orig_loc,
1119 self.buf.as_ptr() as usize,
1120 ))
1121 }
1122 #[doc = "Attribute may repeat multiple times (treat it as array)"]
1123 pub fn get_parent_device(
1124 &self,
1125 ) -> MultiAttrIterable<Self, Pin<'a>, IterablePinParentDevice<'a>> {
1126 MultiAttrIterable::new(self.clone(), |variant| {
1127 if let Pin::ParentDevice(val) = variant {
1128 Some(val)
1129 } else {
1130 None
1131 }
1132 })
1133 }
1134 #[doc = "Attribute may repeat multiple times (treat it as array)"]
1135 pub fn get_parent_pin(&self) -> MultiAttrIterable<Self, Pin<'a>, IterablePinParentPin<'a>> {
1136 MultiAttrIterable::new(self.clone(), |variant| {
1137 if let Pin::ParentPin(val) = variant {
1138 Some(val)
1139 } else {
1140 None
1141 }
1142 })
1143 }
1144 pub fn get_phase_adjust_min(&self) -> Result<i32, ErrorContext> {
1145 let mut iter = self.clone();
1146 iter.pos = 0;
1147 for attr in iter {
1148 if let Ok(Pin::PhaseAdjustMin(val)) = attr {
1149 return Ok(val);
1150 }
1151 }
1152 Err(ErrorContext::new_missing(
1153 "Pin",
1154 "PhaseAdjustMin",
1155 self.orig_loc,
1156 self.buf.as_ptr() as usize,
1157 ))
1158 }
1159 pub fn get_phase_adjust_max(&self) -> Result<i32, ErrorContext> {
1160 let mut iter = self.clone();
1161 iter.pos = 0;
1162 for attr in iter {
1163 if let Ok(Pin::PhaseAdjustMax(val)) = attr {
1164 return Ok(val);
1165 }
1166 }
1167 Err(ErrorContext::new_missing(
1168 "Pin",
1169 "PhaseAdjustMax",
1170 self.orig_loc,
1171 self.buf.as_ptr() as usize,
1172 ))
1173 }
1174 pub fn get_phase_adjust(&self) -> Result<i32, ErrorContext> {
1175 let mut iter = self.clone();
1176 iter.pos = 0;
1177 for attr in iter {
1178 if let Ok(Pin::PhaseAdjust(val)) = attr {
1179 return Ok(val);
1180 }
1181 }
1182 Err(ErrorContext::new_missing(
1183 "Pin",
1184 "PhaseAdjust",
1185 self.orig_loc,
1186 self.buf.as_ptr() as usize,
1187 ))
1188 }
1189 pub fn get_phase_offset(&self) -> Result<i64, ErrorContext> {
1190 let mut iter = self.clone();
1191 iter.pos = 0;
1192 for attr in iter {
1193 if let Ok(Pin::PhaseOffset(val)) = attr {
1194 return Ok(val);
1195 }
1196 }
1197 Err(ErrorContext::new_missing(
1198 "Pin",
1199 "PhaseOffset",
1200 self.orig_loc,
1201 self.buf.as_ptr() as usize,
1202 ))
1203 }
1204 #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPM\n(parts per million). This is a lower-precision version of\nfractional-frequency-offset-ppt.\n"]
1205 pub fn get_fractional_frequency_offset(&self) -> Result<i32, ErrorContext> {
1206 let mut iter = self.clone();
1207 iter.pos = 0;
1208 for attr in iter {
1209 if let Ok(Pin::FractionalFrequencyOffset(val)) = attr {
1210 return Ok(val);
1211 }
1212 }
1213 Err(ErrorContext::new_missing(
1214 "Pin",
1215 "FractionalFrequencyOffset",
1216 self.orig_loc,
1217 self.buf.as_ptr() as usize,
1218 ))
1219 }
1220 #[doc = "Frequency of Embedded SYNC signal. If provided, the pin is configured\nwith a SYNC signal embedded into its base clock frequency.\n"]
1221 pub fn get_esync_frequency(&self) -> Result<u64, ErrorContext> {
1222 let mut iter = self.clone();
1223 iter.pos = 0;
1224 for attr in iter {
1225 if let Ok(Pin::EsyncFrequency(val)) = attr {
1226 return Ok(val);
1227 }
1228 }
1229 Err(ErrorContext::new_missing(
1230 "Pin",
1231 "EsyncFrequency",
1232 self.orig_loc,
1233 self.buf.as_ptr() as usize,
1234 ))
1235 }
1236 #[doc = "If provided a pin is capable of embedding a SYNC signal (within given\nrange) into its base frequency signal.\n\nAttribute may repeat multiple times (treat it as array)"]
1237 pub fn get_esync_frequency_supported(
1238 &self,
1239 ) -> MultiAttrIterable<Self, Pin<'a>, IterableFrequencyRange<'a>> {
1240 MultiAttrIterable::new(self.clone(), |variant| {
1241 if let Pin::EsyncFrequencySupported(val) = variant {
1242 Some(val)
1243 } else {
1244 None
1245 }
1246 })
1247 }
1248 #[doc = "A ratio of high to low state of a SYNC signal pulse embedded into base\nclock frequency. Value is in percents.\n"]
1249 pub fn get_esync_pulse(&self) -> Result<u32, ErrorContext> {
1250 let mut iter = self.clone();
1251 iter.pos = 0;
1252 for attr in iter {
1253 if let Ok(Pin::EsyncPulse(val)) = attr {
1254 return Ok(val);
1255 }
1256 }
1257 Err(ErrorContext::new_missing(
1258 "Pin",
1259 "EsyncPulse",
1260 self.orig_loc,
1261 self.buf.as_ptr() as usize,
1262 ))
1263 }
1264 #[doc = "Capable pin provides list of pins that can be bound to create a\nreference-sync pin pair.\n\nAttribute may repeat multiple times (treat it as array)"]
1265 pub fn get_reference_sync(
1266 &self,
1267 ) -> MultiAttrIterable<Self, Pin<'a>, IterableReferenceSync<'a>> {
1268 MultiAttrIterable::new(self.clone(), |variant| {
1269 if let Pin::ReferenceSync(val) = variant {
1270 Some(val)
1271 } else {
1272 None
1273 }
1274 })
1275 }
1276 #[doc = "Granularity of phase adjustment, in picoseconds. The value of phase\nadjustment must be a multiple of this granularity.\n"]
1277 pub fn get_phase_adjust_gran(&self) -> Result<u32, ErrorContext> {
1278 let mut iter = self.clone();
1279 iter.pos = 0;
1280 for attr in iter {
1281 if let Ok(Pin::PhaseAdjustGran(val)) = attr {
1282 return Ok(val);
1283 }
1284 }
1285 Err(ErrorContext::new_missing(
1286 "Pin",
1287 "PhaseAdjustGran",
1288 self.orig_loc,
1289 self.buf.as_ptr() as usize,
1290 ))
1291 }
1292 #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPT\n(parts per trillion, 10\\^-12). This is a higher-precision version of\nfractional-frequency-offset.\n"]
1293 pub fn get_fractional_frequency_offset_ppt(&self) -> Result<i32, ErrorContext> {
1294 let mut iter = self.clone();
1295 iter.pos = 0;
1296 for attr in iter {
1297 if let Ok(Pin::FractionalFrequencyOffsetPpt(val)) = attr {
1298 return Ok(val);
1299 }
1300 }
1301 Err(ErrorContext::new_missing(
1302 "Pin",
1303 "FractionalFrequencyOffsetPpt",
1304 self.orig_loc,
1305 self.buf.as_ptr() as usize,
1306 ))
1307 }
1308 #[doc = "The measured frequency of the input pin in millihertz (mHz). Value of\n(DPLL_A_PIN_MEASURED_FREQUENCY / DPLL_PIN_MEASURED_FREQUENCY_DIVIDER) is\nan integer part (Hz) of a measured frequency value. Value of\n(DPLL_A_PIN_MEASURED_FREQUENCY % DPLL_PIN_MEASURED_FREQUENCY_DIVIDER) is\na fractional part of a measured frequency value.\n"]
1309 pub fn get_measured_frequency(&self) -> Result<u64, ErrorContext> {
1310 let mut iter = self.clone();
1311 iter.pos = 0;
1312 for attr in iter {
1313 if let Ok(Pin::MeasuredFrequency(val)) = attr {
1314 return Ok(val);
1315 }
1316 }
1317 Err(ErrorContext::new_missing(
1318 "Pin",
1319 "MeasuredFrequency",
1320 self.orig_loc,
1321 self.buf.as_ptr() as usize,
1322 ))
1323 }
1324 #[doc = "Operational state of the pin with respect to its parent DPLL device.\nUnlike state (which reflects the administrative intent), operstate\nreflects the actual hardware status.\n\nAssociated type: [`PinOperstate`] (enum)"]
1325 pub fn get_operstate(&self) -> Result<u32, ErrorContext> {
1326 let mut iter = self.clone();
1327 iter.pos = 0;
1328 for attr in iter {
1329 if let Ok(Pin::Operstate(val)) = attr {
1330 return Ok(val);
1331 }
1332 }
1333 Err(ErrorContext::new_missing(
1334 "Pin",
1335 "Operstate",
1336 self.orig_loc,
1337 self.buf.as_ptr() as usize,
1338 ))
1339 }
1340}
1341impl Pin<'_> {
1342 pub fn new<'a>(buf: &'a [u8]) -> IterablePin<'a> {
1343 IterablePin::with_loc(buf, buf.as_ptr() as usize)
1344 }
1345 fn attr_from_type(r#type: u16) -> Option<&'static str> {
1346 let res = match r#type {
1347 1u16 => "Id",
1348 2u16 => "ParentId",
1349 3u16 => "ModuleName",
1350 4u16 => "Pad",
1351 5u16 => "ClockId",
1352 6u16 => "BoardLabel",
1353 7u16 => "PanelLabel",
1354 8u16 => "PackageLabel",
1355 9u16 => "Type",
1356 10u16 => "Direction",
1357 11u16 => "Frequency",
1358 12u16 => "FrequencySupported",
1359 13u16 => "FrequencyMin",
1360 14u16 => "FrequencyMax",
1361 15u16 => "Prio",
1362 16u16 => "State",
1363 17u16 => "Capabilities",
1364 18u16 => "ParentDevice",
1365 19u16 => "ParentPin",
1366 20u16 => "PhaseAdjustMin",
1367 21u16 => "PhaseAdjustMax",
1368 22u16 => "PhaseAdjust",
1369 23u16 => "PhaseOffset",
1370 24u16 => "FractionalFrequencyOffset",
1371 25u16 => "EsyncFrequency",
1372 26u16 => "EsyncFrequencySupported",
1373 27u16 => "EsyncPulse",
1374 28u16 => "ReferenceSync",
1375 29u16 => "PhaseAdjustGran",
1376 30u16 => "FractionalFrequencyOffsetPpt",
1377 31u16 => "MeasuredFrequency",
1378 32u16 => "Operstate",
1379 _ => return None,
1380 };
1381 Some(res)
1382 }
1383}
1384#[derive(Clone, Copy, Default)]
1385pub struct IterablePin<'a> {
1386 buf: &'a [u8],
1387 pos: usize,
1388 orig_loc: usize,
1389}
1390impl<'a> IterablePin<'a> {
1391 fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
1392 Self {
1393 buf,
1394 pos: 0,
1395 orig_loc,
1396 }
1397 }
1398 pub fn get_buf(&self) -> &'a [u8] {
1399 self.buf
1400 }
1401}
1402impl<'a> Iterator for IterablePin<'a> {
1403 type Item = Result<Pin<'a>, ErrorContext>;
1404 fn next(&mut self) -> Option<Self::Item> {
1405 let mut pos;
1406 let mut r#type;
1407 loop {
1408 pos = self.pos;
1409 r#type = None;
1410 if self.buf.len() == self.pos {
1411 return None;
1412 }
1413 let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
1414 self.pos = self.buf.len();
1415 break;
1416 };
1417 r#type = Some(header.r#type);
1418 let res = match header.r#type {
1419 1u16 => Pin::Id({
1420 let res = parse_u32(next);
1421 let Some(val) = res else { break };
1422 val
1423 }),
1424 2u16 => Pin::ParentId({
1425 let res = parse_u32(next);
1426 let Some(val) = res else { break };
1427 val
1428 }),
1429 3u16 => Pin::ModuleName({
1430 let res = CStr::from_bytes_with_nul(next).ok();
1431 let Some(val) = res else { break };
1432 val
1433 }),
1434 4u16 => Pin::Pad({
1435 let res = Some(next);
1436 let Some(val) = res else { break };
1437 val
1438 }),
1439 5u16 => Pin::ClockId({
1440 let res = parse_u64(next);
1441 let Some(val) = res else { break };
1442 val
1443 }),
1444 6u16 => Pin::BoardLabel({
1445 let res = CStr::from_bytes_with_nul(next).ok();
1446 let Some(val) = res else { break };
1447 val
1448 }),
1449 7u16 => Pin::PanelLabel({
1450 let res = CStr::from_bytes_with_nul(next).ok();
1451 let Some(val) = res else { break };
1452 val
1453 }),
1454 8u16 => Pin::PackageLabel({
1455 let res = CStr::from_bytes_with_nul(next).ok();
1456 let Some(val) = res else { break };
1457 val
1458 }),
1459 9u16 => Pin::Type({
1460 let res = parse_u32(next);
1461 let Some(val) = res else { break };
1462 val
1463 }),
1464 10u16 => Pin::Direction({
1465 let res = parse_u32(next);
1466 let Some(val) = res else { break };
1467 val
1468 }),
1469 11u16 => Pin::Frequency({
1470 let res = parse_u64(next);
1471 let Some(val) = res else { break };
1472 val
1473 }),
1474 12u16 => Pin::FrequencySupported({
1475 let res = Some(IterableFrequencyRange::with_loc(next, self.orig_loc));
1476 let Some(val) = res else { break };
1477 val
1478 }),
1479 13u16 => Pin::FrequencyMin({
1480 let res = parse_u64(next);
1481 let Some(val) = res else { break };
1482 val
1483 }),
1484 14u16 => Pin::FrequencyMax({
1485 let res = parse_u64(next);
1486 let Some(val) = res else { break };
1487 val
1488 }),
1489 15u16 => Pin::Prio({
1490 let res = parse_u32(next);
1491 let Some(val) = res else { break };
1492 val
1493 }),
1494 16u16 => Pin::State({
1495 let res = parse_u32(next);
1496 let Some(val) = res else { break };
1497 val
1498 }),
1499 17u16 => Pin::Capabilities({
1500 let res = parse_u32(next);
1501 let Some(val) = res else { break };
1502 val
1503 }),
1504 18u16 => Pin::ParentDevice({
1505 let res = Some(IterablePinParentDevice::with_loc(next, self.orig_loc));
1506 let Some(val) = res else { break };
1507 val
1508 }),
1509 19u16 => Pin::ParentPin({
1510 let res = Some(IterablePinParentPin::with_loc(next, self.orig_loc));
1511 let Some(val) = res else { break };
1512 val
1513 }),
1514 20u16 => Pin::PhaseAdjustMin({
1515 let res = parse_i32(next);
1516 let Some(val) = res else { break };
1517 val
1518 }),
1519 21u16 => Pin::PhaseAdjustMax({
1520 let res = parse_i32(next);
1521 let Some(val) = res else { break };
1522 val
1523 }),
1524 22u16 => Pin::PhaseAdjust({
1525 let res = parse_i32(next);
1526 let Some(val) = res else { break };
1527 val
1528 }),
1529 23u16 => Pin::PhaseOffset({
1530 let res = parse_i64(next);
1531 let Some(val) = res else { break };
1532 val
1533 }),
1534 24u16 => Pin::FractionalFrequencyOffset({
1535 let res = parse_i32(next);
1536 let Some(val) = res else { break };
1537 val
1538 }),
1539 25u16 => Pin::EsyncFrequency({
1540 let res = parse_u64(next);
1541 let Some(val) = res else { break };
1542 val
1543 }),
1544 26u16 => Pin::EsyncFrequencySupported({
1545 let res = Some(IterableFrequencyRange::with_loc(next, self.orig_loc));
1546 let Some(val) = res else { break };
1547 val
1548 }),
1549 27u16 => Pin::EsyncPulse({
1550 let res = parse_u32(next);
1551 let Some(val) = res else { break };
1552 val
1553 }),
1554 28u16 => Pin::ReferenceSync({
1555 let res = Some(IterableReferenceSync::with_loc(next, self.orig_loc));
1556 let Some(val) = res else { break };
1557 val
1558 }),
1559 29u16 => Pin::PhaseAdjustGran({
1560 let res = parse_u32(next);
1561 let Some(val) = res else { break };
1562 val
1563 }),
1564 30u16 => Pin::FractionalFrequencyOffsetPpt({
1565 let res = parse_i32(next);
1566 let Some(val) = res else { break };
1567 val
1568 }),
1569 31u16 => Pin::MeasuredFrequency({
1570 let res = parse_u64(next);
1571 let Some(val) = res else { break };
1572 val
1573 }),
1574 32u16 => Pin::Operstate({
1575 let res = parse_u32(next);
1576 let Some(val) = res else { break };
1577 val
1578 }),
1579 n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
1580 n => continue,
1581 };
1582 return Some(Ok(res));
1583 }
1584 Some(Err(ErrorContext::new(
1585 "Pin",
1586 r#type.and_then(|t| Pin::attr_from_type(t)),
1587 self.orig_loc,
1588 self.buf.as_ptr().wrapping_add(pos) as usize,
1589 )))
1590 }
1591}
1592impl<'a> std::fmt::Debug for IterablePin<'_> {
1593 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1594 let mut fmt = f.debug_struct("Pin");
1595 for attr in self.clone() {
1596 let attr = match attr {
1597 Ok(a) => a,
1598 Err(err) => {
1599 fmt.finish()?;
1600 f.write_str("Err(")?;
1601 err.fmt(f)?;
1602 return f.write_str(")");
1603 }
1604 };
1605 match attr {
1606 Pin::Id(val) => fmt.field("Id", &val),
1607 Pin::ParentId(val) => fmt.field("ParentId", &val),
1608 Pin::ModuleName(val) => fmt.field("ModuleName", &val),
1609 Pin::Pad(val) => fmt.field("Pad", &val),
1610 Pin::ClockId(val) => fmt.field("ClockId", &val),
1611 Pin::BoardLabel(val) => fmt.field("BoardLabel", &val),
1612 Pin::PanelLabel(val) => fmt.field("PanelLabel", &val),
1613 Pin::PackageLabel(val) => fmt.field("PackageLabel", &val),
1614 Pin::Type(val) => fmt.field("Type", &FormatEnum(val.into(), PinType::from_value)),
1615 Pin::Direction(val) => fmt.field(
1616 "Direction",
1617 &FormatEnum(val.into(), PinDirection::from_value),
1618 ),
1619 Pin::Frequency(val) => fmt.field("Frequency", &val),
1620 Pin::FrequencySupported(val) => fmt.field("FrequencySupported", &val),
1621 Pin::FrequencyMin(val) => fmt.field("FrequencyMin", &val),
1622 Pin::FrequencyMax(val) => fmt.field("FrequencyMax", &val),
1623 Pin::Prio(val) => fmt.field("Prio", &val),
1624 Pin::State(val) => {
1625 fmt.field("State", &FormatEnum(val.into(), PinState::from_value))
1626 }
1627 Pin::Capabilities(val) => fmt.field(
1628 "Capabilities",
1629 &FormatFlags(val.into(), PinCapabilities::from_value),
1630 ),
1631 Pin::ParentDevice(val) => fmt.field("ParentDevice", &val),
1632 Pin::ParentPin(val) => fmt.field("ParentPin", &val),
1633 Pin::PhaseAdjustMin(val) => fmt.field("PhaseAdjustMin", &val),
1634 Pin::PhaseAdjustMax(val) => fmt.field("PhaseAdjustMax", &val),
1635 Pin::PhaseAdjust(val) => fmt.field("PhaseAdjust", &val),
1636 Pin::PhaseOffset(val) => fmt.field("PhaseOffset", &val),
1637 Pin::FractionalFrequencyOffset(val) => fmt.field("FractionalFrequencyOffset", &val),
1638 Pin::EsyncFrequency(val) => fmt.field("EsyncFrequency", &val),
1639 Pin::EsyncFrequencySupported(val) => fmt.field("EsyncFrequencySupported", &val),
1640 Pin::EsyncPulse(val) => fmt.field("EsyncPulse", &val),
1641 Pin::ReferenceSync(val) => fmt.field("ReferenceSync", &val),
1642 Pin::PhaseAdjustGran(val) => fmt.field("PhaseAdjustGran", &val),
1643 Pin::FractionalFrequencyOffsetPpt(val) => {
1644 fmt.field("FractionalFrequencyOffsetPpt", &val)
1645 }
1646 Pin::MeasuredFrequency(val) => fmt.field("MeasuredFrequency", &val),
1647 Pin::Operstate(val) => fmt.field(
1648 "Operstate",
1649 &FormatEnum(val.into(), PinOperstate::from_value),
1650 ),
1651 };
1652 }
1653 fmt.finish()
1654 }
1655}
1656impl IterablePin<'_> {
1657 pub fn lookup_attr(
1658 &self,
1659 offset: usize,
1660 missing_type: Option<u16>,
1661 ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
1662 let mut stack = Vec::new();
1663 let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
1664 if missing_type.is_some() && cur == offset {
1665 stack.push(("Pin", offset));
1666 return (stack, missing_type.and_then(|t| Pin::attr_from_type(t)));
1667 }
1668 if cur > offset || cur + self.buf.len() < offset {
1669 return (stack, None);
1670 }
1671 let mut attrs = self.clone();
1672 let mut last_off = cur + attrs.pos;
1673 let mut missing = None;
1674 while let Some(attr) = attrs.next() {
1675 let Ok(attr) = attr else { break };
1676 match attr {
1677 Pin::Id(val) => {
1678 if last_off == offset {
1679 stack.push(("Id", last_off));
1680 break;
1681 }
1682 }
1683 Pin::ParentId(val) => {
1684 if last_off == offset {
1685 stack.push(("ParentId", last_off));
1686 break;
1687 }
1688 }
1689 Pin::ModuleName(val) => {
1690 if last_off == offset {
1691 stack.push(("ModuleName", last_off));
1692 break;
1693 }
1694 }
1695 Pin::Pad(val) => {
1696 if last_off == offset {
1697 stack.push(("Pad", last_off));
1698 break;
1699 }
1700 }
1701 Pin::ClockId(val) => {
1702 if last_off == offset {
1703 stack.push(("ClockId", last_off));
1704 break;
1705 }
1706 }
1707 Pin::BoardLabel(val) => {
1708 if last_off == offset {
1709 stack.push(("BoardLabel", last_off));
1710 break;
1711 }
1712 }
1713 Pin::PanelLabel(val) => {
1714 if last_off == offset {
1715 stack.push(("PanelLabel", last_off));
1716 break;
1717 }
1718 }
1719 Pin::PackageLabel(val) => {
1720 if last_off == offset {
1721 stack.push(("PackageLabel", last_off));
1722 break;
1723 }
1724 }
1725 Pin::Type(val) => {
1726 if last_off == offset {
1727 stack.push(("Type", last_off));
1728 break;
1729 }
1730 }
1731 Pin::Direction(val) => {
1732 if last_off == offset {
1733 stack.push(("Direction", last_off));
1734 break;
1735 }
1736 }
1737 Pin::Frequency(val) => {
1738 if last_off == offset {
1739 stack.push(("Frequency", last_off));
1740 break;
1741 }
1742 }
1743 Pin::FrequencySupported(val) => {
1744 (stack, missing) = val.lookup_attr(offset, missing_type);
1745 if !stack.is_empty() {
1746 break;
1747 }
1748 }
1749 Pin::FrequencyMin(val) => {
1750 if last_off == offset {
1751 stack.push(("FrequencyMin", last_off));
1752 break;
1753 }
1754 }
1755 Pin::FrequencyMax(val) => {
1756 if last_off == offset {
1757 stack.push(("FrequencyMax", last_off));
1758 break;
1759 }
1760 }
1761 Pin::Prio(val) => {
1762 if last_off == offset {
1763 stack.push(("Prio", last_off));
1764 break;
1765 }
1766 }
1767 Pin::State(val) => {
1768 if last_off == offset {
1769 stack.push(("State", last_off));
1770 break;
1771 }
1772 }
1773 Pin::Capabilities(val) => {
1774 if last_off == offset {
1775 stack.push(("Capabilities", last_off));
1776 break;
1777 }
1778 }
1779 Pin::ParentDevice(val) => {
1780 (stack, missing) = val.lookup_attr(offset, missing_type);
1781 if !stack.is_empty() {
1782 break;
1783 }
1784 }
1785 Pin::ParentPin(val) => {
1786 (stack, missing) = val.lookup_attr(offset, missing_type);
1787 if !stack.is_empty() {
1788 break;
1789 }
1790 }
1791 Pin::PhaseAdjustMin(val) => {
1792 if last_off == offset {
1793 stack.push(("PhaseAdjustMin", last_off));
1794 break;
1795 }
1796 }
1797 Pin::PhaseAdjustMax(val) => {
1798 if last_off == offset {
1799 stack.push(("PhaseAdjustMax", last_off));
1800 break;
1801 }
1802 }
1803 Pin::PhaseAdjust(val) => {
1804 if last_off == offset {
1805 stack.push(("PhaseAdjust", last_off));
1806 break;
1807 }
1808 }
1809 Pin::PhaseOffset(val) => {
1810 if last_off == offset {
1811 stack.push(("PhaseOffset", last_off));
1812 break;
1813 }
1814 }
1815 Pin::FractionalFrequencyOffset(val) => {
1816 if last_off == offset {
1817 stack.push(("FractionalFrequencyOffset", last_off));
1818 break;
1819 }
1820 }
1821 Pin::EsyncFrequency(val) => {
1822 if last_off == offset {
1823 stack.push(("EsyncFrequency", last_off));
1824 break;
1825 }
1826 }
1827 Pin::EsyncFrequencySupported(val) => {
1828 (stack, missing) = val.lookup_attr(offset, missing_type);
1829 if !stack.is_empty() {
1830 break;
1831 }
1832 }
1833 Pin::EsyncPulse(val) => {
1834 if last_off == offset {
1835 stack.push(("EsyncPulse", last_off));
1836 break;
1837 }
1838 }
1839 Pin::ReferenceSync(val) => {
1840 (stack, missing) = val.lookup_attr(offset, missing_type);
1841 if !stack.is_empty() {
1842 break;
1843 }
1844 }
1845 Pin::PhaseAdjustGran(val) => {
1846 if last_off == offset {
1847 stack.push(("PhaseAdjustGran", last_off));
1848 break;
1849 }
1850 }
1851 Pin::FractionalFrequencyOffsetPpt(val) => {
1852 if last_off == offset {
1853 stack.push(("FractionalFrequencyOffsetPpt", last_off));
1854 break;
1855 }
1856 }
1857 Pin::MeasuredFrequency(val) => {
1858 if last_off == offset {
1859 stack.push(("MeasuredFrequency", last_off));
1860 break;
1861 }
1862 }
1863 Pin::Operstate(val) => {
1864 if last_off == offset {
1865 stack.push(("Operstate", last_off));
1866 break;
1867 }
1868 }
1869 _ => {}
1870 };
1871 last_off = cur + attrs.pos;
1872 }
1873 if !stack.is_empty() {
1874 stack.push(("Pin", cur));
1875 }
1876 (stack, missing)
1877 }
1878}
1879#[derive(Clone)]
1880pub enum PinParentDevice {
1881 ParentId(u32),
1882 #[doc = "Associated type: [`PinDirection`] (enum)"]
1883 Direction(u32),
1884 Prio(u32),
1885 #[doc = "Associated type: [`PinState`] (enum)"]
1886 State(u32),
1887 PhaseOffset(i64),
1888 #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPM\n(parts per million). This is a lower-precision version of\nfractional-frequency-offset-ppt.\n"]
1889 FractionalFrequencyOffset(i32),
1890 #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPT\n(parts per trillion, 10\\^-12). This is a higher-precision version of\nfractional-frequency-offset.\n"]
1891 FractionalFrequencyOffsetPpt(i32),
1892 #[doc = "Operational state of the pin with respect to its parent DPLL device.\nUnlike state (which reflects the administrative intent), operstate\nreflects the actual hardware status.\n\nAssociated type: [`PinOperstate`] (enum)"]
1893 Operstate(u32),
1894}
1895impl<'a> IterablePinParentDevice<'a> {
1896 pub fn get_parent_id(&self) -> Result<u32, ErrorContext> {
1897 let mut iter = self.clone();
1898 iter.pos = 0;
1899 for attr in iter {
1900 if let Ok(PinParentDevice::ParentId(val)) = attr {
1901 return Ok(val);
1902 }
1903 }
1904 Err(ErrorContext::new_missing(
1905 "PinParentDevice",
1906 "ParentId",
1907 self.orig_loc,
1908 self.buf.as_ptr() as usize,
1909 ))
1910 }
1911 #[doc = "Associated type: [`PinDirection`] (enum)"]
1912 pub fn get_direction(&self) -> Result<u32, ErrorContext> {
1913 let mut iter = self.clone();
1914 iter.pos = 0;
1915 for attr in iter {
1916 if let Ok(PinParentDevice::Direction(val)) = attr {
1917 return Ok(val);
1918 }
1919 }
1920 Err(ErrorContext::new_missing(
1921 "PinParentDevice",
1922 "Direction",
1923 self.orig_loc,
1924 self.buf.as_ptr() as usize,
1925 ))
1926 }
1927 pub fn get_prio(&self) -> Result<u32, ErrorContext> {
1928 let mut iter = self.clone();
1929 iter.pos = 0;
1930 for attr in iter {
1931 if let Ok(PinParentDevice::Prio(val)) = attr {
1932 return Ok(val);
1933 }
1934 }
1935 Err(ErrorContext::new_missing(
1936 "PinParentDevice",
1937 "Prio",
1938 self.orig_loc,
1939 self.buf.as_ptr() as usize,
1940 ))
1941 }
1942 #[doc = "Associated type: [`PinState`] (enum)"]
1943 pub fn get_state(&self) -> Result<u32, ErrorContext> {
1944 let mut iter = self.clone();
1945 iter.pos = 0;
1946 for attr in iter {
1947 if let Ok(PinParentDevice::State(val)) = attr {
1948 return Ok(val);
1949 }
1950 }
1951 Err(ErrorContext::new_missing(
1952 "PinParentDevice",
1953 "State",
1954 self.orig_loc,
1955 self.buf.as_ptr() as usize,
1956 ))
1957 }
1958 pub fn get_phase_offset(&self) -> Result<i64, ErrorContext> {
1959 let mut iter = self.clone();
1960 iter.pos = 0;
1961 for attr in iter {
1962 if let Ok(PinParentDevice::PhaseOffset(val)) = attr {
1963 return Ok(val);
1964 }
1965 }
1966 Err(ErrorContext::new_missing(
1967 "PinParentDevice",
1968 "PhaseOffset",
1969 self.orig_loc,
1970 self.buf.as_ptr() as usize,
1971 ))
1972 }
1973 #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPM\n(parts per million). This is a lower-precision version of\nfractional-frequency-offset-ppt.\n"]
1974 pub fn get_fractional_frequency_offset(&self) -> Result<i32, ErrorContext> {
1975 let mut iter = self.clone();
1976 iter.pos = 0;
1977 for attr in iter {
1978 if let Ok(PinParentDevice::FractionalFrequencyOffset(val)) = attr {
1979 return Ok(val);
1980 }
1981 }
1982 Err(ErrorContext::new_missing(
1983 "PinParentDevice",
1984 "FractionalFrequencyOffset",
1985 self.orig_loc,
1986 self.buf.as_ptr() as usize,
1987 ))
1988 }
1989 #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPT\n(parts per trillion, 10\\^-12). This is a higher-precision version of\nfractional-frequency-offset.\n"]
1990 pub fn get_fractional_frequency_offset_ppt(&self) -> Result<i32, ErrorContext> {
1991 let mut iter = self.clone();
1992 iter.pos = 0;
1993 for attr in iter {
1994 if let Ok(PinParentDevice::FractionalFrequencyOffsetPpt(val)) = attr {
1995 return Ok(val);
1996 }
1997 }
1998 Err(ErrorContext::new_missing(
1999 "PinParentDevice",
2000 "FractionalFrequencyOffsetPpt",
2001 self.orig_loc,
2002 self.buf.as_ptr() as usize,
2003 ))
2004 }
2005 #[doc = "Operational state of the pin with respect to its parent DPLL device.\nUnlike state (which reflects the administrative intent), operstate\nreflects the actual hardware status.\n\nAssociated type: [`PinOperstate`] (enum)"]
2006 pub fn get_operstate(&self) -> Result<u32, ErrorContext> {
2007 let mut iter = self.clone();
2008 iter.pos = 0;
2009 for attr in iter {
2010 if let Ok(PinParentDevice::Operstate(val)) = attr {
2011 return Ok(val);
2012 }
2013 }
2014 Err(ErrorContext::new_missing(
2015 "PinParentDevice",
2016 "Operstate",
2017 self.orig_loc,
2018 self.buf.as_ptr() as usize,
2019 ))
2020 }
2021}
2022impl PinParentDevice {
2023 pub fn new<'a>(buf: &'a [u8]) -> IterablePinParentDevice<'a> {
2024 IterablePinParentDevice::with_loc(buf, buf.as_ptr() as usize)
2025 }
2026 fn attr_from_type(r#type: u16) -> Option<&'static str> {
2027 Pin::attr_from_type(r#type)
2028 }
2029}
2030#[derive(Clone, Copy, Default)]
2031pub struct IterablePinParentDevice<'a> {
2032 buf: &'a [u8],
2033 pos: usize,
2034 orig_loc: usize,
2035}
2036impl<'a> IterablePinParentDevice<'a> {
2037 fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2038 Self {
2039 buf,
2040 pos: 0,
2041 orig_loc,
2042 }
2043 }
2044 pub fn get_buf(&self) -> &'a [u8] {
2045 self.buf
2046 }
2047}
2048impl<'a> Iterator for IterablePinParentDevice<'a> {
2049 type Item = Result<PinParentDevice, ErrorContext>;
2050 fn next(&mut self) -> Option<Self::Item> {
2051 let mut pos;
2052 let mut r#type;
2053 loop {
2054 pos = self.pos;
2055 r#type = None;
2056 if self.buf.len() == self.pos {
2057 return None;
2058 }
2059 let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
2060 self.pos = self.buf.len();
2061 break;
2062 };
2063 r#type = Some(header.r#type);
2064 let res = match header.r#type {
2065 2u16 => PinParentDevice::ParentId({
2066 let res = parse_u32(next);
2067 let Some(val) = res else { break };
2068 val
2069 }),
2070 10u16 => PinParentDevice::Direction({
2071 let res = parse_u32(next);
2072 let Some(val) = res else { break };
2073 val
2074 }),
2075 15u16 => PinParentDevice::Prio({
2076 let res = parse_u32(next);
2077 let Some(val) = res else { break };
2078 val
2079 }),
2080 16u16 => PinParentDevice::State({
2081 let res = parse_u32(next);
2082 let Some(val) = res else { break };
2083 val
2084 }),
2085 23u16 => PinParentDevice::PhaseOffset({
2086 let res = parse_i64(next);
2087 let Some(val) = res else { break };
2088 val
2089 }),
2090 24u16 => PinParentDevice::FractionalFrequencyOffset({
2091 let res = parse_i32(next);
2092 let Some(val) = res else { break };
2093 val
2094 }),
2095 30u16 => PinParentDevice::FractionalFrequencyOffsetPpt({
2096 let res = parse_i32(next);
2097 let Some(val) = res else { break };
2098 val
2099 }),
2100 32u16 => PinParentDevice::Operstate({
2101 let res = parse_u32(next);
2102 let Some(val) = res else { break };
2103 val
2104 }),
2105 n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
2106 n => continue,
2107 };
2108 return Some(Ok(res));
2109 }
2110 Some(Err(ErrorContext::new(
2111 "PinParentDevice",
2112 r#type.and_then(|t| PinParentDevice::attr_from_type(t)),
2113 self.orig_loc,
2114 self.buf.as_ptr().wrapping_add(pos) as usize,
2115 )))
2116 }
2117}
2118impl std::fmt::Debug for IterablePinParentDevice<'_> {
2119 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2120 let mut fmt = f.debug_struct("PinParentDevice");
2121 for attr in self.clone() {
2122 let attr = match attr {
2123 Ok(a) => a,
2124 Err(err) => {
2125 fmt.finish()?;
2126 f.write_str("Err(")?;
2127 err.fmt(f)?;
2128 return f.write_str(")");
2129 }
2130 };
2131 match attr {
2132 PinParentDevice::ParentId(val) => fmt.field("ParentId", &val),
2133 PinParentDevice::Direction(val) => fmt.field(
2134 "Direction",
2135 &FormatEnum(val.into(), PinDirection::from_value),
2136 ),
2137 PinParentDevice::Prio(val) => fmt.field("Prio", &val),
2138 PinParentDevice::State(val) => {
2139 fmt.field("State", &FormatEnum(val.into(), PinState::from_value))
2140 }
2141 PinParentDevice::PhaseOffset(val) => fmt.field("PhaseOffset", &val),
2142 PinParentDevice::FractionalFrequencyOffset(val) => {
2143 fmt.field("FractionalFrequencyOffset", &val)
2144 }
2145 PinParentDevice::FractionalFrequencyOffsetPpt(val) => {
2146 fmt.field("FractionalFrequencyOffsetPpt", &val)
2147 }
2148 PinParentDevice::Operstate(val) => fmt.field(
2149 "Operstate",
2150 &FormatEnum(val.into(), PinOperstate::from_value),
2151 ),
2152 };
2153 }
2154 fmt.finish()
2155 }
2156}
2157impl IterablePinParentDevice<'_> {
2158 pub fn lookup_attr(
2159 &self,
2160 offset: usize,
2161 missing_type: Option<u16>,
2162 ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2163 let mut stack = Vec::new();
2164 let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2165 if missing_type.is_some() && cur == offset {
2166 stack.push(("PinParentDevice", offset));
2167 return (
2168 stack,
2169 missing_type.and_then(|t| PinParentDevice::attr_from_type(t)),
2170 );
2171 }
2172 if cur > offset || cur + self.buf.len() < offset {
2173 return (stack, None);
2174 }
2175 let mut attrs = self.clone();
2176 let mut last_off = cur + attrs.pos;
2177 while let Some(attr) = attrs.next() {
2178 let Ok(attr) = attr else { break };
2179 match attr {
2180 PinParentDevice::ParentId(val) => {
2181 if last_off == offset {
2182 stack.push(("ParentId", last_off));
2183 break;
2184 }
2185 }
2186 PinParentDevice::Direction(val) => {
2187 if last_off == offset {
2188 stack.push(("Direction", last_off));
2189 break;
2190 }
2191 }
2192 PinParentDevice::Prio(val) => {
2193 if last_off == offset {
2194 stack.push(("Prio", last_off));
2195 break;
2196 }
2197 }
2198 PinParentDevice::State(val) => {
2199 if last_off == offset {
2200 stack.push(("State", last_off));
2201 break;
2202 }
2203 }
2204 PinParentDevice::PhaseOffset(val) => {
2205 if last_off == offset {
2206 stack.push(("PhaseOffset", last_off));
2207 break;
2208 }
2209 }
2210 PinParentDevice::FractionalFrequencyOffset(val) => {
2211 if last_off == offset {
2212 stack.push(("FractionalFrequencyOffset", last_off));
2213 break;
2214 }
2215 }
2216 PinParentDevice::FractionalFrequencyOffsetPpt(val) => {
2217 if last_off == offset {
2218 stack.push(("FractionalFrequencyOffsetPpt", last_off));
2219 break;
2220 }
2221 }
2222 PinParentDevice::Operstate(val) => {
2223 if last_off == offset {
2224 stack.push(("Operstate", last_off));
2225 break;
2226 }
2227 }
2228 _ => {}
2229 };
2230 last_off = cur + attrs.pos;
2231 }
2232 if !stack.is_empty() {
2233 stack.push(("PinParentDevice", cur));
2234 }
2235 (stack, None)
2236 }
2237}
2238#[derive(Clone)]
2239pub enum PinParentPin {
2240 ParentId(u32),
2241 #[doc = "Associated type: [`PinState`] (enum)"]
2242 State(u32),
2243}
2244impl<'a> IterablePinParentPin<'a> {
2245 pub fn get_parent_id(&self) -> Result<u32, ErrorContext> {
2246 let mut iter = self.clone();
2247 iter.pos = 0;
2248 for attr in iter {
2249 if let Ok(PinParentPin::ParentId(val)) = attr {
2250 return Ok(val);
2251 }
2252 }
2253 Err(ErrorContext::new_missing(
2254 "PinParentPin",
2255 "ParentId",
2256 self.orig_loc,
2257 self.buf.as_ptr() as usize,
2258 ))
2259 }
2260 #[doc = "Associated type: [`PinState`] (enum)"]
2261 pub fn get_state(&self) -> Result<u32, ErrorContext> {
2262 let mut iter = self.clone();
2263 iter.pos = 0;
2264 for attr in iter {
2265 if let Ok(PinParentPin::State(val)) = attr {
2266 return Ok(val);
2267 }
2268 }
2269 Err(ErrorContext::new_missing(
2270 "PinParentPin",
2271 "State",
2272 self.orig_loc,
2273 self.buf.as_ptr() as usize,
2274 ))
2275 }
2276}
2277impl PinParentPin {
2278 pub fn new<'a>(buf: &'a [u8]) -> IterablePinParentPin<'a> {
2279 IterablePinParentPin::with_loc(buf, buf.as_ptr() as usize)
2280 }
2281 fn attr_from_type(r#type: u16) -> Option<&'static str> {
2282 Pin::attr_from_type(r#type)
2283 }
2284}
2285#[derive(Clone, Copy, Default)]
2286pub struct IterablePinParentPin<'a> {
2287 buf: &'a [u8],
2288 pos: usize,
2289 orig_loc: usize,
2290}
2291impl<'a> IterablePinParentPin<'a> {
2292 fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2293 Self {
2294 buf,
2295 pos: 0,
2296 orig_loc,
2297 }
2298 }
2299 pub fn get_buf(&self) -> &'a [u8] {
2300 self.buf
2301 }
2302}
2303impl<'a> Iterator for IterablePinParentPin<'a> {
2304 type Item = Result<PinParentPin, ErrorContext>;
2305 fn next(&mut self) -> Option<Self::Item> {
2306 let mut pos;
2307 let mut r#type;
2308 loop {
2309 pos = self.pos;
2310 r#type = None;
2311 if self.buf.len() == self.pos {
2312 return None;
2313 }
2314 let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
2315 self.pos = self.buf.len();
2316 break;
2317 };
2318 r#type = Some(header.r#type);
2319 let res = match header.r#type {
2320 2u16 => PinParentPin::ParentId({
2321 let res = parse_u32(next);
2322 let Some(val) = res else { break };
2323 val
2324 }),
2325 16u16 => PinParentPin::State({
2326 let res = parse_u32(next);
2327 let Some(val) = res else { break };
2328 val
2329 }),
2330 n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
2331 n => continue,
2332 };
2333 return Some(Ok(res));
2334 }
2335 Some(Err(ErrorContext::new(
2336 "PinParentPin",
2337 r#type.and_then(|t| PinParentPin::attr_from_type(t)),
2338 self.orig_loc,
2339 self.buf.as_ptr().wrapping_add(pos) as usize,
2340 )))
2341 }
2342}
2343impl std::fmt::Debug for IterablePinParentPin<'_> {
2344 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2345 let mut fmt = f.debug_struct("PinParentPin");
2346 for attr in self.clone() {
2347 let attr = match attr {
2348 Ok(a) => a,
2349 Err(err) => {
2350 fmt.finish()?;
2351 f.write_str("Err(")?;
2352 err.fmt(f)?;
2353 return f.write_str(")");
2354 }
2355 };
2356 match attr {
2357 PinParentPin::ParentId(val) => fmt.field("ParentId", &val),
2358 PinParentPin::State(val) => {
2359 fmt.field("State", &FormatEnum(val.into(), PinState::from_value))
2360 }
2361 };
2362 }
2363 fmt.finish()
2364 }
2365}
2366impl IterablePinParentPin<'_> {
2367 pub fn lookup_attr(
2368 &self,
2369 offset: usize,
2370 missing_type: Option<u16>,
2371 ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2372 let mut stack = Vec::new();
2373 let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2374 if missing_type.is_some() && cur == offset {
2375 stack.push(("PinParentPin", offset));
2376 return (
2377 stack,
2378 missing_type.and_then(|t| PinParentPin::attr_from_type(t)),
2379 );
2380 }
2381 if cur > offset || cur + self.buf.len() < offset {
2382 return (stack, None);
2383 }
2384 let mut attrs = self.clone();
2385 let mut last_off = cur + attrs.pos;
2386 while let Some(attr) = attrs.next() {
2387 let Ok(attr) = attr else { break };
2388 match attr {
2389 PinParentPin::ParentId(val) => {
2390 if last_off == offset {
2391 stack.push(("ParentId", last_off));
2392 break;
2393 }
2394 }
2395 PinParentPin::State(val) => {
2396 if last_off == offset {
2397 stack.push(("State", last_off));
2398 break;
2399 }
2400 }
2401 _ => {}
2402 };
2403 last_off = cur + attrs.pos;
2404 }
2405 if !stack.is_empty() {
2406 stack.push(("PinParentPin", cur));
2407 }
2408 (stack, None)
2409 }
2410}
2411#[derive(Clone)]
2412pub enum FrequencyRange {
2413 FrequencyMin(u64),
2414 FrequencyMax(u64),
2415}
2416impl<'a> IterableFrequencyRange<'a> {
2417 pub fn get_frequency_min(&self) -> Result<u64, ErrorContext> {
2418 let mut iter = self.clone();
2419 iter.pos = 0;
2420 for attr in iter {
2421 if let Ok(FrequencyRange::FrequencyMin(val)) = attr {
2422 return Ok(val);
2423 }
2424 }
2425 Err(ErrorContext::new_missing(
2426 "FrequencyRange",
2427 "FrequencyMin",
2428 self.orig_loc,
2429 self.buf.as_ptr() as usize,
2430 ))
2431 }
2432 pub fn get_frequency_max(&self) -> Result<u64, ErrorContext> {
2433 let mut iter = self.clone();
2434 iter.pos = 0;
2435 for attr in iter {
2436 if let Ok(FrequencyRange::FrequencyMax(val)) = attr {
2437 return Ok(val);
2438 }
2439 }
2440 Err(ErrorContext::new_missing(
2441 "FrequencyRange",
2442 "FrequencyMax",
2443 self.orig_loc,
2444 self.buf.as_ptr() as usize,
2445 ))
2446 }
2447}
2448impl FrequencyRange {
2449 pub fn new<'a>(buf: &'a [u8]) -> IterableFrequencyRange<'a> {
2450 IterableFrequencyRange::with_loc(buf, buf.as_ptr() as usize)
2451 }
2452 fn attr_from_type(r#type: u16) -> Option<&'static str> {
2453 Pin::attr_from_type(r#type)
2454 }
2455}
2456#[derive(Clone, Copy, Default)]
2457pub struct IterableFrequencyRange<'a> {
2458 buf: &'a [u8],
2459 pos: usize,
2460 orig_loc: usize,
2461}
2462impl<'a> IterableFrequencyRange<'a> {
2463 fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2464 Self {
2465 buf,
2466 pos: 0,
2467 orig_loc,
2468 }
2469 }
2470 pub fn get_buf(&self) -> &'a [u8] {
2471 self.buf
2472 }
2473}
2474impl<'a> Iterator for IterableFrequencyRange<'a> {
2475 type Item = Result<FrequencyRange, ErrorContext>;
2476 fn next(&mut self) -> Option<Self::Item> {
2477 let mut pos;
2478 let mut r#type;
2479 loop {
2480 pos = self.pos;
2481 r#type = None;
2482 if self.buf.len() == self.pos {
2483 return None;
2484 }
2485 let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
2486 self.pos = self.buf.len();
2487 break;
2488 };
2489 r#type = Some(header.r#type);
2490 let res = match header.r#type {
2491 13u16 => FrequencyRange::FrequencyMin({
2492 let res = parse_u64(next);
2493 let Some(val) = res else { break };
2494 val
2495 }),
2496 14u16 => FrequencyRange::FrequencyMax({
2497 let res = parse_u64(next);
2498 let Some(val) = res else { break };
2499 val
2500 }),
2501 n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
2502 n => continue,
2503 };
2504 return Some(Ok(res));
2505 }
2506 Some(Err(ErrorContext::new(
2507 "FrequencyRange",
2508 r#type.and_then(|t| FrequencyRange::attr_from_type(t)),
2509 self.orig_loc,
2510 self.buf.as_ptr().wrapping_add(pos) as usize,
2511 )))
2512 }
2513}
2514impl std::fmt::Debug for IterableFrequencyRange<'_> {
2515 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2516 let mut fmt = f.debug_struct("FrequencyRange");
2517 for attr in self.clone() {
2518 let attr = match attr {
2519 Ok(a) => a,
2520 Err(err) => {
2521 fmt.finish()?;
2522 f.write_str("Err(")?;
2523 err.fmt(f)?;
2524 return f.write_str(")");
2525 }
2526 };
2527 match attr {
2528 FrequencyRange::FrequencyMin(val) => fmt.field("FrequencyMin", &val),
2529 FrequencyRange::FrequencyMax(val) => fmt.field("FrequencyMax", &val),
2530 };
2531 }
2532 fmt.finish()
2533 }
2534}
2535impl IterableFrequencyRange<'_> {
2536 pub fn lookup_attr(
2537 &self,
2538 offset: usize,
2539 missing_type: Option<u16>,
2540 ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2541 let mut stack = Vec::new();
2542 let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2543 if missing_type.is_some() && cur == offset {
2544 stack.push(("FrequencyRange", offset));
2545 return (
2546 stack,
2547 missing_type.and_then(|t| FrequencyRange::attr_from_type(t)),
2548 );
2549 }
2550 if cur > offset || cur + self.buf.len() < offset {
2551 return (stack, None);
2552 }
2553 let mut attrs = self.clone();
2554 let mut last_off = cur + attrs.pos;
2555 while let Some(attr) = attrs.next() {
2556 let Ok(attr) = attr else { break };
2557 match attr {
2558 FrequencyRange::FrequencyMin(val) => {
2559 if last_off == offset {
2560 stack.push(("FrequencyMin", last_off));
2561 break;
2562 }
2563 }
2564 FrequencyRange::FrequencyMax(val) => {
2565 if last_off == offset {
2566 stack.push(("FrequencyMax", last_off));
2567 break;
2568 }
2569 }
2570 _ => {}
2571 };
2572 last_off = cur + attrs.pos;
2573 }
2574 if !stack.is_empty() {
2575 stack.push(("FrequencyRange", cur));
2576 }
2577 (stack, None)
2578 }
2579}
2580#[derive(Clone)]
2581pub enum ReferenceSync {
2582 Id(u32),
2583 #[doc = "Associated type: [`PinState`] (enum)"]
2584 State(u32),
2585}
2586impl<'a> IterableReferenceSync<'a> {
2587 pub fn get_id(&self) -> Result<u32, ErrorContext> {
2588 let mut iter = self.clone();
2589 iter.pos = 0;
2590 for attr in iter {
2591 if let Ok(ReferenceSync::Id(val)) = attr {
2592 return Ok(val);
2593 }
2594 }
2595 Err(ErrorContext::new_missing(
2596 "ReferenceSync",
2597 "Id",
2598 self.orig_loc,
2599 self.buf.as_ptr() as usize,
2600 ))
2601 }
2602 #[doc = "Associated type: [`PinState`] (enum)"]
2603 pub fn get_state(&self) -> Result<u32, ErrorContext> {
2604 let mut iter = self.clone();
2605 iter.pos = 0;
2606 for attr in iter {
2607 if let Ok(ReferenceSync::State(val)) = attr {
2608 return Ok(val);
2609 }
2610 }
2611 Err(ErrorContext::new_missing(
2612 "ReferenceSync",
2613 "State",
2614 self.orig_loc,
2615 self.buf.as_ptr() as usize,
2616 ))
2617 }
2618}
2619impl ReferenceSync {
2620 pub fn new<'a>(buf: &'a [u8]) -> IterableReferenceSync<'a> {
2621 IterableReferenceSync::with_loc(buf, buf.as_ptr() as usize)
2622 }
2623 fn attr_from_type(r#type: u16) -> Option<&'static str> {
2624 Pin::attr_from_type(r#type)
2625 }
2626}
2627#[derive(Clone, Copy, Default)]
2628pub struct IterableReferenceSync<'a> {
2629 buf: &'a [u8],
2630 pos: usize,
2631 orig_loc: usize,
2632}
2633impl<'a> IterableReferenceSync<'a> {
2634 fn with_loc(buf: &'a [u8], orig_loc: usize) -> Self {
2635 Self {
2636 buf,
2637 pos: 0,
2638 orig_loc,
2639 }
2640 }
2641 pub fn get_buf(&self) -> &'a [u8] {
2642 self.buf
2643 }
2644}
2645impl<'a> Iterator for IterableReferenceSync<'a> {
2646 type Item = Result<ReferenceSync, ErrorContext>;
2647 fn next(&mut self) -> Option<Self::Item> {
2648 let mut pos;
2649 let mut r#type;
2650 loop {
2651 pos = self.pos;
2652 r#type = None;
2653 if self.buf.len() == self.pos {
2654 return None;
2655 }
2656 let Some((header, next)) = chop_header(self.buf, &mut self.pos) else {
2657 self.pos = self.buf.len();
2658 break;
2659 };
2660 r#type = Some(header.r#type);
2661 let res = match header.r#type {
2662 1u16 => ReferenceSync::Id({
2663 let res = parse_u32(next);
2664 let Some(val) = res else { break };
2665 val
2666 }),
2667 16u16 => ReferenceSync::State({
2668 let res = parse_u32(next);
2669 let Some(val) = res else { break };
2670 val
2671 }),
2672 n if cfg!(any(test, feature = "deny-unknown-attrs")) => break,
2673 n => continue,
2674 };
2675 return Some(Ok(res));
2676 }
2677 Some(Err(ErrorContext::new(
2678 "ReferenceSync",
2679 r#type.and_then(|t| ReferenceSync::attr_from_type(t)),
2680 self.orig_loc,
2681 self.buf.as_ptr().wrapping_add(pos) as usize,
2682 )))
2683 }
2684}
2685impl std::fmt::Debug for IterableReferenceSync<'_> {
2686 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
2687 let mut fmt = f.debug_struct("ReferenceSync");
2688 for attr in self.clone() {
2689 let attr = match attr {
2690 Ok(a) => a,
2691 Err(err) => {
2692 fmt.finish()?;
2693 f.write_str("Err(")?;
2694 err.fmt(f)?;
2695 return f.write_str(")");
2696 }
2697 };
2698 match attr {
2699 ReferenceSync::Id(val) => fmt.field("Id", &val),
2700 ReferenceSync::State(val) => {
2701 fmt.field("State", &FormatEnum(val.into(), PinState::from_value))
2702 }
2703 };
2704 }
2705 fmt.finish()
2706 }
2707}
2708impl IterableReferenceSync<'_> {
2709 pub fn lookup_attr(
2710 &self,
2711 offset: usize,
2712 missing_type: Option<u16>,
2713 ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
2714 let mut stack = Vec::new();
2715 let cur = ErrorContext::calc_offset(self.orig_loc, self.buf.as_ptr() as usize);
2716 if missing_type.is_some() && cur == offset {
2717 stack.push(("ReferenceSync", offset));
2718 return (
2719 stack,
2720 missing_type.and_then(|t| ReferenceSync::attr_from_type(t)),
2721 );
2722 }
2723 if cur > offset || cur + self.buf.len() < offset {
2724 return (stack, None);
2725 }
2726 let mut attrs = self.clone();
2727 let mut last_off = cur + attrs.pos;
2728 while let Some(attr) = attrs.next() {
2729 let Ok(attr) = attr else { break };
2730 match attr {
2731 ReferenceSync::Id(val) => {
2732 if last_off == offset {
2733 stack.push(("Id", last_off));
2734 break;
2735 }
2736 }
2737 ReferenceSync::State(val) => {
2738 if last_off == offset {
2739 stack.push(("State", last_off));
2740 break;
2741 }
2742 }
2743 _ => {}
2744 };
2745 last_off = cur + attrs.pos;
2746 }
2747 if !stack.is_empty() {
2748 stack.push(("ReferenceSync", cur));
2749 }
2750 (stack, None)
2751 }
2752}
2753pub struct PushDpll<Prev: Pusher> {
2754 pub(crate) prev: Option<Prev>,
2755 pub(crate) header_offset: Option<usize>,
2756}
2757impl<Prev: Pusher> Pusher for PushDpll<Prev> {
2758 fn as_vec_mut(&mut self) -> &mut Vec<u8> {
2759 self.prev.as_mut().unwrap().as_vec_mut()
2760 }
2761 fn as_vec(&self) -> &Vec<u8> {
2762 self.prev.as_ref().unwrap().as_vec()
2763 }
2764}
2765impl<Prev: Pusher> PushDpll<Prev> {
2766 pub fn new(prev: Prev) -> Self {
2767 Self {
2768 prev: Some(prev),
2769 header_offset: None,
2770 }
2771 }
2772 pub fn end_nested(mut self) -> Prev {
2773 let mut prev = self.prev.take().unwrap();
2774 if let Some(header_offset) = &self.header_offset {
2775 finalize_nested_header(prev.as_vec_mut(), *header_offset);
2776 }
2777 prev
2778 }
2779 pub fn push_id(mut self, value: u32) -> Self {
2780 push_header(self.as_vec_mut(), 1u16, 4 as u16);
2781 self.as_vec_mut().extend(value.to_ne_bytes());
2782 self
2783 }
2784 pub fn push_module_name(mut self, value: &CStr) -> Self {
2785 push_header(
2786 self.as_vec_mut(),
2787 2u16,
2788 value.to_bytes_with_nul().len() as u16,
2789 );
2790 self.as_vec_mut().extend(value.to_bytes_with_nul());
2791 self
2792 }
2793 pub fn push_module_name_bytes(mut self, value: &[u8]) -> Self {
2794 push_header(self.as_vec_mut(), 2u16, (value.len() + 1) as u16);
2795 self.as_vec_mut().extend(value);
2796 self.as_vec_mut().push(0);
2797 self
2798 }
2799 pub fn push_pad(mut self, value: &[u8]) -> Self {
2800 push_header(self.as_vec_mut(), 3u16, value.len() as u16);
2801 self.as_vec_mut().extend(value);
2802 self
2803 }
2804 pub fn push_clock_id(mut self, value: u64) -> Self {
2805 push_header(self.as_vec_mut(), 4u16, 8 as u16);
2806 self.as_vec_mut().extend(value.to_ne_bytes());
2807 self
2808 }
2809 #[doc = "Associated type: [`Mode`] (enum)"]
2810 pub fn push_mode(mut self, value: u32) -> Self {
2811 push_header(self.as_vec_mut(), 5u16, 4 as u16);
2812 self.as_vec_mut().extend(value.to_ne_bytes());
2813 self
2814 }
2815 #[doc = "Associated type: [`Mode`] (enum)\nAttribute may repeat multiple times (treat it as array)"]
2816 pub fn push_mode_supported(mut self, value: u32) -> Self {
2817 push_header(self.as_vec_mut(), 6u16, 4 as u16);
2818 self.as_vec_mut().extend(value.to_ne_bytes());
2819 self
2820 }
2821 #[doc = "Associated type: [`LockStatus`] (enum)"]
2822 pub fn push_lock_status(mut self, value: u32) -> Self {
2823 push_header(self.as_vec_mut(), 7u16, 4 as u16);
2824 self.as_vec_mut().extend(value.to_ne_bytes());
2825 self
2826 }
2827 pub fn push_temp(mut self, value: i32) -> Self {
2828 push_header(self.as_vec_mut(), 8u16, 4 as u16);
2829 self.as_vec_mut().extend(value.to_ne_bytes());
2830 self
2831 }
2832 #[doc = "Associated type: [`Type`] (enum)"]
2833 pub fn push_type(mut self, value: u32) -> Self {
2834 push_header(self.as_vec_mut(), 9u16, 4 as u16);
2835 self.as_vec_mut().extend(value.to_ne_bytes());
2836 self
2837 }
2838 #[doc = "Associated type: [`LockStatusError`] (enum)"]
2839 pub fn push_lock_status_error(mut self, value: u32) -> Self {
2840 push_header(self.as_vec_mut(), 10u16, 4 as u16);
2841 self.as_vec_mut().extend(value.to_ne_bytes());
2842 self
2843 }
2844 #[doc = "Level of quality of a clock device. This mainly applies when the dpll\nlock-status is DPLL_LOCK_STATUS_HOLDOVER. This could be put to message\nmultiple times to indicate possible parallel quality levels (e.g. one\nspecified by ITU option 1 and another one specified by option 2).\n\nAssociated type: [`ClockQualityLevel`] (enum)\nAttribute may repeat multiple times (treat it as array)"]
2845 pub fn push_clock_quality_level(mut self, value: u32) -> Self {
2846 push_header(self.as_vec_mut(), 11u16, 4 as u16);
2847 self.as_vec_mut().extend(value.to_ne_bytes());
2848 self
2849 }
2850 #[doc = "Receive or request state of phase offset monitor feature. If enabled,\ndpll device shall monitor and notify all currently available inputs for\nchanges of their phase offset against the dpll device.\n\nAssociated type: [`FeatureState`] (enum)"]
2851 pub fn push_phase_offset_monitor(mut self, value: u32) -> Self {
2852 push_header(self.as_vec_mut(), 12u16, 4 as u16);
2853 self.as_vec_mut().extend(value.to_ne_bytes());
2854 self
2855 }
2856 #[doc = "Averaging factor applied to calculation of reported phase offset.\n"]
2857 pub fn push_phase_offset_avg_factor(mut self, value: u32) -> Self {
2858 push_header(self.as_vec_mut(), 13u16, 4 as u16);
2859 self.as_vec_mut().extend(value.to_ne_bytes());
2860 self
2861 }
2862 #[doc = "Current or desired state of the frequency monitor feature. If enabled,\ndpll device shall measure all currently available inputs for their\nactual input frequency.\n\nAssociated type: [`FeatureState`] (enum)"]
2863 pub fn push_frequency_monitor(mut self, value: u32) -> Self {
2864 push_header(self.as_vec_mut(), 14u16, 4 as u16);
2865 self.as_vec_mut().extend(value.to_ne_bytes());
2866 self
2867 }
2868}
2869impl<Prev: Pusher> Drop for PushDpll<Prev> {
2870 fn drop(&mut self) {
2871 if let Some(prev) = &mut self.prev {
2872 if let Some(header_offset) = &self.header_offset {
2873 finalize_nested_header(prev.as_vec_mut(), *header_offset);
2874 }
2875 }
2876 }
2877}
2878pub struct PushPin<Prev: Pusher> {
2879 pub(crate) prev: Option<Prev>,
2880 pub(crate) header_offset: Option<usize>,
2881}
2882impl<Prev: Pusher> Pusher for PushPin<Prev> {
2883 fn as_vec_mut(&mut self) -> &mut Vec<u8> {
2884 self.prev.as_mut().unwrap().as_vec_mut()
2885 }
2886 fn as_vec(&self) -> &Vec<u8> {
2887 self.prev.as_ref().unwrap().as_vec()
2888 }
2889}
2890impl<Prev: Pusher> PushPin<Prev> {
2891 pub fn new(prev: Prev) -> Self {
2892 Self {
2893 prev: Some(prev),
2894 header_offset: None,
2895 }
2896 }
2897 pub fn end_nested(mut self) -> Prev {
2898 let mut prev = self.prev.take().unwrap();
2899 if let Some(header_offset) = &self.header_offset {
2900 finalize_nested_header(prev.as_vec_mut(), *header_offset);
2901 }
2902 prev
2903 }
2904 pub fn push_id(mut self, value: u32) -> Self {
2905 push_header(self.as_vec_mut(), 1u16, 4 as u16);
2906 self.as_vec_mut().extend(value.to_ne_bytes());
2907 self
2908 }
2909 pub fn push_parent_id(mut self, value: u32) -> Self {
2910 push_header(self.as_vec_mut(), 2u16, 4 as u16);
2911 self.as_vec_mut().extend(value.to_ne_bytes());
2912 self
2913 }
2914 pub fn push_module_name(mut self, value: &CStr) -> Self {
2915 push_header(
2916 self.as_vec_mut(),
2917 3u16,
2918 value.to_bytes_with_nul().len() as u16,
2919 );
2920 self.as_vec_mut().extend(value.to_bytes_with_nul());
2921 self
2922 }
2923 pub fn push_module_name_bytes(mut self, value: &[u8]) -> Self {
2924 push_header(self.as_vec_mut(), 3u16, (value.len() + 1) as u16);
2925 self.as_vec_mut().extend(value);
2926 self.as_vec_mut().push(0);
2927 self
2928 }
2929 pub fn push_pad(mut self, value: &[u8]) -> Self {
2930 push_header(self.as_vec_mut(), 4u16, value.len() as u16);
2931 self.as_vec_mut().extend(value);
2932 self
2933 }
2934 pub fn push_clock_id(mut self, value: u64) -> Self {
2935 push_header(self.as_vec_mut(), 5u16, 8 as u16);
2936 self.as_vec_mut().extend(value.to_ne_bytes());
2937 self
2938 }
2939 pub fn push_board_label(mut self, value: &CStr) -> Self {
2940 push_header(
2941 self.as_vec_mut(),
2942 6u16,
2943 value.to_bytes_with_nul().len() as u16,
2944 );
2945 self.as_vec_mut().extend(value.to_bytes_with_nul());
2946 self
2947 }
2948 pub fn push_board_label_bytes(mut self, value: &[u8]) -> Self {
2949 push_header(self.as_vec_mut(), 6u16, (value.len() + 1) as u16);
2950 self.as_vec_mut().extend(value);
2951 self.as_vec_mut().push(0);
2952 self
2953 }
2954 pub fn push_panel_label(mut self, value: &CStr) -> Self {
2955 push_header(
2956 self.as_vec_mut(),
2957 7u16,
2958 value.to_bytes_with_nul().len() as u16,
2959 );
2960 self.as_vec_mut().extend(value.to_bytes_with_nul());
2961 self
2962 }
2963 pub fn push_panel_label_bytes(mut self, value: &[u8]) -> Self {
2964 push_header(self.as_vec_mut(), 7u16, (value.len() + 1) as u16);
2965 self.as_vec_mut().extend(value);
2966 self.as_vec_mut().push(0);
2967 self
2968 }
2969 pub fn push_package_label(mut self, value: &CStr) -> Self {
2970 push_header(
2971 self.as_vec_mut(),
2972 8u16,
2973 value.to_bytes_with_nul().len() as u16,
2974 );
2975 self.as_vec_mut().extend(value.to_bytes_with_nul());
2976 self
2977 }
2978 pub fn push_package_label_bytes(mut self, value: &[u8]) -> Self {
2979 push_header(self.as_vec_mut(), 8u16, (value.len() + 1) as u16);
2980 self.as_vec_mut().extend(value);
2981 self.as_vec_mut().push(0);
2982 self
2983 }
2984 #[doc = "Associated type: [`PinType`] (enum)"]
2985 pub fn push_type(mut self, value: u32) -> Self {
2986 push_header(self.as_vec_mut(), 9u16, 4 as u16);
2987 self.as_vec_mut().extend(value.to_ne_bytes());
2988 self
2989 }
2990 #[doc = "Associated type: [`PinDirection`] (enum)"]
2991 pub fn push_direction(mut self, value: u32) -> Self {
2992 push_header(self.as_vec_mut(), 10u16, 4 as u16);
2993 self.as_vec_mut().extend(value.to_ne_bytes());
2994 self
2995 }
2996 pub fn push_frequency(mut self, value: u64) -> Self {
2997 push_header(self.as_vec_mut(), 11u16, 8 as u16);
2998 self.as_vec_mut().extend(value.to_ne_bytes());
2999 self
3000 }
3001 #[doc = "Attribute may repeat multiple times (treat it as array)"]
3002 pub fn nested_frequency_supported(mut self) -> PushFrequencyRange<Self> {
3003 let header_offset = push_nested_header(self.as_vec_mut(), 12u16);
3004 PushFrequencyRange {
3005 prev: Some(self),
3006 header_offset: Some(header_offset),
3007 }
3008 }
3009 pub fn push_frequency_min(mut self, value: u64) -> Self {
3010 push_header(self.as_vec_mut(), 13u16, 8 as u16);
3011 self.as_vec_mut().extend(value.to_ne_bytes());
3012 self
3013 }
3014 pub fn push_frequency_max(mut self, value: u64) -> Self {
3015 push_header(self.as_vec_mut(), 14u16, 8 as u16);
3016 self.as_vec_mut().extend(value.to_ne_bytes());
3017 self
3018 }
3019 pub fn push_prio(mut self, value: u32) -> Self {
3020 push_header(self.as_vec_mut(), 15u16, 4 as u16);
3021 self.as_vec_mut().extend(value.to_ne_bytes());
3022 self
3023 }
3024 #[doc = "Associated type: [`PinState`] (enum)"]
3025 pub fn push_state(mut self, value: u32) -> Self {
3026 push_header(self.as_vec_mut(), 16u16, 4 as u16);
3027 self.as_vec_mut().extend(value.to_ne_bytes());
3028 self
3029 }
3030 #[doc = "Associated type: [`PinCapabilities`] (enum)"]
3031 pub fn push_capabilities(mut self, value: u32) -> Self {
3032 push_header(self.as_vec_mut(), 17u16, 4 as u16);
3033 self.as_vec_mut().extend(value.to_ne_bytes());
3034 self
3035 }
3036 #[doc = "Attribute may repeat multiple times (treat it as array)"]
3037 pub fn nested_parent_device(mut self) -> PushPinParentDevice<Self> {
3038 let header_offset = push_nested_header(self.as_vec_mut(), 18u16);
3039 PushPinParentDevice {
3040 prev: Some(self),
3041 header_offset: Some(header_offset),
3042 }
3043 }
3044 #[doc = "Attribute may repeat multiple times (treat it as array)"]
3045 pub fn nested_parent_pin(mut self) -> PushPinParentPin<Self> {
3046 let header_offset = push_nested_header(self.as_vec_mut(), 19u16);
3047 PushPinParentPin {
3048 prev: Some(self),
3049 header_offset: Some(header_offset),
3050 }
3051 }
3052 pub fn push_phase_adjust_min(mut self, value: i32) -> Self {
3053 push_header(self.as_vec_mut(), 20u16, 4 as u16);
3054 self.as_vec_mut().extend(value.to_ne_bytes());
3055 self
3056 }
3057 pub fn push_phase_adjust_max(mut self, value: i32) -> Self {
3058 push_header(self.as_vec_mut(), 21u16, 4 as u16);
3059 self.as_vec_mut().extend(value.to_ne_bytes());
3060 self
3061 }
3062 pub fn push_phase_adjust(mut self, value: i32) -> Self {
3063 push_header(self.as_vec_mut(), 22u16, 4 as u16);
3064 self.as_vec_mut().extend(value.to_ne_bytes());
3065 self
3066 }
3067 pub fn push_phase_offset(mut self, value: i64) -> Self {
3068 push_header(self.as_vec_mut(), 23u16, 8 as u16);
3069 self.as_vec_mut().extend(value.to_ne_bytes());
3070 self
3071 }
3072 #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPM\n(parts per million). This is a lower-precision version of\nfractional-frequency-offset-ppt.\n"]
3073 pub fn push_fractional_frequency_offset(mut self, value: i32) -> Self {
3074 push_header(self.as_vec_mut(), 24u16, 4 as u16);
3075 self.as_vec_mut().extend(value.to_ne_bytes());
3076 self
3077 }
3078 #[doc = "Frequency of Embedded SYNC signal. If provided, the pin is configured\nwith a SYNC signal embedded into its base clock frequency.\n"]
3079 pub fn push_esync_frequency(mut self, value: u64) -> Self {
3080 push_header(self.as_vec_mut(), 25u16, 8 as u16);
3081 self.as_vec_mut().extend(value.to_ne_bytes());
3082 self
3083 }
3084 #[doc = "If provided a pin is capable of embedding a SYNC signal (within given\nrange) into its base frequency signal.\n\nAttribute may repeat multiple times (treat it as array)"]
3085 pub fn nested_esync_frequency_supported(mut self) -> PushFrequencyRange<Self> {
3086 let header_offset = push_nested_header(self.as_vec_mut(), 26u16);
3087 PushFrequencyRange {
3088 prev: Some(self),
3089 header_offset: Some(header_offset),
3090 }
3091 }
3092 #[doc = "A ratio of high to low state of a SYNC signal pulse embedded into base\nclock frequency. Value is in percents.\n"]
3093 pub fn push_esync_pulse(mut self, value: u32) -> Self {
3094 push_header(self.as_vec_mut(), 27u16, 4 as u16);
3095 self.as_vec_mut().extend(value.to_ne_bytes());
3096 self
3097 }
3098 #[doc = "Capable pin provides list of pins that can be bound to create a\nreference-sync pin pair.\n\nAttribute may repeat multiple times (treat it as array)"]
3099 pub fn nested_reference_sync(mut self) -> PushReferenceSync<Self> {
3100 let header_offset = push_nested_header(self.as_vec_mut(), 28u16);
3101 PushReferenceSync {
3102 prev: Some(self),
3103 header_offset: Some(header_offset),
3104 }
3105 }
3106 #[doc = "Granularity of phase adjustment, in picoseconds. The value of phase\nadjustment must be a multiple of this granularity.\n"]
3107 pub fn push_phase_adjust_gran(mut self, value: u32) -> Self {
3108 push_header(self.as_vec_mut(), 29u16, 4 as u16);
3109 self.as_vec_mut().extend(value.to_ne_bytes());
3110 self
3111 }
3112 #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPT\n(parts per trillion, 10\\^-12). This is a higher-precision version of\nfractional-frequency-offset.\n"]
3113 pub fn push_fractional_frequency_offset_ppt(mut self, value: i32) -> Self {
3114 push_header(self.as_vec_mut(), 30u16, 4 as u16);
3115 self.as_vec_mut().extend(value.to_ne_bytes());
3116 self
3117 }
3118 #[doc = "The measured frequency of the input pin in millihertz (mHz). Value of\n(DPLL_A_PIN_MEASURED_FREQUENCY / DPLL_PIN_MEASURED_FREQUENCY_DIVIDER) is\nan integer part (Hz) of a measured frequency value. Value of\n(DPLL_A_PIN_MEASURED_FREQUENCY % DPLL_PIN_MEASURED_FREQUENCY_DIVIDER) is\na fractional part of a measured frequency value.\n"]
3119 pub fn push_measured_frequency(mut self, value: u64) -> Self {
3120 push_header(self.as_vec_mut(), 31u16, 8 as u16);
3121 self.as_vec_mut().extend(value.to_ne_bytes());
3122 self
3123 }
3124 #[doc = "Operational state of the pin with respect to its parent DPLL device.\nUnlike state (which reflects the administrative intent), operstate\nreflects the actual hardware status.\n\nAssociated type: [`PinOperstate`] (enum)"]
3125 pub fn push_operstate(mut self, value: u32) -> Self {
3126 push_header(self.as_vec_mut(), 32u16, 4 as u16);
3127 self.as_vec_mut().extend(value.to_ne_bytes());
3128 self
3129 }
3130}
3131impl<Prev: Pusher> Drop for PushPin<Prev> {
3132 fn drop(&mut self) {
3133 if let Some(prev) = &mut self.prev {
3134 if let Some(header_offset) = &self.header_offset {
3135 finalize_nested_header(prev.as_vec_mut(), *header_offset);
3136 }
3137 }
3138 }
3139}
3140pub struct PushPinParentDevice<Prev: Pusher> {
3141 pub(crate) prev: Option<Prev>,
3142 pub(crate) header_offset: Option<usize>,
3143}
3144impl<Prev: Pusher> Pusher for PushPinParentDevice<Prev> {
3145 fn as_vec_mut(&mut self) -> &mut Vec<u8> {
3146 self.prev.as_mut().unwrap().as_vec_mut()
3147 }
3148 fn as_vec(&self) -> &Vec<u8> {
3149 self.prev.as_ref().unwrap().as_vec()
3150 }
3151}
3152impl<Prev: Pusher> PushPinParentDevice<Prev> {
3153 pub fn new(prev: Prev) -> Self {
3154 Self {
3155 prev: Some(prev),
3156 header_offset: None,
3157 }
3158 }
3159 pub fn end_nested(mut self) -> Prev {
3160 let mut prev = self.prev.take().unwrap();
3161 if let Some(header_offset) = &self.header_offset {
3162 finalize_nested_header(prev.as_vec_mut(), *header_offset);
3163 }
3164 prev
3165 }
3166 pub fn push_parent_id(mut self, value: u32) -> Self {
3167 push_header(self.as_vec_mut(), 2u16, 4 as u16);
3168 self.as_vec_mut().extend(value.to_ne_bytes());
3169 self
3170 }
3171 #[doc = "Associated type: [`PinDirection`] (enum)"]
3172 pub fn push_direction(mut self, value: u32) -> Self {
3173 push_header(self.as_vec_mut(), 10u16, 4 as u16);
3174 self.as_vec_mut().extend(value.to_ne_bytes());
3175 self
3176 }
3177 pub fn push_prio(mut self, value: u32) -> Self {
3178 push_header(self.as_vec_mut(), 15u16, 4 as u16);
3179 self.as_vec_mut().extend(value.to_ne_bytes());
3180 self
3181 }
3182 #[doc = "Associated type: [`PinState`] (enum)"]
3183 pub fn push_state(mut self, value: u32) -> Self {
3184 push_header(self.as_vec_mut(), 16u16, 4 as u16);
3185 self.as_vec_mut().extend(value.to_ne_bytes());
3186 self
3187 }
3188 pub fn push_phase_offset(mut self, value: i64) -> Self {
3189 push_header(self.as_vec_mut(), 23u16, 8 as u16);
3190 self.as_vec_mut().extend(value.to_ne_bytes());
3191 self
3192 }
3193 #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPM\n(parts per million). This is a lower-precision version of\nfractional-frequency-offset-ppt.\n"]
3194 pub fn push_fractional_frequency_offset(mut self, value: i32) -> Self {
3195 push_header(self.as_vec_mut(), 24u16, 4 as u16);
3196 self.as_vec_mut().extend(value.to_ne_bytes());
3197 self
3198 }
3199 #[doc = "The FFO (Fractional Frequency Offset) of the pin. At top level this\nrepresents the RX vs TX symbol rate offset on the media associated with\nthe pin. Inside the pin-parent-device nest it represents the frequency\noffset between the pin and its parent DPLL device. Value is in PPT\n(parts per trillion, 10\\^-12). This is a higher-precision version of\nfractional-frequency-offset.\n"]
3200 pub fn push_fractional_frequency_offset_ppt(mut self, value: i32) -> Self {
3201 push_header(self.as_vec_mut(), 30u16, 4 as u16);
3202 self.as_vec_mut().extend(value.to_ne_bytes());
3203 self
3204 }
3205 #[doc = "Operational state of the pin with respect to its parent DPLL device.\nUnlike state (which reflects the administrative intent), operstate\nreflects the actual hardware status.\n\nAssociated type: [`PinOperstate`] (enum)"]
3206 pub fn push_operstate(mut self, value: u32) -> Self {
3207 push_header(self.as_vec_mut(), 32u16, 4 as u16);
3208 self.as_vec_mut().extend(value.to_ne_bytes());
3209 self
3210 }
3211}
3212impl<Prev: Pusher> Drop for PushPinParentDevice<Prev> {
3213 fn drop(&mut self) {
3214 if let Some(prev) = &mut self.prev {
3215 if let Some(header_offset) = &self.header_offset {
3216 finalize_nested_header(prev.as_vec_mut(), *header_offset);
3217 }
3218 }
3219 }
3220}
3221pub struct PushPinParentPin<Prev: Pusher> {
3222 pub(crate) prev: Option<Prev>,
3223 pub(crate) header_offset: Option<usize>,
3224}
3225impl<Prev: Pusher> Pusher for PushPinParentPin<Prev> {
3226 fn as_vec_mut(&mut self) -> &mut Vec<u8> {
3227 self.prev.as_mut().unwrap().as_vec_mut()
3228 }
3229 fn as_vec(&self) -> &Vec<u8> {
3230 self.prev.as_ref().unwrap().as_vec()
3231 }
3232}
3233impl<Prev: Pusher> PushPinParentPin<Prev> {
3234 pub fn new(prev: Prev) -> Self {
3235 Self {
3236 prev: Some(prev),
3237 header_offset: None,
3238 }
3239 }
3240 pub fn end_nested(mut self) -> Prev {
3241 let mut prev = self.prev.take().unwrap();
3242 if let Some(header_offset) = &self.header_offset {
3243 finalize_nested_header(prev.as_vec_mut(), *header_offset);
3244 }
3245 prev
3246 }
3247 pub fn push_parent_id(mut self, value: u32) -> Self {
3248 push_header(self.as_vec_mut(), 2u16, 4 as u16);
3249 self.as_vec_mut().extend(value.to_ne_bytes());
3250 self
3251 }
3252 #[doc = "Associated type: [`PinState`] (enum)"]
3253 pub fn push_state(mut self, value: u32) -> Self {
3254 push_header(self.as_vec_mut(), 16u16, 4 as u16);
3255 self.as_vec_mut().extend(value.to_ne_bytes());
3256 self
3257 }
3258}
3259impl<Prev: Pusher> Drop for PushPinParentPin<Prev> {
3260 fn drop(&mut self) {
3261 if let Some(prev) = &mut self.prev {
3262 if let Some(header_offset) = &self.header_offset {
3263 finalize_nested_header(prev.as_vec_mut(), *header_offset);
3264 }
3265 }
3266 }
3267}
3268pub struct PushFrequencyRange<Prev: Pusher> {
3269 pub(crate) prev: Option<Prev>,
3270 pub(crate) header_offset: Option<usize>,
3271}
3272impl<Prev: Pusher> Pusher for PushFrequencyRange<Prev> {
3273 fn as_vec_mut(&mut self) -> &mut Vec<u8> {
3274 self.prev.as_mut().unwrap().as_vec_mut()
3275 }
3276 fn as_vec(&self) -> &Vec<u8> {
3277 self.prev.as_ref().unwrap().as_vec()
3278 }
3279}
3280impl<Prev: Pusher> PushFrequencyRange<Prev> {
3281 pub fn new(prev: Prev) -> Self {
3282 Self {
3283 prev: Some(prev),
3284 header_offset: None,
3285 }
3286 }
3287 pub fn end_nested(mut self) -> Prev {
3288 let mut prev = self.prev.take().unwrap();
3289 if let Some(header_offset) = &self.header_offset {
3290 finalize_nested_header(prev.as_vec_mut(), *header_offset);
3291 }
3292 prev
3293 }
3294 pub fn push_frequency_min(mut self, value: u64) -> Self {
3295 push_header(self.as_vec_mut(), 13u16, 8 as u16);
3296 self.as_vec_mut().extend(value.to_ne_bytes());
3297 self
3298 }
3299 pub fn push_frequency_max(mut self, value: u64) -> Self {
3300 push_header(self.as_vec_mut(), 14u16, 8 as u16);
3301 self.as_vec_mut().extend(value.to_ne_bytes());
3302 self
3303 }
3304}
3305impl<Prev: Pusher> Drop for PushFrequencyRange<Prev> {
3306 fn drop(&mut self) {
3307 if let Some(prev) = &mut self.prev {
3308 if let Some(header_offset) = &self.header_offset {
3309 finalize_nested_header(prev.as_vec_mut(), *header_offset);
3310 }
3311 }
3312 }
3313}
3314pub struct PushReferenceSync<Prev: Pusher> {
3315 pub(crate) prev: Option<Prev>,
3316 pub(crate) header_offset: Option<usize>,
3317}
3318impl<Prev: Pusher> Pusher for PushReferenceSync<Prev> {
3319 fn as_vec_mut(&mut self) -> &mut Vec<u8> {
3320 self.prev.as_mut().unwrap().as_vec_mut()
3321 }
3322 fn as_vec(&self) -> &Vec<u8> {
3323 self.prev.as_ref().unwrap().as_vec()
3324 }
3325}
3326impl<Prev: Pusher> PushReferenceSync<Prev> {
3327 pub fn new(prev: Prev) -> Self {
3328 Self {
3329 prev: Some(prev),
3330 header_offset: None,
3331 }
3332 }
3333 pub fn end_nested(mut self) -> Prev {
3334 let mut prev = self.prev.take().unwrap();
3335 if let Some(header_offset) = &self.header_offset {
3336 finalize_nested_header(prev.as_vec_mut(), *header_offset);
3337 }
3338 prev
3339 }
3340 pub fn push_id(mut self, value: u32) -> Self {
3341 push_header(self.as_vec_mut(), 1u16, 4 as u16);
3342 self.as_vec_mut().extend(value.to_ne_bytes());
3343 self
3344 }
3345 #[doc = "Associated type: [`PinState`] (enum)"]
3346 pub fn push_state(mut self, value: u32) -> Self {
3347 push_header(self.as_vec_mut(), 16u16, 4 as u16);
3348 self.as_vec_mut().extend(value.to_ne_bytes());
3349 self
3350 }
3351}
3352impl<Prev: Pusher> Drop for PushReferenceSync<Prev> {
3353 fn drop(&mut self) {
3354 if let Some(prev) = &mut self.prev {
3355 if let Some(header_offset) = &self.header_offset {
3356 finalize_nested_header(prev.as_vec_mut(), *header_offset);
3357 }
3358 }
3359 }
3360}
3361#[doc = "Notify attributes:\n- [`.get_id()`](IterableDpll::get_id)\n- [`.get_module_name()`](IterableDpll::get_module_name)\n- [`.get_mode()`](IterableDpll::get_mode)\n- [`.get_mode_supported()`](IterableDpll::get_mode_supported)\n- [`.get_lock_status()`](IterableDpll::get_lock_status)\n- [`.get_lock_status_error()`](IterableDpll::get_lock_status_error)\n- [`.get_temp()`](IterableDpll::get_temp)\n- [`.get_clock_id()`](IterableDpll::get_clock_id)\n- [`.get_type()`](IterableDpll::get_type)\n- [`.get_phase_offset_monitor()`](IterableDpll::get_phase_offset_monitor)\n- [`.get_phase_offset_avg_factor()`](IterableDpll::get_phase_offset_avg_factor)\n- [`.get_frequency_monitor()`](IterableDpll::get_frequency_monitor)\n"]
3362#[derive(Debug)]
3363pub struct OpDeviceCreateNotif;
3364impl OpDeviceCreateNotif {
3365 pub const CMD: u8 = 4u8;
3366 pub fn decode_notif<'a>(buf: &'a [u8]) -> IterableDpll<'a> {
3367 let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3368 IterableDpll::with_loc(attrs, buf.as_ptr() as usize)
3369 }
3370}
3371#[doc = "Notify attributes:\n- [`.get_id()`](IterableDpll::get_id)\n- [`.get_module_name()`](IterableDpll::get_module_name)\n- [`.get_mode()`](IterableDpll::get_mode)\n- [`.get_mode_supported()`](IterableDpll::get_mode_supported)\n- [`.get_lock_status()`](IterableDpll::get_lock_status)\n- [`.get_lock_status_error()`](IterableDpll::get_lock_status_error)\n- [`.get_temp()`](IterableDpll::get_temp)\n- [`.get_clock_id()`](IterableDpll::get_clock_id)\n- [`.get_type()`](IterableDpll::get_type)\n- [`.get_phase_offset_monitor()`](IterableDpll::get_phase_offset_monitor)\n- [`.get_phase_offset_avg_factor()`](IterableDpll::get_phase_offset_avg_factor)\n- [`.get_frequency_monitor()`](IterableDpll::get_frequency_monitor)\n"]
3372#[derive(Debug)]
3373pub struct OpDeviceDeleteNotif;
3374impl OpDeviceDeleteNotif {
3375 pub const CMD: u8 = 5u8;
3376 pub fn decode_notif<'a>(buf: &'a [u8]) -> IterableDpll<'a> {
3377 let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3378 IterableDpll::with_loc(attrs, buf.as_ptr() as usize)
3379 }
3380}
3381#[doc = "Notify attributes:\n- [`.get_id()`](IterableDpll::get_id)\n- [`.get_module_name()`](IterableDpll::get_module_name)\n- [`.get_mode()`](IterableDpll::get_mode)\n- [`.get_mode_supported()`](IterableDpll::get_mode_supported)\n- [`.get_lock_status()`](IterableDpll::get_lock_status)\n- [`.get_lock_status_error()`](IterableDpll::get_lock_status_error)\n- [`.get_temp()`](IterableDpll::get_temp)\n- [`.get_clock_id()`](IterableDpll::get_clock_id)\n- [`.get_type()`](IterableDpll::get_type)\n- [`.get_phase_offset_monitor()`](IterableDpll::get_phase_offset_monitor)\n- [`.get_phase_offset_avg_factor()`](IterableDpll::get_phase_offset_avg_factor)\n- [`.get_frequency_monitor()`](IterableDpll::get_frequency_monitor)\n"]
3382#[derive(Debug)]
3383pub struct OpDeviceChangeNotif;
3384impl OpDeviceChangeNotif {
3385 pub const CMD: u8 = 6u8;
3386 pub fn decode_notif<'a>(buf: &'a [u8]) -> IterableDpll<'a> {
3387 let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3388 IterableDpll::with_loc(attrs, buf.as_ptr() as usize)
3389 }
3390}
3391#[doc = "Notify attributes:\n- [`.get_id()`](IterablePin::get_id)\n- [`.get_module_name()`](IterablePin::get_module_name)\n- [`.get_clock_id()`](IterablePin::get_clock_id)\n- [`.get_board_label()`](IterablePin::get_board_label)\n- [`.get_panel_label()`](IterablePin::get_panel_label)\n- [`.get_package_label()`](IterablePin::get_package_label)\n- [`.get_type()`](IterablePin::get_type)\n- [`.get_frequency()`](IterablePin::get_frequency)\n- [`.get_frequency_supported()`](IterablePin::get_frequency_supported)\n- [`.get_capabilities()`](IterablePin::get_capabilities)\n- [`.get_parent_device()`](IterablePin::get_parent_device)\n- [`.get_parent_pin()`](IterablePin::get_parent_pin)\n- [`.get_phase_adjust_gran()`](IterablePin::get_phase_adjust_gran)\n- [`.get_phase_adjust_min()`](IterablePin::get_phase_adjust_min)\n- [`.get_phase_adjust_max()`](IterablePin::get_phase_adjust_max)\n- [`.get_phase_adjust()`](IterablePin::get_phase_adjust)\n- [`.get_fractional_frequency_offset()`](IterablePin::get_fractional_frequency_offset)\n- [`.get_fractional_frequency_offset_ppt()`](IterablePin::get_fractional_frequency_offset_ppt)\n- [`.get_esync_frequency()`](IterablePin::get_esync_frequency)\n- [`.get_esync_frequency_supported()`](IterablePin::get_esync_frequency_supported)\n- [`.get_esync_pulse()`](IterablePin::get_esync_pulse)\n- [`.get_reference_sync()`](IterablePin::get_reference_sync)\n- [`.get_measured_frequency()`](IterablePin::get_measured_frequency)\n"]
3392#[derive(Debug)]
3393pub struct OpPinCreateNotif;
3394impl OpPinCreateNotif {
3395 pub const CMD: u8 = 10u8;
3396 pub fn decode_notif<'a>(buf: &'a [u8]) -> IterablePin<'a> {
3397 let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3398 IterablePin::with_loc(attrs, buf.as_ptr() as usize)
3399 }
3400}
3401#[doc = "Notify attributes:\n- [`.get_id()`](IterablePin::get_id)\n- [`.get_module_name()`](IterablePin::get_module_name)\n- [`.get_clock_id()`](IterablePin::get_clock_id)\n- [`.get_board_label()`](IterablePin::get_board_label)\n- [`.get_panel_label()`](IterablePin::get_panel_label)\n- [`.get_package_label()`](IterablePin::get_package_label)\n- [`.get_type()`](IterablePin::get_type)\n- [`.get_frequency()`](IterablePin::get_frequency)\n- [`.get_frequency_supported()`](IterablePin::get_frequency_supported)\n- [`.get_capabilities()`](IterablePin::get_capabilities)\n- [`.get_parent_device()`](IterablePin::get_parent_device)\n- [`.get_parent_pin()`](IterablePin::get_parent_pin)\n- [`.get_phase_adjust_gran()`](IterablePin::get_phase_adjust_gran)\n- [`.get_phase_adjust_min()`](IterablePin::get_phase_adjust_min)\n- [`.get_phase_adjust_max()`](IterablePin::get_phase_adjust_max)\n- [`.get_phase_adjust()`](IterablePin::get_phase_adjust)\n- [`.get_fractional_frequency_offset()`](IterablePin::get_fractional_frequency_offset)\n- [`.get_fractional_frequency_offset_ppt()`](IterablePin::get_fractional_frequency_offset_ppt)\n- [`.get_esync_frequency()`](IterablePin::get_esync_frequency)\n- [`.get_esync_frequency_supported()`](IterablePin::get_esync_frequency_supported)\n- [`.get_esync_pulse()`](IterablePin::get_esync_pulse)\n- [`.get_reference_sync()`](IterablePin::get_reference_sync)\n- [`.get_measured_frequency()`](IterablePin::get_measured_frequency)\n"]
3402#[derive(Debug)]
3403pub struct OpPinDeleteNotif;
3404impl OpPinDeleteNotif {
3405 pub const CMD: u8 = 11u8;
3406 pub fn decode_notif<'a>(buf: &'a [u8]) -> IterablePin<'a> {
3407 let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3408 IterablePin::with_loc(attrs, buf.as_ptr() as usize)
3409 }
3410}
3411#[doc = "Notify attributes:\n- [`.get_id()`](IterablePin::get_id)\n- [`.get_module_name()`](IterablePin::get_module_name)\n- [`.get_clock_id()`](IterablePin::get_clock_id)\n- [`.get_board_label()`](IterablePin::get_board_label)\n- [`.get_panel_label()`](IterablePin::get_panel_label)\n- [`.get_package_label()`](IterablePin::get_package_label)\n- [`.get_type()`](IterablePin::get_type)\n- [`.get_frequency()`](IterablePin::get_frequency)\n- [`.get_frequency_supported()`](IterablePin::get_frequency_supported)\n- [`.get_capabilities()`](IterablePin::get_capabilities)\n- [`.get_parent_device()`](IterablePin::get_parent_device)\n- [`.get_parent_pin()`](IterablePin::get_parent_pin)\n- [`.get_phase_adjust_gran()`](IterablePin::get_phase_adjust_gran)\n- [`.get_phase_adjust_min()`](IterablePin::get_phase_adjust_min)\n- [`.get_phase_adjust_max()`](IterablePin::get_phase_adjust_max)\n- [`.get_phase_adjust()`](IterablePin::get_phase_adjust)\n- [`.get_fractional_frequency_offset()`](IterablePin::get_fractional_frequency_offset)\n- [`.get_fractional_frequency_offset_ppt()`](IterablePin::get_fractional_frequency_offset_ppt)\n- [`.get_esync_frequency()`](IterablePin::get_esync_frequency)\n- [`.get_esync_frequency_supported()`](IterablePin::get_esync_frequency_supported)\n- [`.get_esync_pulse()`](IterablePin::get_esync_pulse)\n- [`.get_reference_sync()`](IterablePin::get_reference_sync)\n- [`.get_measured_frequency()`](IterablePin::get_measured_frequency)\n"]
3412#[derive(Debug)]
3413pub struct OpPinChangeNotif;
3414impl OpPinChangeNotif {
3415 pub const CMD: u8 = 12u8;
3416 pub fn decode_notif<'a>(buf: &'a [u8]) -> IterablePin<'a> {
3417 let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3418 IterablePin::with_loc(attrs, buf.as_ptr() as usize)
3419 }
3420}
3421pub struct NotifGroup;
3422impl NotifGroup {
3423 #[doc = "Notifications:\n- [`OpDeviceCreateNotif`]\n- [`OpDeviceDeleteNotif`]\n- [`OpDeviceChangeNotif`]\n- [`OpPinCreateNotif`]\n- [`OpPinDeleteNotif`]\n- [`OpPinChangeNotif`]\n"]
3424 pub const MONITOR: &str = "monitor";
3425 #[doc = "Notifications:\n- [`OpDeviceCreateNotif`]\n- [`OpDeviceDeleteNotif`]\n- [`OpDeviceChangeNotif`]\n- [`OpPinCreateNotif`]\n- [`OpPinDeleteNotif`]\n- [`OpPinChangeNotif`]\n"]
3426 pub const MONITOR_CSTR: &CStr = c"monitor";
3427}
3428#[doc = "Get id of dpll device that matches given attributes\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_module_name()](PushDpll::push_module_name)\n- [.push_clock_id()](PushDpll::push_clock_id)\n- [.push_type()](PushDpll::push_type)\n\nReply attributes:\n- [.get_id()](IterableDpll::get_id)\n\n"]
3429#[derive(Debug)]
3430pub struct OpDeviceIdGetDo<'r> {
3431 request: Request<'r>,
3432}
3433impl<'r> OpDeviceIdGetDo<'r> {
3434 pub fn new(mut request: Request<'r>) -> Self {
3435 Self::write_header(request.buf_mut());
3436 Self { request: request }
3437 }
3438 pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushDpll<&'buf mut Vec<u8>> {
3439 Self::write_header(buf);
3440 PushDpll::new(buf)
3441 }
3442 pub fn encode(&mut self) -> PushDpll<&mut Vec<u8>> {
3443 PushDpll::new(self.request.buf_mut())
3444 }
3445 pub fn into_encoder(self) -> PushDpll<RequestBuf<'r>> {
3446 PushDpll::new(self.request.buf)
3447 }
3448 pub fn decode_request<'a>(buf: &'a [u8]) -> IterableDpll<'a> {
3449 let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3450 IterableDpll::with_loc(attrs, buf.as_ptr() as usize)
3451 }
3452 fn write_header<Prev: Pusher>(prev: &mut Prev) {
3453 let mut header = BuiltinNfgenmsg::new();
3454 header.cmd = 1u8;
3455 header.version = 1u8;
3456 prev.as_vec_mut().extend(header.as_slice());
3457 }
3458}
3459impl NetlinkRequest for OpDeviceIdGetDo<'_> {
3460 fn protocol(&self) -> Protocol {
3461 Protocol::Generic("dpll".as_bytes())
3462 }
3463 fn flags(&self) -> u16 {
3464 self.request.flags
3465 }
3466 fn payload(&self) -> &[u8] {
3467 self.request.buf()
3468 }
3469 type ReplyType<'buf> = IterableDpll<'buf>;
3470 fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
3471 Self::decode_request(buf)
3472 }
3473 fn lookup(
3474 buf: &[u8],
3475 offset: usize,
3476 missing_type: Option<u16>,
3477 ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3478 Self::decode_request(buf).lookup_attr(offset, missing_type)
3479 }
3480}
3481#[doc = "Get list of DPLL devices (dump) or attributes of a single dpll device\n\nFlags: admin-perm\n\nReply attributes:\n- [.get_id()](IterableDpll::get_id)\n- [.get_module_name()](IterableDpll::get_module_name)\n- [.get_clock_id()](IterableDpll::get_clock_id)\n- [.get_mode()](IterableDpll::get_mode)\n- [.get_mode_supported()](IterableDpll::get_mode_supported)\n- [.get_lock_status()](IterableDpll::get_lock_status)\n- [.get_temp()](IterableDpll::get_temp)\n- [.get_type()](IterableDpll::get_type)\n- [.get_lock_status_error()](IterableDpll::get_lock_status_error)\n- [.get_phase_offset_monitor()](IterableDpll::get_phase_offset_monitor)\n- [.get_phase_offset_avg_factor()](IterableDpll::get_phase_offset_avg_factor)\n- [.get_frequency_monitor()](IterableDpll::get_frequency_monitor)\n\n"]
3482#[derive(Debug)]
3483pub struct OpDeviceGetDump<'r> {
3484 request: Request<'r>,
3485}
3486impl<'r> OpDeviceGetDump<'r> {
3487 pub fn new(mut request: Request<'r>) -> Self {
3488 Self::write_header(request.buf_mut());
3489 Self {
3490 request: request.set_dump(),
3491 }
3492 }
3493 pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushDpll<&'buf mut Vec<u8>> {
3494 Self::write_header(buf);
3495 PushDpll::new(buf)
3496 }
3497 pub fn encode(&mut self) -> PushDpll<&mut Vec<u8>> {
3498 PushDpll::new(self.request.buf_mut())
3499 }
3500 pub fn into_encoder(self) -> PushDpll<RequestBuf<'r>> {
3501 PushDpll::new(self.request.buf)
3502 }
3503 pub fn decode_request<'a>(buf: &'a [u8]) -> IterableDpll<'a> {
3504 let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3505 IterableDpll::with_loc(attrs, buf.as_ptr() as usize)
3506 }
3507 fn write_header<Prev: Pusher>(prev: &mut Prev) {
3508 let mut header = BuiltinNfgenmsg::new();
3509 header.cmd = 2u8;
3510 header.version = 1u8;
3511 prev.as_vec_mut().extend(header.as_slice());
3512 }
3513}
3514impl NetlinkRequest for OpDeviceGetDump<'_> {
3515 fn protocol(&self) -> Protocol {
3516 Protocol::Generic("dpll".as_bytes())
3517 }
3518 fn flags(&self) -> u16 {
3519 self.request.flags
3520 }
3521 fn payload(&self) -> &[u8] {
3522 self.request.buf()
3523 }
3524 type ReplyType<'buf> = IterableDpll<'buf>;
3525 fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
3526 Self::decode_request(buf)
3527 }
3528 fn lookup(
3529 buf: &[u8],
3530 offset: usize,
3531 missing_type: Option<u16>,
3532 ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3533 Self::decode_request(buf).lookup_attr(offset, missing_type)
3534 }
3535}
3536#[doc = "Get list of DPLL devices (dump) or attributes of a single dpll device\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_id()](PushDpll::push_id)\n\nReply attributes:\n- [.get_id()](IterableDpll::get_id)\n- [.get_module_name()](IterableDpll::get_module_name)\n- [.get_clock_id()](IterableDpll::get_clock_id)\n- [.get_mode()](IterableDpll::get_mode)\n- [.get_mode_supported()](IterableDpll::get_mode_supported)\n- [.get_lock_status()](IterableDpll::get_lock_status)\n- [.get_temp()](IterableDpll::get_temp)\n- [.get_type()](IterableDpll::get_type)\n- [.get_lock_status_error()](IterableDpll::get_lock_status_error)\n- [.get_phase_offset_monitor()](IterableDpll::get_phase_offset_monitor)\n- [.get_phase_offset_avg_factor()](IterableDpll::get_phase_offset_avg_factor)\n- [.get_frequency_monitor()](IterableDpll::get_frequency_monitor)\n\n"]
3537#[derive(Debug)]
3538pub struct OpDeviceGetDo<'r> {
3539 request: Request<'r>,
3540}
3541impl<'r> OpDeviceGetDo<'r> {
3542 pub fn new(mut request: Request<'r>) -> Self {
3543 Self::write_header(request.buf_mut());
3544 Self { request: request }
3545 }
3546 pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushDpll<&'buf mut Vec<u8>> {
3547 Self::write_header(buf);
3548 PushDpll::new(buf)
3549 }
3550 pub fn encode(&mut self) -> PushDpll<&mut Vec<u8>> {
3551 PushDpll::new(self.request.buf_mut())
3552 }
3553 pub fn into_encoder(self) -> PushDpll<RequestBuf<'r>> {
3554 PushDpll::new(self.request.buf)
3555 }
3556 pub fn decode_request<'a>(buf: &'a [u8]) -> IterableDpll<'a> {
3557 let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3558 IterableDpll::with_loc(attrs, buf.as_ptr() as usize)
3559 }
3560 fn write_header<Prev: Pusher>(prev: &mut Prev) {
3561 let mut header = BuiltinNfgenmsg::new();
3562 header.cmd = 2u8;
3563 header.version = 1u8;
3564 prev.as_vec_mut().extend(header.as_slice());
3565 }
3566}
3567impl NetlinkRequest for OpDeviceGetDo<'_> {
3568 fn protocol(&self) -> Protocol {
3569 Protocol::Generic("dpll".as_bytes())
3570 }
3571 fn flags(&self) -> u16 {
3572 self.request.flags
3573 }
3574 fn payload(&self) -> &[u8] {
3575 self.request.buf()
3576 }
3577 type ReplyType<'buf> = IterableDpll<'buf>;
3578 fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
3579 Self::decode_request(buf)
3580 }
3581 fn lookup(
3582 buf: &[u8],
3583 offset: usize,
3584 missing_type: Option<u16>,
3585 ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3586 Self::decode_request(buf).lookup_attr(offset, missing_type)
3587 }
3588}
3589#[doc = "Set attributes for a DPLL device\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_id()](PushDpll::push_id)\n- [.push_mode()](PushDpll::push_mode)\n- [.push_phase_offset_monitor()](PushDpll::push_phase_offset_monitor)\n- [.push_phase_offset_avg_factor()](PushDpll::push_phase_offset_avg_factor)\n- [.push_frequency_monitor()](PushDpll::push_frequency_monitor)\n\n"]
3590#[derive(Debug)]
3591pub struct OpDeviceSetDo<'r> {
3592 request: Request<'r>,
3593}
3594impl<'r> OpDeviceSetDo<'r> {
3595 pub fn new(mut request: Request<'r>) -> Self {
3596 Self::write_header(request.buf_mut());
3597 Self { request: request }
3598 }
3599 pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushDpll<&'buf mut Vec<u8>> {
3600 Self::write_header(buf);
3601 PushDpll::new(buf)
3602 }
3603 pub fn encode(&mut self) -> PushDpll<&mut Vec<u8>> {
3604 PushDpll::new(self.request.buf_mut())
3605 }
3606 pub fn into_encoder(self) -> PushDpll<RequestBuf<'r>> {
3607 PushDpll::new(self.request.buf)
3608 }
3609 pub fn decode_request<'a>(buf: &'a [u8]) -> IterableDpll<'a> {
3610 let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3611 IterableDpll::with_loc(attrs, buf.as_ptr() as usize)
3612 }
3613 fn write_header<Prev: Pusher>(prev: &mut Prev) {
3614 let mut header = BuiltinNfgenmsg::new();
3615 header.cmd = 3u8;
3616 header.version = 1u8;
3617 prev.as_vec_mut().extend(header.as_slice());
3618 }
3619}
3620impl NetlinkRequest for OpDeviceSetDo<'_> {
3621 fn protocol(&self) -> Protocol {
3622 Protocol::Generic("dpll".as_bytes())
3623 }
3624 fn flags(&self) -> u16 {
3625 self.request.flags
3626 }
3627 fn payload(&self) -> &[u8] {
3628 self.request.buf()
3629 }
3630 type ReplyType<'buf> = IterableDpll<'buf>;
3631 fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
3632 Self::decode_request(buf)
3633 }
3634 fn lookup(
3635 buf: &[u8],
3636 offset: usize,
3637 missing_type: Option<u16>,
3638 ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3639 Self::decode_request(buf).lookup_attr(offset, missing_type)
3640 }
3641}
3642#[doc = "Get id of a pin that matches given attributes\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_module_name()](PushPin::push_module_name)\n- [.push_clock_id()](PushPin::push_clock_id)\n- [.push_board_label()](PushPin::push_board_label)\n- [.push_panel_label()](PushPin::push_panel_label)\n- [.push_package_label()](PushPin::push_package_label)\n- [.push_type()](PushPin::push_type)\n\nReply attributes:\n- [.get_id()](IterablePin::get_id)\n\n"]
3643#[derive(Debug)]
3644pub struct OpPinIdGetDo<'r> {
3645 request: Request<'r>,
3646}
3647impl<'r> OpPinIdGetDo<'r> {
3648 pub fn new(mut request: Request<'r>) -> Self {
3649 Self::write_header(request.buf_mut());
3650 Self { request: request }
3651 }
3652 pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushPin<&'buf mut Vec<u8>> {
3653 Self::write_header(buf);
3654 PushPin::new(buf)
3655 }
3656 pub fn encode(&mut self) -> PushPin<&mut Vec<u8>> {
3657 PushPin::new(self.request.buf_mut())
3658 }
3659 pub fn into_encoder(self) -> PushPin<RequestBuf<'r>> {
3660 PushPin::new(self.request.buf)
3661 }
3662 pub fn decode_request<'a>(buf: &'a [u8]) -> IterablePin<'a> {
3663 let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3664 IterablePin::with_loc(attrs, buf.as_ptr() as usize)
3665 }
3666 fn write_header<Prev: Pusher>(prev: &mut Prev) {
3667 let mut header = BuiltinNfgenmsg::new();
3668 header.cmd = 7u8;
3669 header.version = 1u8;
3670 prev.as_vec_mut().extend(header.as_slice());
3671 }
3672}
3673impl NetlinkRequest for OpPinIdGetDo<'_> {
3674 fn protocol(&self) -> Protocol {
3675 Protocol::Generic("dpll".as_bytes())
3676 }
3677 fn flags(&self) -> u16 {
3678 self.request.flags
3679 }
3680 fn payload(&self) -> &[u8] {
3681 self.request.buf()
3682 }
3683 type ReplyType<'buf> = IterablePin<'buf>;
3684 fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
3685 Self::decode_request(buf)
3686 }
3687 fn lookup(
3688 buf: &[u8],
3689 offset: usize,
3690 missing_type: Option<u16>,
3691 ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3692 Self::decode_request(buf).lookup_attr(offset, missing_type)
3693 }
3694}
3695#[doc = "Get list of pins and its attributes.\n\n- dump request without any attributes given - list all the pins in the\n system\n- dump request with target dpll - list all the pins registered with a\n given dpll device\n- do request with target dpll and target pin - single pin attributes\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_id()](PushPin::push_id)\n\nReply attributes:\n- [.get_id()](IterablePin::get_id)\n- [.get_module_name()](IterablePin::get_module_name)\n- [.get_clock_id()](IterablePin::get_clock_id)\n- [.get_board_label()](IterablePin::get_board_label)\n- [.get_panel_label()](IterablePin::get_panel_label)\n- [.get_package_label()](IterablePin::get_package_label)\n- [.get_type()](IterablePin::get_type)\n- [.get_frequency()](IterablePin::get_frequency)\n- [.get_frequency_supported()](IterablePin::get_frequency_supported)\n- [.get_capabilities()](IterablePin::get_capabilities)\n- [.get_parent_device()](IterablePin::get_parent_device)\n- [.get_parent_pin()](IterablePin::get_parent_pin)\n- [.get_phase_adjust_min()](IterablePin::get_phase_adjust_min)\n- [.get_phase_adjust_max()](IterablePin::get_phase_adjust_max)\n- [.get_phase_adjust()](IterablePin::get_phase_adjust)\n- [.get_fractional_frequency_offset()](IterablePin::get_fractional_frequency_offset)\n- [.get_esync_frequency()](IterablePin::get_esync_frequency)\n- [.get_esync_frequency_supported()](IterablePin::get_esync_frequency_supported)\n- [.get_esync_pulse()](IterablePin::get_esync_pulse)\n- [.get_reference_sync()](IterablePin::get_reference_sync)\n- [.get_phase_adjust_gran()](IterablePin::get_phase_adjust_gran)\n- [.get_fractional_frequency_offset_ppt()](IterablePin::get_fractional_frequency_offset_ppt)\n- [.get_measured_frequency()](IterablePin::get_measured_frequency)\n\n"]
3696#[derive(Debug)]
3697pub struct OpPinGetDump<'r> {
3698 request: Request<'r>,
3699}
3700impl<'r> OpPinGetDump<'r> {
3701 pub fn new(mut request: Request<'r>) -> Self {
3702 Self::write_header(request.buf_mut());
3703 Self {
3704 request: request.set_dump(),
3705 }
3706 }
3707 pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushPin<&'buf mut Vec<u8>> {
3708 Self::write_header(buf);
3709 PushPin::new(buf)
3710 }
3711 pub fn encode(&mut self) -> PushPin<&mut Vec<u8>> {
3712 PushPin::new(self.request.buf_mut())
3713 }
3714 pub fn into_encoder(self) -> PushPin<RequestBuf<'r>> {
3715 PushPin::new(self.request.buf)
3716 }
3717 pub fn decode_request<'a>(buf: &'a [u8]) -> IterablePin<'a> {
3718 let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3719 IterablePin::with_loc(attrs, buf.as_ptr() as usize)
3720 }
3721 fn write_header<Prev: Pusher>(prev: &mut Prev) {
3722 let mut header = BuiltinNfgenmsg::new();
3723 header.cmd = 8u8;
3724 header.version = 1u8;
3725 prev.as_vec_mut().extend(header.as_slice());
3726 }
3727}
3728impl NetlinkRequest for OpPinGetDump<'_> {
3729 fn protocol(&self) -> Protocol {
3730 Protocol::Generic("dpll".as_bytes())
3731 }
3732 fn flags(&self) -> u16 {
3733 self.request.flags
3734 }
3735 fn payload(&self) -> &[u8] {
3736 self.request.buf()
3737 }
3738 type ReplyType<'buf> = IterablePin<'buf>;
3739 fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
3740 Self::decode_request(buf)
3741 }
3742 fn lookup(
3743 buf: &[u8],
3744 offset: usize,
3745 missing_type: Option<u16>,
3746 ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3747 Self::decode_request(buf).lookup_attr(offset, missing_type)
3748 }
3749}
3750#[doc = "Get list of pins and its attributes.\n\n- dump request without any attributes given - list all the pins in the\n system\n- dump request with target dpll - list all the pins registered with a\n given dpll device\n- do request with target dpll and target pin - single pin attributes\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_id()](PushPin::push_id)\n\nReply attributes:\n- [.get_id()](IterablePin::get_id)\n- [.get_module_name()](IterablePin::get_module_name)\n- [.get_clock_id()](IterablePin::get_clock_id)\n- [.get_board_label()](IterablePin::get_board_label)\n- [.get_panel_label()](IterablePin::get_panel_label)\n- [.get_package_label()](IterablePin::get_package_label)\n- [.get_type()](IterablePin::get_type)\n- [.get_frequency()](IterablePin::get_frequency)\n- [.get_frequency_supported()](IterablePin::get_frequency_supported)\n- [.get_capabilities()](IterablePin::get_capabilities)\n- [.get_parent_device()](IterablePin::get_parent_device)\n- [.get_parent_pin()](IterablePin::get_parent_pin)\n- [.get_phase_adjust_min()](IterablePin::get_phase_adjust_min)\n- [.get_phase_adjust_max()](IterablePin::get_phase_adjust_max)\n- [.get_phase_adjust()](IterablePin::get_phase_adjust)\n- [.get_fractional_frequency_offset()](IterablePin::get_fractional_frequency_offset)\n- [.get_esync_frequency()](IterablePin::get_esync_frequency)\n- [.get_esync_frequency_supported()](IterablePin::get_esync_frequency_supported)\n- [.get_esync_pulse()](IterablePin::get_esync_pulse)\n- [.get_reference_sync()](IterablePin::get_reference_sync)\n- [.get_phase_adjust_gran()](IterablePin::get_phase_adjust_gran)\n- [.get_fractional_frequency_offset_ppt()](IterablePin::get_fractional_frequency_offset_ppt)\n- [.get_measured_frequency()](IterablePin::get_measured_frequency)\n\n"]
3751#[derive(Debug)]
3752pub struct OpPinGetDo<'r> {
3753 request: Request<'r>,
3754}
3755impl<'r> OpPinGetDo<'r> {
3756 pub fn new(mut request: Request<'r>) -> Self {
3757 Self::write_header(request.buf_mut());
3758 Self { request: request }
3759 }
3760 pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushPin<&'buf mut Vec<u8>> {
3761 Self::write_header(buf);
3762 PushPin::new(buf)
3763 }
3764 pub fn encode(&mut self) -> PushPin<&mut Vec<u8>> {
3765 PushPin::new(self.request.buf_mut())
3766 }
3767 pub fn into_encoder(self) -> PushPin<RequestBuf<'r>> {
3768 PushPin::new(self.request.buf)
3769 }
3770 pub fn decode_request<'a>(buf: &'a [u8]) -> IterablePin<'a> {
3771 let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3772 IterablePin::with_loc(attrs, buf.as_ptr() as usize)
3773 }
3774 fn write_header<Prev: Pusher>(prev: &mut Prev) {
3775 let mut header = BuiltinNfgenmsg::new();
3776 header.cmd = 8u8;
3777 header.version = 1u8;
3778 prev.as_vec_mut().extend(header.as_slice());
3779 }
3780}
3781impl NetlinkRequest for OpPinGetDo<'_> {
3782 fn protocol(&self) -> Protocol {
3783 Protocol::Generic("dpll".as_bytes())
3784 }
3785 fn flags(&self) -> u16 {
3786 self.request.flags
3787 }
3788 fn payload(&self) -> &[u8] {
3789 self.request.buf()
3790 }
3791 type ReplyType<'buf> = IterablePin<'buf>;
3792 fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
3793 Self::decode_request(buf)
3794 }
3795 fn lookup(
3796 buf: &[u8],
3797 offset: usize,
3798 missing_type: Option<u16>,
3799 ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3800 Self::decode_request(buf).lookup_attr(offset, missing_type)
3801 }
3802}
3803#[doc = "Set attributes of a target pin\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_id()](PushPin::push_id)\n- [.push_direction()](PushPin::push_direction)\n- [.push_frequency()](PushPin::push_frequency)\n- [.push_prio()](PushPin::push_prio)\n- [.push_state()](PushPin::push_state)\n- [.nested_parent_device()](PushPin::nested_parent_device)\n- [.nested_parent_pin()](PushPin::nested_parent_pin)\n- [.push_phase_adjust()](PushPin::push_phase_adjust)\n- [.push_esync_frequency()](PushPin::push_esync_frequency)\n- [.nested_reference_sync()](PushPin::nested_reference_sync)\n\n"]
3804#[derive(Debug)]
3805pub struct OpPinSetDo<'r> {
3806 request: Request<'r>,
3807}
3808impl<'r> OpPinSetDo<'r> {
3809 pub fn new(mut request: Request<'r>) -> Self {
3810 Self::write_header(request.buf_mut());
3811 Self { request: request }
3812 }
3813 pub fn encode_request<'buf>(buf: &'buf mut Vec<u8>) -> PushPin<&'buf mut Vec<u8>> {
3814 Self::write_header(buf);
3815 PushPin::new(buf)
3816 }
3817 pub fn encode(&mut self) -> PushPin<&mut Vec<u8>> {
3818 PushPin::new(self.request.buf_mut())
3819 }
3820 pub fn into_encoder(self) -> PushPin<RequestBuf<'r>> {
3821 PushPin::new(self.request.buf)
3822 }
3823 pub fn decode_request<'a>(buf: &'a [u8]) -> IterablePin<'a> {
3824 let (_header, attrs) = buf.split_at(buf.len().min(BuiltinNfgenmsg::len()));
3825 IterablePin::with_loc(attrs, buf.as_ptr() as usize)
3826 }
3827 fn write_header<Prev: Pusher>(prev: &mut Prev) {
3828 let mut header = BuiltinNfgenmsg::new();
3829 header.cmd = 9u8;
3830 header.version = 1u8;
3831 prev.as_vec_mut().extend(header.as_slice());
3832 }
3833}
3834impl NetlinkRequest for OpPinSetDo<'_> {
3835 fn protocol(&self) -> Protocol {
3836 Protocol::Generic("dpll".as_bytes())
3837 }
3838 fn flags(&self) -> u16 {
3839 self.request.flags
3840 }
3841 fn payload(&self) -> &[u8] {
3842 self.request.buf()
3843 }
3844 type ReplyType<'buf> = IterablePin<'buf>;
3845 fn decode_reply<'buf>(buf: &'buf [u8]) -> Self::ReplyType<'buf> {
3846 Self::decode_request(buf)
3847 }
3848 fn lookup(
3849 buf: &[u8],
3850 offset: usize,
3851 missing_type: Option<u16>,
3852 ) -> (Vec<(&'static str, usize)>, Option<&'static str>) {
3853 Self::decode_request(buf).lookup_attr(offset, missing_type)
3854 }
3855}
3856use crate::traits::LookupFn;
3857use crate::utils::RequestBuf;
3858#[derive(Debug)]
3859pub struct Request<'buf> {
3860 buf: RequestBuf<'buf>,
3861 flags: u16,
3862 writeback: Option<&'buf mut Option<RequestInfo>>,
3863}
3864#[allow(unused)]
3865#[derive(Debug, Clone)]
3866pub struct RequestInfo {
3867 protocol: Protocol,
3868 flags: u16,
3869 name: &'static str,
3870 lookup: LookupFn,
3871}
3872impl Request<'static> {
3873 pub fn new() -> Self {
3874 Self::new_from_buf(Vec::new())
3875 }
3876 pub fn new_from_buf(buf: Vec<u8>) -> Self {
3877 Self {
3878 flags: 0,
3879 buf: RequestBuf::Own(buf),
3880 writeback: None,
3881 }
3882 }
3883 pub fn into_buf(self) -> Vec<u8> {
3884 match self.buf {
3885 RequestBuf::Own(buf) => buf,
3886 _ => unreachable!(),
3887 }
3888 }
3889}
3890impl<'buf> Request<'buf> {
3891 pub fn new_with_buf(buf: &'buf mut Vec<u8>) -> Self {
3892 buf.clear();
3893 Self::new_extend(buf)
3894 }
3895 pub fn new_extend(buf: &'buf mut Vec<u8>) -> Self {
3896 Self {
3897 flags: 0,
3898 buf: RequestBuf::Ref(buf),
3899 writeback: None,
3900 }
3901 }
3902 fn do_writeback(&mut self, protocol: Protocol, name: &'static str, lookup: LookupFn) {
3903 let Some(writeback) = &mut self.writeback else {
3904 return;
3905 };
3906 **writeback = Some(RequestInfo {
3907 protocol,
3908 flags: self.flags,
3909 name,
3910 lookup,
3911 })
3912 }
3913 pub fn buf(&self) -> &Vec<u8> {
3914 self.buf.buf()
3915 }
3916 pub fn buf_mut(&mut self) -> &mut Vec<u8> {
3917 self.buf.buf_mut()
3918 }
3919 #[doc = "Set `NLM_F_CREATE` flag"]
3920 pub fn set_create(mut self) -> Self {
3921 self.flags |= consts::NLM_F_CREATE as u16;
3922 self
3923 }
3924 #[doc = "Set `NLM_F_EXCL` flag"]
3925 pub fn set_excl(mut self) -> Self {
3926 self.flags |= consts::NLM_F_EXCL as u16;
3927 self
3928 }
3929 #[doc = "Set `NLM_F_REPLACE` flag"]
3930 pub fn set_replace(mut self) -> Self {
3931 self.flags |= consts::NLM_F_REPLACE as u16;
3932 self
3933 }
3934 #[doc = "Set `NLM_F_CREATE` and `NLM_F_REPLACE` flag"]
3935 pub fn set_change(self) -> Self {
3936 self.set_create().set_replace()
3937 }
3938 #[doc = "Set `NLM_F_APPEND` flag"]
3939 pub fn set_append(mut self) -> Self {
3940 self.flags |= consts::NLM_F_APPEND as u16;
3941 self
3942 }
3943 #[doc = "Set `self.flags |= flags`"]
3944 pub fn set_flags(mut self, flags: u16) -> Self {
3945 self.flags |= flags;
3946 self
3947 }
3948 #[doc = "Set `self.flags ^= self.flags & flags`"]
3949 pub fn unset_flags(mut self, flags: u16) -> Self {
3950 self.flags ^= self.flags & flags;
3951 self
3952 }
3953 #[doc = "Set `NLM_F_DUMP` flag"]
3954 fn set_dump(mut self) -> Self {
3955 self.flags |= consts::NLM_F_DUMP as u16;
3956 self
3957 }
3958 #[doc = "Get id of dpll device that matches given attributes\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_module_name()](PushDpll::push_module_name)\n- [.push_clock_id()](PushDpll::push_clock_id)\n- [.push_type()](PushDpll::push_type)\n\nReply attributes:\n- [.get_id()](IterableDpll::get_id)\n\n"]
3959 pub fn op_device_id_get_do(self) -> OpDeviceIdGetDo<'buf> {
3960 let mut res = OpDeviceIdGetDo::new(self);
3961 res.request.do_writeback(
3962 res.protocol(),
3963 "op-device-id-get-do",
3964 OpDeviceIdGetDo::lookup,
3965 );
3966 res
3967 }
3968 #[doc = "Get list of DPLL devices (dump) or attributes of a single dpll device\n\nFlags: admin-perm\n\nReply attributes:\n- [.get_id()](IterableDpll::get_id)\n- [.get_module_name()](IterableDpll::get_module_name)\n- [.get_clock_id()](IterableDpll::get_clock_id)\n- [.get_mode()](IterableDpll::get_mode)\n- [.get_mode_supported()](IterableDpll::get_mode_supported)\n- [.get_lock_status()](IterableDpll::get_lock_status)\n- [.get_temp()](IterableDpll::get_temp)\n- [.get_type()](IterableDpll::get_type)\n- [.get_lock_status_error()](IterableDpll::get_lock_status_error)\n- [.get_phase_offset_monitor()](IterableDpll::get_phase_offset_monitor)\n- [.get_phase_offset_avg_factor()](IterableDpll::get_phase_offset_avg_factor)\n- [.get_frequency_monitor()](IterableDpll::get_frequency_monitor)\n\n"]
3969 pub fn op_device_get_dump(self) -> OpDeviceGetDump<'buf> {
3970 let mut res = OpDeviceGetDump::new(self);
3971 res.request.do_writeback(
3972 res.protocol(),
3973 "op-device-get-dump",
3974 OpDeviceGetDump::lookup,
3975 );
3976 res
3977 }
3978 #[doc = "Get list of DPLL devices (dump) or attributes of a single dpll device\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_id()](PushDpll::push_id)\n\nReply attributes:\n- [.get_id()](IterableDpll::get_id)\n- [.get_module_name()](IterableDpll::get_module_name)\n- [.get_clock_id()](IterableDpll::get_clock_id)\n- [.get_mode()](IterableDpll::get_mode)\n- [.get_mode_supported()](IterableDpll::get_mode_supported)\n- [.get_lock_status()](IterableDpll::get_lock_status)\n- [.get_temp()](IterableDpll::get_temp)\n- [.get_type()](IterableDpll::get_type)\n- [.get_lock_status_error()](IterableDpll::get_lock_status_error)\n- [.get_phase_offset_monitor()](IterableDpll::get_phase_offset_monitor)\n- [.get_phase_offset_avg_factor()](IterableDpll::get_phase_offset_avg_factor)\n- [.get_frequency_monitor()](IterableDpll::get_frequency_monitor)\n\n"]
3979 pub fn op_device_get_do(self) -> OpDeviceGetDo<'buf> {
3980 let mut res = OpDeviceGetDo::new(self);
3981 res.request
3982 .do_writeback(res.protocol(), "op-device-get-do", OpDeviceGetDo::lookup);
3983 res
3984 }
3985 #[doc = "Set attributes for a DPLL device\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_id()](PushDpll::push_id)\n- [.push_mode()](PushDpll::push_mode)\n- [.push_phase_offset_monitor()](PushDpll::push_phase_offset_monitor)\n- [.push_phase_offset_avg_factor()](PushDpll::push_phase_offset_avg_factor)\n- [.push_frequency_monitor()](PushDpll::push_frequency_monitor)\n\n"]
3986 pub fn op_device_set_do(self) -> OpDeviceSetDo<'buf> {
3987 let mut res = OpDeviceSetDo::new(self);
3988 res.request
3989 .do_writeback(res.protocol(), "op-device-set-do", OpDeviceSetDo::lookup);
3990 res
3991 }
3992 #[doc = "Get id of a pin that matches given attributes\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_module_name()](PushPin::push_module_name)\n- [.push_clock_id()](PushPin::push_clock_id)\n- [.push_board_label()](PushPin::push_board_label)\n- [.push_panel_label()](PushPin::push_panel_label)\n- [.push_package_label()](PushPin::push_package_label)\n- [.push_type()](PushPin::push_type)\n\nReply attributes:\n- [.get_id()](IterablePin::get_id)\n\n"]
3993 pub fn op_pin_id_get_do(self) -> OpPinIdGetDo<'buf> {
3994 let mut res = OpPinIdGetDo::new(self);
3995 res.request
3996 .do_writeback(res.protocol(), "op-pin-id-get-do", OpPinIdGetDo::lookup);
3997 res
3998 }
3999 #[doc = "Get list of pins and its attributes.\n\n- dump request without any attributes given - list all the pins in the\n system\n- dump request with target dpll - list all the pins registered with a\n given dpll device\n- do request with target dpll and target pin - single pin attributes\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_id()](PushPin::push_id)\n\nReply attributes:\n- [.get_id()](IterablePin::get_id)\n- [.get_module_name()](IterablePin::get_module_name)\n- [.get_clock_id()](IterablePin::get_clock_id)\n- [.get_board_label()](IterablePin::get_board_label)\n- [.get_panel_label()](IterablePin::get_panel_label)\n- [.get_package_label()](IterablePin::get_package_label)\n- [.get_type()](IterablePin::get_type)\n- [.get_frequency()](IterablePin::get_frequency)\n- [.get_frequency_supported()](IterablePin::get_frequency_supported)\n- [.get_capabilities()](IterablePin::get_capabilities)\n- [.get_parent_device()](IterablePin::get_parent_device)\n- [.get_parent_pin()](IterablePin::get_parent_pin)\n- [.get_phase_adjust_min()](IterablePin::get_phase_adjust_min)\n- [.get_phase_adjust_max()](IterablePin::get_phase_adjust_max)\n- [.get_phase_adjust()](IterablePin::get_phase_adjust)\n- [.get_fractional_frequency_offset()](IterablePin::get_fractional_frequency_offset)\n- [.get_esync_frequency()](IterablePin::get_esync_frequency)\n- [.get_esync_frequency_supported()](IterablePin::get_esync_frequency_supported)\n- [.get_esync_pulse()](IterablePin::get_esync_pulse)\n- [.get_reference_sync()](IterablePin::get_reference_sync)\n- [.get_phase_adjust_gran()](IterablePin::get_phase_adjust_gran)\n- [.get_fractional_frequency_offset_ppt()](IterablePin::get_fractional_frequency_offset_ppt)\n- [.get_measured_frequency()](IterablePin::get_measured_frequency)\n\n"]
4000 pub fn op_pin_get_dump(self) -> OpPinGetDump<'buf> {
4001 let mut res = OpPinGetDump::new(self);
4002 res.request
4003 .do_writeback(res.protocol(), "op-pin-get-dump", OpPinGetDump::lookup);
4004 res
4005 }
4006 #[doc = "Get list of pins and its attributes.\n\n- dump request without any attributes given - list all the pins in the\n system\n- dump request with target dpll - list all the pins registered with a\n given dpll device\n- do request with target dpll and target pin - single pin attributes\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_id()](PushPin::push_id)\n\nReply attributes:\n- [.get_id()](IterablePin::get_id)\n- [.get_module_name()](IterablePin::get_module_name)\n- [.get_clock_id()](IterablePin::get_clock_id)\n- [.get_board_label()](IterablePin::get_board_label)\n- [.get_panel_label()](IterablePin::get_panel_label)\n- [.get_package_label()](IterablePin::get_package_label)\n- [.get_type()](IterablePin::get_type)\n- [.get_frequency()](IterablePin::get_frequency)\n- [.get_frequency_supported()](IterablePin::get_frequency_supported)\n- [.get_capabilities()](IterablePin::get_capabilities)\n- [.get_parent_device()](IterablePin::get_parent_device)\n- [.get_parent_pin()](IterablePin::get_parent_pin)\n- [.get_phase_adjust_min()](IterablePin::get_phase_adjust_min)\n- [.get_phase_adjust_max()](IterablePin::get_phase_adjust_max)\n- [.get_phase_adjust()](IterablePin::get_phase_adjust)\n- [.get_fractional_frequency_offset()](IterablePin::get_fractional_frequency_offset)\n- [.get_esync_frequency()](IterablePin::get_esync_frequency)\n- [.get_esync_frequency_supported()](IterablePin::get_esync_frequency_supported)\n- [.get_esync_pulse()](IterablePin::get_esync_pulse)\n- [.get_reference_sync()](IterablePin::get_reference_sync)\n- [.get_phase_adjust_gran()](IterablePin::get_phase_adjust_gran)\n- [.get_fractional_frequency_offset_ppt()](IterablePin::get_fractional_frequency_offset_ppt)\n- [.get_measured_frequency()](IterablePin::get_measured_frequency)\n\n"]
4007 pub fn op_pin_get_do(self) -> OpPinGetDo<'buf> {
4008 let mut res = OpPinGetDo::new(self);
4009 res.request
4010 .do_writeback(res.protocol(), "op-pin-get-do", OpPinGetDo::lookup);
4011 res
4012 }
4013 #[doc = "Set attributes of a target pin\n\nFlags: admin-perm\n\nRequest attributes:\n- [.push_id()](PushPin::push_id)\n- [.push_direction()](PushPin::push_direction)\n- [.push_frequency()](PushPin::push_frequency)\n- [.push_prio()](PushPin::push_prio)\n- [.push_state()](PushPin::push_state)\n- [.nested_parent_device()](PushPin::nested_parent_device)\n- [.nested_parent_pin()](PushPin::nested_parent_pin)\n- [.push_phase_adjust()](PushPin::push_phase_adjust)\n- [.push_esync_frequency()](PushPin::push_esync_frequency)\n- [.nested_reference_sync()](PushPin::nested_reference_sync)\n\n"]
4014 pub fn op_pin_set_do(self) -> OpPinSetDo<'buf> {
4015 let mut res = OpPinSetDo::new(self);
4016 res.request
4017 .do_writeback(res.protocol(), "op-pin-set-do", OpPinSetDo::lookup);
4018 res
4019 }
4020}
4021#[cfg(test)]
4022mod generated_tests {
4023 use super::*;
4024 #[test]
4025 fn tests() {
4026 let _ = IterableDpll::get_clock_id;
4027 let _ = IterableDpll::get_frequency_monitor;
4028 let _ = IterableDpll::get_id;
4029 let _ = IterableDpll::get_lock_status;
4030 let _ = IterableDpll::get_lock_status_error;
4031 let _ = IterableDpll::get_mode;
4032 let _ = IterableDpll::get_mode_supported;
4033 let _ = IterableDpll::get_module_name;
4034 let _ = IterableDpll::get_phase_offset_avg_factor;
4035 let _ = IterableDpll::get_phase_offset_monitor;
4036 let _ = IterableDpll::get_temp;
4037 let _ = IterableDpll::get_type;
4038 let _ = IterablePin::get_board_label;
4039 let _ = IterablePin::get_capabilities;
4040 let _ = IterablePin::get_clock_id;
4041 let _ = IterablePin::get_esync_frequency;
4042 let _ = IterablePin::get_esync_frequency_supported;
4043 let _ = IterablePin::get_esync_pulse;
4044 let _ = IterablePin::get_fractional_frequency_offset;
4045 let _ = IterablePin::get_fractional_frequency_offset_ppt;
4046 let _ = IterablePin::get_frequency;
4047 let _ = IterablePin::get_frequency_supported;
4048 let _ = IterablePin::get_id;
4049 let _ = IterablePin::get_measured_frequency;
4050 let _ = IterablePin::get_module_name;
4051 let _ = IterablePin::get_package_label;
4052 let _ = IterablePin::get_panel_label;
4053 let _ = IterablePin::get_parent_device;
4054 let _ = IterablePin::get_parent_pin;
4055 let _ = IterablePin::get_phase_adjust;
4056 let _ = IterablePin::get_phase_adjust_gran;
4057 let _ = IterablePin::get_phase_adjust_max;
4058 let _ = IterablePin::get_phase_adjust_min;
4059 let _ = IterablePin::get_reference_sync;
4060 let _ = IterablePin::get_type;
4061 let _ = OpDeviceChangeNotif;
4062 let _ = OpDeviceCreateNotif;
4063 let _ = OpDeviceDeleteNotif;
4064 let _ = OpPinChangeNotif;
4065 let _ = OpPinCreateNotif;
4066 let _ = OpPinDeleteNotif;
4067 let _ = PushDpll::<&mut Vec<u8>>::push_clock_id;
4068 let _ = PushDpll::<&mut Vec<u8>>::push_frequency_monitor;
4069 let _ = PushDpll::<&mut Vec<u8>>::push_id;
4070 let _ = PushDpll::<&mut Vec<u8>>::push_mode;
4071 let _ = PushDpll::<&mut Vec<u8>>::push_module_name;
4072 let _ = PushDpll::<&mut Vec<u8>>::push_phase_offset_avg_factor;
4073 let _ = PushDpll::<&mut Vec<u8>>::push_phase_offset_monitor;
4074 let _ = PushDpll::<&mut Vec<u8>>::push_type;
4075 let _ = PushPin::<&mut Vec<u8>>::nested_parent_device;
4076 let _ = PushPin::<&mut Vec<u8>>::nested_parent_pin;
4077 let _ = PushPin::<&mut Vec<u8>>::nested_reference_sync;
4078 let _ = PushPin::<&mut Vec<u8>>::push_board_label;
4079 let _ = PushPin::<&mut Vec<u8>>::push_clock_id;
4080 let _ = PushPin::<&mut Vec<u8>>::push_direction;
4081 let _ = PushPin::<&mut Vec<u8>>::push_esync_frequency;
4082 let _ = PushPin::<&mut Vec<u8>>::push_frequency;
4083 let _ = PushPin::<&mut Vec<u8>>::push_id;
4084 let _ = PushPin::<&mut Vec<u8>>::push_module_name;
4085 let _ = PushPin::<&mut Vec<u8>>::push_package_label;
4086 let _ = PushPin::<&mut Vec<u8>>::push_panel_label;
4087 let _ = PushPin::<&mut Vec<u8>>::push_phase_adjust;
4088 let _ = PushPin::<&mut Vec<u8>>::push_prio;
4089 let _ = PushPin::<&mut Vec<u8>>::push_state;
4090 let _ = PushPin::<&mut Vec<u8>>::push_type;
4091 }
4092}