| 1 | |
| 2 | |
| 3 |
|
| 4 | use crate::bindings;
|
| 5 | use crate::prelude::*;
|
| 6 |
|
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | #[derive(Clone, Copy, PartialEq, Eq)]
|
| 27 | pub struct Flags(c_ulong);
|
| 28 |
|
| 29 | impl Flags {
|
| 30 | |
| 31 | pub const TRIGGER_NONE: Flags = Flags::new(bindings::IRQF_TRIGGER_NONE);
|
| 32 |
|
| 33 | |
| 34 | pub const TRIGGER_RISING: Flags = Flags::new(bindings::IRQF_TRIGGER_RISING);
|
| 35 |
|
| 36 | |
| 37 | pub const TRIGGER_FALLING: Flags = Flags::new(bindings::IRQF_TRIGGER_FALLING);
|
| 38 |
|
| 39 | |
| 40 | pub const TRIGGER_HIGH: Flags = Flags::new(bindings::IRQF_TRIGGER_HIGH);
|
| 41 |
|
| 42 | |
| 43 | pub const TRIGGER_LOW: Flags = Flags::new(bindings::IRQF_TRIGGER_LOW);
|
| 44 |
|
| 45 | |
| 46 | pub const SHARED: Flags = Flags::new(bindings::IRQF_SHARED);
|
| 47 |
|
| 48 | |
| 49 | pub const PROBE_SHARED: Flags = Flags::new(bindings::IRQF_PROBE_SHARED);
|
| 50 |
|
| 51 | |
| 52 | pub const TIMER: Flags = Flags::new(bindings::IRQF_TIMER);
|
| 53 |
|
| 54 | |
| 55 | pub const PERCPU: Flags = Flags::new(bindings::IRQF_PERCPU);
|
| 56 |
|
| 57 | |
| 58 | pub const NOBALANCING: Flags = Flags::new(bindings::IRQF_NOBALANCING);
|
| 59 |
|
| 60 | |
| 61 | |
| 62 | pub const IRQPOLL: Flags = Flags::new(bindings::IRQF_IRQPOLL);
|
| 63 |
|
| 64 | |
| 65 | |
| 66 | |
| 67 | pub const ONESHOT: Flags = Flags::new(bindings::IRQF_ONESHOT);
|
| 68 |
|
| 69 | |
| 70 | |
| 71 | pub const NO_SUSPEND: Flags = Flags::new(bindings::IRQF_NO_SUSPEND);
|
| 72 |
|
| 73 | |
| 74 | pub const FORCE_RESUME: Flags = Flags::new(bindings::IRQF_FORCE_RESUME);
|
| 75 |
|
| 76 | |
| 77 | pub const NO_THREAD: Flags = Flags::new(bindings::IRQF_NO_THREAD);
|
| 78 |
|
| 79 | |
| 80 | pub const EARLY_RESUME: Flags = Flags::new(bindings::IRQF_EARLY_RESUME);
|
| 81 |
|
| 82 | |
| 83 | |
| 84 | |
| 85 | pub const COND_SUSPEND: Flags = Flags::new(bindings::IRQF_COND_SUSPEND);
|
| 86 |
|
| 87 | |
| 88 | |
| 89 | pub const NO_AUTOEN: Flags = Flags::new(bindings::IRQF_NO_AUTOEN);
|
| 90 |
|
| 91 | |
| 92 | |
| 93 | pub const NO_DEBUG: Flags = Flags::new(bindings::IRQF_NO_DEBUG);
|
| 94 |
|
| 95 | pub(crate) fn into_inner(self) -> c_ulong {
|
| 96 | self.0
|
| 97 | }
|
| 98 |
|
| 99 | |
| 100 | #[inline(always)]
|
| 101 | const fn new(value: u32) -> Self {
|
| 102 | build_assert!(value as u64 <= c_ulong::MAX as u64);
|
| 103 | Self(value as c_ulong)
|
| 104 | }
|
| 105 | }
|
| 106 |
|
| 107 | impl core::ops::BitOr for Flags {
|
| 108 | type Output = Self;
|
| 109 | fn bitor(self, rhs: Self) -> Self::Output {
|
| 110 | Self(self.0 | rhs.0)
|
| 111 | }
|
| 112 | }
|
| 113 |
|
| 114 | impl core::ops::BitAnd for Flags {
|
| 115 | type Output = Self;
|
| 116 | fn bitand(self, rhs: Self) -> Self::Output {
|
| 117 | Self(self.0 & rhs.0)
|
| 118 | }
|
| 119 | }
|
| 120 |
|
| 121 | impl core::ops::Not for Flags {
|
| 122 | type Output = Self;
|
| 123 | fn not(self) -> Self::Output {
|
| 124 | Self(!self.0)
|
| 125 | }
|
| 126 | }
|