fidl_data_zx/
zx_common.rs1use zerocopy::{Immutable, IntoBytes, TryFromBytes};
9
10pub type Status = i32;
11
12pub type Result = i32;
13
14pub type Time = i64;
15
16pub type InstantMono = i64;
17
18pub type InstantBoot = i64;
19
20pub type Ticks = i64;
21
22pub type InstantMonoTicks = i64;
23
24pub type InstantBootTicks = i64;
25
26pub type Duration = i64;
27
28pub type DurationMono = i64;
29
30pub type DurationBoot = i64;
31
32pub type Koid = u64;
33
34pub type Off = u64;
35
36pub type Signals = u32;
37
38pub const CHANNEL_MAX_MSG_BYTES: u64 = 65536;
39
40pub const CHANNEL_MAX_MSG_HANDLES: u64 = 64;
41
42pub const IOB_MAX_REGIONS: u64 = 64;
43
44pub const MAX_NAME_LEN: u64 = 32;
45
46pub const MAX_CPUS: u64 = 512;
47
48#[repr(u32)]
49#[derive(Clone, Copy, Debug, Eq, Hash, Immutable, IntoBytes, PartialEq, TryFromBytes)]
50pub enum ObjType {
51 None = 0,
52 Process = 1,
53 Thread = 2,
54 Vmo = 3,
55 Channel = 4,
56 Event = 5,
57 Port = 6,
58 Interrupt = 9,
59 PciDevice = 11,
60 Log = 12,
61 Socket = 14,
62 Resource = 15,
63 Eventpair = 16,
64 Job = 17,
65 Vmar = 18,
66 Fifo = 19,
67 Guest = 20,
68 Vcpu = 21,
69 Timer = 22,
70 Iommu = 23,
71 Bti = 24,
72 Profile = 25,
73 Pmt = 26,
74 SuspendToken = 27,
75 Pager = 28,
76 Exception = 29,
77 Clock = 30,
78 Stream = 31,
79 Msi = 32,
80 Iob = 33,
81 Counter = 34,
82}
83
84impl ObjType {
85 pub fn from_raw(raw: u32) -> Option<Self> {
86 match raw {
87 0 => Some(Self::None),
88
89 1 => Some(Self::Process),
90
91 2 => Some(Self::Thread),
92
93 3 => Some(Self::Vmo),
94
95 4 => Some(Self::Channel),
96
97 5 => Some(Self::Event),
98
99 6 => Some(Self::Port),
100
101 9 => Some(Self::Interrupt),
102
103 11 => Some(Self::PciDevice),
104
105 12 => Some(Self::Log),
106
107 14 => Some(Self::Socket),
108
109 15 => Some(Self::Resource),
110
111 16 => Some(Self::Eventpair),
112
113 17 => Some(Self::Job),
114
115 18 => Some(Self::Vmar),
116
117 19 => Some(Self::Fifo),
118
119 20 => Some(Self::Guest),
120
121 21 => Some(Self::Vcpu),
122
123 22 => Some(Self::Timer),
124
125 23 => Some(Self::Iommu),
126
127 24 => Some(Self::Bti),
128
129 25 => Some(Self::Profile),
130
131 26 => Some(Self::Pmt),
132
133 27 => Some(Self::SuspendToken),
134
135 28 => Some(Self::Pager),
136
137 29 => Some(Self::Exception),
138
139 30 => Some(Self::Clock),
140
141 31 => Some(Self::Stream),
142
143 32 => Some(Self::Msi),
144
145 33 => Some(Self::Iob),
146
147 34 => Some(Self::Counter),
148
149 _ => None,
150 }
151 }
152}
153
154impl From<ObjType> for u32 {
155 fn from(val: ObjType) -> Self {
156 val as Self
157 }
158}
159
160pub type Handle = u32;